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..7ba9b364ec16c3a359ebc6d3ef0c0eaccf4bef2c 100644 |
| --- a/content/renderer/android/synchronous_compositor_output_surface.cc |
| +++ b/content/renderer/android/synchronous_compositor_output_surface.cc |
| @@ -153,50 +153,58 @@ bool SynchronousCompositorOutputSurface::IsHwReady() { |
| return context3d() != NULL; |
| } |
| +static gfx::Transform adjustTransformForClip(gfx::Transform transform, |
|
joth
2013/05/25 02:56:40
nits:
prefer namespace {} to static functions.
c
|
| + gfx::Rect clip) { |
| + transform.matrix().postTranslate(-clip.x(), -clip.y(), 0); |
| + return transform; |
| +} |
| + |
| 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. |
| - InvokeComposite(transform, damage_area); |
| + client_->SetDeviceTransformAndClip(adjustTransformForClip(transform, clip), |
| + clip); |
| + InvokeComposite(clip); |
| bool finished_draw = current_sw_canvas_ == NULL; |
| current_sw_canvas_ = NULL; |
| return finished_draw; |
| } |
| +static gfx::Rect clipFlipY(gfx::Rect clip, gfx::Size view_size) { |
|
joth
2013/05/25 02:56:40
ditto - namespace {} / capitalize
|
| + clip.set_y(view_size.height() - clip.bottom()); |
| + return clip; |
| +} |
| + |
| bool SynchronousCompositorOutputSurface::DemandDrawHw( |
| gfx::Size view_size, |
| const gfx::Transform& transform, |
| - gfx::Rect damage_area) { |
| + gfx::Rect clip) { |
| DCHECK(CalledOnValidThread()); |
| DCHECK(client_); |
| did_swap_buffer_ = false; |
| - InvokeComposite(transform, damage_area); |
| + client_->SetDeviceTransformAndClip(adjustTransformForClip(transform, clip), |
| + clipFlipY(clip, view_size)); |
|
joth
2013/05/25 02:56:40
any idea why we do need to flip Y for clip (in HW
|
| + InvokeComposite(clip); |
| 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); |
| + client_->SetNeedsRedrawRect(gfx::Rect(damage_area.size())); |
| if (needs_begin_frame_) |
| client_->BeginFrame(base::TimeTicks::Now()); |
| } |