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

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

Issue 655813004: Part 1: Refactor Android WebView graphics code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@refactor
Patch Set: comments Created 6 years, 2 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
OLDNEW
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/single_thread_task_runner.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(
31 BrowserViewRendererClient* client); 32 const scoped_refptr<base::SingleThreadTaskRunner>& ui_loop,
33 BrowserViewRenderer* browser_view_renderer);
32 ~SharedRendererState(); 34 ~SharedRendererState();
33 35
34 void ClientRequestDrawGL(); 36 void ClientRequestDrawGL();
35 void DidDrawGLProcess(); 37 void DidDrawGLProcess();
36 38
37 void SetScrollOffset(gfx::Vector2d scroll_offset); 39 void SetScrollOffsetOnUI(gfx::Vector2d scroll_offset);
38 gfx::Vector2d GetScrollOffset(); 40 gfx::Vector2d GetScrollOffsetOnRT();
39 41
40 bool HasCompositorFrame() const; 42 bool HasCompositorFrameOnUI() const;
41 void SetCompositorFrame(scoped_ptr<cc::CompositorFrame> frame, 43 void SetCompositorFrameOnUI(scoped_ptr<cc::CompositorFrame> frame,
42 bool force_commit); 44 bool force_commit);
45 // Right now this method is called on both UI and RT.
46 // TODO(hush): Make it only called from RT.
43 scoped_ptr<cc::CompositorFrame> PassCompositorFrame(); 47 scoped_ptr<cc::CompositorFrame> PassCompositorFrame();
44 bool ForceCommit() const; 48 bool ForceCommitOnRT() const;
45 49
50 // TODO(hush): this will be private after DrawGL moves to this class.
46 bool IsInsideHardwareRelease() const; 51 bool IsInsideHardwareRelease() const;
47 // Returns true if the draw constraints are updated. 52 // Returns true if the draw constraints are updated.
48 bool UpdateDrawConstraints( 53 bool UpdateDrawConstraintsOnRT(
49 const ParentCompositorDrawConstraints& parent_draw_constraints); 54 const ParentCompositorDrawConstraints& parent_draw_constraints);
50 void PostExternalDrawConstraintsToChildCompositor( 55 void PostExternalDrawConstraintsToChildCompositorOnRT(
51 const ParentCompositorDrawConstraints& parent_draw_constraints); 56 const ParentCompositorDrawConstraints& parent_draw_constraints);
52 void DidSkipCommitFrame(); 57 ParentCompositorDrawConstraints GetParentDrawConstraintsOnUI() const;
53 58
54 const ParentCompositorDrawConstraints ParentDrawConstraints() const; 59 void DidSkipCommitFrameOnRT();
60 void SetForceInvalidateOnNextDrawGLOnUI(
61 bool needs_force_invalidate_on_next_draw_gl);
62 bool NeedsForceInvalidateOnNextDrawGLOnUI() const;
55 63
56 void SetForceInvalidateOnNextDrawGL( 64 void InsertReturnedResourcesOnRT(const cc::ReturnedResourceArray& resources);
57 bool needs_force_invalidate_on_next_draw_gl); 65 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; 66 bool ReturnedResourcesEmpty() const;
63 67
64 private: 68 private:
65 friend class InsideHardwareReleaseReset; 69 friend class InsideHardwareReleaseReset;
66 friend class internal::RequestDrawGLTracker; 70 friend class internal::RequestDrawGLTracker;
67 71
68 void ResetRequestDrawGLCallback(); 72 void ResetRequestDrawGLCallback();
69 void ClientRequestDrawGLOnUIThread(); 73 void ClientRequestDrawGLOnUIThread();
70 void UpdateParentDrawConstraintsOnUIThread(); 74 void UpdateParentDrawConstraintsOnUIThread();
71 void DidSkipCommitFrameOnUIThread(); 75 void DidSkipCommitFrameOnUI();
72 void SetInsideHardwareRelease(bool inside); 76 void SetInsideHardwareRelease(bool inside);
73 77
74 scoped_refptr<base::MessageLoopProxy> ui_loop_; 78 scoped_refptr<base::SingleThreadTaskRunner> ui_loop_;
75 BrowserViewRendererClient* client_on_ui_; 79 BrowserViewRenderer* browser_view_renderer_;
76 base::WeakPtr<SharedRendererState> ui_thread_weak_ptr_; 80 base::WeakPtr<SharedRendererState> ui_thread_weak_ptr_;
77 base::CancelableClosure request_draw_gl_cancelable_closure_; 81 base::CancelableClosure request_draw_gl_cancelable_closure_;
78 82
79 // Accessed by both UI and RT thread. 83 // Accessed by both UI and RT thread.
80 mutable base::Lock lock_; 84 mutable base::Lock lock_;
81 gfx::Vector2d scroll_offset_; 85 gfx::Vector2d scroll_offset_;
82 scoped_ptr<cc::CompositorFrame> compositor_frame_; 86 scoped_ptr<cc::CompositorFrame> compositor_frame_;
83 bool force_commit_; 87 bool force_commit_;
84 bool inside_hardware_release_; 88 bool inside_hardware_release_;
85 bool needs_force_invalidate_on_next_draw_gl_; 89 bool needs_force_invalidate_on_next_draw_gl_;
(...skipping 14 matching lines...) Expand all
100 104
101 private: 105 private:
102 SharedRendererState* shared_renderer_state_; 106 SharedRendererState* shared_renderer_state_;
103 107
104 DISALLOW_COPY_AND_ASSIGN(InsideHardwareReleaseReset); 108 DISALLOW_COPY_AND_ASSIGN(InsideHardwareReleaseReset);
105 }; 109 };
106 110
107 } // namespace android_webview 111 } // namespace android_webview
108 112
109 #endif // ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_ 113 #endif // ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_
OLDNEW
« no previous file with comments | « android_webview/browser/hardware_renderer.cc ('k') | android_webview/browser/shared_renderer_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698