OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_ | 5 #ifndef ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_ |
6 #define ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_ | 6 #define ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_ |
7 | 7 |
8 #include "base/android/scoped_java_ref.h" | 8 #include "base/android/scoped_java_ref.h" |
9 #include "ui/gfx/point.h" | 9 #include "ui/gfx/point.h" |
10 #include "ui/gfx/rect.h" | 10 #include "ui/gfx/rect.h" |
11 #include "ui/gfx/vector2d_f.h" | |
11 | 12 |
12 struct AwDrawGLInfo; | 13 struct AwDrawGLInfo; |
13 struct AwDrawSWFunctionTable; | 14 struct AwDrawSWFunctionTable; |
14 | 15 |
15 namespace content { | 16 namespace content { |
16 class ContentViewCore; | 17 class ContentViewCore; |
17 } | 18 } |
18 | 19 |
19 namespace gfx { | |
20 class Rect; | |
21 } | |
22 | |
23 namespace android_webview { | 20 namespace android_webview { |
24 | 21 |
25 // Interface for all the WebView-specific content rendering operations. | 22 // Interface for all the WebView-specific content rendering operations. |
26 // Provides software and hardware rendering and the Capture Picture API. | 23 // Provides software and hardware rendering and the Capture Picture API. |
27 class BrowserViewRenderer { | 24 class BrowserViewRenderer { |
28 public: | 25 public: |
29 class Client { | 26 class Client { |
30 public: | 27 public: |
31 // Request DrawGL be called. Passing null canvas implies the request | 28 // Request DrawGL be called. Passing null canvas implies the request |
32 // will be of AwDrawGLInfo::kModeProcess type. The callback | 29 // will be of AwDrawGLInfo::kModeProcess type. The callback |
33 // may never be made, and the mode may be promoted to kModeDraw. | 30 // may never be made, and the mode may be promoted to kModeDraw. |
34 virtual bool RequestDrawGL(jobject canvas) = 0; | 31 virtual bool RequestDrawGL(jobject canvas) = 0; |
35 | 32 |
36 // Called when a new Picture is available. Needs to be enabled | 33 // Called when a new Picture is available. Needs to be enabled |
37 // via the EnableOnNewPicture method. | 34 // via the EnableOnNewPicture method. |
38 virtual void OnNewPicture() = 0; | 35 virtual void OnNewPicture() = 0; |
39 | 36 |
40 // Called to trigger view invalidations. | 37 // Called to trigger view invalidations. |
41 virtual void Invalidate() = 0; | 38 virtual void Invalidate() = 0; |
42 | 39 |
43 // Called to get view's absolute location on the screen. | 40 // Called to get view's absolute location on the screen. |
44 virtual gfx::Point GetLocationOnScreen() = 0; | 41 virtual gfx::Point GetLocationOnScreen() = 0; |
45 | 42 |
43 // Try to set the view's scroll offset to |new_value_css|. | |
44 virtual void ScrollContainerViewTo(gfx::Vector2dF new_value_css) = 0; | |
45 | |
46 protected: | 46 protected: |
47 virtual ~Client() {} | 47 virtual ~Client() {} |
48 }; | 48 }; |
49 | 49 |
50 // Delegate to perform rendering actions involving Java objects. | 50 // Delegate to perform rendering actions involving Java objects. |
51 class JavaHelper { | 51 class JavaHelper { |
52 public: | 52 public: |
53 // Creates a RGBA_8888 Java Bitmap object of the requested size. | 53 // Creates a RGBA_8888 Java Bitmap object of the requested size. |
54 virtual base::android::ScopedJavaLocalRef<jobject> CreateBitmap( | 54 virtual base::android::ScopedJavaLocalRef<jobject> CreateBitmap( |
55 JNIEnv* env, | 55 JNIEnv* env, |
(...skipping 28 matching lines...) Expand all Loading... | |
84 // Rendering methods. | 84 // Rendering methods. |
85 | 85 |
86 // Main handler for view drawing: performs a SW draw immediately, or sets up | 86 // Main handler for view drawing: performs a SW draw immediately, or sets up |
87 // a subsequent GL Draw (via Client::RequestDrawGL) and returns true. A false | 87 // a subsequent GL Draw (via Client::RequestDrawGL) and returns true. A false |
88 // return value indicates nothing was or will be drawn. | 88 // return value indicates nothing was or will be drawn. |
89 // |java_canvas| is the target of the draw. |is_hardware_canvas| indicates | 89 // |java_canvas| is the target of the draw. |is_hardware_canvas| indicates |
90 // a GL Draw maybe possible on this canvas. |scroll| if the view's current | 90 // a GL Draw maybe possible on this canvas. |scroll| if the view's current |
91 // scroll offset. |clip| is the canvas's clip bounds. | 91 // scroll offset. |clip| is the canvas's clip bounds. |
92 virtual bool OnDraw(jobject java_canvas, | 92 virtual bool OnDraw(jobject java_canvas, |
93 bool is_hardware_canvas, | 93 bool is_hardware_canvas, |
94 const gfx::Point& scroll, | 94 const gfx::Vector2d& scroll_pix, |
joth
2013/06/18 03:19:50
is _pix a standard convention? If not, it doesn't
mkosiba (inactive)
2013/06/18 18:09:25
it seems to be the convention used in RenderCorrdi
| |
95 const gfx::Rect& clip) = 0; | 95 const gfx::Rect& clip) = 0; |
96 // Called in response to a prior Client::RequestDrawGL() call. See | 96 // Called in response to a prior Client::RequestDrawGL() call. See |
97 // AwDrawGLInfo documentation for more details of the contract. | 97 // AwDrawGLInfo documentation for more details of the contract. |
98 virtual void DrawGL(AwDrawGLInfo* draw_info) = 0; | 98 virtual void DrawGL(AwDrawGLInfo* draw_info) = 0; |
99 | 99 |
100 // CapturePicture API methods. | 100 // CapturePicture API methods. |
101 virtual base::android::ScopedJavaLocalRef<jobject> CapturePicture() = 0; | 101 virtual base::android::ScopedJavaLocalRef<jobject> CapturePicture() = 0; |
102 virtual void EnableOnNewPicture(bool enabled) = 0; | 102 virtual void EnableOnNewPicture(bool enabled) = 0; |
103 | 103 |
104 // View update notifications. | 104 // View update notifications. |
105 virtual void OnVisibilityChanged(bool view_visible, bool window_visible) = 0; | 105 virtual void OnVisibilityChanged(bool view_visible, bool window_visible) = 0; |
106 virtual void OnSizeChanged(int width, int height) = 0; | 106 virtual void OnSizeChanged(int width, int height) = 0; |
107 virtual void OnAttachedToWindow(int width, int height) = 0; | 107 virtual void OnAttachedToWindow(int width, int height) = 0; |
108 virtual void OnDetachedFromWindow() = 0; | 108 virtual void OnDetachedFromWindow() = 0; |
109 | 109 |
110 // Set the root layer scroll offset to |new_value|. |new_value| is in | |
111 // physical pixels. | |
joth
2013/06/18 03:19:50
physical pixels? these are normally scalar, not fl
mkosiba (inactive)
2013/06/18 18:09:25
Done.
| |
112 virtual void ScrollTo(gfx::Vector2dF new_value) = 0; | |
113 | |
110 // Android views hierarchy gluing. | 114 // Android views hierarchy gluing. |
111 virtual bool IsAttachedToWindow() = 0; | 115 virtual bool IsAttachedToWindow() = 0; |
112 virtual bool IsViewVisible() = 0; | 116 virtual bool IsViewVisible() = 0; |
113 virtual gfx::Rect GetScreenRect() = 0; | 117 virtual gfx::Rect GetScreenRect() = 0; |
114 | 118 |
115 virtual ~BrowserViewRenderer() {} | 119 virtual ~BrowserViewRenderer() {} |
116 }; | 120 }; |
117 | 121 |
118 } // namespace android_webview | 122 } // namespace android_webview |
119 | 123 |
120 #endif // ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_ | 124 #endif // ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_ |
OLD | NEW |