diff --git a/ash/fast_ink/fast_ink_view.cc b/ash/fast_ink/fast_ink_view.cc index 42f558c9c4246..1bf46d04923b0 100644 --- a/ash/fast_ink/fast_ink_view.cc +++ b/ash/fast_ink/fast_ink_view.cc @@ -359,11 +359,16 @@ void FastInkView::UpdateSurface() { gfx::Rect quad_rect(buffer_size); bool needs_blending = true; + gfx::Rect damage_rect( + gfx::ScaleToEnclosingRect(surface_damage_rect_, device_scale_factor)); + surface_damage_rect_ = gfx::Rect(); + // Constrain damage rectangle to output rectangle. + damage_rect.Intersect(output_rect); + const int kRenderPassId = 1; std::unique_ptr render_pass = cc::RenderPass::Create(); - render_pass->SetNew(kRenderPassId, output_rect, surface_damage_rect_, + render_pass->SetNew(kRenderPassId, output_rect, damage_rect, buffer_to_target_transform); - surface_damage_rect_ = gfx::Rect(); viz::SharedQuadState* quad_state = render_pass->CreateAndAppendSharedQuadState(); diff --git a/ash/laser/laser_pointer_view.cc b/ash/laser/laser_pointer_view.cc index 6323a51b31ad1..c11f6a93c5397 100644 --- a/ash/laser/laser_pointer_view.cc +++ b/ash/laser/laser_pointer_view.cc @@ -182,6 +182,7 @@ void LaserPointerView::AddNewPoint(const gfx::PointF& new_point, .Length()) : 0); AddPoint(new_point, new_time); + stationary_point_location_ = new_point; stationary_timer_->Reset(); } @@ -213,8 +214,7 @@ void LaserPointerView::FadeOut(const base::Closure& done) { void LaserPointerView::UpdateTime() { if (fadeout_done_.is_null()) { // Pointer still active but stationary, repeat the most recent position. - DCHECK(!laser_points_.IsEmpty()); - AddPoint(laser_points_.GetNewest().location, ui::EventTimeForNow()); + AddPoint(stationary_point_location_, ui::EventTimeForNow()); return; } @@ -237,10 +237,28 @@ void LaserPointerView::UpdateTime() { } gfx::Rect LaserPointerView::GetBoundingBox() { + // Early out if there are no points. + if (laser_points_.IsEmpty() && predicted_laser_points_.IsEmpty()) + return gfx::Rect(); + + // Merge bounding boxes. Note that this is not a union as the bounding box + // for a single point is empty. + gfx::Rect bounding_box; + if (laser_points_.IsEmpty()) { + bounding_box = predicted_laser_points_.GetBoundingBox(); + } else if (predicted_laser_points_.IsEmpty()) { + bounding_box = laser_points_.GetBoundingBox(); + } else { + gfx::Rect rect = laser_points_.GetBoundingBox(); + gfx::Rect predicted_rect = predicted_laser_points_.GetBoundingBox(); + bounding_box.SetByBounds(std::min(predicted_rect.x(), rect.x()), + std::min(predicted_rect.y(), rect.y()), + std::max(predicted_rect.right(), rect.right()), + std::max(predicted_rect.bottom(), rect.bottom())); + } + // Expand the bounding box so that it includes the radius of the points on the // edges and antialiasing. - gfx::Rect bounding_box = laser_points_.GetBoundingBox(); - bounding_box.Union(predicted_laser_points_.GetBoundingBox()); const int kOutsetForAntialiasing = 1; int outset = kPointInitialRadius + kOutsetForAntialiasing; bounding_box.Inset(-outset, -outset); diff --git a/ash/laser/laser_pointer_view.h b/ash/laser/laser_pointer_view.h index 3ce00650ea29a..f731d46e9e78d 100644 --- a/ash/laser/laser_pointer_view.h +++ b/ash/laser/laser_pointer_view.h @@ -47,6 +47,7 @@ class LaserPointerView : public FastInkView { // Timer which will add a new stationary point when the stylus stops moving. // This will remove points that are too old. std::unique_ptr stationary_timer_; + gfx::PointF stationary_point_location_; // A callback for when the fadeout is complete. base::Closure fadeout_done_;