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" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 float page_scale) OVERRIDE {} | 78 float page_scale) OVERRIDE {} |
79 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback) | 79 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback) |
80 OVERRIDE; | 80 OVERRIDE; |
81 virtual void DidInitializeOutputSurface() OVERRIDE {} | 81 virtual void DidInitializeOutputSurface() OVERRIDE {} |
82 virtual void WillCommit() OVERRIDE {} | 82 virtual void WillCommit() OVERRIDE {} |
83 virtual void DidCommit() OVERRIDE; | 83 virtual void DidCommit() OVERRIDE; |
84 virtual void DidCommitAndDrawFrame() OVERRIDE {} | 84 virtual void DidCommitAndDrawFrame() OVERRIDE {} |
85 virtual void DidCompleteSwapBuffers() OVERRIDE; | 85 virtual void DidCompleteSwapBuffers() OVERRIDE; |
86 | 86 |
87 // LayerTreeHostSingleThreadClient implementation. | 87 // LayerTreeHostSingleThreadClient implementation. |
88 virtual void ScheduleComposite() OVERRIDE; | |
89 virtual void ScheduleAnimation() OVERRIDE; | |
90 virtual void DidPostSwapBuffers() OVERRIDE; | 88 virtual void DidPostSwapBuffers() OVERRIDE; |
91 virtual void DidAbortSwapBuffers() OVERRIDE; | 89 virtual void DidAbortSwapBuffers() OVERRIDE; |
92 | 90 |
93 // ImageTransportFactoryAndroidObserver implementation. | 91 // ImageTransportFactoryAndroidObserver implementation. |
94 virtual void OnLostResources() OVERRIDE; | 92 virtual void OnLostResources() OVERRIDE; |
95 | 93 |
96 // WindowAndroidCompositor implementation. | 94 // WindowAndroidCompositor implementation. |
97 virtual void AttachLayerForReadback(scoped_refptr<cc::Layer> layer) OVERRIDE; | 95 virtual void AttachLayerForReadback(scoped_refptr<cc::Layer> layer) OVERRIDE; |
98 virtual void RequestCopyOfOutputOnRootLayer( | 96 virtual void RequestCopyOfOutputOnRootLayer( |
99 scoped_ptr<cc::CopyOutputRequest> request) OVERRIDE; | 97 scoped_ptr<cc::CopyOutputRequest> request) OVERRIDE; |
100 virtual void OnVSync(base::TimeTicks frame_time, | 98 virtual void OnVSync(base::TimeTicks frame_time, |
101 base::TimeDelta vsync_period) OVERRIDE; | 99 base::TimeDelta vsync_period) OVERRIDE; |
102 virtual void SetNeedsAnimate() OVERRIDE; | 100 virtual void SetNeedsAnimate() OVERRIDE; |
103 | 101 |
104 enum CompositingTrigger { | |
105 DO_NOT_COMPOSITE, | |
106 COMPOSITE_IMMEDIATELY, | |
107 COMPOSITE_EVENTUALLY, | |
108 }; | |
109 void PostComposite(CompositingTrigger trigger); | |
110 void Composite(CompositingTrigger trigger); | |
111 | |
112 bool WillCompositeThisFrame() const { | |
113 return current_composite_task_ && | |
114 !current_composite_task_->callback().is_null(); | |
115 } | |
116 bool DidCompositeThisFrame() const { | |
117 return current_composite_task_ && | |
118 current_composite_task_->callback().is_null(); | |
119 } | |
120 bool WillComposite() const { | |
121 return WillCompositeThisFrame() || | |
122 composite_on_vsync_trigger_ != DO_NOT_COMPOSITE; | |
123 } | |
124 void CancelComposite() { | |
125 DCHECK(WillComposite()); | |
126 if (WillCompositeThisFrame()) | |
127 current_composite_task_->Cancel(); | |
128 current_composite_task_.reset(); | |
129 composite_on_vsync_trigger_ = DO_NOT_COMPOSITE; | |
130 will_composite_immediately_ = false; | |
131 } | |
132 cc::UIResourceId GenerateUIResourceFromUIResourceBitmap( | 102 cc::UIResourceId GenerateUIResourceFromUIResourceBitmap( |
133 const cc::UIResourceBitmap& bitmap, | 103 const cc::UIResourceBitmap& bitmap, |
134 bool is_transient); | 104 bool is_transient); |
135 void OnGpuChannelEstablished(); | 105 void OnGpuChannelEstablished(); |
136 | 106 |
137 scoped_refptr<cc::Layer> root_layer_; | 107 scoped_refptr<cc::Layer> root_layer_; |
138 scoped_ptr<cc::LayerTreeHost> host_; | 108 scoped_ptr<cc::LayerTreeHost> host_; |
139 content::UIResourceProviderImpl ui_resource_provider_; | 109 content::UIResourceProviderImpl ui_resource_provider_; |
140 | 110 |
141 gfx::Size size_; | 111 gfx::Size size_; |
142 bool has_transparent_background_; | 112 bool has_transparent_background_; |
143 float device_scale_factor_; | 113 float device_scale_factor_; |
144 | 114 |
145 ANativeWindow* window_; | 115 ANativeWindow* window_; |
146 int surface_id_; | 116 int surface_id_; |
147 | 117 |
148 CompositorClient* client_; | 118 CompositorClient* client_; |
149 | 119 |
150 gfx::NativeWindow root_window_; | 120 gfx::NativeWindow root_window_; |
151 | 121 |
152 // Used locally to track whether a call to LTH::Composite() did result in | |
153 // a posted SwapBuffers(). | |
154 bool did_post_swapbuffers_; | |
155 | |
156 // Used locally to inhibit ScheduleComposite() during Layout(). | |
157 bool ignore_schedule_composite_; | |
158 | |
159 // Whether we need to composite in general because of any invalidation or | |
160 // explicit request. | |
161 bool needs_composite_; | |
162 | |
163 // Whether we need to update animations on the next composite. | |
164 bool needs_animate_; | |
165 | |
166 // Whether we posted a task and are about to composite. | |
167 bool will_composite_immediately_; | |
168 | |
169 // How we should schedule Composite during the next vsync. | |
170 CompositingTrigger composite_on_vsync_trigger_; | |
171 | |
172 // The Composite operation scheduled for the current vsync interval. | |
173 scoped_ptr<base::CancelableClosure> current_composite_task_; | |
174 | |
175 // The number of SwapBuffer calls that have not returned and ACK'd from | 122 // The number of SwapBuffer calls that have not returned and ACK'd from |
176 // the GPU thread. | 123 // the GPU thread. |
177 unsigned int pending_swapbuffers_; | 124 unsigned int pending_swapbuffers_; |
178 | 125 |
179 base::TimeDelta vsync_period_; | |
180 base::TimeTicks last_vsync_; | |
181 | |
182 base::WeakPtrFactory<CompositorImpl> weak_factory_; | 126 base::WeakPtrFactory<CompositorImpl> weak_factory_; |
183 | 127 |
184 DISALLOW_COPY_AND_ASSIGN(CompositorImpl); | 128 DISALLOW_COPY_AND_ASSIGN(CompositorImpl); |
185 }; | 129 }; |
186 | 130 |
187 } // namespace content | 131 } // namespace content |
188 | 132 |
189 #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ | 133 #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ |
OLD | NEW |