OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "content/browser/android/in_process/synchronous_compositor_output_surfa
ce.h" | 5 #include "content/browser/android/in_process/synchronous_compositor_output_surfa
ce.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "cc/output/begin_frame_args.h" | 9 #include "cc/output/begin_frame_args.h" |
10 #include "cc/output/compositor_frame.h" | 10 #include "cc/output/compositor_frame.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 delegate->DidBindOutputSurface(this); | 115 delegate->DidBindOutputSurface(this); |
116 | 116 |
117 return true; | 117 return true; |
118 } | 118 } |
119 | 119 |
120 void SynchronousCompositorOutputSurface::Reshape( | 120 void SynchronousCompositorOutputSurface::Reshape( |
121 const gfx::Size& size, float scale_factor) { | 121 const gfx::Size& size, float scale_factor) { |
122 // Intentional no-op: surface size is controlled by the embedder. | 122 // Intentional no-op: surface size is controlled by the embedder. |
123 } | 123 } |
124 | 124 |
125 void SynchronousCompositorOutputSurface::SetNeedsBeginImplFrame( | 125 void SynchronousCompositorOutputSurface::SetNeedsBeginFrame(bool enable) { |
126 bool enable) { | |
127 DCHECK(CalledOnValidThread()); | 126 DCHECK(CalledOnValidThread()); |
128 needs_begin_impl_frame_ = enable; | 127 needs_begin_impl_frame_ = enable; |
129 client_ready_for_begin_impl_frame_ = true; | |
130 SynchronousCompositorOutputSurfaceDelegate* delegate = GetDelegate(); | 128 SynchronousCompositorOutputSurfaceDelegate* delegate = GetDelegate(); |
131 if (delegate && !invoking_composite_) | 129 if (delegate && !invoking_composite_) |
132 delegate->SetContinuousInvalidate(needs_begin_impl_frame_); | 130 delegate->SetContinuousInvalidate(needs_begin_impl_frame_); |
133 } | 131 } |
134 | 132 |
135 void SynchronousCompositorOutputSurface::SwapBuffers( | 133 void SynchronousCompositorOutputSurface::SwapBuffers( |
136 cc::CompositorFrame* frame) { | 134 cc::CompositorFrame* frame) { |
137 DCHECK(CalledOnValidThread()); | 135 DCHECK(CalledOnValidThread()); |
138 if (!ForcedDrawToSoftwareDevice()) { | 136 if (!ForcedDrawToSoftwareDevice()) { |
139 DCHECK(context_provider_); | 137 DCHECK(context_provider_); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 bool valid_for_tile_management) { | 214 bool valid_for_tile_management) { |
217 DCHECK(!invoking_composite_); | 215 DCHECK(!invoking_composite_); |
218 base::AutoReset<bool> invoking_composite_resetter(&invoking_composite_, true); | 216 base::AutoReset<bool> invoking_composite_resetter(&invoking_composite_, true); |
219 did_swap_buffer_ = false; | 217 did_swap_buffer_ = false; |
220 | 218 |
221 gfx::Transform adjusted_transform = transform; | 219 gfx::Transform adjusted_transform = transform; |
222 AdjustTransform(&adjusted_transform, viewport); | 220 AdjustTransform(&adjusted_transform, viewport); |
223 SetExternalDrawConstraints( | 221 SetExternalDrawConstraints( |
224 adjusted_transform, viewport, clip, valid_for_tile_management); | 222 adjusted_transform, viewport, clip, valid_for_tile_management); |
225 SetNeedsRedrawRect(gfx::Rect(viewport.size())); | 223 SetNeedsRedrawRect(gfx::Rect(viewport.size())); |
226 BeginImplFrame(cc::BeginFrameArgs::CreateForSynchronousCompositor()); | 224 BeginFrame(cc::BeginFrameArgs::CreateForSynchronousCompositor()); |
227 | 225 |
228 // After software draws (which might move the viewport arbitrarily), restore | 226 // After software draws (which might move the viewport arbitrarily), restore |
229 // the previous hardware viewport to allow CC's tile manager to prioritize | 227 // the previous hardware viewport to allow CC's tile manager to prioritize |
230 // properly. | 228 // properly. |
231 if (valid_for_tile_management) { | 229 if (valid_for_tile_management) { |
232 cached_hw_transform_ = adjusted_transform; | 230 cached_hw_transform_ = adjusted_transform; |
233 cached_hw_viewport_ = viewport; | 231 cached_hw_viewport_ = viewport; |
234 cached_hw_clip_ = clip; | 232 cached_hw_clip_ = clip; |
235 } else { | 233 } else { |
236 SetExternalDrawConstraints( | 234 SetExternalDrawConstraints( |
237 cached_hw_transform_, cached_hw_viewport_, cached_hw_clip_, true); | 235 cached_hw_transform_, cached_hw_viewport_, cached_hw_clip_, true); |
238 } | 236 } |
239 | 237 |
240 if (did_swap_buffer_) | 238 if (did_swap_buffer_) |
241 OnSwapBuffersComplete(); | 239 OnSwapBuffersComplete(); |
242 | 240 |
243 SynchronousCompositorOutputSurfaceDelegate* delegate = GetDelegate(); | 241 SynchronousCompositorOutputSurfaceDelegate* delegate = GetDelegate(); |
244 if (delegate) | 242 if (delegate) |
245 delegate->SetContinuousInvalidate(needs_begin_impl_frame_); | 243 delegate->SetContinuousInvalidate(needs_begin_impl_frame_); |
246 } | 244 } |
247 | 245 |
248 void | 246 void SynchronousCompositorOutputSurface::PostCheckForRetroactiveBeginFrame() { |
249 SynchronousCompositorOutputSurface::PostCheckForRetroactiveBeginImplFrame() { | 247 // Synchronous compositor cannot perform retroactive BeginFrames, so |
250 // Synchronous compositor cannot perform retroactive BeginImplFrames, so | |
251 // intentionally no-op here. | 248 // intentionally no-op here. |
252 } | 249 } |
253 | 250 |
254 void SynchronousCompositorOutputSurface::SetMemoryPolicy( | 251 void SynchronousCompositorOutputSurface::SetMemoryPolicy( |
255 const SynchronousCompositorMemoryPolicy& policy) { | 252 const SynchronousCompositorMemoryPolicy& policy) { |
256 DCHECK(CalledOnValidThread()); | 253 DCHECK(CalledOnValidThread()); |
257 memory_policy_.bytes_limit_when_visible = policy.bytes_limit; | 254 memory_policy_.bytes_limit_when_visible = policy.bytes_limit; |
258 memory_policy_.num_resources_limit = policy.num_resources_limit; | 255 memory_policy_.num_resources_limit = policy.num_resources_limit; |
259 | 256 |
260 if (output_surface_client_) | 257 if (output_surface_client_) |
261 output_surface_client_->SetMemoryPolicy(memory_policy_); | 258 output_surface_client_->SetMemoryPolicy(memory_policy_); |
262 } | 259 } |
263 | 260 |
264 // Not using base::NonThreadSafe as we want to enforce a more exacting threading | 261 // Not using base::NonThreadSafe as we want to enforce a more exacting threading |
265 // requirement: SynchronousCompositorOutputSurface() must only be used on the UI | 262 // requirement: SynchronousCompositorOutputSurface() must only be used on the UI |
266 // thread. | 263 // thread. |
267 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { | 264 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { |
268 return BrowserThread::CurrentlyOn(BrowserThread::UI); | 265 return BrowserThread::CurrentlyOn(BrowserThread::UI); |
269 } | 266 } |
270 | 267 |
271 SynchronousCompositorOutputSurfaceDelegate* | 268 SynchronousCompositorOutputSurfaceDelegate* |
272 SynchronousCompositorOutputSurface::GetDelegate() { | 269 SynchronousCompositorOutputSurface::GetDelegate() { |
273 return SynchronousCompositorImpl::FromRoutingID(routing_id_); | 270 return SynchronousCompositorImpl::FromRoutingID(routing_id_); |
274 } | 271 } |
275 | 272 |
276 } // namespace content | 273 } // namespace content |
OLD | NEW |