8000 Flutter 1.20.3 engine cherrypicks by christopherfujino · Pull Request #20838 · flutter/engine · GitHub
[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flutter 1.20.3 engine cherrypicks #20838

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
cherry-pick e09af86
  • Loading branch information
christopherfujino committed Aug 29, 2020
commit 14864c30397c4e7c1643f98fff9a73c7e4ae2482
7 changes: 3 additions & 4 deletions lib/ui/painting/canvas.cc
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,11 @@ void Canvas::drawImage(const CanvasImage* image,
const PaintData& paint_data) {
if (!canvas_)
return;
if (!image)
if (!image) {
Dart_ThrowException(
ToDart("Canvas.drawImage called with non-genuine Image."));
external_allocation_size_ += image->GetAllocationSize();
return;
}
canvas_->drawImage(image->image(), x, y, paint.paint());
}

Expand All @@ -317,7 +318,6 @@ void Canvas::drawImageRect(const CanvasImage* image,
ToDart("Canvas.drawImageRect called with non-genuine Image."));
SkRect src = SkRect::MakeLTRB(src_left, src_top, src_right, src_bottom);
SkRect dst = SkRect::MakeLTRB(dst_left, dst_top, dst_right, dst_bottom);
external_allocation_size_ += image->GetAllocationSize();
canvas_->drawImageRect(image->image(), src, dst, paint.paint(),
SkCanvas::kFast_SrcRectConstraint);
}
Expand All @@ -343,7 +343,6 @@ void Canvas::drawImageNine(const CanvasImage* image,
SkIRect icenter;
center.round(&icenter);
SkRect dst = SkRect::MakeLTRB(dst_left, dst_top, dst_right, dst_bottom);
external_allocation_size_ += image->GetAllocationSize();
canvas_->drawImageNine(image->image(), icenter, dst, paint.paint());
}

Expand Down
28 changes: 0 additions & 28 deletions testing/dart/canvas_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -218,34 +218,6 @@ void main() {
expect(areEqual, true);
}, skip: !Platform.isLinux); // https://github.com/flutter/flutter/issues/53784

test('Image size reflected in picture size for image*, drawAtlas, and drawPicture methods', () async {
final Image image = await createImage(100, 100);
final PictureRecorder recorder = PictureRecorder();
final Canvas canvas = Canvas(recorder);
const Rect rect = Rect.fromLTWH(0, 0, 100, 100);
canvas.drawImage(image, Offset.zero, Paint());
canvas.drawImageRect(image, rect, rect, Paint());
canvas.drawImageNine(image, rect, rect, Paint());
canvas.drawAtlas(image, <RSTransform>[], <Rect>[], <Color>[], BlendMode.src, rect, Paint());
final Picture picture = recorder.endRecording();

// Some of the numbers here appear to utilize sharing/reuse of common items,
// e.g. of the Paint() or same `Rect` usage, etc.
// The raw utilization of a 100x100 picture here should be 53333:
// 100 * 100 * 4 * (4/3) = 53333.333333....
// To avoid platform specific idiosyncrasies and brittleness against changes
// to Skia, we just assert this is _at least_ 4x the image size.
const int minimumExpected = 53333 * 4;
expect(picture.approximateBytesUsed, greaterThan(minimumExpected));

final PictureRecorder recorder2 = PictureRecorder();
final Canvas canvas2 = Canvas(recorder2);
canvas2.drawPicture(picture);
final Picture picture2 = recorder2.endRecording();

expect(picture2.approximateBytesUsed, greaterThan(minimumExpected));
});

test('Vertex buffer size reflected in picture size for drawVertices', () async {
final PictureRecorder recorder = PictureRecorder();
final Canvas canvas = Canvas(recorder);
Expand Down
0