Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
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
7 changes: 6 additions & 1 deletion lib/web_ui/lib/src/engine/surface/picture.dart
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,11 @@ abstract class PersistedPicture extends PersistedLeafSurface {

EngineCanvas _canvas;

/// Returns the canvas used by this picture layer.
///
/// Useful for tests.
EngineCanvas get debugCanvas => _canvas;

final double dx;
final double dy;
final EnginePicture picture;
Expand Down Expand Up @@ -624,7 +629,7 @@ abstract class PersistedPicture extends PersistedLeafSurface {
super.debugValidate(validationErrors);

if (picture.recordingCanvas.didDraw) {
if (_canvas == null) {
if (debugCanvas == null) {
validationErrors
.add('$runtimeType has non-trivial picture but it has null canvas');
}
Expand Down
11 changes: 9 additions & 2 deletions lib/web_ui/test/compositing_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void main() {

scene2.preroll();
scene2.update(scene1);
commitScene(scene1);
commitScene(scene2);
expect(picture.retainCount, 1);
expect(picture.buildCount, 1);
expect(picture.updateCount, 0);
Expand All @@ -169,7 +169,7 @@ void main() {

scene3.preroll();
scene3.update(scene2);
commitScene(scene1);
commitScene(scene3);
expect(picture.retainCount, 2);
expect(picture.buildCount, 1);
expect(picture.updateCount, 0);
Expand Down Expand Up @@ -271,6 +271,13 @@ class MockPersistedPicture extends PersistedPicture {
int updateCount = 0;
int applyPaintCount = 0;

final BitmapCanvas _fakeCanvas = BitmapCanvas(const Rect.fromLTRB(0, 0, 10, 10));

@override
EngineCanvas get debugCanvas {
return _fakeCanvas;
}

@override
double matchForUpdate(PersistedPicture existingSurface) {
return identical(existingSurface.picture, picture) ? 0.0 : 1.0;
Expand Down