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

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

Issue 287993004: [Android WebView] Implement Ubercomp for Render Thread support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix clang compile Created 6 years, 7 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 "base/message_loop/message_loop_proxy.h" 8 #include "base/message_loop/message_loop_proxy.h"
9 #include "base/synchronization/lock.h" 9 #include "base/synchronization/lock.h"
10 #include "cc/output/compositor_frame.h"
11 #include "cc/output/compositor_frame_ack.h"
10 #include "content/public/browser/android/synchronous_compositor.h" 12 #include "content/public/browser/android/synchronous_compositor.h"
11 #include "ui/gfx/geometry/rect.h" 13 #include "ui/gfx/geometry/rect.h"
12 #include "ui/gfx/geometry/vector2d.h" 14 #include "ui/gfx/geometry/vector2d.h"
13 15
16 namespace cc {
17 class CompositorFrameAck;
18 }
19
20 namespace gpu {
21 class GLInProcessContext;
22 }
23
14 namespace android_webview { 24 namespace android_webview {
15 25
16 class BrowserViewRendererClient; 26 class BrowserViewRendererClient;
17 27
18 // Set by BrowserViewRenderer and read by HardwareRenderer. 28 // Set by BrowserViewRenderer and read by HardwareRenderer.
19 struct DrawGLInput { 29 struct DrawGLInput {
20 unsigned int frame_id;
21 gfx::Rect global_visible_rect; 30 gfx::Rect global_visible_rect;
22 gfx::Vector2d scroll_offset; 31 gfx::Vector2d scroll_offset;
23 int width; 32 int width;
24 int height; 33 int height;
34 cc::CompositorFrame frame;
25 35
26 DrawGLInput(); 36 DrawGLInput();
37 ~DrawGLInput();
27 }; 38 };
28 39
29 // Set by HardwareRenderer and read by BrowserViewRenderer. 40 // Set by HardwareRenderer and read by BrowserViewRenderer.
30 struct DrawGLResult { 41 struct DrawGLResult {
31 unsigned int frame_id;
32 bool clip_contains_visible_rect; 42 bool clip_contains_visible_rect;
33 43
34 DrawGLResult(); 44 DrawGLResult();
35 }; 45 };
36 46
37 // This class holds renderer state that is shared between UI and RT threads. 47 // This class holds renderer state that is shared between UI and RT threads.
38 // Android framework will block the UI thread when RT is drawing, so no locking 48 // Android framework will block the UI thread when RT is drawing, so no locking
39 // is needed in this class. In the interim, this class is also responsible for 49 // is needed in this class. In the interim, this class is also responsible for
40 // thread hopping that should eventually be removed once RT support work is 50 // thread hopping that should eventually be removed once RT support work is
41 // complete. 51 // complete.
42 class SharedRendererState { 52 class SharedRendererState {
43 public: 53 public:
44 SharedRendererState(scoped_refptr<base::MessageLoopProxy> ui_loop, 54 SharedRendererState(scoped_refptr<base::MessageLoopProxy> ui_loop,
45 BrowserViewRendererClient* client); 55 BrowserViewRendererClient* client);
46 ~SharedRendererState(); 56 ~SharedRendererState();
47 57
48 void ClientRequestDrawGL(); 58 void ClientRequestDrawGL();
49 59
50 // This function should only be called on UI thread. 60 // This function should only be called on UI thread.
51 void SetCompositorOnUiThread(content::SynchronousCompositor* compositor); 61 void SetCompositorOnUiThread(content::SynchronousCompositor* compositor);
52 62
53 // This function can be called on both UI and RT thread. 63 // This function can be called on both UI and RT thread.
54 content::SynchronousCompositor* GetCompositor(); 64 content::SynchronousCompositor* GetCompositor();
55 65
56 void SetMemoryPolicy(const content::SynchronousCompositorMemoryPolicy policy); 66 void SetMemoryPolicy(const content::SynchronousCompositorMemoryPolicy policy);
57 content::SynchronousCompositorMemoryPolicy GetMemoryPolicy() const; 67 content::SynchronousCompositorMemoryPolicy GetMemoryPolicy() const;
58 68
59 void SetMemoryPolicyDirty(bool is_dirty); 69 void SetMemoryPolicyDirty(bool is_dirty);
60 bool IsMemoryPolicyDirty() const; 70 bool IsMemoryPolicyDirty() const;
61 void SetDrawGLInput(const DrawGLInput& input); 71 void SetDrawGLInput(scoped_ptr<DrawGLInput> input);
62 DrawGLInput GetDrawGLInput() const; 72 scoped_ptr<DrawGLInput> PassDrawGLInput();
63 73
64 // Set by UI and read by RT. 74 // Set by UI and read by RT.
65 void SetHardwareAllowed(bool allowed); 75 void SetHardwareAllowed(bool allowed);
66 bool IsHardwareAllowed() const; 76 bool IsHardwareAllowed() const;
67 77
68 // Set by RT and read by UI. 78 // Set by RT and read by UI.
69 void SetHardwareInitialized(bool initialized); 79 void SetHardwareInitialized(bool initialized);
70 bool IsHardwareInitialized() const; 80 bool IsHardwareInitialized() const;
71 81
82 void SetSharedContext(gpu::GLInProcessContext* context);
83 gpu::GLInProcessContext* GetSharedContext() const;
84
85 void ReturnResources(const cc::TransferableResourceArray& input);
86 void InsertReturnedResources(const cc::ReturnedResourceArray& resources);
87 void SwapReturnedResources(cc::ReturnedResourceArray* resources);
88 bool ReturnedResourcesEmpty() const;
89
72 private: 90 private:
73 void ClientRequestDrawGLOnUIThread(); 91 void ClientRequestDrawGLOnUIThread();
74 92
75 scoped_refptr<base::MessageLoopProxy> ui_loop_; 93 scoped_refptr<base::MessageLoopProxy> ui_loop_;
76 // TODO(boliu): Remove |client_on_ui_| from shared state. 94 // TODO(boliu): Remove |client_on_ui_| from shared state.
77 BrowserViewRendererClient* client_on_ui_; 95 BrowserViewRendererClient* client_on_ui_;
78 base::WeakPtrFactory<SharedRendererState> weak_factory_on_ui_thread_; 96 base::WeakPtrFactory<SharedRendererState> weak_factory_on_ui_thread_;
79 base::WeakPtr<SharedRendererState> ui_thread_weak_ptr_; 97 base::WeakPtr<SharedRendererState> ui_thread_weak_ptr_;
80 98
81 // Accessed by both UI and RT thread. 99 // Accessed by both UI and RT thread.
82 mutable base::Lock lock_; 100 mutable base::Lock lock_;
83 content::SynchronousCompositor* compositor_; 101 content::SynchronousCompositor* compositor_;
84 content::SynchronousCompositorMemoryPolicy memory_policy_; 102 content::SynchronousCompositorMemoryPolicy memory_policy_;
85 // Set to true when SetMemoryPolicy called with a different memory policy. 103 // Set to true when SetMemoryPolicy called with a different memory policy.
86 // Set to false when memory policy is read and enforced to compositor. 104 // Set to false when memory policy is read and enforced to compositor.
87 bool memory_policy_dirty_; 105 bool memory_policy_dirty_;
88 DrawGLInput draw_gl_input_; 106 scoped_ptr<DrawGLInput> draw_gl_input_;
89 bool hardware_allowed_; 107 bool hardware_allowed_;
90 bool hardware_initialized_; 108 bool hardware_initialized_;
109 gpu::GLInProcessContext* share_context_;
110 cc::ReturnedResourceArray returned_resources_;
91 }; 111 };
92 112
93 } // namespace android_webview 113 } // namespace android_webview
94 114
95 #endif // ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_ 115 #endif // ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_
OLDNEW
« no previous file with comments | « android_webview/browser/parent_output_surface.cc ('k') | android_webview/browser/shared_renderer_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698