@@ -324,13 +324,18 @@ class BitmapCanvas extends EngineCanvas {
324324 /// DOM to render correctly.
325325 /// - Pictures typically have large rect/rounded rectangles as background
326326 /// prefer DOM if canvas has not been allocated yet.
327+ ///
328+ /// Future optimization: The check below can be used to prevent excessive
329+ /// canvas sandwiching (switching between dom and multiple canvas(s)).
330+ /// Once RecordingCanvas is updated to detect switch count, this can be
331+ /// enabled.
332+ /// (_canvasPool._canvas == null &&
333+ /// paint.maskFilter == null &&
334+ /// paint.shader == null &&
335+ /// paint.style != ui.PaintingStyle.stroke)
336+ ///
327337 bool _useDomForRendering (SurfacePaintData paint) =>
328- _preserveImageData == false && (
329- _contains3dTransform ||
330- (_canvasPool._canvas == null &&
331- paint.maskFilter == null &&
332- paint.shader == null &&
333- paint.style != ui.PaintingStyle .stroke));
338+ _preserveImageData == false && _contains3dTransform;
334339
335340 @override
336341 void drawColor (ui.Color color, ui.BlendMode blendMode) {
@@ -488,10 +493,13 @@ class BitmapCanvas extends EngineCanvas {
488493 html.Element svgElm = _pathToSvgElement (
489494 surfacePath, paint, '${pathBounds .right }' , '${pathBounds .bottom }' );
490495 if (! _canvasPool.isClipped) {
491- svgElm.style
492- ..transform = matrix4ToCssTransform (transform)
493- ..transformOrigin = '0 0 0'
494- ..position = 'absolute' ;
496+ html.CssStyleDeclaration style = svgElm.style;
497+ style.position = 'absolute' ;
498+ if (! transform.isIdentity ()) {
499+ style
500+ ..transform = matrix4ToCssTransform (transform)
501+ ..transformOrigin = '0 0 0' ;
502+ }
495503 }
496504 _drawElement (svgElm, ui.Offset (0 , 0 ), paint);
497505 } else {
0 commit comments