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_VIEW_RENDERER_H_ | |
6 #define ANDROID_WEBVIEW_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 ViewRenderer { | |
joth
2013/01/21 22:54:24
The normal naming scheme in chromium is if FooBar
Leandro Graciá Gil
2013/01/22 08:18:46
Going for:
renderer/ - ViewRenderer
browser/render
| |
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 base::android::ScopedJavaLocalRef<jobject> picture) = 0; | |
benm (inactive)
2013/01/21 20:34:49
const reference?
joth
2013/01/21 22:54:24
can even be const JavaRef<jobject>&
Leandro Graciá Gil
2013/01/22 08:18:46
Done.
| |
38 | |
39 protected: | |
40 virtual ~Client() {} | |
41 }; | |
42 | |
43 // Delegate to perform rendering actions involving Java objects. | |
44 class JavaHelper { | |
mkosiba (inactive)
2013/01/22 02:13:34
since there is a coresponding java-side class this
Leandro Graciá Gil
2013/01/22 08:18:46
There is a Java-side class implementing this, but
| |
45 public: | |
46 // Creates a RGBA_8888 Java Bitmap object of the requested size. | |
47 virtual base::android::ScopedJavaLocalRef<jobject> CreateBitmap( | |
48 JNIEnv* env, int width, int height) = 0; | |
49 | |
50 // Draws the provided Java Bitmap into the provided Java Canvas. | |
51 virtual void DrawBitmapIntoCanvas(JNIEnv* env, | |
52 jobject jbitmap, | |
53 jobject jcanvas) = 0; | |
54 | |
55 // Creates a Java Picture object that records drawing the provided Bitmap. | |
56 virtual base::android::ScopedJavaLocalRef<jobject> RecordRasterizedBitmap( | |
57 JNIEnv* env, jobject jbitmap) = 0; | |
58 | |
59 protected: | |
60 virtual ~JavaHelper() {} | |
61 }; | |
62 | |
63 enum OnNewPictureMode { | |
64 kOnNewPictureDisabled = 0, | |
65 kOnNewPictureEnabled, | |
66 kOnNewPictureInvalidationOnly, | |
67 }; | |
68 | |
69 virtual ~ViewRenderer(); | |
70 | |
71 // Content control methods. | |
72 virtual void SetContents(content::ContentViewCore* content_view_core) = 0; | |
mkosiba (inactive)
2013/01/22 02:13:34
naming nit: SetContents sounds like a WebContents-
Leandro Graciá Gil
2013/01/22 08:18:46
Actually, it gets the WebContents and the content
| |
73 | |
74 // Hardware rendering methods. | |
75 virtual void DrawGL(AwDrawGLInfo* draw_info) = 0; | |
76 virtual void SetScrollForHWFrame(int x, int y) = 0; | |
77 | |
78 // Software rendering methods. | |
79 virtual bool DrawSW(jobject java_canvas, const gfx::Rect& clip_bounds) = 0; | |
80 | |
81 // CapturePicture API methods. | |
82 virtual base::android::ScopedJavaLocalRef<jobject> CapturePicture() = 0; | |
83 virtual void EnableOnNewPicture(OnNewPictureMode mode) = 0; | |
84 | |
85 // View update notifications. | |
86 virtual void OnVisibilityChanged(bool view_visible, bool window_visible) = 0; | |
87 virtual void OnSizeChanged(int width, int height) = 0; | |
88 virtual void OnAttachedToWindow(int width, int height) = 0; | |
89 virtual void OnDetachedFromWindow() = 0; | |
90 | |
91 // Platform methods. | |
92 static void SetAwDrawSWFunctionTable(AwDrawSWFunctionTable* table); | |
93 | |
94 protected: | |
95 ViewRenderer(Client* client, JavaHelper* java_helper); | |
96 | |
97 Client* client() const { return client_; } | |
98 JavaHelper* java_helper() const { return java_helper_; } | |
99 | |
100 static AwDrawSWFunctionTable* SWDrawFunctions(); | |
101 static bool IsSkiaVersionCompatible(); | |
102 | |
103 private: | |
104 Client* client_; | |
105 JavaHelper* java_helper_; | |
106 }; | |
joth
2013/01/21 22:54:24
DISALLOW_COPY_AND_ASSIGN
Leandro Graciá Gil
2013/01/22 08:18:46
Done.
| |
107 | |
108 } // namespace android_webview | |
109 | |
110 #endif // ANDROID_WEBVIEW_BROWSER_VIEW_RENDERER_H_ | |
OLD | NEW |