1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RWHV_AURA_OFFSCREEN_HELPER_EFL_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_RWHV_AURA_OFFSCREEN_HELPER_EFL_H_
13 #include <Ecore_Evas.h>
14 #include <Ecore_Input.h>
15 #include <Elementary.h>
17 #include "base/timer/timer.h"
18 #include "content/browser/renderer_host/rwhv_aura_common_helper_efl.h"
19 #include "ui/gfx/native_widget_types.h"
23 typedef base::OnceCallback<void()> SnapshotTask;
25 class ScreenshotCapturedCallback;
28 class CONTENT_EXPORT RWHVAuraOffscreenHelperEfl
29 : public RWHVAuraCommonHelperEfl {
32 using OnFocusCallback = base::RepeatingCallback<void(void)>;
34 RWHVAuraOffscreenHelperEfl(RenderWidgetHostViewAura* rwhva,
35 WebContents* web_contents);
36 ~RWHVAuraOffscreenHelperEfl() override;
38 // RWHVAuraCommonHelperEfl overrides
39 void SetAuraParentWindow(gfx::NativeView parent_window) override {
40 aura_parent_window_ = parent_window;
42 void AuraChildWindowAdded() override;
43 void NotifySwap(const size_t texture_id) override;
46 gfx::Size GetVisibleViewportSize() override;
47 gfx::Rect GetViewBounds() override;
48 gfx::Size GetPhysicalBackingSize() const override;
49 void HandleGestureBegin() override;
50 void HandleGestureEnd() override;
51 void HandleGesture(blink::WebGestureEvent& event) override;
52 void DidOverscroll(const ui::DidOverscrollParams& params) override;
53 void Focus(bool focus) override;
54 bool HasFocus() override;
56 void SetCustomViewportSize(const gfx::Size& size);
57 bool GetHorizontalPanningHold() const { return horizontal_panning_hold_; }
58 void SetHorizontalPanningHold(bool hold) { horizontal_panning_hold_ = hold; }
59 bool GetVerticalPanningHold() const { return vertical_panning_hold_; }
60 void SetVerticalPanningHold(bool hold) { vertical_panning_hold_ = hold; }
62 #if BUILDFLAG(IS_TIZEN_TV)
63 void DrawLabel(Evas_Object* image, Eina_Rectangle rect);
67 gfx::Rect GetViewBoundsInPix() const;
68 const gfx::Size GetScrollableSize() const;
69 void SetScaledContentSize(const gfx::SizeF& size) {
70 scaled_contents_size_ = size;
72 int GetTopControlsHeight();
74 #if BUILDFLAG(IS_TIZEN)
75 void OnEdgeEffectForUIF(bool, bool, bool, bool);
78 // |snapshot_area| is relative coordinate system based on Webview.
79 // (0,0) is top left corner.
80 Evas_Object* GetSnapshot(const gfx::Rect& snapshot_area,
82 bool is_magnifier = false);
83 void RequestSnapshotAsync(const gfx::Rect& snapshot_area,
84 Screenshot_Captured_Callback callback,
86 float scale_factor = 1.0);
88 EdgeEffect& EnsureEdgeEffect();
89 void UpdateEdgeEffect();
90 void EvasToBlinkCords(int x, int y, int* view_x, int* view_y);
92 Evas_Object* content_image() const { return content_image_; }
93 Evas_Object* content_image_elm_host() const {
94 return content_image_elm_host_;
96 gfx::Point ConvertPointInViewPix(gfx::Point point);
98 void SetFocusInOutCallbacks(const OnFocusCallback& on_focus_in,
99 const OnFocusCallback& on_focus_out);
100 void MoveCaret(const gfx::Point& point);
101 void SelectClosestWord(const gfx::Point& touch_point);
102 void RequestMagnifierSnapshotAsync(const Eina_Rectangle rect,
103 Screenshot_Captured_Callback callback,
105 float scale_factor = 1.0f);
108 static void OnParentViewResize(void* data, Evas*, Evas_Object*, void*);
109 static void EvasObjectImagePixelsGetCallback(void*, Evas_Object*);
110 static void OnFocusIn(void* data, Evas*, Evas_Object*, void*);
111 static void OnFocusOut(void* data, Evas*, Evas_Object*, void*);
112 static void OnHostFocusIn(void* data, Evas_Object*, void*);
113 static void OnHostFocusOut(void* data, Evas_Object*, void*);
114 static void OnEvasRenderFlushPre(void* data, Evas* evas, void* event_info);
117 void InitializeProgram();
118 void PaintTextureToSurface(GLuint texture_id);
121 gfx::Size CreateNativeSurface();
124 void ClearBrowserFrame();
126 void InvalidateForSnapshot();
127 void ProcessSnapshotRequest();
128 void RunGetSnapshotOnMainThread(const gfx::Rect snapshot_area,
131 void GetMagnifierSnapshot(gfx::Rect snapshot_area,
133 std::unique_ptr<ScreenshotCapturedCallback> cb);
135 Evas* evas_ = nullptr;
136 Evas_GL* evas_gl_ = nullptr;
137 Evas_GL_API* evas_gl_api_ = nullptr;
138 Evas_GL_Config* evas_gl_config_ = nullptr;
139 Evas_GL_Context* evas_gl_context_ = nullptr;
140 Evas_GL_Surface* evas_gl_surface_ = nullptr;
141 Evas_Object* content_image_ = nullptr;
142 Evas_Object* efl_main_layout_ = nullptr;
143 Evas_Object* content_image_elm_host_ = nullptr;
146 GLint source_texture_location_;
147 GLuint position_attrib_;
148 GLuint rotate_position_attrib_;
149 GLuint texcoord_attrib_;
150 GLuint texture_id_ = 0;
151 GLuint vertex_buffer_obj_;
152 GLuint index_buffer_obj_;
153 gfx::NativeView aura_parent_window_ = nullptr;
156 gfx::SizeF scaled_contents_size_;
157 gfx::Size custom_viewport_size_;
159 #if BUILDFLAG(IS_TIZEN_TV)
160 bool radio_or_checkbox_focused_ = false;
161 int password_input_minlength_ = -1;
162 int input_maxlength_ = DEFAULT_MAX_LENGTH;
163 std::vector<Evas_Object*> voice_manager_labels_;
166 std::unique_ptr<RenderWidgetHostHelper> rwh_helper_;
168 bool frame_rendered_ = false;
169 std::list<SnapshotTask> snapshot_task_list_;
170 std::unique_ptr<base::OneShotTimer> snapshot_timer_;
172 bool horizontal_panning_hold_ = false;
173 bool vertical_panning_hold_ = false;
175 OnFocusCallback on_focus_in_callback_;
176 OnFocusCallback on_focus_out_callback_;
178 std::unique_ptr<EdgeEffect> edge_effect_;
179 // Magnifier snapshot requests are not added to snapshot_task_list_, because
180 // we only care about the last one if they piled up - we can only display
182 SnapshotTask magnifier_snapshot_request_;
185 } // namespace content