Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit e09af86

Browse files
Remove image sizes from Picture::GetAllocationSize (#20673)
1 parent fe8c154 commit e09af86

File tree

2 files changed

+0
-31
lines changed

2 files changed

+0
-31
lines changed

lib/ui/painting/canvas.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,6 @@ void Canvas::drawImage(const CanvasImage* image,
327327
ToDart("Canvas.drawImage called with non-genuine Image."));
328328
return;
329329
}
330-
external_allocation_size_ += image->GetAllocationSize();
331330
canvas_->drawImage(image->image(), x, y, paint.paint());
332331
}
333332

@@ -352,7 +351,6 @@ void Canvas::drawImageRect(const CanvasImage* image,
352351
}
353352
SkRect src = SkRect::MakeLTRB(src_left, src_top, src_right, src_bottom);
354353
SkRect dst = SkRect::MakeLTRB(dst_left, dst_top, dst_right, dst_bottom);
355-
external_allocation_size_ += image->GetAllocationSize();
356354
canvas_->drawImageRect(image->image(), src, dst, paint.paint(),
357355
SkCanvas::kFast_SrcRectConstraint);
358356
}
@@ -381,7 +379,6 @@ void Canvas::drawImageNine(const CanvasImage* image,
381379
SkIRect icenter;
382380
center.round(&icenter);
383381
SkRect dst = SkRect::MakeLTRB(dst_left, dst_top, dst_right, dst_bottom);
384-
external_allocation_size_ += image->GetAllocationSize();
385382
canvas_->drawImageNine(image->image(), icenter, dst, paint.paint());
386383
}
387384

testing/dart/canvas_test.dart

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -297,34 +297,6 @@ void main() {
297297
expectArgumentError(() => canvas.drawRawAtlas(image, Float32List(4), Float32List(4), Int32List(2), BlendMode.src, rect, paint));
298298
});
299299

300-
test('Image size reflected in picture size for image*, drawAtlas, and drawPicture methods', () async {
301-
final Image image = await createImage(100, 100);
302-
final PictureRecorder recorder = PictureRecorder();
303-
final Canvas canvas = Canvas(recorder);
304-
const Rect rect = Rect.fromLTWH(0, 0, 100, 100);
305-
canvas.drawImage(image, Offset.zero, Paint());
306-
canvas.drawImageRect(image, rect, rect, Paint());
307-
canvas.drawImageNine(image, rect, rect, Paint());
308-
canvas.drawAtlas(image, <RSTransform>[], <Rect>[], <Color>[], BlendMode.src, rect, Paint());
309-
final Picture picture = recorder.endRecording();
310-
311-
// Some of the numbers here appear to utilize sharing/reuse of common items,
312-
// e.g. of the Paint() or same `Rect` usage, etc.
313-
// The raw utilization of a 100x100 picture here should be 53333:
314-
// 100 * 100 * 4 * (4/3) = 53333.333333....
315-
// To avoid platform specific idiosyncrasies and brittleness against changes
316-
// to Skia, we just assert this is _at least_ 4x the image size.
317-
const int minimumExpected = 53333 * 4;
318-
expect(picture.approximateBytesUsed, greaterThan(minimumExpected));
319-
320-
final PictureRecorder recorder2 = PictureRecorder();
321-
final Canvas canvas2 = Canvas(recorder2);
322-
canvas2.drawPicture(picture);
323-
final Picture picture2 = recorder2.endRecording();
324-
325-
expect(picture2.approximateBytesUsed, greaterThan(minimumExpected));
326-
});
327-
328300
test('Vertex buffer size reflected in picture size for drawVertices', () async {
329301
final PictureRecorder recorder = PictureRecorder();
330302
final Canvas canvas = Canvas(recorder);

0 commit comments

Comments
 (0)