Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_ | |
| 6 #define ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_ | |
| 7 | |
| 8 #include "base/android/scoped_java_ref.h" | |
| 9 #include "skia/ext/refptr.h" | |
| 10 | |
| 11 struct AwDrawGLInfo; | |
| 12 struct AwDrawSWFunctionTable; | |
| 13 class SkPicture; | |
| 14 | |
| 15 namespace content { | |
| 16 class ContentViewCore; | |
| 17 } | |
| 18 | |
| 19 namespace gfx { | |
| 20 class Rect; | |
| 21 } | |
| 22 | |
| 23 namespace android_webview { | |
| 24 | |
| 25 // Interface for all the WebView-specific content rendering operations. | |
| 26 // Provides software and hardware rendering and the Capture Picture API. | |
| 27 class BrowserViewRenderer { | |
| 28 public: | |
| 29 class Client { | |
| 30 public: | |
| 31 // Called to trigger view invalidations. | |
| 32 virtual void Invalidate() = 0; | |
| 33 | |
| 34 // Called when a new Picture is available. Needs to be enabled | |
| 35 // via the EnableOnNewPicture method. | |
| 36 virtual void OnNewPicture( | |
| 37 const base::android::JavaRef<jobject>& picture) = 0; | |
| 38 | |
| 39 protected: | |
| 40 virtual ~Client() {} | |
| 41 }; | |
| 42 | |
| 43 // Delegate to perform rendering actions involving Java objects. | |
| 44 class JavaHelper { | |
| 45 public: | |
| 46 // Creates a RGBA_8888 Java Bitmap object of the requested size. | |
| 47 virtual base::android::ScopedJavaLocalRef<jobject> CreateBitmap( | |
| 48 JNIEnv* env, | |
| 49 int width, | |
| 50 int height) = 0; | |
| 51 | |
| 52 // Draws the provided Java Bitmap into the provided Java Canvas. | |
| 53 virtual void DrawBitmapIntoCanvas( | |
| 54 JNIEnv* env, | |
| 55 const base::android::JavaRef<jobject>& jbitmap, | |
| 56 const base::android::JavaRef<jobject>& jcanvas) = 0; | |
| 57 | |
| 58 // Creates a Java Picture object that records drawing the provided Bitmap. | |
| 59 virtual base::android::ScopedJavaLocalRef<jobject> RecordBitmapIntoPicture( | |
| 60 JNIEnv* env, | |
| 61 const base::android::JavaRef<jobject>& jbitmap) = 0; | |
| 62 | |
| 63 protected: | |
| 64 virtual ~JavaHelper() {} | |
| 65 }; | |
| 66 | |
| 67 enum OnNewPictureMode { | |
| 68 kOnNewPictureDisabled = 0, | |
| 69 kOnNewPictureEnabled, | |
| 70 kOnNewPictureInvalidationOnly, | |
| 71 }; | |
| 72 | |
| 73 virtual ~BrowserViewRenderer(); | |
| 74 | |
| 75 // Content control methods. | |
| 76 virtual void SetContents(content::ContentViewCore* content_view_core) = 0; | |
| 77 | |
| 78 // Hardware rendering methods. | |
| 79 virtual void DrawGL(AwDrawGLInfo* draw_info) = 0; | |
| 80 virtual void SetScrollForHWFrame(int x, int y) = 0; | |
| 81 | |
| 82 // Software rendering methods. | |
| 83 virtual bool DrawSW(jobject java_canvas, const gfx::Rect& clip_bounds) = 0; | |
| 84 | |
| 85 // CapturePicture API methods. | |
| 86 virtual base::android::ScopedJavaLocalRef<jobject> CapturePicture() = 0; | |
| 87 virtual void EnableOnNewPicture(OnNewPictureMode mode) = 0; | |
| 88 | |
| 89 // View update notifications. | |
| 90 virtual void OnVisibilityChanged(bool view_visible, bool window_visible) = 0; | |
| 91 virtual void OnSizeChanged(int width, int height) = 0; | |
| 92 virtual void OnAttachedToWindow(int width, int height) = 0; | |
| 93 virtual void OnDetachedFromWindow() = 0; | |
| 94 | |
| 95 // Platform methods. | |
| 96 static void SetAwDrawSWFunctionTable(AwDrawSWFunctionTable* table); | |
| 97 | |
| 98 protected: | |
| 99 BrowserViewRenderer(Client* client, JavaHelper* java_helper); | |
| 100 | |
| 101 Client* client() const { return client_; } | |
| 102 JavaHelper* java_helper() const { return java_helper_; } | |
| 103 | |
| 104 static AwDrawSWFunctionTable* SWDrawFunctions(); | |
| 105 static bool IsSkiaVersionCompatible(); | |
| 106 | |
| 107 private: | |
| 108 Client* client_; | |
| 109 JavaHelper* java_helper_; | |
|
joth
2013/02/06 20:26:31
I think if we're going to make this a real interfa
Leandro GraciĆ” Gil
2013/02/07 12:43:56
Made a pure interface. Moving data members and Set
| |
| 110 | |
| 111 DISALLOW_COPY_AND_ASSIGN(BrowserViewRenderer); | |
| 112 }; | |
| 113 | |
| 114 } // namespace android_webview | |
| 115 | |
| 116 #endif // ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_ | |
| OLD | NEW |