Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion flow/layers/opacity_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void OpacityLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
FML_DCHECK(!GetChildContainer()->layers().empty()); // We can't be a leaf.

SkMatrix child_matrix = matrix;
child_matrix.postTranslate(offset_.fX, offset_.fY);
child_matrix.preTranslate(offset_.fX, offset_.fY);

// Similar to what's done in TransformLayer::Preroll, we have to apply the
// reverse transformation to the cull rect to properly cull child layers.
Expand Down
17 changes: 17 additions & 0 deletions flow/layers/opacity_layer_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,23 @@ TEST_F(OpacityLayerTest, PaintBeforePreollDies) {
}
#endif

TEST_F(OpacityLayerTest, TranslateChildren) {
SkPath child_path1;
child_path1.addRect(10.0f, 10.0f, 20.0f, 20.f);
SkPaint child_paint1(SkColors::kGray);
auto layer = std::make_shared<OpacityLayer>(0.5, SkPoint::Make(10, 10));
auto mock_layer1 = std::make_shared<MockLayer>(child_path1, child_paint1);
layer->Add(mock_layer1);

auto initial_transform = SkMatrix::Scale(2.0, 2.0);
layer->Preroll(preroll_context(), initial_transform);

SkRect layer_bounds = mock_layer1->paint_bounds();
mock_layer1->parent_matrix().mapRect(&layer_bounds);

EXPECT_EQ(layer_bounds, SkRect::MakeXYWH(40, 40, 20, 20));
}

TEST_F(OpacityLayerTest, ChildIsCached) {
const SkAlpha alpha_half = 255 / 2;
auto initial_transform = SkMatrix::Translate(50.0, 25.5);
Expand Down
2 changes: 1 addition & 1 deletion flow/layers/picture_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void PictureLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
TRACE_EVENT0("flutter", "PictureLayer::RasterCache (Preroll)");

SkMatrix ctm = matrix;
ctm.postTranslate(offset_.x(), offset_.y());
ctm.preTranslate(offset_.x(), offset_.y());
#ifndef SUPPORT_FRACTIONAL_TRANSLATION
ctm = RasterCache::GetIntegralTransCTM(ctm);
#endif
Expand Down