OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/cancelable_callback.h" | 9 #include "base/cancelable_callback.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/containers/scoped_ptr_hash_map.h" | |
12 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
14 #include "cc/resources/ui_resource_client.h" | |
15 #include "cc/trees/layer_tree_host_client.h" | 13 #include "cc/trees/layer_tree_host_client.h" |
16 #include "cc/trees/layer_tree_host_single_thread_client.h" | 14 #include "cc/trees/layer_tree_host_single_thread_client.h" |
17 #include "content/browser/android/ui_resource_provider_impl.h" | 15 #include "content/browser/android/ui_resource_provider_impl.h" |
18 #include "content/browser/renderer_host/image_transport_factory_android.h" | 16 #include "content/browser/renderer_host/image_transport_factory_android.h" |
19 #include "content/common/content_export.h" | 17 #include "content/common/content_export.h" |
20 #include "content/public/browser/android/compositor.h" | 18 #include "content/public/browser/android/compositor.h" |
21 #include "third_party/khronos/GLES2/gl2.h" | 19 #include "third_party/khronos/GLES2/gl2.h" |
| 20 #include "ui/base/android/system_ui_resource_manager.h" |
22 #include "ui/base/android/window_android_compositor.h" | 21 #include "ui/base/android/window_android_compositor.h" |
23 | 22 |
24 class SkBitmap; | 23 class SkBitmap; |
25 struct ANativeWindow; | 24 struct ANativeWindow; |
26 | 25 |
27 namespace cc { | 26 namespace cc { |
28 class Layer; | 27 class Layer; |
29 class LayerTreeHost; | 28 class LayerTreeHost; |
30 } | 29 } |
31 | 30 |
32 namespace content { | 31 namespace content { |
33 class CompositorClient; | 32 class CompositorClient; |
34 class UIResourceProvider; | |
35 | 33 |
36 // ----------------------------------------------------------------------------- | 34 // ----------------------------------------------------------------------------- |
37 // Browser-side compositor that manages a tree of content and UI layers. | 35 // Browser-side compositor that manages a tree of content and UI layers. |
38 // ----------------------------------------------------------------------------- | 36 // ----------------------------------------------------------------------------- |
39 class CONTENT_EXPORT CompositorImpl | 37 class CONTENT_EXPORT CompositorImpl |
40 : public Compositor, | 38 : public Compositor, |
41 public cc::LayerTreeHostClient, | 39 public cc::LayerTreeHostClient, |
42 public cc::LayerTreeHostSingleThreadClient, | 40 public cc::LayerTreeHostSingleThreadClient, |
43 public ImageTransportFactoryAndroidObserver, | 41 public ImageTransportFactoryAndroidObserver, |
44 public ui::WindowAndroidCompositor { | 42 public ui::WindowAndroidCompositor { |
(...skipping 13 matching lines...) Expand all Loading... |
58 private: | 56 private: |
59 // Compositor implementation. | 57 // Compositor implementation. |
60 virtual void SetRootLayer(scoped_refptr<cc::Layer> root) OVERRIDE; | 58 virtual void SetRootLayer(scoped_refptr<cc::Layer> root) OVERRIDE; |
61 virtual void SetWindowSurface(ANativeWindow* window) OVERRIDE; | 59 virtual void SetWindowSurface(ANativeWindow* window) OVERRIDE; |
62 virtual void SetSurface(jobject surface) OVERRIDE; | 60 virtual void SetSurface(jobject surface) OVERRIDE; |
63 virtual void SetVisible(bool visible) OVERRIDE; | 61 virtual void SetVisible(bool visible) OVERRIDE; |
64 virtual void setDeviceScaleFactor(float factor) OVERRIDE; | 62 virtual void setDeviceScaleFactor(float factor) OVERRIDE; |
65 virtual void SetWindowBounds(const gfx::Size& size) OVERRIDE; | 63 virtual void SetWindowBounds(const gfx::Size& size) OVERRIDE; |
66 virtual void SetHasTransparentBackground(bool flag) OVERRIDE; | 64 virtual void SetHasTransparentBackground(bool flag) OVERRIDE; |
67 virtual void SetNeedsComposite() OVERRIDE; | 65 virtual void SetNeedsComposite() OVERRIDE; |
68 virtual UIResourceProvider& GetUIResourceProvider() OVERRIDE; | |
69 | 66 |
70 // LayerTreeHostClient implementation. | 67 // LayerTreeHostClient implementation. |
71 virtual void WillBeginMainFrame(int frame_id) OVERRIDE {} | 68 virtual void WillBeginMainFrame(int frame_id) OVERRIDE {} |
72 virtual void DidBeginMainFrame() OVERRIDE {} | 69 virtual void DidBeginMainFrame() OVERRIDE {} |
73 virtual void Animate(base::TimeTicks frame_begin_time) OVERRIDE {} | 70 virtual void Animate(base::TimeTicks frame_begin_time) OVERRIDE {} |
74 virtual void Layout() OVERRIDE; | 71 virtual void Layout() OVERRIDE; |
75 virtual void ApplyScrollAndScale(const gfx::Vector2d& scroll_delta, | 72 virtual void ApplyScrollAndScale(const gfx::Vector2d& scroll_delta, |
76 float page_scale) OVERRIDE {} | 73 float page_scale) OVERRIDE {} |
77 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback) | 74 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback) |
78 OVERRIDE; | 75 OVERRIDE; |
(...skipping 12 matching lines...) Expand all Loading... |
91 // ImageTransportFactoryAndroidObserver implementation. | 88 // ImageTransportFactoryAndroidObserver implementation. |
92 virtual void OnLostResources() OVERRIDE; | 89 virtual void OnLostResources() OVERRIDE; |
93 | 90 |
94 // WindowAndroidCompositor implementation. | 91 // WindowAndroidCompositor implementation. |
95 virtual void AttachLayerForReadback(scoped_refptr<cc::Layer> layer) OVERRIDE; | 92 virtual void AttachLayerForReadback(scoped_refptr<cc::Layer> layer) OVERRIDE; |
96 virtual void RequestCopyOfOutputOnRootLayer( | 93 virtual void RequestCopyOfOutputOnRootLayer( |
97 scoped_ptr<cc::CopyOutputRequest> request) OVERRIDE; | 94 scoped_ptr<cc::CopyOutputRequest> request) OVERRIDE; |
98 virtual void OnVSync(base::TimeTicks frame_time, | 95 virtual void OnVSync(base::TimeTicks frame_time, |
99 base::TimeDelta vsync_period) OVERRIDE; | 96 base::TimeDelta vsync_period) OVERRIDE; |
100 virtual void SetNeedsAnimate() OVERRIDE; | 97 virtual void SetNeedsAnimate() OVERRIDE; |
| 98 virtual ui::UIResourceProvider& GetUIResourceProvider() OVERRIDE; |
| 99 virtual ui::SystemUIResourceManager& GetSystemUIResourceManager() OVERRIDE; |
101 | 100 |
102 enum CompositingTrigger { | 101 enum CompositingTrigger { |
103 DO_NOT_COMPOSITE, | 102 DO_NOT_COMPOSITE, |
104 COMPOSITE_IMMEDIATELY, | 103 COMPOSITE_IMMEDIATELY, |
105 COMPOSITE_EVENTUALLY, | 104 COMPOSITE_EVENTUALLY, |
106 }; | 105 }; |
107 void PostComposite(CompositingTrigger trigger); | 106 void PostComposite(CompositingTrigger trigger); |
108 void Composite(CompositingTrigger trigger); | 107 void Composite(CompositingTrigger trigger); |
109 | 108 |
110 bool WillCompositeThisFrame() const { | 109 bool WillCompositeThisFrame() const { |
111 return current_composite_task_ && | 110 return current_composite_task_ && |
112 !current_composite_task_->callback().is_null(); | 111 !current_composite_task_->callback().is_null(); |
113 } | 112 } |
114 bool DidCompositeThisFrame() const { | 113 bool DidCompositeThisFrame() const { |
115 return current_composite_task_ && | 114 return current_composite_task_ && |
116 current_composite_task_->callback().is_null(); | 115 current_composite_task_->callback().is_null(); |
117 } | 116 } |
118 bool WillComposite() const { | 117 bool WillComposite() const { |
119 return WillCompositeThisFrame() || | 118 return WillCompositeThisFrame() || |
120 composite_on_vsync_trigger_ != DO_NOT_COMPOSITE; | 119 composite_on_vsync_trigger_ != DO_NOT_COMPOSITE; |
121 } | 120 } |
122 void CancelComposite() { | 121 void CancelComposite() { |
123 DCHECK(WillComposite()); | 122 DCHECK(WillComposite()); |
124 if (WillCompositeThisFrame()) | 123 if (WillCompositeThisFrame()) |
125 current_composite_task_->Cancel(); | 124 current_composite_task_->Cancel(); |
126 current_composite_task_.reset(); | 125 current_composite_task_.reset(); |
127 composite_on_vsync_trigger_ = DO_NOT_COMPOSITE; | 126 composite_on_vsync_trigger_ = DO_NOT_COMPOSITE; |
128 will_composite_immediately_ = false; | 127 will_composite_immediately_ = false; |
129 } | 128 } |
130 cc::UIResourceId GenerateUIResourceFromUIResourceBitmap( | |
131 const cc::UIResourceBitmap& bitmap, | |
132 bool is_transient); | |
133 void OnGpuChannelEstablished(); | 129 void OnGpuChannelEstablished(); |
134 | 130 |
135 scoped_refptr<cc::Layer> root_layer_; | 131 scoped_refptr<cc::Layer> root_layer_; |
136 scoped_ptr<cc::LayerTreeHost> host_; | 132 scoped_ptr<cc::LayerTreeHost> host_; |
137 content::UIResourceProviderImpl ui_resource_provider_; | 133 content::UIResourceProviderImpl ui_resource_provider_; |
138 | 134 |
139 gfx::Size size_; | 135 gfx::Size size_; |
140 bool has_transparent_background_; | 136 bool has_transparent_background_; |
141 float device_scale_factor_; | 137 float device_scale_factor_; |
142 | 138 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 base::TimeTicks last_vsync_; | 174 base::TimeTicks last_vsync_; |
179 | 175 |
180 base::WeakPtrFactory<CompositorImpl> weak_factory_; | 176 base::WeakPtrFactory<CompositorImpl> weak_factory_; |
181 | 177 |
182 DISALLOW_COPY_AND_ASSIGN(CompositorImpl); | 178 DISALLOW_COPY_AND_ASSIGN(CompositorImpl); |
183 }; | 179 }; |
184 | 180 |
185 } // namespace content | 181 } // namespace content |
186 | 182 |
187 #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ | 183 #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ |
OLD | NEW |