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" |
11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "cc/resources/ui_resource_client.h" |
13 #include "cc/trees/layer_tree_host_client.h" | 15 #include "cc/trees/layer_tree_host_client.h" |
14 #include "cc/trees/layer_tree_host_single_thread_client.h" | 16 #include "cc/trees/layer_tree_host_single_thread_client.h" |
15 #include "content/browser/android/ui_resource_provider_impl.h" | 17 #include "content/browser/android/ui_resource_provider_impl.h" |
16 #include "content/browser/renderer_host/image_transport_factory_android.h" | 18 #include "content/browser/renderer_host/image_transport_factory_android.h" |
17 #include "content/common/content_export.h" | 19 #include "content/common/content_export.h" |
18 #include "content/public/browser/android/compositor.h" | 20 #include "content/public/browser/android/compositor.h" |
19 #include "third_party/khronos/GLES2/gl2.h" | 21 #include "third_party/khronos/GLES2/gl2.h" |
20 #include "ui/base/android/system_ui_resource_manager.h" | |
21 #include "ui/base/android/window_android_compositor.h" | 22 #include "ui/base/android/window_android_compositor.h" |
22 | 23 |
23 class SkBitmap; | 24 class SkBitmap; |
24 struct ANativeWindow; | 25 struct ANativeWindow; |
25 | 26 |
26 namespace cc { | 27 namespace cc { |
27 class Layer; | 28 class Layer; |
28 class LayerTreeHost; | 29 class LayerTreeHost; |
29 } | 30 } |
30 | 31 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 // ImageTransportFactoryAndroidObserver implementation. | 91 // ImageTransportFactoryAndroidObserver implementation. |
91 virtual void OnLostResources() OVERRIDE; | 92 virtual void OnLostResources() OVERRIDE; |
92 | 93 |
93 // WindowAndroidCompositor implementation. | 94 // WindowAndroidCompositor implementation. |
94 virtual void AttachLayerForReadback(scoped_refptr<cc::Layer> layer) OVERRIDE; | 95 virtual void AttachLayerForReadback(scoped_refptr<cc::Layer> layer) OVERRIDE; |
95 virtual void RequestCopyOfOutputOnRootLayer( | 96 virtual void RequestCopyOfOutputOnRootLayer( |
96 scoped_ptr<cc::CopyOutputRequest> request) OVERRIDE; | 97 scoped_ptr<cc::CopyOutputRequest> request) OVERRIDE; |
97 virtual void OnVSync(base::TimeTicks frame_time, | 98 virtual void OnVSync(base::TimeTicks frame_time, |
98 base::TimeDelta vsync_period) OVERRIDE; | 99 base::TimeDelta vsync_period) OVERRIDE; |
99 virtual void SetNeedsAnimate() OVERRIDE; | 100 virtual void SetNeedsAnimate() OVERRIDE; |
100 virtual ui::SystemUIResourceManager& GetSystemUIResourceManager() OVERRIDE; | |
101 | 101 |
102 enum CompositingTrigger { | 102 enum CompositingTrigger { |
103 DO_NOT_COMPOSITE, | 103 DO_NOT_COMPOSITE, |
104 COMPOSITE_IMMEDIATELY, | 104 COMPOSITE_IMMEDIATELY, |
105 COMPOSITE_EVENTUALLY, | 105 COMPOSITE_EVENTUALLY, |
106 }; | 106 }; |
107 void PostComposite(CompositingTrigger trigger); | 107 void PostComposite(CompositingTrigger trigger); |
108 void Composite(CompositingTrigger trigger); | 108 void Composite(CompositingTrigger trigger); |
109 | 109 |
110 bool WillCompositeThisFrame() const { | 110 bool WillCompositeThisFrame() const { |
111 return current_composite_task_ && | 111 return current_composite_task_ && |
112 !current_composite_task_->callback().is_null(); | 112 !current_composite_task_->callback().is_null(); |
113 } | 113 } |
114 bool DidCompositeThisFrame() const { | 114 bool DidCompositeThisFrame() const { |
115 return current_composite_task_ && | 115 return current_composite_task_ && |
116 current_composite_task_->callback().is_null(); | 116 current_composite_task_->callback().is_null(); |
117 } | 117 } |
118 bool WillComposite() const { | 118 bool WillComposite() const { |
119 return WillCompositeThisFrame() || | 119 return WillCompositeThisFrame() || |
120 composite_on_vsync_trigger_ != DO_NOT_COMPOSITE; | 120 composite_on_vsync_trigger_ != DO_NOT_COMPOSITE; |
121 } | 121 } |
122 void CancelComposite() { | 122 void CancelComposite() { |
123 DCHECK(WillComposite()); | 123 DCHECK(WillComposite()); |
124 if (WillCompositeThisFrame()) | 124 if (WillCompositeThisFrame()) |
125 current_composite_task_->Cancel(); | 125 current_composite_task_->Cancel(); |
126 current_composite_task_.reset(); | 126 current_composite_task_.reset(); |
127 composite_on_vsync_trigger_ = DO_NOT_COMPOSITE; | 127 composite_on_vsync_trigger_ = DO_NOT_COMPOSITE; |
128 will_composite_immediately_ = false; | 128 will_composite_immediately_ = false; |
129 } | 129 } |
| 130 cc::UIResourceId GenerateUIResourceFromUIResourceBitmap( |
| 131 const cc::UIResourceBitmap& bitmap, |
| 132 bool is_transient); |
130 void OnGpuChannelEstablished(); | 133 void OnGpuChannelEstablished(); |
131 | 134 |
132 // root_layer_ is the persistent internal root layer, while subroot_layer_ | 135 // root_layer_ is the persistent internal root layer, while subroot_layer_ |
133 // is the one attached by the compositor client. | 136 // is the one attached by the compositor client. |
134 scoped_refptr<cc::Layer> root_layer_; | 137 scoped_refptr<cc::Layer> root_layer_; |
135 scoped_refptr<cc::Layer> subroot_layer_; | 138 scoped_refptr<cc::Layer> subroot_layer_; |
136 | 139 |
137 scoped_ptr<cc::LayerTreeHost> host_; | 140 scoped_ptr<cc::LayerTreeHost> host_; |
138 content::UIResourceProviderImpl ui_resource_provider_; | 141 content::UIResourceProviderImpl ui_resource_provider_; |
139 | 142 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 base::TimeTicks last_vsync_; | 182 base::TimeTicks last_vsync_; |
180 | 183 |
181 base::WeakPtrFactory<CompositorImpl> weak_factory_; | 184 base::WeakPtrFactory<CompositorImpl> weak_factory_; |
182 | 185 |
183 DISALLOW_COPY_AND_ASSIGN(CompositorImpl); | 186 DISALLOW_COPY_AND_ASSIGN(CompositorImpl); |
184 }; | 187 }; |
185 | 188 |
186 } // namespace content | 189 } // namespace content |
187 | 190 |
188 #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ | 191 #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ |
OLD | NEW |