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() ...@@ -29,23 +29,17 @@ DamageTracker::DamageTracker()
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( static inline void ExpandDamageRectInsideRectWithFilters(
gfx::Rect* damage_rect, gfx::Rect* damage_rect,
const gfx::Rect& pre_filter_rect, const gfx::Rect& pre_filter_rect,
const FilterOperations& filters) { const FilterOperations& filters) {
gfx::Rect expanded_damage_rect = *damage_rect; // Compute the pixels in the background of the surface that could be affected
ExpandRectWithFilters(&expanded_damage_rect, filters); // by the damage in the content below.
gfx::Rect filter_rect = pre_filter_rect; gfx::Rect expanded_damage_rect = filters.MapRect(*damage_rect, SkMatrix::I());
ExpandRectWithFilters(&filter_rect, filters);
// 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); damage_rect->Union(expanded_damage_rect);
} }
...@@ -144,8 +138,8 @@ void DamageTracker::UpdateDamageTrackingState( ...@@ -144,8 +138,8 @@ void DamageTracker::UpdateDamageTrackingState(
damage_rect_for_this_update = damage_from_active_layers; 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_surface_mask);
damage_rect_for_this_update.Union(damage_from_leftover_rects); damage_rect_for_this_update.Union(damage_from_leftover_rects);
damage_rect_for_this_update =
ExpandRectWithFilters(&damage_rect_for_this_update, filters); filters.MapRect(damage_rect_for_this_update, SkMatrix::I());
} }
// Damage accumulates until we are notified that we actually did draw on that // Damage accumulates until we are notified that we actually did draw on that
......
...@@ -703,7 +703,8 @@ TEST_F(DamageTrackerTest, VerifyDamageForBackgroundBlurredChild) { ...@@ -703,7 +703,8 @@ TEST_F(DamageTrackerTest, VerifyDamageForBackgroundBlurredChild) {
// CASE 1: Setting the update rect should cause the corresponding damage to // CASE 1: Setting the update rect should cause the corresponding damage to
// the surface, blurred based on the size of the child's background // 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); ClearDamageForAllSurfaces(root);
root->SetUpdateRect(gfx::Rect(297, 297, 2, 2)); root->SetUpdateRect(gfx::Rect(297, 297, 2, 2));
root->layer_tree_impl()->property_trees()->needs_rebuild = true; root->layer_tree_impl()->property_trees()->needs_rebuild = true;
...@@ -769,15 +770,12 @@ TEST_F(DamageTrackerTest, VerifyDamageForBackgroundBlurredChild) { ...@@ -769,15 +770,12 @@ TEST_F(DamageTrackerTest, VerifyDamageForBackgroundBlurredChild) {
root_damage_rect = root_damage_rect =
root->render_surface()->damage_tracker()->current_damage_rect(); root->render_surface()->damage_tracker()->current_damage_rect();
// Damage on the root should be: position of update_rect (99, 99), expanded by // Damage on the root should be: the originally damaged rect (99,99 1x1)
// the blurring on child1, but since it is 1 pixel outside the layer, the // plus the rect that can influence with a 2px blur (93,93 13x13) intersected
// expanding should be reduced by 1. // with the surface rect (100,100 206x208). So no additional damage occurs
expected_damage_rect = gfx::Rect(99, 99, 1, 1); // above or to the left, but there is additional damage within the blurred
// area.
expected_damage_rect.Inset(-outset_left + 1, expected_damage_rect = gfx::Rect(99, 99, 7, 7);
-outset_top + 1,
-outset_right,
-outset_bottom);
EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString()); EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString());
// CASE 5: Setting the update rect on child2, which is above child1, will // CASE 5: Setting the update rect on child2, which is above child1, will
...@@ -807,12 +805,12 @@ TEST_F(DamageTrackerTest, VerifyDamageForBackgroundBlurredChild) { ...@@ -807,12 +805,12 @@ TEST_F(DamageTrackerTest, VerifyDamageForBackgroundBlurredChild) {
root->render_surface()->damage_tracker()->current_damage_rect(); root->render_surface()->damage_tracker()->current_damage_rect();
// Damage on child1 should be: position of update_rect offset by the child's // Damage on child1 should be: position of update_rect offset by the child's
// position (100, 100), and expanded by the damage. // position (100, 100), and expanded by the damage.
expected_damage_rect = gfx::Rect(100, 100, 1, 1);
expected_damage_rect.Inset(-outset_left, // Damage should be (0,0 1x1), offset by the 100,100 offset of child1 in
-outset_top, // root, and expanded 6px for the 2px blur (i.e., 94,94 13x13), but there
-outset_right, // should be no damage outside child1 (i.e. none above or to the left of
-outset_bottom); // 100,100.
expected_damage_rect = gfx::Rect(100, 100, 7, 7);
EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString()); 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