Commit 8eb5fb7c authored by jbroman's avatar jbroman Committed by Commit bot

cc: Move DamageTracker filter handling to MapRect.

While here, also fix a bug in which the rectangle in which the filter is
assumed to be visible was also mapped through the filter, and update unit
tests accordingly.

BUG=600821
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel

Review-Url: https://codereview.chromium.org/2015343002
Cr-Commit-Position: refs/heads/master@{#397192}
parent 23e130d1
......@@ -29,23 +29,17 @@ DamageTracker::DamageTracker()
DamageTracker::~DamageTracker() {}
static inline void ExpandRectWithFilters(gfx::Rect* rect,
const FilterOperations& filters) {
int top, right, bottom, left;
filters.GetOutsets(&top, &right, &bottom, &left);
rect->Inset(-left, -top, -right, -bottom);
}
static inline void ExpandDamageRectInsideRectWithFilters(
gfx::Rect* damage_rect,
const gfx::Rect& pre_filter_rect,
const FilterOperations& filters) {
gfx::Rect expanded_damage_rect = *damage_rect;
ExpandRectWithFilters(&expanded_damage_rect, filters);
gfx::Rect filter_rect = pre_filter_rect;
ExpandRectWithFilters(&filter_rect, filters);
// Compute the pixels in the background of the surface that could be affected
// by the damage in the content below.
gfx::Rect expanded_damage_rect = filters.MapRect(*damage_rect, SkMatrix::I());
// Restrict it to the rectangle in which the background filter is shown.
expanded_damage_rect.Intersect(pre_filter_rect);
expanded_damage_rect.Intersect(filter_rect);
damage_rect->Union(expanded_damage_rect);
}
......@@ -144,8 +138,8 @@ void DamageTracker::UpdateDamageTrackingState(
damage_rect_for_this_update = damage_from_active_layers;
damage_rect_for_this_update.Union(damage_from_surface_mask);
damage_rect_for_this_update.Union(damage_from_leftover_rects);
ExpandRectWithFilters(&damage_rect_for_this_update, filters);
damage_rect_for_this_update =
filters.MapRect(damage_rect_for_this_update, SkMatrix::I());
}
// Damage accumulates until we are notified that we actually did draw on that
......
......@@ -703,7 +703,8 @@ TEST_F(DamageTrackerTest, VerifyDamageForBackgroundBlurredChild) {
// CASE 1: Setting the update rect should cause the corresponding damage to
// the surface, blurred based on the size of the child's background
// blur filter.
// blur filter. Note that child1's render surface has a size of
// 206x208 due to contributions from grand_child1 and grand_child2.
ClearDamageForAllSurfaces(root);
root->SetUpdateRect(gfx::Rect(297, 297, 2, 2));
root->layer_tree_impl()->property_trees()->needs_rebuild = true;
......@@ -769,15 +770,12 @@ TEST_F(DamageTrackerTest, VerifyDamageForBackgroundBlurredChild) {
root_damage_rect =
root->render_surface()->damage_tracker()->current_damage_rect();
// Damage on the root should be: position of update_rect (99, 99), expanded by
// the blurring on child1, but since it is 1 pixel outside the layer, the
// expanding should be reduced by 1.
expected_damage_rect = gfx::Rect(99, 99, 1, 1);
expected_damage_rect.Inset(-outset_left + 1,
-outset_top + 1,
-outset_right,
-outset_bottom);
// Damage on the root should be: the originally damaged rect (99,99 1x1)
// plus the rect that can influence with a 2px blur (93,93 13x13) intersected
// with the surface rect (100,100 206x208). So no additional damage occurs
// above or to the left, but there is additional damage within the blurred
// area.
expected_damage_rect = gfx::Rect(99, 99, 7, 7);
EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString());
// CASE 5: Setting the update rect on child2, which is above child1, will
......@@ -807,12 +805,12 @@ TEST_F(DamageTrackerTest, VerifyDamageForBackgroundBlurredChild) {
root->render_surface()->damage_tracker()->current_damage_rect();
// Damage on child1 should be: position of update_rect offset by the child's
// position (100, 100), and expanded by the damage.
expected_damage_rect = gfx::Rect(100, 100, 1, 1);
expected_damage_rect.Inset(-outset_left,
-outset_top,
-outset_right,
-outset_bottom);
// Damage should be (0,0 1x1), offset by the 100,100 offset of child1 in
// root, and expanded 6px for the 2px blur (i.e., 94,94 13x13), but there
// should be no damage outside child1 (i.e. none above or to the left of
// 100,100.
expected_damage_rect = gfx::Rect(100, 100, 7, 7);
EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString());
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment