Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(626)

Side by Side Diff: android_webview/browser/browser_view_renderer.h

Issue 12041009: [Android WebView] Migrate the rendering code to a separate set of classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updated and rebased. Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698