Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 1f183ba

Browse files
authored
fuchsia: Remove Opacity hole-punch (#21527)
1 parent af5717e commit 1f183ba

File tree

4 files changed

+5
-26
lines changed

4 files changed

+5
-26
lines changed

flow/layers/child_scene_layer.cc

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,10 @@ void ChildSceneLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
2020

2121
context->child_scene_layer_exists_below = true;
2222
CheckForChildLayerBelow(context);
23-
24-
// An alpha "hole punch" is required if the frame behind us is not opaque.
25-
if (!context->is_opaque) {
26-
set_paint_bounds(
27-
SkRect::MakeXYWH(offset_.fX, offset_.fY, size_.fWidth, size_.fHeight));
28-
}
2923
}
3024

3125
void ChildSceneLayer::Paint(PaintContext& context) const {
32-
TRACE_EVENT0("flutter", "ChildSceneLayer::Paint");
33-
FML_DCHECK(needs_painting());
34-
FML_DCHECK(needs_system_composite());
35-
36-
// If we are being rendered into our own frame using the system compositor,
37-
// then it is neccesary to "punch a hole" in the canvas/frame behind us so
38-
// that group opacity looks correct.
39-
SkPaint paint;
40-
paint.setColor(SK_ColorTRANSPARENT);
41-
paint.setBlendMode(SkBlendMode::kSrc);
42-
context.leaf_nodes_canvas->drawRect(paint_bounds(), paint);
26+
FML_NOTREACHED();
4327
}
4428

4529
void ChildSceneLayer::UpdateScene(SceneUpdateContext& context) {

flow/layers/layer.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ struct PrerollContext {
5959
// These allow us to track properties like elevation, opacity, and the
6060
// prescence of a platform view during Preroll.
6161
bool has_platform_view = false;
62-
bool is_opaque = true;
6362
#if defined(LEGACY_FUCHSIA_EMBEDDER)
6463
// True if, during the traversal so far, we have seen a child_scene_layer.
6564
// Informs whether a layer needs to be system composited.

flow/layers/opacity_layer.cc

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,15 @@ OpacityLayer::OpacityLayer(SkAlpha alpha, const SkPoint& offset)
1414

1515
void OpacityLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
1616
TRACE_EVENT0("flutter", "OpacityLayer::Preroll");
17+
FML_DCHECK(!GetChildContainer()->layers().empty()); // We can't be a leaf.
1718

18-
ContainerLayer* container = GetChildContainer();
19-
FML_DCHECK(!container->layers().empty()); // OpacityLayer can't be a leaf.
20-
21-
const bool parent_is_opaque = context->is_opaque;
2219
SkMatrix child_matrix = matrix;
2320
child_matrix.postTranslate(offset_.fX, offset_.fY);
2421

2522
// Similar to what's done in TransformLayer::Preroll, we have to apply the
2623
// reverse transformation to the cull rect to properly cull child layers.
2724
context->cull_rect = context->cull_rect.makeOffset(-offset_.fX, -offset_.fY);
2825

29-
context->is_opaque = parent_is_opaque && (alpha_ == SK_AlphaOPAQUE);
3026
context->mutators_stack.PushTransform(
3127
SkMatrix::Translate(offset_.fX, offset_.fY));
3228
context->mutators_stack.PushOpacity(alpha_);
@@ -35,7 +31,6 @@ void OpacityLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
3531
ContainerLayer::Preroll(context, child_matrix);
3632
context->mutators_stack.Pop();
3733
context->mutators_stack.Pop();
38-
context->is_opaque = parent_is_opaque;
3934

4035
{
4136
set_paint_bounds(paint_bounds().makeOffset(offset_.fX, offset_.fY));

flow/layers/opacity_layer_unittests.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ TEST_F(OpacityLayerTest, LeafLayer) {
2020
auto layer =
2121
std::make_shared<OpacityLayer>(SK_AlphaOPAQUE, SkPoint::Make(0.0f, 0.0f));
2222

23-
EXPECT_DEATH_IF_SUPPORTED(layer->Preroll(preroll_context(), SkMatrix()),
24-
"\\!container->layers\\(\\)\\.empty\\(\\)");
23+
EXPECT_DEATH_IF_SUPPORTED(
24+
layer->Preroll(preroll_context(), SkMatrix()),
25+
"\\!GetChildContainer\\(\\)->layers\\(\\)\\.empty\\(\\)");
2526
}
2627

2728
TEST_F(OpacityLayerTest, PaintingEmptyLayerDies) {

0 commit comments

Comments
 (0)