From f8cab6d4c993af5e42b862263c3b6a9d417d9c1a Mon Sep 17 00:00:00 2001 From: Yuqian Li Date: Mon, 12 Nov 2018 09:59:25 -0800 Subject: [PATCH 1/3] Respect offset in OpacityLayer's paint bounds This fixes https://github.com/flutter/flutter/issues/23890 I'll add unit tests to flutter/flutter shortly. --- flow/layers/opacity_layer.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/flow/layers/opacity_layer.cc b/flow/layers/opacity_layer.cc index bd2c05188c725..a1c3f474b3a1f 100644 --- a/flow/layers/opacity_layer.cc +++ b/flow/layers/opacity_layer.cc @@ -14,6 +14,7 @@ void OpacityLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) { SkMatrix child_matrix = matrix; child_matrix.postTranslate(offset_.fX, offset_.fY); ContainerLayer::Preroll(context, child_matrix); + set_paint_bounds(paint_bounds().makeOffset(offset_.fX, offset_.fY)); if (context->raster_cache && layers().size() == 1) { Layer* child = layers()[0].get(); SkMatrix ctm = child_matrix; From beabdb4677ac5c44c21bdf6f835fe616bfd876b8 Mon Sep 17 00:00:00 2001 From: Yuqian Li Date: Mon, 12 Nov 2018 11:49:12 -0800 Subject: [PATCH 2/3] Fix software rendering without raster cache --- flow/layers/opacity_layer.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/flow/layers/opacity_layer.cc b/flow/layers/opacity_layer.cc index a1c3f474b3a1f..570d9cfaa0d59 100644 --- a/flow/layers/opacity_layer.cc +++ b/flow/layers/opacity_layer.cc @@ -55,8 +55,20 @@ void OpacityLayer::Paint(PaintContext& context) const { } } + // Skia may clip the content with saveLayerBounds (although it's not a + // guaranteed clip). So we have to provide a big enough saveLayerBounds. To do + // so, we first remove the offset from paint bounds since it's already in the + // matrix. Then we round out the bounds because of our + // RasterCache::GetIntegralTransCTM optimization. + // + // Note that the following lines are only accessible when the raster cache is + // not available (e.g., when we're using the software backend in golden + // tests). + SkRect saveLayerBounds; + paint_bounds().makeOffset(-offset_.fX, -offset_.fY).roundOut(&saveLayerBounds); + Layer::AutoSaveLayer save_layer = - Layer::AutoSaveLayer::Create(context, paint_bounds(), &paint); + Layer::AutoSaveLayer::Create(context, saveLayerBounds, &paint); PaintChildren(context); } From f857b02c9704f9f0cc061bb9f09ccf784a645949 Mon Sep 17 00:00:00 2001 From: Yuqian Li Date: Mon, 12 Nov 2018 12:00:25 -0800 Subject: [PATCH 3/3] Clang-format --- flow/layers/opacity_layer.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/flow/layers/opacity_layer.cc b/flow/layers/opacity_layer.cc index 570d9cfaa0d59..361a134d92262 100644 --- a/flow/layers/opacity_layer.cc +++ b/flow/layers/opacity_layer.cc @@ -65,7 +65,9 @@ void OpacityLayer::Paint(PaintContext& context) const { // not available (e.g., when we're using the software backend in golden // tests). SkRect saveLayerBounds; - paint_bounds().makeOffset(-offset_.fX, -offset_.fY).roundOut(&saveLayerBounds); + paint_bounds() + .makeOffset(-offset_.fX, -offset_.fY) + .roundOut(&saveLayerBounds); Layer::AutoSaveLayer save_layer = Layer::AutoSaveLayer::Create(context, saveLayerBounds, &paint);