未验证 提交 1f183bab 编写于 作者: D David Worsham 提交者: GitHub

fuchsia: Remove Opacity hole-punch (#21527)

上级 af5717eb
......@@ -20,26 +20,10 @@ void ChildSceneLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
context->child_scene_layer_exists_below = true;
CheckForChildLayerBelow(context);
// An alpha "hole punch" is required if the frame behind us is not opaque.
if (!context->is_opaque) {
set_paint_bounds(
SkRect::MakeXYWH(offset_.fX, offset_.fY, size_.fWidth, size_.fHeight));
}
}
void ChildSceneLayer::Paint(PaintContext& context) const {
TRACE_EVENT0("flutter", "ChildSceneLayer::Paint");
FML_DCHECK(needs_painting());
FML_DCHECK(needs_system_composite());
// If we are being rendered into our own frame using the system compositor,
// then it is neccesary to "punch a hole" in the canvas/frame behind us so
// that group opacity looks correct.
SkPaint paint;
paint.setColor(SK_ColorTRANSPARENT);
paint.setBlendMode(SkBlendMode::kSrc);
context.leaf_nodes_canvas->drawRect(paint_bounds(), paint);
FML_NOTREACHED();
}
void ChildSceneLayer::UpdateScene(SceneUpdateContext& context) {
......
......@@ -59,7 +59,6 @@ struct PrerollContext {
// These allow us to track properties like elevation, opacity, and the
// prescence of a platform view during Preroll.
bool has_platform_view = false;
bool is_opaque = true;
#if defined(LEGACY_FUCHSIA_EMBEDDER)
// True if, during the traversal so far, we have seen a child_scene_layer.
// Informs whether a layer needs to be system composited.
......
......@@ -14,11 +14,8 @@ OpacityLayer::OpacityLayer(SkAlpha alpha, const SkPoint& offset)
void OpacityLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
TRACE_EVENT0("flutter", "OpacityLayer::Preroll");
FML_DCHECK(!GetChildContainer()->layers().empty()); // We can't be a leaf.
ContainerLayer* container = GetChildContainer();
FML_DCHECK(!container->layers().empty()); // OpacityLayer can't be a leaf.
const bool parent_is_opaque = context->is_opaque;
SkMatrix child_matrix = matrix;
child_matrix.postTranslate(offset_.fX, offset_.fY);
......@@ -26,7 +23,6 @@ void OpacityLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
// reverse transformation to the cull rect to properly cull child layers.
context->cull_rect = context->cull_rect.makeOffset(-offset_.fX, -offset_.fY);
context->is_opaque = parent_is_opaque && (alpha_ == SK_AlphaOPAQUE);
context->mutators_stack.PushTransform(
SkMatrix::Translate(offset_.fX, offset_.fY));
context->mutators_stack.PushOpacity(alpha_);
......@@ -35,7 +31,6 @@ void OpacityLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
ContainerLayer::Preroll(context, child_matrix);
context->mutators_stack.Pop();
context->mutators_stack.Pop();
context->is_opaque = parent_is_opaque;
{
set_paint_bounds(paint_bounds().makeOffset(offset_.fX, offset_.fY));
......
......@@ -20,8 +20,9 @@ TEST_F(OpacityLayerTest, LeafLayer) {
auto layer =
std::make_shared<OpacityLayer>(SK_AlphaOPAQUE, SkPoint::Make(0.0f, 0.0f));
EXPECT_DEATH_IF_SUPPORTED(layer->Preroll(preroll_context(), SkMatrix()),
"\\!container->layers\\(\\)\\.empty\\(\\)");
EXPECT_DEATH_IF_SUPPORTED(
layer->Preroll(preroll_context(), SkMatrix()),
"\\!GetChildContainer\\(\\)->layers\\(\\)\\.empty\\(\\)");
}
TEST_F(OpacityLayerTest, PaintingEmptyLayerDies) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册