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_IMPL_H_ |
| 6 #define ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_IMPL_H_ |
| 7 |
| 8 #include "android_webview/browser/browser_view_renderer.h" |
| 9 #include "android_webview/browser/renderer_host/view_renderer_host.h" |
| 10 #include "content/public/browser/android/compositor.h" |
| 11 #include "content/public/browser/web_contents_observer.h" |
| 12 #include "skia/ext/refptr.h" |
| 13 #include "ui/gfx/point.h" |
| 14 #include "ui/gfx/size.h" |
| 15 |
| 16 typedef void* EGLContext; |
| 17 struct AwDrawSWFunctionTable; |
| 18 struct AwDrawGLInfo; |
| 19 class SkCanvas; |
| 20 class SkPicture; |
| 21 |
| 22 namespace content { |
| 23 class WebContents; |
| 24 } |
| 25 |
| 26 namespace android_webview { |
| 27 |
| 28 class BrowserViewRendererImpl |
| 29 : public BrowserViewRenderer, |
| 30 public ViewRendererHost::Client, |
| 31 public content::Compositor::Client { |
| 32 public: |
| 33 static BrowserViewRendererImpl* Create(BrowserViewRenderer::Client* client, |
| 34 JavaHelper* java_helper); |
| 35 virtual ~BrowserViewRendererImpl(); |
| 36 |
| 37 // Platform methods. |
| 38 static void SetAwDrawSWFunctionTable(AwDrawSWFunctionTable* table); |
| 39 |
| 40 // BrowserViewRenderer implementation. |
| 41 virtual void SetContents( |
| 42 content::ContentViewCore* content_view_core) OVERRIDE; |
| 43 virtual void DrawGL(AwDrawGLInfo* draw_info) OVERRIDE; |
| 44 virtual void SetScrollForHWFrame(int x, int y) OVERRIDE; |
| 45 virtual bool DrawSW(jobject java_canvas, const gfx::Rect& clip) OVERRIDE; |
| 46 virtual base::android::ScopedJavaLocalRef<jobject> CapturePicture() OVERRIDE; |
| 47 virtual void EnableOnNewPicture(OnNewPictureMode mode) OVERRIDE; |
| 48 virtual void OnVisibilityChanged( |
| 49 bool view_visible, bool window_visible) OVERRIDE; |
| 50 virtual void OnSizeChanged(int width, int height) OVERRIDE; |
| 51 virtual void OnAttachedToWindow(int width, int height) OVERRIDE; |
| 52 virtual void OnDetachedFromWindow() OVERRIDE; |
| 53 |
| 54 // content::Compositor::Client implementation. |
| 55 virtual void ScheduleComposite() OVERRIDE; |
| 56 |
| 57 // ViewRendererHost::Client implementation. |
| 58 virtual void OnPictureUpdated(int process_id, int render_view_id) OVERRIDE; |
| 59 |
| 60 protected: |
| 61 BrowserViewRendererImpl(BrowserViewRenderer::Client* client, |
| 62 JavaHelper* java_helper); |
| 63 |
| 64 private: |
| 65 // Returns the latest locally available picture if any. |
| 66 // If none is available will synchronously request the latest one |
| 67 // and block until the result is received. |
| 68 skia::RefPtr<SkPicture> GetLastCapturedPicture(); |
| 69 void OnPictureUpdated(); |
| 70 |
| 71 void SetCompositorVisibility(bool visible); |
| 72 void ResetCompositor(); |
| 73 void Invalidate(); |
| 74 bool RenderSW(SkCanvas* canvas); |
| 75 bool RenderPicture(SkCanvas* canvas); |
| 76 |
| 77 BrowserViewRenderer::Client* client_; |
| 78 BrowserViewRenderer::JavaHelper* java_helper_; |
| 79 |
| 80 scoped_ptr<ViewRendererHost> view_renderer_host_; |
| 81 scoped_ptr<content::Compositor> compositor_; |
| 82 |
| 83 // Ensures content keeps clipped within the view during transformations. |
| 84 scoped_refptr<cc::Layer> view_clip_layer_; |
| 85 |
| 86 // Applies the transformation matrix. |
| 87 scoped_refptr<cc::Layer> transform_layer_; |
| 88 |
| 89 // Ensures content is drawn within the scissor clip rect provided by the |
| 90 // Android framework. |
| 91 scoped_refptr<cc::Layer> scissor_clip_layer_; |
| 92 |
| 93 // Last View scroll before hardware rendering is triggered. |
| 94 gfx::Point hw_rendering_scroll_; |
| 95 |
| 96 bool view_visible_; |
| 97 bool compositor_visible_; |
| 98 bool is_composite_pending_; |
| 99 float dpi_scale_; |
| 100 gfx::Size view_size_; |
| 101 OnNewPictureMode on_new_picture_mode_; |
| 102 |
| 103 // Used only for detecting Android View System context changes. |
| 104 // Not to be used between draw calls. |
| 105 EGLContext last_frame_context_; |
| 106 |
| 107 // Set via SetContents. Used to recognize updates to the local WebView. |
| 108 content::WebContents* web_contents_; |
| 109 |
| 110 DISALLOW_COPY_AND_ASSIGN(BrowserViewRendererImpl); |
| 111 }; |
| 112 |
| 113 } // namespace android_webview |
| 114 |
| 115 #endif // ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_IMPL_H_ |
OLD | NEW |