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

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: fix typo 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(); 53 bool CurrentlyOnUIThread();
49 void ClientRequestDrawGL(); 54 void ClientRequestDrawGL();
55 void DidDrawGLProcess();
50 56
51 void SetDrawGLInput(scoped_ptr<DrawGLInput> input); 57 void SetDrawGLInput(scoped_ptr<DrawGLInput> input);
52 scoped_ptr<DrawGLInput> PassDrawGLInput(); 58 scoped_ptr<DrawGLInput> PassDrawGLInput();
53 59
54 bool IsInsideHardwareRelease() const; 60 bool IsInsideHardwareRelease() const;
55 void PostExternalDrawConstraintsToChildCompositor( 61 void PostExternalDrawConstraintsToChildCompositor(
56 const ParentCompositorDrawConstraints& parent_draw_constraints); 62 const ParentCompositorDrawConstraints& parent_draw_constraints);
57 63
58 const ParentCompositorDrawConstraints ParentDrawConstraints() const; 64 const ParentCompositorDrawConstraints ParentDrawConstraints() const;
59 65
60 void SetSharedContext(gpu::GLInProcessContext* context); 66 void SetSharedContext(gpu::GLInProcessContext* context);
61 gpu::GLInProcessContext* GetSharedContext() const; 67 gpu::GLInProcessContext* GetSharedContext() const;
62 68
63 void InsertReturnedResources(const cc::ReturnedResourceArray& resources); 69 void InsertReturnedResources(const cc::ReturnedResourceArray& resources);
64 void SwapReturnedResources(cc::ReturnedResourceArray* resources); 70 void SwapReturnedResources(cc::ReturnedResourceArray* resources);
65 bool ReturnedResourcesEmpty() const; 71 bool ReturnedResourcesEmpty() const;
66 72
67 private: 73 private:
68 friend class InsideHardwareReleaseReset; 74 friend class InsideHardwareReleaseReset;
75 friend class internal::RequestDrawGLTracker;
69 76
77 void ResetRequestDrawGLCallback();
70 void ClientRequestDrawGLOnUIThread(); 78 void ClientRequestDrawGLOnUIThread();
71 void UpdateParentDrawConstraintsOnUIThread(); 79 void UpdateParentDrawConstraintsOnUIThread();
72 void SetInsideHardwareRelease(bool inside); 80 void SetInsideHardwareRelease(bool inside);
73 81
74 scoped_refptr<base::MessageLoopProxy> ui_loop_; 82 scoped_refptr<base::MessageLoopProxy> ui_loop_;
75 BrowserViewRendererClient* client_on_ui_; 83 BrowserViewRendererClient* client_on_ui_;
76 base::WeakPtrFactory<SharedRendererState> weak_factory_on_ui_thread_; 84 base::WeakPtrFactory<SharedRendererState> weak_factory_on_ui_thread_;
77 base::WeakPtr<SharedRendererState> ui_thread_weak_ptr_; 85 base::WeakPtr<SharedRendererState> ui_thread_weak_ptr_;
86 base::CancelableClosure request_draw_gl_cancelable_closure_;
78 87
79 // Accessed by both UI and RT thread. 88 // Accessed by both UI and RT thread.
80 mutable base::Lock lock_; 89 mutable base::Lock lock_;
81 scoped_ptr<DrawGLInput> draw_gl_input_; 90 scoped_ptr<DrawGLInput> draw_gl_input_;
82 bool inside_hardware_release_; 91 bool inside_hardware_release_;
83 ParentCompositorDrawConstraints parent_draw_constraints_; 92 ParentCompositorDrawConstraints parent_draw_constraints_;
84 gpu::GLInProcessContext* share_context_; 93 gpu::GLInProcessContext* share_context_;
85 cc::ReturnedResourceArray returned_resources_; 94 cc::ReturnedResourceArray returned_resources_;
95 base::Closure request_draw_gl_closure_;
86 96
87 DISALLOW_COPY_AND_ASSIGN(SharedRendererState); 97 DISALLOW_COPY_AND_ASSIGN(SharedRendererState);
88 }; 98 };
89 99
90 class InsideHardwareReleaseReset { 100 class InsideHardwareReleaseReset {
91 public: 101 public:
92 explicit InsideHardwareReleaseReset( 102 explicit InsideHardwareReleaseReset(
93 SharedRendererState* shared_renderer_state); 103 SharedRendererState* shared_renderer_state);
94 ~InsideHardwareReleaseReset(); 104 ~InsideHardwareReleaseReset();
95 105
96 private: 106 private:
97 SharedRendererState* shared_renderer_state_; 107 SharedRendererState* shared_renderer_state_;
98 108
99 DISALLOW_COPY_AND_ASSIGN(InsideHardwareReleaseReset); 109 DISALLOW_COPY_AND_ASSIGN(InsideHardwareReleaseReset);
100 }; 110 };
101 111
102 } // namespace android_webview 112 } // namespace android_webview
103 113
104 #endif // ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_ 114 #endif // ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698