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 PostInvalidate() = 0; | 38 virtual void PostInvalidate() = 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|. |
| 44 virtual void ScrollContainerViewTo(gfx::Vector2d new_value) = 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 25 matching lines...) Expand all Loading... |
81 // Rendering methods. | 81 // Rendering methods. |
82 | 82 |
83 // Main handler for view drawing: performs a SW draw immediately, or sets up | 83 // Main handler for view drawing: performs a SW draw immediately, or sets up |
84 // a subsequent GL Draw (via Client::RequestDrawGL) and returns true. A false | 84 // a subsequent GL Draw (via Client::RequestDrawGL) and returns true. A false |
85 // return value indicates nothing was or will be drawn. | 85 // return value indicates nothing was or will be drawn. |
86 // |java_canvas| is the target of the draw. |is_hardware_canvas| indicates | 86 // |java_canvas| is the target of the draw. |is_hardware_canvas| indicates |
87 // a GL Draw maybe possible on this canvas. |scroll| if the view's current | 87 // a GL Draw maybe possible on this canvas. |scroll| if the view's current |
88 // scroll offset. |clip| is the canvas's clip bounds. | 88 // scroll offset. |clip| is the canvas's clip bounds. |
89 virtual bool OnDraw(jobject java_canvas, | 89 virtual bool OnDraw(jobject java_canvas, |
90 bool is_hardware_canvas, | 90 bool is_hardware_canvas, |
91 const gfx::Point& scroll, | 91 const gfx::Vector2d& scroll, |
92 const gfx::Rect& clip) = 0; | 92 const gfx::Rect& clip) = 0; |
93 // Called in response to a prior Client::RequestDrawGL() call. See | 93 // Called in response to a prior Client::RequestDrawGL() call. See |
94 // AwDrawGLInfo documentation for more details of the contract. | 94 // AwDrawGLInfo documentation for more details of the contract. |
95 virtual void DrawGL(AwDrawGLInfo* draw_info) = 0; | 95 virtual void DrawGL(AwDrawGLInfo* draw_info) = 0; |
96 | 96 |
97 // CapturePicture API methods. | 97 // CapturePicture API methods. |
98 virtual base::android::ScopedJavaLocalRef<jobject> CapturePicture() = 0; | 98 virtual base::android::ScopedJavaLocalRef<jobject> CapturePicture() = 0; |
99 virtual void EnableOnNewPicture(bool enabled) = 0; | 99 virtual void EnableOnNewPicture(bool enabled) = 0; |
100 | 100 |
101 // View update notifications. | 101 // View update notifications. |
102 virtual void OnVisibilityChanged(bool view_visible, bool window_visible) = 0; | 102 virtual void OnVisibilityChanged(bool view_visible, bool window_visible) = 0; |
103 virtual void OnSizeChanged(int width, int height) = 0; | 103 virtual void OnSizeChanged(int width, int height) = 0; |
104 virtual void OnAttachedToWindow(int width, int height) = 0; | 104 virtual void OnAttachedToWindow(int width, int height) = 0; |
105 virtual void OnDetachedFromWindow() = 0; | 105 virtual void OnDetachedFromWindow() = 0; |
106 | 106 |
| 107 // Sets the scale for logical<->physical pixel conversions. |
| 108 virtual void SetDipScale(float dip_scale) = 0; |
| 109 |
| 110 // Set the root layer scroll offset to |new_value|. |
| 111 virtual void ScrollTo(gfx::Vector2d new_value) = 0; |
| 112 |
107 // Android views hierarchy gluing. | 113 // Android views hierarchy gluing. |
108 virtual bool IsAttachedToWindow() = 0; | 114 virtual bool IsAttachedToWindow() = 0; |
109 virtual bool IsViewVisible() = 0; | 115 virtual bool IsViewVisible() = 0; |
110 virtual gfx::Rect GetScreenRect() = 0; | 116 virtual gfx::Rect GetScreenRect() = 0; |
111 | 117 |
112 virtual ~BrowserViewRenderer() {} | 118 virtual ~BrowserViewRenderer() {} |
113 }; | 119 }; |
114 | 120 |
115 } // namespace android_webview | 121 } // namespace android_webview |
116 | 122 |
117 #endif // ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_ | 123 #endif // ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_ |
OLD | NEW |