Chromium Code Reviews| Index: android_webview/browser/view_renderer.h |
| diff --git a/android_webview/browser/view_renderer.h b/android_webview/browser/view_renderer.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..95e2284f6ccd0c6adc3279a81f026056ed9abf1e |
| --- /dev/null |
| +++ b/android_webview/browser/view_renderer.h |
| @@ -0,0 +1,110 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef ANDROID_WEBVIEW_BROWSER_VIEW_RENDERER_H_ |
| +#define ANDROID_WEBVIEW_BROWSER_VIEW_RENDERER_H_ |
| + |
| +#include "base/android/scoped_java_ref.h" |
| +#include "skia/ext/refptr.h" |
| + |
| +struct AwDrawGLInfo; |
| +struct AwDrawSWFunctionTable; |
| +class SkPicture; |
| + |
| +namespace content { |
| +class ContentViewCore; |
| +} |
| + |
| +namespace gfx { |
| +class Rect; |
| +} |
| + |
| +namespace android_webview { |
| + |
| +// Interface for all the WebView-specific content rendering operations. |
| +// Provides software and hardware rendering and the Capture Picture API. |
| +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
|
| + public: |
| + class Client { |
| + public: |
| + // Called to trigger view invalidations. |
| + virtual void Invalidate() = 0; |
| + |
| + // Called when a new Picture is available. Needs to be enabled |
| + // via the EnableOnNewPicture method. |
| + virtual void OnNewPicture( |
| + 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.
|
| + |
| + protected: |
| + virtual ~Client() {} |
| + }; |
| + |
| + // Delegate to perform rendering actions involving Java objects. |
| + 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
|
| + public: |
| + // Creates a RGBA_8888 Java Bitmap object of the requested size. |
| + virtual base::android::ScopedJavaLocalRef<jobject> CreateBitmap( |
| + JNIEnv* env, int width, int height) = 0; |
| + |
| + // Draws the provided Java Bitmap into the provided Java Canvas. |
| + virtual void DrawBitmapIntoCanvas(JNIEnv* env, |
| + jobject jbitmap, |
| + jobject jcanvas) = 0; |
| + |
| + // Creates a Java Picture object that records drawing the provided Bitmap. |
| + virtual base::android::ScopedJavaLocalRef<jobject> RecordRasterizedBitmap( |
| + JNIEnv* env, jobject jbitmap) = 0; |
| + |
| + protected: |
| + virtual ~JavaHelper() {} |
| + }; |
| + |
| + enum OnNewPictureMode { |
| + kOnNewPictureDisabled = 0, |
| + kOnNewPictureEnabled, |
| + kOnNewPictureInvalidationOnly, |
| + }; |
| + |
| + virtual ~ViewRenderer(); |
| + |
| + // Content control methods. |
| + 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
|
| + |
| + // Hardware rendering methods. |
| + virtual void DrawGL(AwDrawGLInfo* draw_info) = 0; |
| + virtual void SetScrollForHWFrame(int x, int y) = 0; |
| + |
| + // Software rendering methods. |
| + virtual bool DrawSW(jobject java_canvas, const gfx::Rect& clip_bounds) = 0; |
| + |
| + // CapturePicture API methods. |
| + virtual base::android::ScopedJavaLocalRef<jobject> CapturePicture() = 0; |
| + virtual void EnableOnNewPicture(OnNewPictureMode mode) = 0; |
| + |
| + // View update notifications. |
| + virtual void OnVisibilityChanged(bool view_visible, bool window_visible) = 0; |
| + virtual void OnSizeChanged(int width, int height) = 0; |
| + virtual void OnAttachedToWindow(int width, int height) = 0; |
| + virtual void OnDetachedFromWindow() = 0; |
| + |
| + // Platform methods. |
| + static void SetAwDrawSWFunctionTable(AwDrawSWFunctionTable* table); |
| + |
| + protected: |
| + ViewRenderer(Client* client, JavaHelper* java_helper); |
| + |
| + Client* client() const { return client_; } |
| + JavaHelper* java_helper() const { return java_helper_; } |
| + |
| + static AwDrawSWFunctionTable* SWDrawFunctions(); |
| + static bool IsSkiaVersionCompatible(); |
| + |
| + private: |
| + Client* client_; |
| + JavaHelper* java_helper_; |
| +}; |
|
joth
2013/01/21 22:54:24
DISALLOW_COPY_AND_ASSIGN
Leandro Graciá Gil
2013/01/22 08:18:46
Done.
|
| + |
| +} // namespace android_webview |
| + |
| +#endif // ANDROID_WEBVIEW_BROWSER_VIEW_RENDERER_H_ |