| 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" |
| 10 #include "ui/gfx/rect.h" |
| 9 | 11 |
| 10 struct AwDrawGLInfo; | 12 struct AwDrawGLInfo; |
| 11 | 13 |
| 12 namespace content { | 14 namespace content { |
| 13 class ContentViewCore; | 15 class ContentViewCore; |
| 16 class WebContents; |
| 14 } | 17 } |
| 15 | 18 |
| 16 namespace gfx { | 19 namespace gfx { |
| 17 class Rect; | 20 class Rect; |
| 18 } | 21 } |
| 19 | 22 |
| 20 namespace android_webview { | 23 namespace android_webview { |
| 21 | 24 |
| 22 // Interface for all the WebView-specific content rendering operations. | 25 // Interface for all the WebView-specific content rendering operations. |
| 23 // Provides software and hardware rendering and the Capture Picture API. | 26 // Provides software and hardware rendering and the Capture Picture API. |
| 24 class BrowserViewRenderer { | 27 class BrowserViewRenderer { |
| 25 public: | 28 public: |
| 26 class Client { | 29 class Client { |
| 27 public: | 30 public: |
| 28 // Called to trigger view invalidations. | 31 // Called to trigger view invalidations. |
| 29 virtual void Invalidate() = 0; | 32 virtual void Invalidate() = 0; |
| 30 | 33 |
| 31 // Called when a new Picture is available. Needs to be enabled | 34 // Called when a new Picture is available. Needs to be enabled |
| 32 // via the EnableOnNewPicture method. | 35 // via the EnableOnNewPicture method. |
| 33 virtual void OnNewPicture( | 36 virtual void OnNewPicture( |
| 34 const base::android::JavaRef<jobject>& picture) = 0; | 37 const base::android::JavaRef<jobject>& picture) = 0; |
| 35 | 38 |
| 39 // Called to get view's absolute location on the screen. |
| 40 virtual gfx::Point GetLocationOnScreen() = 0; |
| 41 |
| 36 protected: | 42 protected: |
| 37 virtual ~Client() {} | 43 virtual ~Client() {} |
| 38 }; | 44 }; |
| 39 | 45 |
| 40 // Delegate to perform rendering actions involving Java objects. | 46 // Delegate to perform rendering actions involving Java objects. |
| 41 class JavaHelper { | 47 class JavaHelper { |
| 42 public: | 48 public: |
| 43 // Creates a RGBA_8888 Java Bitmap object of the requested size. | 49 // Creates a RGBA_8888 Java Bitmap object of the requested size. |
| 44 virtual base::android::ScopedJavaLocalRef<jobject> CreateBitmap( | 50 virtual base::android::ScopedJavaLocalRef<jobject> CreateBitmap( |
| 45 JNIEnv* env, | 51 JNIEnv* env, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 60 protected: | 66 protected: |
| 61 virtual ~JavaHelper() {} | 67 virtual ~JavaHelper() {} |
| 62 }; | 68 }; |
| 63 | 69 |
| 64 enum OnNewPictureMode { | 70 enum OnNewPictureMode { |
| 65 kOnNewPictureDisabled = 0, | 71 kOnNewPictureDisabled = 0, |
| 66 kOnNewPictureEnabled, | 72 kOnNewPictureEnabled, |
| 67 kOnNewPictureInvalidationOnly, | 73 kOnNewPictureInvalidationOnly, |
| 68 }; | 74 }; |
| 69 | 75 |
| 76 static BrowserViewRenderer* FromWebContents( |
| 77 content::WebContents* web_contents); |
| 78 |
| 70 // Content control methods. | 79 // Content control methods. |
| 71 virtual void SetContents(content::ContentViewCore* content_view_core) = 0; | 80 virtual void SetContents(content::ContentViewCore* content_view_core) = 0; |
| 72 | 81 |
| 73 // Hardware rendering methods. | 82 // Hardware rendering methods. |
| 74 virtual void DrawGL(AwDrawGLInfo* draw_info) = 0; | 83 virtual void DrawGL(AwDrawGLInfo* draw_info) = 0; |
| 75 virtual void SetScrollForHWFrame(int x, int y) = 0; | 84 virtual void SetScrollForHWFrame(int x, int y) = 0; |
| 76 | 85 |
| 77 // Software rendering methods. | 86 // Software rendering methods. |
| 78 virtual bool DrawSW(jobject java_canvas, const gfx::Rect& clip_bounds) = 0; | 87 virtual bool DrawSW(jobject java_canvas, const gfx::Rect& clip_bounds) = 0; |
| 79 | 88 |
| 80 // CapturePicture API methods. | 89 // CapturePicture API methods. |
| 81 virtual base::android::ScopedJavaLocalRef<jobject> CapturePicture() = 0; | 90 virtual base::android::ScopedJavaLocalRef<jobject> CapturePicture() = 0; |
| 82 virtual void EnableOnNewPicture(OnNewPictureMode mode) = 0; | 91 virtual void EnableOnNewPicture(OnNewPictureMode mode) = 0; |
| 83 | 92 |
| 84 // View update notifications. | 93 // View update notifications. |
| 85 virtual void OnVisibilityChanged(bool view_visible, bool window_visible) = 0; | 94 virtual void OnVisibilityChanged(bool view_visible, bool window_visible) = 0; |
| 86 virtual void OnSizeChanged(int width, int height) = 0; | 95 virtual void OnSizeChanged(int width, int height) = 0; |
| 87 virtual void OnAttachedToWindow(int width, int height) = 0; | 96 virtual void OnAttachedToWindow(int width, int height) = 0; |
| 88 virtual void OnDetachedFromWindow() = 0; | 97 virtual void OnDetachedFromWindow() = 0; |
| 89 | 98 |
| 99 // Android views hierarchy gluing. |
| 100 virtual bool IsAttachedToWindow() = 0; |
| 101 virtual bool IsViewVisible() = 0; |
| 102 virtual gfx::Rect GetScreenRect() = 0; |
| 103 |
| 90 virtual ~BrowserViewRenderer() {} | 104 virtual ~BrowserViewRenderer() {} |
| 91 }; | 105 }; |
| 92 | 106 |
| 93 } // namespace android_webview | 107 } // namespace android_webview |
| 94 | 108 |
| 95 #endif // ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_ | 109 #endif // ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_ |
| OLD | NEW |