Skip to content

ShaderMask needs to play nicely with compositing #1155

Closed

Description

@apwilson

Something like the following code used to work, and now no longer works.

This code should put a fading edge at the top of the block so the children fade away to the background color as they go under the mask. Now the entire block goes away. In my use case I see a chunk of area that is fully faded away that isn't faded away when just the shader mask is removed.

Future main() async =>
  runApp(new Container(
      decoration: new BoxDecoration(backgroundColor: new Color(0xFF808080)),
      child: new ShaderMask(
          shaderCallback: _createShader,
          child: new Block([
            _createColoredBox(0xFFFF0000),
            _createColoredBox(0xFF0FF000),
            _createColoredBox(0xFF0000FF),
            _createColoredBox(0xFFFFFF00)
          ]))));

Widget _createColoredBox(int hexColor) => new Container(
    height: 300.0,
    decoration: new BoxDecoration(backgroundColor: new Color(hexColor)));

// Fading edge colors need to be pure white with some value of alpha to properly fade the children.
ui.Shader _createShader(Rect bounds) => new LinearGradient(
    begin: Point.origin,
    end: new Point(0.0, 100.0),
    colors: [const Color(0x00FFFFFF), const Color(0xFFFFFFFF)],
    stops: [0.0, 1.0]).createShader();

Activity

  1. HansMuller commented on Jan 9, 2016

    @HansMuller
    Contributor

    This problem can also be demonstrated with the "Swipe Away" (card_collection.dart) widget example. Select "Let the sun shine" from the drawer:

    android: I/flutter : -- EXCEPTION CAUGHT BY RENDERING LIBRARY -------------------------------
    android: I/flutter : The following exception was raised during paint():
    android: I/flutter : 'packages/flutter/src/rendering/object.dart': Failed assertion: line 330: '!needsCompositing' is not true.
    android: I/flutter : The following RenderObject was being processed when the exception was fired:
    android: I/flutter : RenderShaderMask
    android: I/flutter : That RenderObject had the following owner:
    android: I/flutter : ShaderMask ← Stack ← Padding ← DecoratedBox ← ⋯
    android: I/flutter : Stack trace:
    android: I/flutter : #0      _AssertionError._throwNew (dart:core-patch/errors_patch.dart:27)
    android: I/flutter : #1      PaintingContext.pushShaderMask (packages/flutter/src/rendering/object.dart:330)
    android: I/flutter : #2      RenderShaderMask.paint (packages/flutter/src/rendering/proxy_box.dart:591)
    android: I/flutter : #3      RenderObject._paintWithContext (packages/flutter/src/rendering/object.dart:1042)
    android: I/flutter : #4      PaintingContext.paintChild (packages/flutter/src/rendering/object.dart:93)
    android: I/flutter : #5      RenderBox&ContainerRenderObjectMixin&RenderBoxContainerDefaultsMixin.defaultPaint (packages/flutter/src/rendering/box.dart:819)
    android: I/flutter : #6      RenderStack.paintStack (packages/flutter/src/rendering/stack.dart:428)
    android: I/flutter : #7      RenderStackBase.paint (packages/flutter/src/rendering/stack.dart:383)
    
  2. abarth commented on Jan 9, 2016

    @abarth
    Contributor

    We've started using compositing more. I don't think we can afford to have paint operations that the compositor doesn't understand anymore.

  3. changed the title [-]ShaderMask is broken.[/-] [+]ShaderMask needs to play nicely with compositing[/+] on Jan 9, 2016
  4. self-assigned this
    on Jan 11, 2016
  5. abarth commented on Jan 11, 2016

    @abarth
    Contributor
  6. github-actions commented on Sep 6, 2021

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  7. locked as resolved and limited conversation to collaborators on Sep 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions