Unverified Commit c3527389 authored by Jason Simmons's avatar Jason Simmons Committed by GitHub

Avoid the overhead of instantiating a generator in paintImage (#28736)

This function is called frequently with non-repeating images during many
animations
parent 1ffd5f02
......@@ -438,22 +438,25 @@ void paintImage({
final Rect sourceRect = alignment.inscribe(
sourceSize, Offset.zero & inputSize,
);
for (Rect tileRect in _generateImageTileRects(rect, destinationRect, repeat))
canvas.drawImageRect(image, sourceRect, tileRect, paint);
if (repeat == ImageRepeat.noRepeat) {
canvas.drawImageRect(image, sourceRect, destinationRect, paint);
} else {
for (Rect tileRect in _generateImageTileRects(rect, destinationRect, repeat))
canvas.drawImageRect(image, sourceRect, tileRect, paint);
}
} else {
for (Rect tileRect in _generateImageTileRects(rect, destinationRect, repeat))
canvas.drawImageNine(image, centerSlice, tileRect, paint);
if (repeat == ImageRepeat.noRepeat) {
canvas.drawImageNine(image, centerSlice, destinationRect, paint);
} else {
for (Rect tileRect in _generateImageTileRects(rect, destinationRect, repeat))
canvas.drawImageNine(image, centerSlice, tileRect, paint);
}
}
if (needSave)
canvas.restore();
}
Iterable<Rect> _generateImageTileRects(Rect outputRect, Rect fundamentalRect, ImageRepeat repeat) sync* {
if (repeat == ImageRepeat.noRepeat) {
yield fundamentalRect;
return;
}
int startX = 0;
int startY = 0;
int stopX = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment