| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; | 88 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; |
| 89 } | 89 } |
| 90 | 90 |
| 91 SynchronousCompositorOutputSurface::~SynchronousCompositorOutputSurface() { | 91 SynchronousCompositorOutputSurface::~SynchronousCompositorOutputSurface() { |
| 92 DCHECK(CalledOnValidThread()); | 92 DCHECK(CalledOnValidThread()); |
| 93 SynchronousCompositorOutputSurfaceDelegate* delegate = GetDelegate(); | 93 SynchronousCompositorOutputSurfaceDelegate* delegate = GetDelegate(); |
| 94 if (delegate) | 94 if (delegate) |
| 95 delegate->DidDestroySynchronousOutputSurface(this); | 95 delegate->DidDestroySynchronousOutputSurface(this); |
| 96 } | 96 } |
| 97 | 97 |
| 98 bool SynchronousCompositorOutputSurface::ForcedDrawToSoftwareDevice() const { | |
| 99 // |current_sw_canvas_| indicates we're in a DemandDrawSw call. In addition | |
| 100 // |invoking_composite_| == false indicates an attempt to draw outside of | |
| 101 // the synchronous compositor's control: force it into SW path and hence to | |
| 102 // the null canvas (and will log a warning there). | |
| 103 return current_sw_canvas_ != NULL || !invoking_composite_; | |
| 104 } | |
| 105 | |
| 106 bool SynchronousCompositorOutputSurface::BindToClient( | 98 bool SynchronousCompositorOutputSurface::BindToClient( |
| 107 cc::OutputSurfaceClient* surface_client) { | 99 cc::OutputSurfaceClient* surface_client) { |
| 108 DCHECK(CalledOnValidThread()); | 100 DCHECK(CalledOnValidThread()); |
| 109 if (!cc::OutputSurface::BindToClient(surface_client)) | 101 if (!cc::OutputSurface::BindToClient(surface_client)) |
| 110 return false; | 102 return false; |
| 111 | 103 |
| 112 output_surface_client_ = surface_client; | 104 output_surface_client_ = surface_client; |
| 113 output_surface_client_->SetTreeActivationCallback( | 105 output_surface_client_->SetTreeActivationCallback( |
| 114 base::Bind(&DidActivatePendingTree, routing_id_)); | 106 base::Bind(&DidActivatePendingTree, routing_id_)); |
| 115 output_surface_client_->SetMemoryPolicy(memory_policy_); | 107 output_surface_client_->SetMemoryPolicy(memory_policy_); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 | 192 |
| 201 InvokeComposite(transform, clip, clip, false); | 193 InvokeComposite(transform, clip, clip, false); |
| 202 | 194 |
| 203 return frame_holder_.Pass(); | 195 return frame_holder_.Pass(); |
| 204 } | 196 } |
| 205 | 197 |
| 206 void SynchronousCompositorOutputSurface::InvokeComposite( | 198 void SynchronousCompositorOutputSurface::InvokeComposite( |
| 207 const gfx::Transform& transform, | 199 const gfx::Transform& transform, |
| 208 gfx::Rect viewport, | 200 gfx::Rect viewport, |
| 209 gfx::Rect clip, | 201 gfx::Rect clip, |
| 210 bool valid_for_tile_management) { | 202 bool hardware_draw) { |
| 211 DCHECK(!invoking_composite_); | 203 DCHECK(!invoking_composite_); |
| 212 DCHECK(!frame_holder_.get()); | 204 DCHECK(!frame_holder_.get()); |
| 213 base::AutoReset<bool> invoking_composite_resetter(&invoking_composite_, true); | 205 base::AutoReset<bool> invoking_composite_resetter(&invoking_composite_, true); |
| 214 | 206 |
| 215 gfx::Transform adjusted_transform = transform; | 207 gfx::Transform adjusted_transform = transform; |
| 216 AdjustTransform(&adjusted_transform, viewport); | 208 AdjustTransform(&adjusted_transform, viewport); |
| 217 SetExternalDrawConstraints( | 209 SetExternalDrawConstraints( |
| 218 adjusted_transform, viewport, clip, valid_for_tile_management); | 210 adjusted_transform, viewport, clip, !hardware_draw, hardware_draw); |
| 219 SetNeedsRedrawRect(gfx::Rect(viewport.size())); | 211 SetNeedsRedrawRect(gfx::Rect(viewport.size())); |
| 220 client_->BeginFrame(cc::BeginFrameArgs::CreateForSynchronousCompositor()); | 212 client_->BeginFrame(cc::BeginFrameArgs::CreateForSynchronousCompositor()); |
| 221 | 213 |
| 222 // After software draws (which might move the viewport arbitrarily), restore | 214 // After software draws (which might move the viewport arbitrarily), restore |
| 223 // the previous hardware viewport to allow CC's tile manager to prioritize | 215 // the previous hardware viewport to allow CC's tile manager to prioritize |
| 224 // properly. | 216 // properly. |
| 225 if (valid_for_tile_management) { | 217 if (hardware_draw) { |
| 226 cached_hw_transform_ = adjusted_transform; | 218 cached_hw_transform_ = adjusted_transform; |
| 227 cached_hw_viewport_ = viewport; | 219 cached_hw_viewport_ = viewport; |
| 228 cached_hw_clip_ = clip; | 220 cached_hw_clip_ = clip; |
| 229 } else { | 221 } else { |
| 230 SetExternalDrawConstraints( | 222 SetExternalDrawConstraints(cached_hw_transform_, |
| 231 cached_hw_transform_, cached_hw_viewport_, cached_hw_clip_, true); | 223 cached_hw_viewport_, |
| 224 cached_hw_clip_, |
| 225 false, |
| 226 true); |
| 232 } | 227 } |
| 233 | 228 |
| 234 if (frame_holder_.get()) | 229 if (frame_holder_.get()) |
| 235 client_->DidSwapBuffersComplete(); | 230 client_->DidSwapBuffersComplete(); |
| 236 | 231 |
| 237 SynchronousCompositorOutputSurfaceDelegate* delegate = GetDelegate(); | 232 SynchronousCompositorOutputSurfaceDelegate* delegate = GetDelegate(); |
| 238 if (delegate) | 233 if (delegate) |
| 239 delegate->SetContinuousInvalidate(needs_begin_frame_); | 234 delegate->SetContinuousInvalidate(needs_begin_frame_); |
| 240 } | 235 } |
| 241 | 236 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 260 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { | 255 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { |
| 261 return BrowserThread::CurrentlyOn(BrowserThread::UI); | 256 return BrowserThread::CurrentlyOn(BrowserThread::UI); |
| 262 } | 257 } |
| 263 | 258 |
| 264 SynchronousCompositorOutputSurfaceDelegate* | 259 SynchronousCompositorOutputSurfaceDelegate* |
| 265 SynchronousCompositorOutputSurface::GetDelegate() { | 260 SynchronousCompositorOutputSurface::GetDelegate() { |
| 266 return SynchronousCompositorImpl::FromRoutingID(routing_id_); | 261 return SynchronousCompositorImpl::FromRoutingID(routing_id_); |
| 267 } | 262 } |
| 268 | 263 |
| 269 } // namespace content | 264 } // namespace content |
| OLD | NEW |