Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/ui/painting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3191,6 +3191,14 @@ class Canvas extends NativeFieldWrapperClass2 {
/// This number cannot go below 1.
int getSaveCount() native 'Canvas_getSaveCount';

/// Flush the operations on this canvas so far.
///
/// This prevents Skia's GPU backend to group the operations across the flush
/// boundary. It's useful for [ShaderWarmUp] to force Skia's GPU backend to
/// warm up different shaders that may otherwise be combined by grouping the
/// operations together.
void flush() native 'Canvas_flush';

/// Add a translation to the current transform, shifting the coordinate space
/// horizontally by the first argument and vertically by the second argument.
void translate(double dx, double dy) native 'Canvas_translate';
Expand Down
7 changes: 7 additions & 0 deletions lib/ui/painting/canvas.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ IMPLEMENT_WRAPPERTYPEINFO(ui, Canvas);
V(Canvas, saveLayer) \
V(Canvas, restore) \
V(Canvas, getSaveCount) \
V(Canvas, flush) \
V(Canvas, translate) \
V(Canvas, scale) \
V(Canvas, rotate) \
Expand Down Expand Up @@ -126,6 +127,12 @@ int Canvas::getSaveCount() {
return canvas_->getSaveCount();
}

void Canvas::flush() {
if (!canvas_)
return;
canvas_->flush();
}

void Canvas::translate(double dx, double dy) {
if (!canvas_)
return;
Expand Down
2 changes: 2 additions & 0 deletions lib/ui/painting/canvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class Canvas : public RefCountedDartWrappable<Canvas> {
void restore();
int getSaveCount();

void flush();

void translate(double dx, double dy);
void scale(double sx, double sy);
void rotate(double radians);
Expand Down