Skip to content

Commit

Permalink
ash: Fast ink damage fixes.
Browse files Browse the repository at this point in the history
Limit damage rectangle to output rectangle and fix stationary point
generation and bounding box calculations for laser pointer to
make sure damage is reported correctly.

[email protected]

(cherry picked from commit 545a726)

Bug: 764007
Test: manual
Change-Id: Ie6352d539391776aa99ee00b7d1d302f0249e3dc
Reviewed-on: https://chromium-review.googlesource.com/668663
Commit-Queue: David Reveman <[email protected]>
Reviewed-by: Mitsuru Oshima <[email protected]>
Reviewed-by: Vladislav Kaznacheev <[email protected]>
Cr-Original-Commit-Position: refs/heads/master@{#502408}
Reviewed-on: https://chromium-review.googlesource.com/671868
Reviewed-by: David Reveman <[email protected]>
Cr-Commit-Position: refs/branch-heads/3202@{crosswalk-project#309}
Cr-Branched-From: fa6a5d8-refs/heads/master@{#499098}
  • Loading branch information
reveman-chromium committed Sep 18, 2017
1 parent a0fa0a4 commit cb1bf5a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
9 changes: 7 additions & 2 deletions ash/fast_ink/fast_ink_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<cc::RenderPass> 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();
Expand Down
26 changes: 22 additions & 4 deletions ash/laser/laser_pointer_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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;
}

Expand All @@ -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);
Expand Down
1 change: 1 addition & 0 deletions ash/laser/laser_pointer_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<base::Timer> stationary_timer_;
gfx::PointF stationary_point_location_;

// A callback for when the fadeout is complete.
base::Closure fadeout_done_;
Expand Down

0 comments on commit cb1bf5a

Please sign in to comment.