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

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

Issue 444173003: aw: Improve idle task scheduling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove CurrentlyOnUIThread Created 6 years, 4 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 | Annotate | Revision Log
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/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
10 #include "base/message_loop/message_loop_proxy.h" 11 #include "base/message_loop/message_loop_proxy.h"
11 #include "base/synchronization/lock.h" 12 #include "base/synchronization/lock.h"
12 #include "cc/output/compositor_frame.h" 13 #include "cc/output/compositor_frame.h"
13 #include "cc/output/compositor_frame_ack.h" 14 #include "cc/output/compositor_frame_ack.h"
14 #include "ui/gfx/geometry/rect.h" 15 #include "ui/gfx/geometry/rect.h"
15 #include "ui/gfx/geometry/vector2d.h" 16 #include "ui/gfx/geometry/vector2d.h"
16 17
17 namespace cc { 18 namespace cc {
18 class CompositorFrameAck; 19 class CompositorFrameAck;
19 } 20 }
20 21
21 namespace gpu { 22 namespace gpu {
22 class GLInProcessContext; 23 class GLInProcessContext;
23 } 24 }
24 25
25 namespace android_webview { 26 namespace android_webview {
26 27
28 namespace internal {
29 class RequestDrawGLTracker;
30 }
31
27 class BrowserViewRendererClient; 32 class BrowserViewRendererClient;
28 class InsideHardwareReleaseReset; 33 class InsideHardwareReleaseReset;
29 34
30 // Set by BrowserViewRenderer and read by HardwareRenderer. 35 // Set by BrowserViewRenderer and read by HardwareRenderer.
31 struct DrawGLInput { 36 struct DrawGLInput {
32 gfx::Vector2d scroll_offset; 37 gfx::Vector2d scroll_offset;
33 int width; 38 int width;
34 int height; 39 int height;
35 cc::CompositorFrame frame; 40 cc::CompositorFrame frame;
36 41
37 DrawGLInput(); 42 DrawGLInput();
38 ~DrawGLInput(); 43 ~DrawGLInput();
39 }; 44 };
40 45
41 // This class is used to pass data between UI thread and RenderThread. 46 // This class is used to pass data between UI thread and RenderThread.
42 class SharedRendererState { 47 class SharedRendererState {
43 public: 48 public:
44 SharedRendererState(scoped_refptr<base::MessageLoopProxy> ui_loop, 49 SharedRendererState(scoped_refptr<base::MessageLoopProxy> ui_loop,
45 BrowserViewRendererClient* client); 50 BrowserViewRendererClient* client);
46 ~SharedRendererState(); 51 ~SharedRendererState();
47 52
48 bool CurrentlyOnUIThread();
49 void ClientRequestDrawGL(); 53 void ClientRequestDrawGL();
54 void DidDrawGLProcess();
50 55
51 void SetDrawGLInput(scoped_ptr<DrawGLInput> input); 56 void SetDrawGLInput(scoped_ptr<DrawGLInput> input);
52 scoped_ptr<DrawGLInput> PassDrawGLInput(); 57 scoped_ptr<DrawGLInput> PassDrawGLInput();
53 58
54 bool IsInsideHardwareRelease() const; 59 bool IsInsideHardwareRelease() const;
55 void PostExternalDrawConstraintsToChildCompositor( 60 void PostExternalDrawConstraintsToChildCompositor(
56 const ParentCompositorDrawConstraints& parent_draw_constraints); 61 const ParentCompositorDrawConstraints& parent_draw_constraints);
57 62
58 const ParentCompositorDrawConstraints ParentDrawConstraints() const; 63 const ParentCompositorDrawConstraints ParentDrawConstraints() const;
59 64
60 void SetSharedContext(gpu::GLInProcessContext* context); 65 void SetSharedContext(gpu::GLInProcessContext* context);
61 gpu::GLInProcessContext* GetSharedContext() const; 66 gpu::GLInProcessContext* GetSharedContext() const;
62 67
63 void InsertReturnedResources(const cc::ReturnedResourceArray& resources); 68 void InsertReturnedResources(const cc::ReturnedResourceArray& resources);
64 void SwapReturnedResources(cc::ReturnedResourceArray* resources); 69 void SwapReturnedResources(cc::ReturnedResourceArray* resources);
65 bool ReturnedResourcesEmpty() const; 70 bool ReturnedResourcesEmpty() const;
66 71
67 private: 72 private:
68 friend class InsideHardwareReleaseReset; 73 friend class InsideHardwareReleaseReset;
74 friend class internal::RequestDrawGLTracker;
69 75
76 void ResetRequestDrawGLCallback();
70 void ClientRequestDrawGLOnUIThread(); 77 void ClientRequestDrawGLOnUIThread();
71 void UpdateParentDrawConstraintsOnUIThread(); 78 void UpdateParentDrawConstraintsOnUIThread();
72 void SetInsideHardwareRelease(bool inside); 79 void SetInsideHardwareRelease(bool inside);
73 80
74 scoped_refptr<base::MessageLoopProxy> ui_loop_; 81 scoped_refptr<base::MessageLoopProxy> ui_loop_;
75 BrowserViewRendererClient* client_on_ui_; 82 BrowserViewRendererClient* client_on_ui_;
76 base::WeakPtrFactory<SharedRendererState> weak_factory_on_ui_thread_; 83 base::WeakPtrFactory<SharedRendererState> weak_factory_on_ui_thread_;
77 base::WeakPtr<SharedRendererState> ui_thread_weak_ptr_; 84 base::WeakPtr<SharedRendererState> ui_thread_weak_ptr_;
85 base::CancelableClosure request_draw_gl_cancelable_closure_;
78 86
79 // Accessed by both UI and RT thread. 87 // Accessed by both UI and RT thread.
80 mutable base::Lock lock_; 88 mutable base::Lock lock_;
81 scoped_ptr<DrawGLInput> draw_gl_input_; 89 scoped_ptr<DrawGLInput> draw_gl_input_;
82 bool inside_hardware_release_; 90 bool inside_hardware_release_;
83 ParentCompositorDrawConstraints parent_draw_constraints_; 91 ParentCompositorDrawConstraints parent_draw_constraints_;
84 gpu::GLInProcessContext* share_context_; 92 gpu::GLInProcessContext* share_context_;
85 cc::ReturnedResourceArray returned_resources_; 93 cc::ReturnedResourceArray returned_resources_;
94 base::Closure request_draw_gl_closure_;
86 95
87 DISALLOW_COPY_AND_ASSIGN(SharedRendererState); 96 DISALLOW_COPY_AND_ASSIGN(SharedRendererState);
88 }; 97 };
89 98
90 class InsideHardwareReleaseReset { 99 class InsideHardwareReleaseReset {
91 public: 100 public:
92 explicit InsideHardwareReleaseReset( 101 explicit InsideHardwareReleaseReset(
93 SharedRendererState* shared_renderer_state); 102 SharedRendererState* shared_renderer_state);
94 ~InsideHardwareReleaseReset(); 103 ~InsideHardwareReleaseReset();
95 104
96 private: 105 private:
97 SharedRendererState* shared_renderer_state_; 106 SharedRendererState* shared_renderer_state_;
98 107
99 DISALLOW_COPY_AND_ASSIGN(InsideHardwareReleaseReset); 108 DISALLOW_COPY_AND_ASSIGN(InsideHardwareReleaseReset);
100 }; 109 };
101 110
102 } // namespace android_webview 111 } // namespace android_webview
103 112
104 #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/deferred_gpu_command_service.cc ('k') | android_webview/browser/shared_renderer_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698