| 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_IN_PROCESS_IN_PROCESS_VIEW_RENDERER_H_ | |
| 6 #define ANDROID_WEBVIEW_BROWSER_IN_PROCESS_IN_PROCESS_VIEW_RENDERER_H_ | |
| 7 | |
| 8 #include "android_webview/browser/browser_view_renderer_impl.h" | |
| 9 | |
| 10 #include "base/memory/weak_ptr.h" | |
| 11 #include "content/public/renderer/android/synchronous_compositor_client.h" | |
| 12 | |
| 13 namespace content { | |
| 14 class SynchronousCompositor; | |
| 15 class WebContents; | |
| 16 } | |
| 17 | |
| 18 namespace android_webview { | |
| 19 | |
| 20 // Provides RenderViewHost wrapper functionality for sending WebView-specific | |
| 21 // IPC messages to the renderer and from there to WebKit. | |
| 22 class InProcessViewRenderer : public BrowserViewRenderer, | |
| 23 public content::SynchronousCompositorClient { | |
| 24 public: | |
| 25 InProcessViewRenderer(BrowserViewRenderer::Client* client, | |
| 26 JavaHelper* java_helper); | |
| 27 virtual ~InProcessViewRenderer(); | |
| 28 | |
| 29 static InProcessViewRenderer* FromWebContents( | |
| 30 content::WebContents* contents); | |
| 31 static InProcessViewRenderer* FromId( | |
| 32 int render_process_id, int render_view_id); | |
| 33 void BindSynchronousCompositor( | |
| 34 content::SynchronousCompositor* compositor); | |
| 35 | |
| 36 // BrowserViewRenderer overrides | |
| 37 virtual void SetContents( | |
| 38 content::ContentViewCore* content_view_core) OVERRIDE; | |
| 39 virtual bool PrepareDrawGL(int x, int y) OVERRIDE; | |
| 40 virtual void DrawGL(AwDrawGLInfo* draw_info) OVERRIDE; | |
| 41 virtual bool DrawSW(jobject java_canvas, | |
| 42 const gfx::Rect& clip_bounds) OVERRIDE; | |
| 43 virtual base::android::ScopedJavaLocalRef<jobject> CapturePicture() OVERRIDE; | |
| 44 virtual void EnableOnNewPicture(bool enabled) OVERRIDE; | |
| 45 virtual void OnVisibilityChanged( | |
| 46 bool view_visible, bool window_visible) OVERRIDE; | |
| 47 virtual void OnSizeChanged(int width, int height) OVERRIDE; | |
| 48 virtual void OnAttachedToWindow(int width, int height) OVERRIDE; | |
| 49 virtual void OnDetachedFromWindow() OVERRIDE; | |
| 50 virtual bool IsAttachedToWindow() OVERRIDE; | |
| 51 virtual bool IsViewVisible() OVERRIDE; | |
| 52 virtual gfx::Rect GetScreenRect() OVERRIDE; | |
| 53 | |
| 54 // SynchronousCompositorClient overrides | |
| 55 virtual void DidDestroyCompositor( | |
| 56 content::SynchronousCompositor* compositor) OVERRIDE; | |
| 57 virtual void SetContinuousInvalidate(bool invalidate) OVERRIDE; | |
| 58 | |
| 59 void WebContentsGone(); | |
| 60 | |
| 61 private: | |
| 62 void Invalidate(); | |
| 63 void EnsureContinuousInvalidation(); | |
| 64 bool DrawSWInternal(jobject java_canvas, | |
| 65 const gfx::Rect& clip_bounds); | |
| 66 bool RenderSW(SkCanvas* canvas); | |
| 67 bool CompositeSW(SkCanvas* canvas); | |
| 68 | |
| 69 BrowserViewRenderer::Client* client_; | |
| 70 BrowserViewRenderer::JavaHelper* java_helper_; | |
| 71 content::WebContents* web_contents_; | |
| 72 content::SynchronousCompositor* compositor_; | |
| 73 | |
| 74 bool view_visible_; | |
| 75 | |
| 76 // When true, we should continuously invalidate and keep drawing, for example | |
| 77 // to drive animation. | |
| 78 bool continuous_invalidate_; | |
| 79 // True while an asynchronous invalidation task is pending. | |
| 80 bool continuous_invalidate_task_pending_; | |
| 81 | |
| 82 int width_; | |
| 83 int height_; | |
| 84 | |
| 85 bool attached_to_window_; | |
| 86 bool hardware_initialized_; | |
| 87 bool hardware_failed_; | |
| 88 | |
| 89 // Used only for detecting Android View System context changes. | |
| 90 // Not to be used between draw calls. | |
| 91 EGLContext egl_context_at_init_; | |
| 92 | |
| 93 // Last View scroll before hardware rendering is triggered. | |
| 94 gfx::Point hw_rendering_scroll_; | |
| 95 | |
| 96 base::WeakPtrFactory<InProcessViewRenderer> weak_factory_; | |
| 97 | |
| 98 DISALLOW_COPY_AND_ASSIGN(InProcessViewRenderer); | |
| 99 }; | |
| 100 | |
| 101 } // namespace android_webview | |
| 102 | |
| 103 #endif // ANDROID_WEBVIEW_BROWSER_IN_PROCESS_IN_PROCESS_VIEW_RENDERER_H_ | |
| OLD | NEW |