Commit 232beac2 authored by hendrikw's avatar hendrikw Committed by Commit bot

cc: Translate the canvas to correctly detect solid colors

While animating the transition, the origin is off in outerspace, as a
result we weren't correctly detecting the layer as non-solid since
the bitmap wasn't in the viewport

Also wrote a test for this.

BUG=420571

Review URL: https://codereview.chromium.org/692473003

Cr-Commit-Position: refs/heads/master@{#301983}
parent 3638a21d
......@@ -570,7 +570,8 @@ void PicturePile::DetermineIfSolidColor() {
}
skia::AnalysisCanvas canvas(recorded_viewport_.width(),
recorded_viewport_.height());
picture->Raster(&canvas, NULL, Region(), 1.0f);
canvas.translate(-recorded_viewport_.x(), -recorded_viewport_.y());
picture->Raster(&canvas, nullptr, Region(), 1.0f);
is_solid_color_ = canvas.GetColorIfSolid(&solid_color_);
}
......
......@@ -1432,5 +1432,29 @@ TEST_F(PicturePileTest, SolidRectangleIsSolid) {
EXPECT_FALSE(pile_.is_solid_color());
}
TEST_F(PicturePileTest, NonSolidRectangleOnOffsettedLayerIsNonSolid) {
gfx::Rect visible_rect(tiling_rect());
visible_rect.Offset(gfx::Vector2d(1000, 1000));
// The picture pile requires that the tiling completely encompass the viewport
// to make this test work correctly since the recorded viewport is an
// intersection of the tile size and viewport rect. This is possibly a flaw
// in |PicturePile|.
gfx::Size tiling_size(visible_rect.right(), visible_rect.bottom());
// |Setup()| will create pictures here that mess with the test, clear it!
pile_.Clear();
SkPaint paint;
paint.setColor(SK_ColorCYAN);
// Add a rect that doesn't cover the viewport completely, the solid state
// will be false.
gfx::Rect smallRect = visible_rect;
smallRect.Inset(10, 10, 10, 10);
client_.add_draw_rect(smallRect, paint);
Region invalidation(visible_rect);
UpdateAndExpandInvalidation(&invalidation, tiling_size, visible_rect);
EXPECT_FALSE(pile_.is_solid_color());
}
} // namespace
} // namespace cc
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