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

Commit d8b4ad3

Browse files
committed
cache size correctly
1 parent 24adfd0 commit d8b4ad3

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

lib/web_ui/lib/src/engine/compositor/surface.dart

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,22 +89,20 @@ class Surface {
8989
_addedToScene = true;
9090
}
9191

92+
ui.Size? _currentSize;
93+
9294
void _createOrUpdateSurfaces(ui.Size size) {
9395
if (size.isEmpty) {
9496
throw CanvasKitError('Cannot create surfaces of empty size.');
9597
}
9698

97-
final CkSurface? currentSurface = _surface;
98-
if (currentSurface != null) {
99-
final bool isSameSize = size.width == currentSurface.width() &&
100-
size.height == currentSurface.height();
101-
if (isSameSize) {
102-
// The existing surface is still reusable.
103-
return;
104-
}
99+
if (size == _currentSize) {
100+
// The existing surface is still reusable.
101+
return;
105102
}
106103

107-
currentSurface?.dispose();
104+
_currentSize = size;
105+
_surface?.dispose();
108106
_surface = null;
109107
htmlElement?.remove();
110108
htmlElement = null;

0 commit comments

Comments
 (0)