Chromium Code Reviews| Index: content/renderer/android/synchronous_compositor_output_surface.cc |
| diff --git a/content/renderer/android/synchronous_compositor_output_surface.cc b/content/renderer/android/synchronous_compositor_output_surface.cc |
| index 7acdf8a31b62e13e82872e3c2fdafe87a418f4b1..fc0b113bb4ec2261267af90ef3a15fc94e8908d7 100644 |
| --- a/content/renderer/android/synchronous_compositor_output_surface.cc |
| +++ b/content/renderer/android/synchronous_compositor_output_surface.cc |
| @@ -153,24 +153,38 @@ bool SynchronousCompositorOutputSurface::IsHwReady() { |
| return context3d() != NULL; |
| } |
| +namespace { |
| +void AdjustTransformForClip(gfx::Transform* transform, gfx::Rect clip) { |
| + // The system-provided transform translates us from the screen origin to the |
| + // origin of the clip rect, but CC's draw origin starts at the clip. |
| + transform->matrix().postTranslate(-clip.x(), -clip.y(), 0); |
| +} |
| + |
| +gfx::Rect ClipFlipY(gfx::Rect clip, gfx::Size view_size) { |
| + // CC's cliprect is relative to the bottom-left in hardware mode and |
|
enne (OOO)
2013/05/29 20:34:12
This seems like an unfortunate inconsistency. Doe
|
| + // top-left in software mode, but the system always provides it to us |
| + // from the top-left. |
| + clip.set_y(view_size.height() - clip.bottom()); |
| + return clip; |
| +} |
| +} // namespace |
| + |
| bool SynchronousCompositorOutputSurface::DemandDrawSw(SkCanvas* canvas) { |
| DCHECK(CalledOnValidThread()); |
| DCHECK(canvas); |
| DCHECK(!current_sw_canvas_); |
| current_sw_canvas_ = canvas; |
| - SkRect canvas_clip; |
| - gfx::Rect damage_area; |
| - if (canvas->getClipBounds(&canvas_clip)) { |
| - damage_area = gfx::ToEnclosedRect(gfx::SkRectToRectF(canvas_clip)); |
| - } else { |
| - damage_area = gfx::Rect(kint16max, kint16max); |
| - } |
| + SkIRect canvas_clip; |
| + canvas->getClipDeviceBounds(&canvas_clip); |
| + gfx::Rect clip = gfx::SkIRectToRect(canvas_clip); |
| - gfx::Transform transform; |
| + gfx::Transform transform(gfx::Transform::kSkipInitialization); |
| transform.matrix() = canvas->getTotalMatrix(); // Converts 3x3 matrix to 4x4. |
| + AdjustTransformForClip(&transform, clip); |
| - InvokeComposite(transform, damage_area); |
| + client_->SetDeviceTransformAndClip(transform, clip); |
| + InvokeComposite(clip.size()); |
| bool finished_draw = current_sw_canvas_ == NULL; |
| current_sw_canvas_ = NULL; |
| @@ -180,23 +194,24 @@ bool SynchronousCompositorOutputSurface::DemandDrawSw(SkCanvas* canvas) { |
| bool SynchronousCompositorOutputSurface::DemandDrawHw( |
| gfx::Size view_size, |
|
joth
2013/06/01 01:28:20
view_size -> surface_size or device_size ?
|
| const gfx::Transform& transform, |
| - gfx::Rect damage_area) { |
| + gfx::Rect clip) { |
| DCHECK(CalledOnValidThread()); |
| DCHECK(client_); |
| did_swap_buffer_ = false; |
| - InvokeComposite(transform, damage_area); |
| + gfx::Transform adjusted_transform = transform; |
| + AdjustTransformForClip(&adjusted_transform, clip); |
| + client_->SetDeviceTransformAndClip(adjusted_transform, |
| + ClipFlipY(clip, view_size)); |
| + InvokeComposite(clip.size()); |
| return did_swap_buffer_; |
| } |
| void SynchronousCompositorOutputSurface::InvokeComposite( |
| - const gfx::Transform& transform, |
| - gfx::Rect damage_area) { |
| - // TODO(boliu): This assumes |transform| is identity and |damage_area| is the |
| - // whole view. Tracking bug to implement this: crbug.com/230463. |
| - client_->SetNeedsRedrawRect(damage_area); |
| + gfx::Size damage_size) { |
| + client_->SetNeedsRedrawRect(gfx::Rect(damage_size)); |
| if (needs_begin_frame_) |
| client_->BeginFrame(base::TimeTicks::Now()); |
| } |