| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_ | 5 #ifndef ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_ |
| 6 #define ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_ | 6 #define ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_ |
| 7 | 7 |
| 8 #include "android_webview/browser/parent_compositor_draw_constraints.h" | 8 #include "android_webview/browser/parent_compositor_draw_constraints.h" |
| 9 #include "base/cancelable_callback.h" | 9 #include "base/cancelable_callback.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 #include "base/message_loop/message_loop_proxy.h" | 11 #include "base/message_loop/message_loop_proxy.h" |
| 12 #include "base/synchronization/lock.h" | 12 #include "base/synchronization/lock.h" |
| 13 #include "cc/output/compositor_frame.h" | 13 #include "cc/output/compositor_frame.h" |
| 14 #include "cc/output/compositor_frame_ack.h" | 14 #include "cc/output/compositor_frame_ack.h" |
| 15 #include "ui/gfx/geometry/rect.h" | 15 #include "ui/gfx/geometry/rect.h" |
| 16 #include "ui/gfx/geometry/vector2d.h" | 16 #include "ui/gfx/geometry/vector2d.h" |
| 17 | 17 |
| 18 namespace android_webview { | 18 namespace android_webview { |
| 19 | 19 |
| 20 namespace internal { | 20 namespace internal { |
| 21 class RequestDrawGLTracker; | 21 class RequestDrawGLTracker; |
| 22 } | 22 } |
| 23 | 23 |
| 24 class BrowserViewRendererClient; | 24 class BrowserViewRenderer; |
| 25 class InsideHardwareReleaseReset; | 25 class InsideHardwareReleaseReset; |
| 26 | 26 |
| 27 // This class is used to pass data between UI thread and RenderThread. | 27 // This class is used to pass data between UI thread and RenderThread. |
| 28 // TODO(hush): this class should own HardwareRenderer. |
| 28 class SharedRendererState { | 29 class SharedRendererState { |
| 29 public: | 30 public: |
| 30 SharedRendererState(scoped_refptr<base::MessageLoopProxy> ui_loop, | 31 SharedRendererState(scoped_refptr<base::MessageLoopProxy> ui_loop, |
| 31 BrowserViewRendererClient* client); | 32 BrowserViewRenderer* browser_view_renderer); |
| 32 ~SharedRendererState(); | 33 ~SharedRendererState(); |
| 33 | 34 |
| 34 void ClientRequestDrawGL(); | 35 void ClientRequestDrawGL(); |
| 35 void DidDrawGLProcess(); | 36 void DidDrawGLProcess(); |
| 36 | 37 |
| 37 void SetScrollOffset(gfx::Vector2d scroll_offset); | 38 void SetScrollOffsetOnUI(gfx::Vector2d scroll_offset); |
| 38 gfx::Vector2d GetScrollOffset(); | 39 gfx::Vector2d GetScrollOffsetOnRT(); |
| 39 | 40 |
| 40 bool HasCompositorFrame() const; | 41 bool HasCompositorFrameOnUI() const; |
| 41 void SetCompositorFrame(scoped_ptr<cc::CompositorFrame> frame, | 42 void SetCompositorFrameOnUI(scoped_ptr<cc::CompositorFrame> frame, |
| 42 bool force_commit); | 43 bool force_commit); |
| 44 // Right now this method is called on both UI and RT. |
| 45 // TODO(hush): Make it only called from RT. |
| 43 scoped_ptr<cc::CompositorFrame> PassCompositorFrame(); | 46 scoped_ptr<cc::CompositorFrame> PassCompositorFrame(); |
| 44 bool ForceCommit() const; | 47 bool ForceCommitOnRT() const; |
| 45 | 48 |
| 49 // TODO(hush): this will be private after DrawGL moves to this class. |
| 46 bool IsInsideHardwareRelease() const; | 50 bool IsInsideHardwareRelease() const; |
| 47 // Returns true if the draw constraints are updated. | 51 // Returns true if the draw constraints are updated. |
| 48 bool UpdateDrawConstraints( | 52 bool UpdateDrawConstraintsOnRT( |
| 49 const ParentCompositorDrawConstraints& parent_draw_constraints); | 53 const ParentCompositorDrawConstraints& parent_draw_constraints); |
| 50 void PostExternalDrawConstraintsToChildCompositor( | 54 void PostExternalDrawConstraintsToChildCompositorOnRT( |
| 51 const ParentCompositorDrawConstraints& parent_draw_constraints); | 55 const ParentCompositorDrawConstraints& parent_draw_constraints); |
| 52 void DidSkipCommitFrame(); | 56 ParentCompositorDrawConstraints GetParentDrawConstraintsOnUI() const; |
| 53 | 57 |
| 54 const ParentCompositorDrawConstraints ParentDrawConstraints() const; | 58 void DidSkipCommitFrameOnRT(); |
| 59 void SetForceInvalidateOnNextDrawGLOnUI( |
| 60 bool needs_force_invalidate_on_next_draw_gl); |
| 61 bool NeedsForceInvalidateOnNextDrawGLOnUI() const; |
| 55 | 62 |
| 56 void SetForceInvalidateOnNextDrawGL( | 63 void InsertReturnedResourcesOnRT(const cc::ReturnedResourceArray& resources); |
| 57 bool needs_force_invalidate_on_next_draw_gl); | 64 void SwapReturnedResourcesOnUI(cc::ReturnedResourceArray* resources); |
| 58 bool NeedsForceInvalidateOnNextDrawGL() const; | |
| 59 | |
| 60 void InsertReturnedResources(const cc::ReturnedResourceArray& resources); | |
| 61 void SwapReturnedResources(cc::ReturnedResourceArray* resources); | |
| 62 bool ReturnedResourcesEmpty() const; | |
| 63 | 65 |
| 64 private: | 66 private: |
| 65 friend class InsideHardwareReleaseReset; | 67 friend class InsideHardwareReleaseReset; |
| 66 friend class internal::RequestDrawGLTracker; | 68 friend class internal::RequestDrawGLTracker; |
| 67 | 69 |
| 68 void ResetRequestDrawGLCallback(); | 70 void ResetRequestDrawGLCallback(); |
| 69 void ClientRequestDrawGLOnUIThread(); | 71 void ClientRequestDrawGLOnUIThread(); |
| 70 void UpdateParentDrawConstraintsOnUIThread(); | 72 void UpdateParentDrawConstraintsOnUIThread(); |
| 71 void DidSkipCommitFrameOnUIThread(); | 73 void DidSkipCommitFrameOnUI(); |
| 72 void SetInsideHardwareRelease(bool inside); | 74 void SetInsideHardwareRelease(bool inside); |
| 73 | 75 |
| 74 scoped_refptr<base::MessageLoopProxy> ui_loop_; | 76 scoped_refptr<base::MessageLoopProxy> ui_loop_; |
| 75 BrowserViewRendererClient* client_on_ui_; | 77 BrowserViewRenderer* browser_view_renderer_; |
| 76 base::WeakPtr<SharedRendererState> ui_thread_weak_ptr_; | 78 base::WeakPtr<SharedRendererState> ui_thread_weak_ptr_; |
| 77 base::CancelableClosure request_draw_gl_cancelable_closure_; | 79 base::CancelableClosure request_draw_gl_cancelable_closure_; |
| 78 | 80 |
| 79 // Accessed by both UI and RT thread. | 81 // Accessed by both UI and RT thread. |
| 80 mutable base::Lock lock_; | 82 mutable base::Lock lock_; |
| 81 gfx::Vector2d scroll_offset_; | 83 gfx::Vector2d scroll_offset_; |
| 82 scoped_ptr<cc::CompositorFrame> compositor_frame_; | 84 scoped_ptr<cc::CompositorFrame> compositor_frame_; |
| 83 bool force_commit_; | 85 bool force_commit_; |
| 84 bool inside_hardware_release_; | 86 bool inside_hardware_release_; |
| 85 bool needs_force_invalidate_on_next_draw_gl_; | 87 bool needs_force_invalidate_on_next_draw_gl_; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 100 | 102 |
| 101 private: | 103 private: |
| 102 SharedRendererState* shared_renderer_state_; | 104 SharedRendererState* shared_renderer_state_; |
| 103 | 105 |
| 104 DISALLOW_COPY_AND_ASSIGN(InsideHardwareReleaseReset); | 106 DISALLOW_COPY_AND_ASSIGN(InsideHardwareReleaseReset); |
| 105 }; | 107 }; |
| 106 | 108 |
| 107 } // namespace android_webview | 109 } // namespace android_webview |
| 108 | 110 |
| 109 #endif // ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_ | 111 #endif // ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_ |
| OLD | NEW |