Skip to content

Add TargetPixelFormat to toImageSync #178539

@gaaclarke

Description

@gaaclarke

This would allow users to generate high bitrate textures in one shader and consume them in another.

example

class Foo {
  final ui.FragmentShader sdfMaker;
  final ui.FragmentShader renderer;
  final ui.Rect _rect;
  ui.Image _sdf;
  bool _isDirty;

  void draw(Canvas canvas) {
    if (_isDirty) {
      final recorder = PictureRecorder();
      final subCanvas = Canvas(recorder);
      final paint = Paint()..shader = sdfMaker;
      subCanvas.drawRect(_rect, paint);
      final picture = recorder.endRecording();
      _sdf = picture.toImageSync(
          canvas.size.width, 
          canvas.size.height,
          targetPixelFormat: TargetPixelFormat.r32Float);
    }

    renderer.setImageSampler(0, _sdf);
    final paint = Paint()..shader = renderer;
    canvas.drawRect(_rect, paint);
  }
}

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work liste: impellerImpeller rendering backend issues and features requeststeam-engineOwned by Engine teamtriaged-engineTriaged by Engine team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions