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

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

Issue 1816283005: Move SharedRendererState ownership to AwContents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: All tests passing Created 4 years, 8 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 <map> 8 #include <map>
9 9
10 #include "android_webview/browser/gl_view_renderer_manager.h" 10 #include "android_webview/browser/gl_view_renderer_manager.h"
11 #include "android_webview/browser/parent_compositor_draw_constraints.h" 11 #include "android_webview/browser/parent_compositor_draw_constraints.h"
12 #include "base/cancelable_callback.h" 12 #include "base/cancelable_callback.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/single_thread_task_runner.h" 15 #include "base/single_thread_task_runner.h"
16 #include "base/synchronization/lock.h" 16 #include "base/synchronization/lock.h"
17 #include "cc/output/compositor_frame_ack.h" 17 #include "cc/output/compositor_frame_ack.h"
18 #include "ui/gfx/geometry/rect.h" 18 #include "ui/gfx/geometry/rect.h"
19 #include "ui/gfx/geometry/vector2d.h" 19 #include "ui/gfx/geometry/vector2d.h"
20 20
21 struct AwDrawGLInfo; 21 struct AwDrawGLInfo;
22
23 namespace android_webview { 22 namespace android_webview {
24 23
25 namespace internal { 24 namespace internal {
26 class RequestDrawGLTracker; 25 class RequestDrawGLTracker;
27 } 26 }
28 27
29 class BrowserViewRenderer; 28 class SharedRendererStateClient;
30 class ChildFrame; 29 class ChildFrame;
31 class HardwareRenderer; 30 class HardwareRenderer;
32 class InsideHardwareReleaseReset; 31 class InsideHardwareReleaseReset;
33 32
34 // This class is used to pass data between UI thread and RenderThread. 33 // This class is used to pass data between UI thread and RenderThread.
35 class SharedRendererState { 34 class SharedRendererState {
36 public: 35 public:
37 struct ReturnedResources { 36 struct ReturnedResources {
38 ReturnedResources(); 37 ReturnedResources();
39 ~ReturnedResources(); 38 ~ReturnedResources();
40 39
41 uint32_t output_surface_id; 40 uint32_t output_surface_id;
42 cc::ReturnedResourceArray resources; 41 cc::ReturnedResourceArray resources;
43 }; 42 };
44 using ReturnedResourcesMap = std::map<uint32_t, ReturnedResources>; 43 using ReturnedResourcesMap = std::map<uint32_t, ReturnedResources>;
45 44
46 SharedRendererState( 45 SharedRendererState(
47 const scoped_refptr<base::SingleThreadTaskRunner>& ui_loop, 46 SharedRendererStateClient* client,
48 BrowserViewRenderer* browser_view_renderer); 47 const scoped_refptr<base::SingleThreadTaskRunner>& ui_loop);
49 ~SharedRendererState(); 48 ~SharedRendererState();
50 49
51 // This function can be called from any thread. 50 // This function can be called from any thread.
52 void ClientRequestDrawGL(bool for_idle); 51 void ClientRequestDrawGL(bool for_idle);
53 52
54 // UI thread methods. 53 // UI thread methods.
55 void SetScrollOffsetOnUI(gfx::Vector2d scroll_offset); 54 void SetScrollOffsetOnUI(gfx::Vector2d scroll_offset);
56 void SetCompositorFrameOnUI(scoped_ptr<ChildFrame> frame); 55 void SetFrameOnUI(scoped_ptr<ChildFrame> frame);
57 void InitializeHardwareDrawIfNeededOnUI(); 56 void InitializeHardwareDrawIfNeededOnUI();
58 void ReleaseHardwareDrawIfNeededOnUI();
59 ParentCompositorDrawConstraints GetParentDrawConstraintsOnUI() const; 57 ParentCompositorDrawConstraints GetParentDrawConstraintsOnUI() const;
60 void SwapReturnedResourcesOnUI(ReturnedResourcesMap* returned_resource_map); 58 void SwapReturnedResourcesOnUI(ReturnedResourcesMap* returned_resource_map);
61 bool ReturnedResourcesEmptyOnUI() const; 59 bool ReturnedResourcesEmptyOnUI() const;
62 scoped_ptr<ChildFrame> PassUncommittedFrameOnUI(); 60 scoped_ptr<ChildFrame> PassUncommittedFrameOnUI();
61 bool HasFrameOnUI() const;
63 void DeleteHardwareRendererOnUI(); 62 void DeleteHardwareRendererOnUI();
64 bool HasFrameOnUI() const;
65 63
66 // RT thread methods. 64 // RT thread methods.
67 gfx::Vector2d GetScrollOffsetOnRT(); 65 gfx::Vector2d GetScrollOffsetOnRT();
68 scoped_ptr<ChildFrame> PassCompositorFrameOnRT(); 66 scoped_ptr<ChildFrame> PassFrameOnRT();
69 void DrawGL(AwDrawGLInfo* draw_info); 67 void DrawGL(AwDrawGLInfo* draw_info);
70 void PostExternalDrawConstraintsToChildCompositorOnRT( 68 void PostExternalDrawConstraintsToChildCompositorOnRT(
71 const ParentCompositorDrawConstraints& parent_draw_constraints); 69 const ParentCompositorDrawConstraints& parent_draw_constraints);
72 void InsertReturnedResourcesOnRT(const cc::ReturnedResourceArray& resources, 70 void InsertReturnedResourcesOnRT(const cc::ReturnedResourceArray& resources,
73 uint32_t compositor_id, 71 uint32_t compositor_id,
74 uint32_t output_surface_id); 72 uint32_t output_surface_id);
75 73
76 private: 74 private:
77 friend class internal::RequestDrawGLTracker; 75 friend class internal::RequestDrawGLTracker;
78 class InsideHardwareReleaseReset { 76 class InsideHardwareReleaseReset {
79 public: 77 public:
80 explicit InsideHardwareReleaseReset( 78 explicit InsideHardwareReleaseReset(
81 SharedRendererState* shared_renderer_state); 79 SharedRendererState* shared_renderer_state);
82 ~InsideHardwareReleaseReset(); 80 ~InsideHardwareReleaseReset();
83 81
84 private: 82 private:
85 SharedRendererState* shared_renderer_state_; 83 SharedRendererState* shared_renderer_state_;
86 }; 84 };
87 85
88 // RT thread method. 86 // RT thread method.
89 void DidDrawGLProcess(); 87 void DidDrawGLProcess();
90 88
91 // UI thread methods. 89 // UI thread methods.
92 void ResetRequestDrawGLCallback(); 90 void ResetRequestDrawGLCallback();
93 void ClientRequestDrawGLOnUI(); 91 void ClientRequestDrawGLOnUI();
94 void UpdateParentDrawConstraintsOnUI(); 92 void UpdateParentDrawConstraintsOnUI();
95 bool IsInsideHardwareRelease() const; 93 bool IsInsideHardwareRelease() const;
96 void SetInsideHardwareRelease(bool inside); 94 void SetInsideHardwareRelease(bool inside);
97 void ReleaseCompositorResourcesIfNeededOnUI(bool release_hardware_draw);
98 95
99 // Accessed by UI thread. 96 // Accessed by UI thread.
100 scoped_refptr<base::SingleThreadTaskRunner> ui_loop_; 97 scoped_refptr<base::SingleThreadTaskRunner> ui_loop_;
101 BrowserViewRenderer* browser_view_renderer_; 98 SharedRendererStateClient* client_;
boliu 2016/03/30 16:12:13 const
Tobias Sargeant 2016/03/30 17:17:17 Done.
102 base::WeakPtr<SharedRendererState> ui_thread_weak_ptr_; 99 base::WeakPtr<SharedRendererState> ui_thread_weak_ptr_;
103 base::CancelableClosure request_draw_gl_cancelable_closure_; 100 base::CancelableClosure request_draw_gl_cancelable_closure_;
104 101
105 // Accessed by RT thread. 102 // Accessed by RT thread.
106 scoped_ptr<HardwareRenderer> hardware_renderer_; 103 scoped_ptr<HardwareRenderer> hardware_renderer_;
107 104
108 // This is accessed by both UI and RT now. TODO(hush): move to RT only. 105 // This is accessed by both UI and RT now. TODO(hush): move to RT only.
109 GLViewRendererManager::Key renderer_manager_key_; 106 GLViewRendererManager::Key renderer_manager_key_;
110 107
111 // Accessed by both UI and RT thread. 108 // Accessed by both UI and RT thread.
112 mutable base::Lock lock_; 109 mutable base::Lock lock_;
113 bool hardware_renderer_has_frame_; 110 bool hardware_renderer_has_frame_;
114 gfx::Vector2d scroll_offset_; 111 gfx::Vector2d scroll_offset_;
115 scoped_ptr<ChildFrame> child_frame_; 112 scoped_ptr<ChildFrame> child_frame_;
116 bool inside_hardware_release_; 113 bool inside_hardware_release_;
117 ParentCompositorDrawConstraints parent_draw_constraints_; 114 ParentCompositorDrawConstraints parent_draw_constraints_;
118 ReturnedResourcesMap returned_resources_map_; 115 ReturnedResourcesMap returned_resources_map_;
119 base::Closure request_draw_gl_closure_; 116 base::Closure request_draw_gl_closure_;
120 117
121 base::WeakPtrFactory<SharedRendererState> weak_factory_on_ui_thread_; 118 base::WeakPtrFactory<SharedRendererState> weak_factory_on_ui_thread_;
122 119
123 DISALLOW_COPY_AND_ASSIGN(SharedRendererState); 120 DISALLOW_COPY_AND_ASSIGN(SharedRendererState);
124 }; 121 };
125 122
126 } // namespace android_webview 123 } // namespace android_webview
127 124
128 #endif // ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_ 125 #endif // ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698