| 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/renderer/android/synchronous_compositor_output_surface.h" | 5 #include "content/renderer/android/synchronous_compositor_output_surface.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 NOTREACHED(); | 295 NOTREACHED(); |
| 296 } | 296 } |
| 297 | 297 |
| 298 uint32_t SynchronousCompositorOutputSurface::GetFramebufferCopyTextureFormat() { | 298 uint32_t SynchronousCompositorOutputSurface::GetFramebufferCopyTextureFormat() { |
| 299 // This is a delegating output surface, no framebuffer/direct drawing support. | 299 // This is a delegating output surface, no framebuffer/direct drawing support. |
| 300 NOTREACHED(); | 300 NOTREACHED(); |
| 301 return 0; | 301 return 0; |
| 302 } | 302 } |
| 303 | 303 |
| 304 void SynchronousCompositorOutputSurface::DemandDrawHw( | 304 void SynchronousCompositorOutputSurface::DemandDrawHw( |
| 305 const gfx::Size& surface_size, | 305 const gfx::Size& viewport_size, |
| 306 const gfx::Transform& transform, | |
| 307 const gfx::Rect& viewport, | |
| 308 const gfx::Rect& clip, | |
| 309 const gfx::Rect& viewport_rect_for_tile_priority, | 306 const gfx::Rect& viewport_rect_for_tile_priority, |
| 310 const gfx::Transform& transform_for_tile_priority) { | 307 const gfx::Transform& transform_for_tile_priority) { |
| 311 DCHECK(CalledOnValidThread()); | 308 DCHECK(CalledOnValidThread()); |
| 312 DCHECK(HasClient()); | 309 DCHECK(HasClient()); |
| 313 DCHECK(context_provider_.get()); | 310 DCHECK(context_provider_.get()); |
| 314 CancelFallbackTick(); | 311 CancelFallbackTick(); |
| 315 | 312 |
| 316 client_->SetExternalTilePriorityConstraints(viewport_rect_for_tile_priority, | 313 client_->SetExternalTilePriorityConstraints(viewport_rect_for_tile_priority, |
| 317 transform_for_tile_priority); | 314 transform_for_tile_priority); |
| 318 InvokeComposite(transform, viewport, clip); | 315 InvokeComposite(gfx::Transform(), gfx::Rect(viewport_size)); |
| 319 } | 316 } |
| 320 | 317 |
| 321 void SynchronousCompositorOutputSurface::DemandDrawSw(SkCanvas* canvas) { | 318 void SynchronousCompositorOutputSurface::DemandDrawSw(SkCanvas* canvas) { |
| 322 DCHECK(CalledOnValidThread()); | 319 DCHECK(CalledOnValidThread()); |
| 323 DCHECK(canvas); | 320 DCHECK(canvas); |
| 324 DCHECK(!current_sw_canvas_); | 321 DCHECK(!current_sw_canvas_); |
| 325 CancelFallbackTick(); | 322 CancelFallbackTick(); |
| 326 | 323 |
| 327 base::AutoReset<SkCanvas*> canvas_resetter(¤t_sw_canvas_, canvas); | 324 base::AutoReset<SkCanvas*> canvas_resetter(¤t_sw_canvas_, canvas); |
| 328 | 325 |
| 329 SkIRect canvas_clip; | 326 SkIRect canvas_clip; |
| 330 canvas->getClipDeviceBounds(&canvas_clip); | 327 canvas->getClipDeviceBounds(&canvas_clip); |
| 331 gfx::Rect clip = gfx::SkIRectToRect(canvas_clip); | 328 gfx::Rect viewport = gfx::SkIRectToRect(canvas_clip); |
| 332 | 329 |
| 333 gfx::Transform transform(gfx::Transform::kSkipInitialization); | 330 gfx::Transform transform(gfx::Transform::kSkipInitialization); |
| 334 transform.matrix() = canvas->getTotalMatrix(); // Converts 3x3 matrix to 4x4. | 331 transform.matrix() = canvas->getTotalMatrix(); // Converts 3x3 matrix to 4x4. |
| 335 | 332 |
| 336 base::AutoReset<bool> set_in_software_draw(&in_software_draw_, true); | 333 base::AutoReset<bool> set_in_software_draw(&in_software_draw_, true); |
| 337 display_->SetExternalViewport(clip); | 334 display_->SetExternalViewport(viewport); |
| 338 display_->SetExternalClip(clip); | 335 display_->SetExternalClip(viewport); |
| 339 software_output_surface_->SetSurfaceSize( | 336 software_output_surface_->SetSurfaceSize( |
| 340 gfx::SkISizeToSize(canvas->getBaseLayerSize())); | 337 gfx::SkISizeToSize(canvas->getBaseLayerSize())); |
| 341 InvokeComposite(transform, clip, clip); | 338 InvokeComposite(transform, viewport); |
| 342 } | 339 } |
| 343 | 340 |
| 344 void SynchronousCompositorOutputSurface::InvokeComposite( | 341 void SynchronousCompositorOutputSurface::InvokeComposite( |
| 345 const gfx::Transform& transform, | 342 const gfx::Transform& transform, |
| 346 const gfx::Rect& viewport, | 343 const gfx::Rect& viewport) { |
| 347 const gfx::Rect& clip) { | |
| 348 gfx::Transform adjusted_transform = transform; | 344 gfx::Transform adjusted_transform = transform; |
| 349 adjusted_transform.matrix().postTranslate(-viewport.x(), -viewport.y(), 0); | 345 adjusted_transform.matrix().postTranslate(-viewport.x(), -viewport.y(), 0); |
| 350 did_swap_ = false; | 346 did_swap_ = false; |
| 351 client_->OnDraw(adjusted_transform, viewport, clip, in_software_draw_); | 347 client_->OnDraw(adjusted_transform, viewport, in_software_draw_); |
| 352 | 348 |
| 353 if (did_swap_) { | 349 if (did_swap_) { |
| 354 // This must happen after unwinding the stack and leaving the compositor. | 350 // This must happen after unwinding the stack and leaving the compositor. |
| 355 // Usually it is a separate task but we just defer it until OnDraw completes | 351 // Usually it is a separate task but we just defer it until OnDraw completes |
| 356 // instead. | 352 // instead. |
| 357 client_->DidSwapBuffersComplete(); | 353 client_->DidSwapBuffersComplete(); |
| 358 } | 354 } |
| 359 } | 355 } |
| 360 | 356 |
| 361 void SynchronousCompositorOutputSurface::OnReclaimResources( | 357 void SynchronousCompositorOutputSurface::OnReclaimResources( |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 client_->ReclaimResources(resources); | 418 client_->ReclaimResources(resources); |
| 423 } | 419 } |
| 424 | 420 |
| 425 void SynchronousCompositorOutputSurface::SetBeginFrameSource( | 421 void SynchronousCompositorOutputSurface::SetBeginFrameSource( |
| 426 cc::BeginFrameSource* begin_frame_source) { | 422 cc::BeginFrameSource* begin_frame_source) { |
| 427 // Software output is synchronous and doesn't use a BeginFrameSource. | 423 // Software output is synchronous and doesn't use a BeginFrameSource. |
| 428 NOTREACHED(); | 424 NOTREACHED(); |
| 429 } | 425 } |
| 430 | 426 |
| 431 } // namespace content | 427 } // namespace content |
| OLD | NEW |