From 24b99d5019d4a695c102491bbb8e74de7c29977e Mon Sep 17 00:00:00 2001 From: Harry Terkelsen Date: Tue, 1 Nov 2022 16:31:47 -0700 Subject: [PATCH] [web] Store Paint.color as an int. Only create a ui.Color when the color getter is called. (#37092) * Store color as the int value. Only create a color when getter is called * Refactor tests and painting * Change SurfacePaintData to have default opaque black color --- lib/web_ui/lib/src/engine/canvas_pool.dart | 10 ++--- .../lib/src/engine/canvaskit/painting.dart | 15 ++++--- .../lib/src/engine/html/bitmap_canvas.dart | 9 ++--- lib/web_ui/lib/src/engine/html/clip.dart | 2 +- .../lib/src/engine/html/dom_canvas.dart | 10 ++--- lib/web_ui/lib/src/engine/html/painting.dart | 13 +++--- .../lib/src/engine/html/render_vertices.dart | 3 +- lib/web_ui/lib/src/engine/util.dart | 11 +++++ .../test/html/bitmap_canvas_golden_test.dart | 6 +-- .../html/canvas_winding_rule_golden_test.dart | 2 +- .../html/drawing/canvas_arc_golden_test.dart | 8 ++-- .../canvas_draw_points_golden_test.dart | 8 ++-- .../drawing/canvas_lines_golden_test.dart | 12 +++--- .../html/drawing/canvas_rect_golden_test.dart | 8 ++-- .../canvas_stroke_joins_golden_test.dart | 4 +- .../canvas_stroke_rects_golden_test.dart | 10 ++--- .../drawing/dom_clip_stroke_golden_test.dart | 18 ++++----- .../test/html/paragraph/bidi_golden_test.dart | 40 +++++++++---------- .../html/paragraph/general_golden_test.dart | 12 +++--- lib/web_ui/test/html/paragraph/helper.dart | 2 +- .../html/paragraph/overflow_golden_test.dart | 2 +- .../html/recording_canvas_golden_test.dart | 2 +- 22 files changed, 104 insertions(+), 103 deletions(-) diff --git a/lib/web_ui/lib/src/engine/canvas_pool.dart b/lib/web_ui/lib/src/engine/canvas_pool.dart index 188cf7d0ec2a0..60365b892d0e3 100644 --- a/lib/web_ui/lib/src/engine/canvas_pool.dart +++ b/lib/web_ui/lib/src/engine/canvas_pool.dart @@ -1012,7 +1012,7 @@ class ContextStateHandle { } } } else if (paint.color != null) { - final String? colorString = colorToCssString(paint.color); + final String? colorString = colorValueToCssString(paint.color); fillStyle = colorString; strokeStyle = colorString; } else { @@ -1036,12 +1036,8 @@ class ContextStateHandle { if (maskFilter != null) { context.save(); context.shadowBlur = convertSigmaToRadius(maskFilter.webOnlySigma); - if (paint.color != null) { - // Shadow color must be fully opaque. - context.shadowColor = colorToCssString(paint.color!.withAlpha(255)); - } else { - context.shadowColor = colorToCssString(const ui.Color(0xFF000000)); - } + // Shadow color must be fully opaque. + context.shadowColor = colorToCssString(ui.Color(paint.color).withAlpha(255)); // On the web a shadow must always be painted together with the shape // that casts it. In order to paint just the shadow, we offset the shape diff --git a/lib/web_ui/lib/src/engine/canvaskit/painting.dart b/lib/web_ui/lib/src/engine/canvaskit/painting.dart index 0b83e6cad9861..419037574b9ba 100644 --- a/lib/web_ui/lib/src/engine/canvaskit/painting.dart +++ b/lib/web_ui/lib/src/engine/canvaskit/painting.dart @@ -21,7 +21,7 @@ import 'skia_object_cache.dart'; class CkPaint extends ManagedSkiaObject implements ui.Paint { CkPaint(); - static const ui.Color _defaultPaintColor = ui.Color(0xFF000000); + static const int _defaultPaintColor = 0xFF000000; @override ui.BlendMode get blendMode => _blendMode; @@ -103,18 +103,17 @@ class CkPaint extends ManagedSkiaObject implements ui.Paint { bool _isAntiAlias = true; @override - ui.Color get color => _color; + ui.Color get color => ui.Color(_color); @override set color(ui.Color value) { - if (_color == value) { + if (_color == value.value) { return; } - _color = - value.runtimeType == ui.Color ? value : ui.Color(value.value); + _color = value.value; skiaObject.setColorInt(value.value); } - ui.Color _color = _defaultPaintColor; + int _color = _defaultPaintColor; @override bool get invertColors => _invertColors; @@ -269,7 +268,7 @@ class CkPaint extends ManagedSkiaObject implements ui.Paint { SkPaint createDefault() { final SkPaint paint = SkPaint(); paint.setAntiAlias(_isAntiAlias); - paint.setColorInt(_color.value); + paint.setColorInt(_color); return paint; } @@ -282,7 +281,7 @@ class CkPaint extends ManagedSkiaObject implements ui.Paint { paint.setStyle(toSkPaintStyle(_style)); paint.setStrokeWidth(_strokeWidth); paint.setAntiAlias(_isAntiAlias); - paint.setColorInt(_color.value); + paint.setColorInt(_color); paint.setShader(_shader?.withQuality(_filterQuality)); paint.setMaskFilter(_ckMaskFilter?.skiaObject); paint.setColorFilter(_effectiveColorFilter?.skiaObject); diff --git a/lib/web_ui/lib/src/engine/html/bitmap_canvas.dart b/lib/web_ui/lib/src/engine/html/bitmap_canvas.dart index a051183395568..844c8290ac7d0 100644 --- a/lib/web_ui/lib/src/engine/html/bitmap_canvas.dart +++ b/lib/web_ui/lib/src/engine/html/bitmap_canvas.dart @@ -399,7 +399,7 @@ class BitmapCanvas extends EngineCanvas { @override void drawColor(ui.Color color, ui.BlendMode blendMode) { final SurfacePaintData paintData = SurfacePaintData() - ..color = color + ..color = color.value ..blendMode = blendMode; if (_useDomForRenderingFill(paintData)) { drawRect(_computeScreenBounds(_canvasPool.currentTransform), paintData); @@ -592,8 +592,7 @@ class BitmapCanvas extends EngineCanvas { void _applyFilter(DomElement element, SurfacePaintData paint) { if (paint.maskFilter != null) { final bool isStroke = paint.style == ui.PaintingStyle.stroke; - final String cssColor = - paint.color == null ? '#000000' : colorToCssString(paint.color)!; + final String cssColor = colorValueToCssString(paint.color)!; final double sigma = paint.maskFilter!.webOnlySigma; if (browserEngine == BrowserEngine.webkit && !isStroke) { // A bug in webkit leaves artifacts when this element is animated @@ -1031,7 +1030,7 @@ class BitmapCanvas extends EngineCanvas { : convertVertexPositions(mode, vertices.positions); // Draw hairline for vertices if no vertex colors are specified. save(); - final ui.Color color = paint.color ?? const ui.Color(0xFF000000); + final ui.Color color = ui.Color(paint.color); _canvasPool.contextHandle ..fillStyle = null ..strokeStyle = colorToCssString(color); @@ -1059,7 +1058,7 @@ class BitmapCanvas extends EngineCanvas { } else { _drawPointsPaint.style = ui.PaintingStyle.fill; } - _drawPointsPaint.color = paint.color ?? const ui.Color(0xFF000000); + _drawPointsPaint.color = paint.color; _drawPointsPaint.maskFilter = paint.maskFilter; final double dpr = ui.window.devicePixelRatio; diff --git a/lib/web_ui/lib/src/engine/html/clip.dart b/lib/web_ui/lib/src/engine/html/clip.dart index 08cd5aa580be0..892bc88403825 100644 --- a/lib/web_ui/lib/src/engine/html/clip.dart +++ b/lib/web_ui/lib/src/engine/html/clip.dart @@ -392,7 +392,7 @@ class PersistedPhysicalShape extends PersistedContainerSurface path, SurfacePaintData() ..style = ui.PaintingStyle.fill - ..color = color, + ..color = color.value, '${pathBounds2.right}', '${pathBounds2.bottom}'); diff --git a/lib/web_ui/lib/src/engine/html/dom_canvas.dart b/lib/web_ui/lib/src/engine/html/dom_canvas.dart index c7caeea6cde89..3e63a0b99ff03 100644 --- a/lib/web_ui/lib/src/engine/html/dom_canvas.dart +++ b/lib/web_ui/lib/src/engine/html/dom_canvas.dart @@ -257,7 +257,7 @@ DomHTMLElement buildDrawRectElement( ..transform = effectiveTransform; String cssColor = - paint.color == null ? '#000000' : colorToCssString(paint.color)!; + paint.color == null ? '#000000' : colorValueToCssString(paint.color)!; if (paint.maskFilter != null) { final double sigma = paint.maskFilter!.webOnlySigma; @@ -265,8 +265,7 @@ DomHTMLElement buildDrawRectElement( // A bug in webkit leaves artifacts when this element is animated // with filter: blur, we use boxShadow instead. style.boxShadow = '0px 0px ${sigma * 2.0}px $cssColor'; - cssColor = colorToCssString( - blurColor(paint.color ?? const ui.Color(0xFF000000), sigma))!; + cssColor = colorToCssString(blurColor(ui.Color(paint.color), sigma))!; } else { style.filter = 'blur(${sigma}px)'; } @@ -345,16 +344,15 @@ SVGSVGElement pathToSvgElement( final SVGPathElement svgPath = createSVGPathElement(); root.append(svgPath); - final ui.Color color = paint.color ?? const ui.Color(0xFF000000); if (paint.style == ui.PaintingStyle.stroke || (paint.style != ui.PaintingStyle.fill && paint.strokeWidth != 0 && paint.strokeWidth != null)) { - svgPath.setAttribute('stroke', colorToCssString(color)!); + svgPath.setAttribute('stroke', colorValueToCssString(paint.color)!); svgPath.setAttribute('stroke-width', '${paint.strokeWidth ?? 1.0}'); svgPath.setAttribute('fill', 'none'); } else if (paint.color != null) { - svgPath.setAttribute('fill', colorToCssString(color)!); + svgPath.setAttribute('fill', colorValueToCssString(paint.color)!); } else { svgPath.setAttribute('fill', '#000000'); } diff --git a/lib/web_ui/lib/src/engine/html/painting.dart b/lib/web_ui/lib/src/engine/html/painting.dart index c0c206214a6d4..27ff910ec4769 100644 --- a/lib/web_ui/lib/src/engine/html/painting.dart +++ b/lib/web_ui/lib/src/engine/html/painting.dart @@ -83,7 +83,7 @@ class SurfacePaint implements ui.Paint { } @override - ui.Color get color => _paintData.color ?? _defaultPaintColor; + ui.Color get color => ui.Color(_paintData.color); @override set color(ui.Color value) { @@ -91,8 +91,7 @@ class SurfacePaint implements ui.Paint { _paintData = _paintData.clone(); _frozen = false; } - _paintData.color = - value.runtimeType == ui.Color ? value : ui.Color(value.value); + _paintData.color = value.value; } @override @@ -103,7 +102,7 @@ class SurfacePaint implements ui.Paint { @override set invertColors(bool value) {} - static const ui.Color _defaultPaintColor = ui.Color(0xFF000000); + static const int _defaultPaintColor = 0xFF000000; @override ui.Shader? get shader => _paintData.shader; @@ -207,7 +206,7 @@ class SurfacePaint implements ui.Paint { result.write('${semicolon}antialias off'); semicolon = '; '; } - if (color != _defaultPaintColor) { + if (color.value != _defaultPaintColor) { result.write('$semicolon$color'); semicolon = '; '; } @@ -225,7 +224,7 @@ class SurfacePaintData { ui.StrokeCap? strokeCap; ui.StrokeJoin? strokeJoin; bool isAntiAlias = true; - ui.Color? color; + int color = 0xFF000000; ui.Shader? shader; ui.MaskFilter? maskFilter; ui.FilterQuality? filterQuality; @@ -269,7 +268,7 @@ class SurfacePaintData { buffer.write('strokeJoin = $strokeJoin; '); } if (color != null) { - buffer.write('color = ${colorToCssString(color)}; '); + buffer.write('color = ${colorToCssString(ui.Color(color))}; '); } if (shader != null) { buffer.write('shader = $shader; '); diff --git a/lib/web_ui/lib/src/engine/html/render_vertices.dart b/lib/web_ui/lib/src/engine/html/render_vertices.dart index 7ab470c4dba8d..2b062f8f5f607 100644 --- a/lib/web_ui/lib/src/engine/html/render_vertices.dart +++ b/lib/web_ui/lib/src/engine/html/render_vertices.dart @@ -230,10 +230,9 @@ class _WebGlRenderer implements GlRenderer { // Buffer kBGRA_8888. if (vertices.colors == null) { - final ui.Color color = paint.color ?? const ui.Color(0xFF000000); final Uint32List vertexColors = Uint32List(vertexCount); for (int i = 0; i < vertexCount; i++) { - vertexColors[i] = color.value; + vertexColors[i] = paint.color; } gl.bufferData(vertexColors, gl.kStaticDraw); } else { diff --git a/lib/web_ui/lib/src/engine/util.dart b/lib/web_ui/lib/src/engine/util.dart index 16c1446e08d23..3f78e859e8286 100644 --- a/lib/web_ui/lib/src/engine/util.dart +++ b/lib/web_ui/lib/src/engine/util.dart @@ -344,6 +344,17 @@ String? colorToCssString(ui.Color? color) { return null; } final int value = color.value; + return colorValueToCssString(value); +} + +// Converts a color value (as an int) into a CSS-compatible value. +String? colorValueToCssString(int? value) { + if (value == null) { + return null; + } + if (value == 0xFF000000) { + return '#000000'; + } if ((0xff000000 & value) == 0xff000000) { final String hexValue = (value & 0xFFFFFF).toRadixString(16); final int hexValueLength = hexValue.length; diff --git a/lib/web_ui/test/html/bitmap_canvas_golden_test.dart b/lib/web_ui/test/html/bitmap_canvas_golden_test.dart index 656bd3025d4e4..8f3f5db1c31cf 100644 --- a/lib/web_ui/test/html/bitmap_canvas_golden_test.dart +++ b/lib/web_ui/test/html/bitmap_canvas_golden_test.dart @@ -126,7 +126,7 @@ Future testMain() async { canvas.clipRect(const Rect.fromLTWH(0, 0, 50, 50), ClipOp.intersect); canvas.translate(25, 25); canvas.drawPaint(SurfacePaintData() - ..color = const Color.fromRGBO(0, 255, 0, 1.0) + ..color = const Color.fromRGBO(0, 255, 0, 1.0).value ..style = PaintingStyle.fill); appendToScene(); @@ -209,7 +209,7 @@ Future testMain() async { canvas.debugChildOverdraw = true; final SurfacePaintData pathPaint = SurfacePaintData() - ..color = const Color(0xFF7F7F7F) + ..color = 0xFF7F7F7F ..style = PaintingStyle.fill; const double r = 200.0; @@ -227,7 +227,7 @@ Future testMain() async { ..close()).shift(const Offset(250, 250)); final SurfacePaintData borderPaint = SurfacePaintData() - ..color = black + ..color = black.value ..style = PaintingStyle.stroke; canvas.drawPath(path, pathPaint); diff --git a/lib/web_ui/test/html/canvas_winding_rule_golden_test.dart b/lib/web_ui/test/html/canvas_winding_rule_golden_test.dart index 342032e43c797..ec3c23129dfea 100644 --- a/lib/web_ui/test/html/canvas_winding_rule_golden_test.dart +++ b/lib/web_ui/test/html/canvas_winding_rule_golden_test.dart @@ -37,7 +37,7 @@ Future testMain() async { void paintPaths(BitmapCanvas canvas) { canvas.drawRect(const Rect.fromLTRB(0, 0, 500, 500), SurfacePaintData() - ..color = const Color(0xFFFFFFFF) + ..color = 0xFFFFFFFF ..style = PaintingStyle.fill); // white final SurfacePaint paintFill = SurfacePaint() diff --git a/lib/web_ui/test/html/drawing/canvas_arc_golden_test.dart b/lib/web_ui/test/html/drawing/canvas_arc_golden_test.dart index 879bb2b641391..e9bc105852915 100644 --- a/lib/web_ui/test/html/drawing/canvas_arc_golden_test.dart +++ b/lib/web_ui/test/html/drawing/canvas_arc_golden_test.dart @@ -54,7 +54,7 @@ Future testMain() async { ..addArc(Rect.fromCircle(center: rect.center, radius: rect.size.shortestSide / 2), 0.25 * math.pi, 1.5 * math.pi); canvas.drawPath(p, SurfacePaintData() - ..color = const Color(0xFFFF9800) // orange + ..color = 0xFFFF9800 // orange ..style = PaintingStyle.fill); domDocument.body!.append(canvas.rootElement); @@ -72,7 +72,7 @@ Future testMain() async { 4.71238898038469 - 5.759586531581287, true); path.lineTo(149.999999999999997, 20); canvas.drawPath(path, SurfacePaintData() - ..color = const Color(0xFFFF9800) // orange + ..color = 0xFFFF9800 // orange ..style = PaintingStyle.fill); domDocument.body!.append(canvas.rootElement); @@ -91,7 +91,7 @@ void paintArc(BitmapCanvas canvas, Offset offset, Rect.fromLTRB(startP.dx, startP.dy, endP.dx, endP.dy), SurfacePaintData() ..strokeWidth = 1 - ..color = const Color(0xFFFF9800) // orange + ..color = 0xFFFF9800 // orange ..style = PaintingStyle.stroke); final Path path = Path(); path.moveTo(startP.dx, startP.dy); @@ -104,6 +104,6 @@ void paintArc(BitmapCanvas canvas, Offset offset, path, SurfacePaintData() ..strokeWidth = 2 - ..color = const Color(0x61000000) // black38 + ..color = 0x61000000 // black38 ..style = PaintingStyle.stroke); } diff --git a/lib/web_ui/test/html/drawing/canvas_draw_points_golden_test.dart b/lib/web_ui/test/html/drawing/canvas_draw_points_golden_test.dart index b22b296ff1f63..97e19fd0e713e 100644 --- a/lib/web_ui/test/html/drawing/canvas_draw_points_golden_test.dart +++ b/lib/web_ui/test/html/drawing/canvas_draw_points_golden_test.dart @@ -31,7 +31,7 @@ Future testMain() async { test('draws points in all 3 modes', () async { final SurfacePaintData paint = SurfacePaintData(); paint.strokeWidth = 2.0; - paint.color = const Color(0xFF0000FF); + paint.color = 0xFF0000FF; final Float32List points = offsetListToFloat32List(const [ Offset(10, 10), Offset(50, 10), @@ -60,17 +60,17 @@ Future testMain() async { test('Should draw points with strokeWidth', () async { final SurfacePaintData nullStrokePaint = - SurfacePaintData()..color = const Color(0xffff0000); + SurfacePaintData()..color = 0xffff0000; canvas.drawPoints(PointMode.lines, Float32List.fromList([ 30.0, 20.0, 200.0, 20.0]), nullStrokePaint); final SurfacePaintData strokePaint1 = SurfacePaintData() ..strokeWidth = 1.0 - ..color = const Color(0xff0000ff); + ..color = 0xff0000ff; canvas.drawPoints(PointMode.lines, Float32List.fromList([ 30.0, 30.0, 200.0, 30.0]), strokePaint1); final SurfacePaintData strokePaint3 = SurfacePaintData() ..strokeWidth = 3.0 - ..color = const Color(0xff00a000); + ..color = 0xff00a000; canvas.drawPoints(PointMode.lines, Float32List.fromList([ 30.0, 40.0, 200.0, 40.0]), strokePaint3); canvas.drawPoints(PointMode.points, Float32List.fromList([ diff --git a/lib/web_ui/test/html/drawing/canvas_lines_golden_test.dart b/lib/web_ui/test/html/drawing/canvas_lines_golden_test.dart index ec4870dfaa206..166df80c58277 100644 --- a/lib/web_ui/test/html/drawing/canvas_lines_golden_test.dart +++ b/lib/web_ui/test/html/drawing/canvas_lines_golden_test.dart @@ -40,15 +40,15 @@ void paintLines(BitmapCanvas canvas) { ..strokeWidth = 1.0 ..style = PaintingStyle.stroke; final SurfacePaintData paint1 = SurfacePaintData() - ..color = const Color(0xFF9E9E9E) // Colors.grey + ..color = 0xFF9E9E9E // Colors.grey ..strokeWidth = 1.0 ..style = PaintingStyle.stroke; final SurfacePaintData paint2 = SurfacePaintData() - ..color = const Color(0x7fff0000) + ..color = 0x7fff0000 ..strokeWidth = 1.0 ..style = PaintingStyle.stroke; final SurfacePaintData paint3 = SurfacePaintData() - ..color = const Color(0xFF4CAF50) //Colors.green + ..color = 0xFF4CAF50 //Colors.green ..strokeWidth = 1.0 ..style = PaintingStyle.stroke; // Draw markers around 100x100 box @@ -61,12 +61,12 @@ void paintLines(BitmapCanvas canvas) { canvas.drawLine(const Offset(50, 50), const Offset(150, 150), paint2); // Draw horizontal paint3.strokeWidth = 1.0; - paint3.color = const Color(0xFFFF0000); + paint3.color = 0xFFFF0000; canvas.drawLine(const Offset(50, 55), const Offset(150, 55), paint3); paint3.strokeWidth = 2.0; - paint3.color = const Color(0xFF2196F3); // Colors.blue; + paint3.color = 0xFF2196F3; // Colors.blue; canvas.drawLine(const Offset(50, 60), const Offset(150, 60), paint3); paint3.strokeWidth = 4.0; - paint3.color = const Color(0xFFFF9800); // Colors.orange; + paint3.color = 0xFFFF9800; // Colors.orange; canvas.drawLine(const Offset(50, 70), const Offset(150, 70), paint3); } diff --git a/lib/web_ui/test/html/drawing/canvas_rect_golden_test.dart b/lib/web_ui/test/html/drawing/canvas_rect_golden_test.dart index 05bdbe9803c3c..42a6705e89f5b 100644 --- a/lib/web_ui/test/html/drawing/canvas_rect_golden_test.dart +++ b/lib/web_ui/test/html/drawing/canvas_rect_golden_test.dart @@ -39,26 +39,26 @@ void paintRects(BitmapCanvas canvas) { canvas.drawRect(const Rect.fromLTRB(30, 40, 100, 50), SurfacePaintData() - ..color = const Color(0xFF4CAF50) //Colors.green + ..color = 0xFF4CAF50 //Colors.green ..strokeWidth = 1.0 ..style = PaintingStyle.stroke); // swap left and right. canvas.drawRect(const Rect.fromLTRB(100, 150, 30, 140), SurfacePaintData() - ..color = const Color(0xFFF44336) //Colors.red + ..color = 0xFFF44336 //Colors.red ..strokeWidth = 1.0 ..style = PaintingStyle.stroke); // Repeat above for fill canvas.drawRect(const Rect.fromLTRB(30, 240, 100, 250), SurfacePaintData() - ..color = const Color(0xFF4CAF50) //Colors.green + ..color = 0xFF4CAF50 //Colors.green ..style = PaintingStyle.fill); // swap left and right. canvas.drawRect(const Rect.fromLTRB(100, 350, 30, 340), SurfacePaintData() - ..color = const Color(0xFFF44336) //Colors.red + ..color = 0xFFF44336 //Colors.red ..style = PaintingStyle.fill); } diff --git a/lib/web_ui/test/html/drawing/canvas_stroke_joins_golden_test.dart b/lib/web_ui/test/html/drawing/canvas_stroke_joins_golden_test.dart index 7382cfeb0e98e..b0080f1afebfa 100644 --- a/lib/web_ui/test/html/drawing/canvas_stroke_joins_golden_test.dart +++ b/lib/web_ui/test/html/drawing/canvas_stroke_joins_golden_test.dart @@ -39,7 +39,7 @@ Future testMain() async { void paintStrokeJoins(BitmapCanvas canvas) { canvas.drawRect(const Rect.fromLTRB(0, 0, 300, 300), SurfacePaintData() - ..color = const Color(0xFFFFFFFF) + ..color = 0xFFFFFFFF ..style = PaintingStyle.fill); // white Offset start = const Offset(20, 10); @@ -62,7 +62,7 @@ void paintStrokeJoins(BitmapCanvas canvas) { canvas.drawPath(path, SurfacePaintData() ..style = PaintingStyle.stroke ..strokeWidth = 4 - ..color = color + ..color = color.value ..strokeJoin = join ..strokeCap = cap); diff --git a/lib/web_ui/test/html/drawing/canvas_stroke_rects_golden_test.dart b/lib/web_ui/test/html/drawing/canvas_stroke_rects_golden_test.dart index dcea2645c0505..a02c509371ad9 100644 --- a/lib/web_ui/test/html/drawing/canvas_stroke_rects_golden_test.dart +++ b/lib/web_ui/test/html/drawing/canvas_stroke_rects_golden_test.dart @@ -41,18 +41,18 @@ Future testMain() async { void paintSideBySideRects(BitmapCanvas canvas) { canvas.drawRect(const Rect.fromLTRB(0, 0, 300, 300), SurfacePaintData() - ..color = const Color(0xFFFFFFFF) + ..color = 0xFFFFFFFF ..style = PaintingStyle.fill); // white canvas.drawRect(const Rect.fromLTRB(0, 20, 40, 60), SurfacePaintData() ..style = PaintingStyle.fill - ..color = const Color(0x7f0000ff)); + ..color = 0x7f0000ff); canvas.drawRect(const Rect.fromLTRB(40, 20, 80, 60), SurfacePaintData() ..style = PaintingStyle.stroke ..strokeWidth = 4 - ..color = const Color(0x7fff0000)); + ..color = 0x7fff0000); // Rotate 30 degrees (in rad: deg*pi/180) canvas.transform(Matrix4.rotationZ(30.0 * math.pi / 180.0).storage); @@ -60,10 +60,10 @@ void paintSideBySideRects(BitmapCanvas canvas) { canvas.drawRect(const Rect.fromLTRB(100, 60, 140, 100), SurfacePaintData() ..style = PaintingStyle.fill - ..color = const Color(0x7fff00ff)); + ..color = 0x7fff00ff); canvas.drawRect(const Rect.fromLTRB(140, 60, 180, 100), SurfacePaintData() ..style = PaintingStyle.stroke ..strokeWidth = 4 - ..color = const Color(0x7fffff00)); + ..color = 0x7fffff00); } diff --git a/lib/web_ui/test/html/drawing/dom_clip_stroke_golden_test.dart b/lib/web_ui/test/html/drawing/dom_clip_stroke_golden_test.dart index 648353e924749..d44c6cfa8dc0e 100644 --- a/lib/web_ui/test/html/drawing/dom_clip_stroke_golden_test.dart +++ b/lib/web_ui/test/html/drawing/dom_clip_stroke_golden_test.dart @@ -27,7 +27,7 @@ Future testMain() async { canvas.drawRect( rect, SurfacePaintData() - ..color = const Color(0x6fff0000) + ..color = 0x6fff0000 ..strokeWidth = 20.0 ..style = PaintingStyle.stroke, ); @@ -35,7 +35,7 @@ Future testMain() async { canvas.drawRect( rect, SurfacePaintData() - ..color = const Color(0x6f0000ff) + ..color = 0x6f0000ff ..strokeWidth = 10.0 ..style = PaintingStyle.stroke, ); @@ -43,7 +43,7 @@ Future testMain() async { canvas.drawRect( rect, SurfacePaintData() - ..color = const Color(0xff000000) + ..color = 0xff000000 ..strokeWidth = 1.0 ..style = PaintingStyle.stroke, ); @@ -70,7 +70,7 @@ Future testMain() async { canvas.drawRRect( rrect, SurfacePaintData() - ..color = const Color(0x6fff0000) + ..color = 0x6fff0000 ..strokeWidth = 20.0 ..style = PaintingStyle.stroke, ); @@ -78,7 +78,7 @@ Future testMain() async { canvas.drawRRect( rrect, SurfacePaintData() - ..color = const Color(0x6f0000ff) + ..color = 0x6f0000ff ..strokeWidth = 10.0 ..style = PaintingStyle.stroke, ); @@ -86,7 +86,7 @@ Future testMain() async { canvas.drawRRect( rrect, SurfacePaintData() - ..color = const Color(0xff000000) + ..color = 0xff000000 ..strokeWidth = 1.0 ..style = PaintingStyle.stroke, ); @@ -111,7 +111,7 @@ Future testMain() async { rect.center, rect.width / 2, SurfacePaintData() - ..color = const Color(0x6fff0000) + ..color = 0x6fff0000 ..strokeWidth = 20.0 ..style = PaintingStyle.stroke, ); @@ -120,7 +120,7 @@ Future testMain() async { rect.center, rect.width / 2, SurfacePaintData() - ..color = const Color(0x6f0000ff) + ..color = 0x6f0000ff ..strokeWidth = 10.0 ..style = PaintingStyle.stroke, ); @@ -129,7 +129,7 @@ Future testMain() async { rect.center, rect.width / 2, SurfacePaintData() - ..color = const Color(0xff000000) + ..color = 0xff000000 ..strokeWidth = 1.0 ..style = PaintingStyle.stroke, ); diff --git a/lib/web_ui/test/html/paragraph/bidi_golden_test.dart b/lib/web_ui/test/html/paragraph/bidi_golden_test.dart index e4d0f18e1dfe9..8f1c6f2060568 100644 --- a/lib/web_ui/test/html/paragraph/bidi_golden_test.dart +++ b/lib/web_ui/test/html/paragraph/bidi_golden_test.dart @@ -57,7 +57,7 @@ Future testMain() async { canvas.drawRect( ltrBox, SurfacePaintData() - ..color = black + ..color = black.value ..style = PaintingStyle.stroke, ); // LTR with different text align values: @@ -72,7 +72,7 @@ Future testMain() async { canvas.drawRect( rtlBox, SurfacePaintData() - ..color = black + ..color = black.value ..style = PaintingStyle.stroke, ); // RTL with different text align values: @@ -96,7 +96,7 @@ Future testMain() async { canvas.drawRect( ltrBox, SurfacePaintData() - ..color = black + ..color = black.value ..style = PaintingStyle.stroke, ); // LTR with different text align values: @@ -111,7 +111,7 @@ Future testMain() async { canvas.drawRect( rtlBox, SurfacePaintData() - ..color = black + ..color = black.value ..style = PaintingStyle.stroke, ); // RTL with different text align values: @@ -161,7 +161,7 @@ Future testMain() async { canvas.drawRect( ltrBox, SurfacePaintData() - ..color = black + ..color = black.value ..style = PaintingStyle.stroke, ); // LTR with different text align values: @@ -176,7 +176,7 @@ Future testMain() async { canvas.drawRect( rtlBox, SurfacePaintData() - ..color = black + ..color = black.value ..style = PaintingStyle.stroke, ); // RTL with different text align values: @@ -200,7 +200,7 @@ Future testMain() async { canvas.drawRect( ltrBox, SurfacePaintData() - ..color = black + ..color = black.value ..style = PaintingStyle.stroke, ); // LTR with different text align values: @@ -215,7 +215,7 @@ Future testMain() async { canvas.drawRect( rtlBox, SurfacePaintData() - ..color = black + ..color = black.value ..style = PaintingStyle.stroke, ); // RTL with different text align values: @@ -269,7 +269,7 @@ Future testMain() async { canvas.drawRect( ltrBox, SurfacePaintData() - ..color = black + ..color = black.value ..style = PaintingStyle.stroke, ); // LTR with different text align values: @@ -284,7 +284,7 @@ Future testMain() async { canvas.drawRect( rtlBox, SurfacePaintData() - ..color = black + ..color = black.value ..style = PaintingStyle.stroke, ); // RTL with different text align values: @@ -307,7 +307,7 @@ Future testMain() async { canvas.drawRect( ltrBox, SurfacePaintData() - ..color = black + ..color = black.value ..style = PaintingStyle.stroke, ); // LTR with different text align values: @@ -322,7 +322,7 @@ Future testMain() async { canvas.drawRect( rtlBox, SurfacePaintData() - ..color = black + ..color = black.value ..style = PaintingStyle.stroke, ); // RTL with different text align values: @@ -383,7 +383,7 @@ Future testMain() async { canvas.drawRect( ltrBox, SurfacePaintData() - ..color = black + ..color = black.value ..style = PaintingStyle.stroke, ); // LTR with different text align values: @@ -398,7 +398,7 @@ Future testMain() async { canvas.drawRect( rtlBox, SurfacePaintData() - ..color = black + ..color = black.value ..style = PaintingStyle.stroke, ); // RTL with different text align values: @@ -422,7 +422,7 @@ Future testMain() async { canvas.drawRect( ltrBox, SurfacePaintData() - ..color = black + ..color = black.value ..style = PaintingStyle.stroke, ); // LTR with different text align values: @@ -437,7 +437,7 @@ Future testMain() async { canvas.drawRect( rtlBox, SurfacePaintData() - ..color = black + ..color = black.value ..style = PaintingStyle.stroke, ); // RTL with different text align values: @@ -502,7 +502,7 @@ Future testMain() async { canvas.drawRect( ltrBox, SurfacePaintData() - ..color = black + ..color = black.value ..style = PaintingStyle.stroke, ); // LTR with different text align values: @@ -517,7 +517,7 @@ Future testMain() async { canvas.drawRect( rtlBox, SurfacePaintData() - ..color = black + ..color = black.value ..style = PaintingStyle.stroke, ); // RTL with different text align values: @@ -541,7 +541,7 @@ Future testMain() async { canvas.drawRect( ltrBox, SurfacePaintData() - ..color = black + ..color = black.value ..style = PaintingStyle.stroke, ); // LTR with different text align values: @@ -556,7 +556,7 @@ Future testMain() async { canvas.drawRect( rtlBox, SurfacePaintData() - ..color = black + ..color = black.value ..style = PaintingStyle.stroke, ); // RTL with different text align values: diff --git a/lib/web_ui/test/html/paragraph/general_golden_test.dart b/lib/web_ui/test/html/paragraph/general_golden_test.dart index caff7f814d466..82d2e4da230f0 100644 --- a/lib/web_ui/test/html/paragraph/general_golden_test.dart +++ b/lib/web_ui/test/html/paragraph/general_golden_test.dart @@ -172,7 +172,7 @@ Future testMain() async { canvas.translate(offset.dx, offset.dy); canvas.rotate(math.pi / 4); final Rect rect = Rect.fromLTRB(0.0, 0.0, 150.0, paragraph.height); - canvas.drawRect(rect, SurfacePaintData()..color = black); + canvas.drawRect(rect, SurfacePaintData()..color = black.value); canvas.drawParagraph(paragraph, Offset.zero); canvas.restore(); } @@ -205,7 +205,7 @@ Future testMain() async { }, )..layout(constrain(double.infinity)); final Rect rect = Rect.fromLTRB(0.0, 0.0, paragraph.maxIntrinsicWidth, paragraph.height); - canvas.drawRect(rect, SurfacePaintData()..color = black); + canvas.drawRect(rect, SurfacePaintData()..color = black.value); canvas.drawParagraph(paragraph, Offset.zero); } @@ -243,7 +243,7 @@ Future testMain() async { }, )..layout(constrain(double.infinity)); final Rect rect = Rect.fromLTWH(offset.dx, offset.dy, paragraph.maxIntrinsicWidth, paragraph.height); - canvas.drawRect(rect, SurfacePaintData()..color = black); + canvas.drawRect(rect, SurfacePaintData()..color = black.value); canvas.drawParagraph(paragraph, offset); offset = offset.translate(paragraph.maxIntrinsicWidth, 0.0); @@ -262,7 +262,7 @@ Future testMain() async { }, )..layout(constrain(double.infinity)); final Rect rect2 = Rect.fromLTWH(offset.dx, offset.dy, paragraph2.maxIntrinsicWidth, paragraph2.height); - canvas.drawRect(rect2, SurfacePaintData()..color = black); + canvas.drawRect(rect2, SurfacePaintData()..color = black.value); canvas.drawParagraph(paragraph2, offset); // Draw a rect in the placeholder. // Leave some padding around the placeholder to make the black paragraph @@ -271,7 +271,7 @@ Future testMain() async { final TextBox placeholderBox = paragraph2.getBoxesForPlaceholders().single; canvas.drawRect( placeholderBox.toRect().shift(offset).deflate(padding), - SurfacePaintData()..color = red, + SurfacePaintData()..color = red.value, ); await takeScreenshot(canvas, bounds, 'canvas_paragraph_giant_body_font_size_dom'); @@ -630,7 +630,7 @@ Future testMain() async { canvas.drawRect( paragraph.paintBounds, SurfacePaintData() - ..color = const Color(0xFF00FF00) + ..color = 0xFF00FF00 ..style = PaintingStyle.stroke ..strokeWidth = 1, ); diff --git a/lib/web_ui/test/html/paragraph/helper.dart b/lib/web_ui/test/html/paragraph/helper.dart index e9cb07f5b889a..1497f7b4ab2ff 100644 --- a/lib/web_ui/test/html/paragraph/helper.dart +++ b/lib/web_ui/test/html/paragraph/helper.dart @@ -112,7 +112,7 @@ void fillPlaceholder( void fillBoxes(EngineCanvas canvas, Offset offset, List boxes, Color color) { for (final TextBox box in boxes) { final Rect rect = box.toRect().shift(offset); - canvas.drawRect(rect, SurfacePaintData()..color = color); + canvas.drawRect(rect, SurfacePaintData()..color = color.value); } } diff --git a/lib/web_ui/test/html/paragraph/overflow_golden_test.dart b/lib/web_ui/test/html/paragraph/overflow_golden_test.dart index 3e6e130a50723..eebfde0c1489e 100644 --- a/lib/web_ui/test/html/paragraph/overflow_golden_test.dart +++ b/lib/web_ui/test/html/paragraph/overflow_golden_test.dart @@ -27,7 +27,7 @@ Future testMain() async { const double width = 126.0; const double padding = 20.0; final SurfacePaintData borderPaint = SurfacePaintData() - ..color = black + ..color = black.value ..style = PaintingStyle.stroke; paragraph = rich( diff --git a/lib/web_ui/test/html/recording_canvas_golden_test.dart b/lib/web_ui/test/html/recording_canvas_golden_test.dart index f77e990518311..eaad748b4b8de 100644 --- a/lib/web_ui/test/html/recording_canvas_golden_test.dart +++ b/lib/web_ui/test/html/recording_canvas_golden_test.dart @@ -43,7 +43,7 @@ Future testMain() async { ..drawRect( rc.pictureBounds!, SurfacePaintData() - ..color = const Color.fromRGBO(0, 0, 255, 1.0) + ..color = const Color.fromRGBO(0, 0, 255, 1.0).value ..style = PaintingStyle.stroke ..strokeWidth = 1.0, )