blob: 7aecf37c7e18b4e5c0673ed638e515f3b633e555 [file] [log] [blame]
Mike Klein8f5a7a62018-09-11 12:11:46 -04001/*
2 * Copyright 2018 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
Mike Kleinc0bd9f92019-04-23 12:05:21 -05008#include "gm/gm.h"
Ben Wagner7fde8e12019-05-01 17:28:53 -04009#include "include/core/SkBitmap.h"
10#include "include/core/SkCanvas.h"
11#include "include/core/SkColor.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050012#include "include/core/SkColorSpace.h"
13#include "include/core/SkFont.h"
Mike Reed607a3822021-01-24 19:49:21 -050014#include "include/core/SkImage.h"
Ben Wagner7fde8e12019-05-01 17:28:53 -040015#include "include/core/SkImageInfo.h"
16#include "include/core/SkMatrix.h"
17#include "include/core/SkPaint.h"
18#include "include/core/SkPathEffect.h"
19#include "include/core/SkPixmap.h"
20#include "include/core/SkPoint.h"
Ben Wagner7fde8e12019-05-01 17:28:53 -040021#include "include/core/SkShader.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050022#include "include/core/SkString.h"
Ben Wagner7fde8e12019-05-01 17:28:53 -040023#include "include/core/SkTileMode.h"
24#include "include/core/SkTypes.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050025#include "include/effects/SkDashPathEffect.h"
26#include "include/effects/SkGradientShader.h"
Mike Klein8aa0edf2020-10-16 11:04:18 -050027#include "include/private/SkTPin.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050028#include "src/core/SkColorSpaceXformSteps.h"
Mike Klein8f5a7a62018-09-11 12:11:46 -040029
Ben Wagner7fde8e12019-05-01 17:28:53 -040030#include <math.h>
31#include <string.h>
32
Mike Kleinfd007642018-09-12 13:03:06 -040033static bool nearly_equal(SkColor4f x, SkColor4f y) {
34 const float K = 0.01f;
35 return fabsf(x.fR - y.fR) < K
36 && fabsf(x.fG - y.fG) < K
37 && fabsf(x.fB - y.fB) < K
38 && fabsf(x.fA - y.fA) < K;
39}
40
41static SkString fmt(SkColor4f c) {
42 return SkStringPrintf("%.2g %.2g %.2g %.2g", c.fR, c.fG, c.fB, c.fA);
43}
44
45static SkColor4f transform(SkColor4f c, SkColorSpace* src, SkColorSpace* dst) {
46 SkColorSpaceXformSteps(src, kUnpremul_SkAlphaType,
47 dst, kUnpremul_SkAlphaType).apply(c.vec());
48 return c;
49}
50
Mike Klein5e31ec62018-09-12 18:04:49 -040051static void compare_pixel(const char* label,
52 SkCanvas* canvas, int x, int y,
53 SkColor4f color, SkColorSpace* cs) {
Hal Canarydf2d27e2019-01-08 09:38:02 -050054 SkPaint paint;
55 SkFont font;
Mike Klein5e31ec62018-09-12 18:04:49 -040056 auto canvas_cs = canvas->imageInfo().refColorSpace();
Mike Klein8f5a7a62018-09-11 12:11:46 -040057
Mike Klein5e31ec62018-09-12 18:04:49 -040058 // I'm not really sure if this makes things easier or harder to follow,
59 // but we sniff the canvas to grab its current y-translate, so that (x,y)
60 // can be written in sort of chunk-relative terms.
61 const SkMatrix& m = canvas->getTotalMatrix();
John Stilesc766dd52021-06-18 12:22:56 -040062 SkASSERT(m.isScaleTranslate());
Mike Klein5e31ec62018-09-12 18:04:49 -040063 SkScalar dy = m.getTranslateY();
64 SkASSERT(dy == (int)dy);
65 y += (int)dy;
Mike Klein8f5a7a62018-09-11 12:11:46 -040066
Mike Kleinfd007642018-09-12 13:03:06 -040067 SkBitmap bm;
Mike Klein5e31ec62018-09-12 18:04:49 -040068 bm.allocPixels(SkImageInfo::Make(1,1, kRGBA_F32_SkColorType, kUnpremul_SkAlphaType, canvas_cs));
69 if (!canvas->readPixels(bm, x,y)) {
Mike Kleinc9eace82018-10-31 10:49:38 -040070 MarkGMGood(canvas, 140,40);
Hal Canarydf2d27e2019-01-08 09:38:02 -050071 canvas->drawString("can't readPixels() on this canvas :(", 100,20, font, paint);
Mike Kleinfd007642018-09-12 13:03:06 -040072 return;
73 }
Mike Klein8f5a7a62018-09-11 12:11:46 -040074
Mike Kleinfd007642018-09-12 13:03:06 -040075 SkColor4f pixel;
Mike Klein5e31ec62018-09-12 18:04:49 -040076 memcpy(&pixel, bm.getAddr(0,0), sizeof(pixel));
Mike Klein8f5a7a62018-09-11 12:11:46 -040077
Mike Klein5e31ec62018-09-12 18:04:49 -040078 SkColor4f expected = transform(color,cs, canvas_cs.get());
Mike Klein21e82882020-07-17 14:01:18 -050079 if (SkColorTypeIsNormalized(canvas->imageInfo().colorType())) {
Mike Kleinfd007642018-09-12 13:03:06 -040080 // We can't expect normalized formats to hold values outside [0,1].
Brian Osmand5ea9982018-10-31 15:59:49 -040081 for (int i = 0; i < 4; ++i) {
82 expected[i] = SkTPin(expected[i], 0.0f, 1.0f);
83 }
Mike Kleinfd007642018-09-12 13:03:06 -040084 }
85 if (canvas->imageInfo().colorType() == kGray_8_SkColorType) {
86 // Drawing into Gray8 is known to be maybe-totally broken.
87 // TODO: update expectation here to be {lum,lum,lum,1} if we fix Gray8.
88 expected = SkColor4f{NAN, NAN, NAN, 1};
89 }
Mike Klein8f5a7a62018-09-11 12:11:46 -040090
Mike Kleinfd007642018-09-12 13:03:06 -040091 if (nearly_equal(pixel, expected)) {
Mike Kleinc9eace82018-10-31 10:49:38 -040092 MarkGMGood(canvas, 140,40);
Mike Klein8f5a7a62018-09-11 12:11:46 -040093 } else {
Mike Kleinc9eace82018-10-31 10:49:38 -040094 MarkGMBad(canvas, 140,40);
Mike Kleinfd007642018-09-12 13:03:06 -040095 }
96
97 struct {
98 const char* label;
99 SkColor4f color;
100 } lines[] = {
Mike Klein5e31ec62018-09-12 18:04:49 -0400101 {"Pixel:" , pixel },
102 {"Expected:", expected},
Mike Kleinfd007642018-09-12 13:03:06 -0400103 };
104
105 SkAutoCanvasRestore saveRestore(canvas, true);
Hal Canarydf2d27e2019-01-08 09:38:02 -0500106 canvas->drawString(label, 80,20, font, paint);
Mike Kleinfd007642018-09-12 13:03:06 -0400107 for (auto l : lines) {
Mike Klein5e31ec62018-09-12 18:04:49 -0400108 canvas->translate(0,20);
Hal Canarydf2d27e2019-01-08 09:38:02 -0500109 canvas->drawString(l.label, 80,20, font, paint);
110 canvas->drawString(fmt(l.color).c_str(), 140,20, font, paint);
Mike Klein5e31ec62018-09-12 18:04:49 -0400111 }
112}
113
Brian Osman3f4602f2018-10-18 16:35:49 -0400114DEF_SIMPLE_GM(p3, canvas, 450, 1300) {
Mike Kleinb147ace2020-01-16 11:11:06 -0600115 auto p3 = SkColorSpace::MakeRGB(SkNamedTransferFn::kSRGB, SkNamedGamut::kDisplayP3);
Mike Kleineee83152018-10-12 13:53:03 -0400116 auto srgb = SkColorSpace::MakeSRGB();
117
118 auto p3_to_srgb = [&](SkColor4f c) {
119 SkPaint p;
120 p.setColor4f(c, p3.get());
121 return p.getColor4f();
122 };
Mike Klein5e31ec62018-09-12 18:04:49 -0400123
124 // Draw a P3 red rectangle and check the corner.
125 {
126 SkPaint paint;
127 paint.setColor4f({1,0,0,1}, p3.get());
Mike Klein5e31ec62018-09-12 18:04:49 -0400128
Mike Klein62bd12f2018-09-17 12:39:09 -0400129 canvas->drawRect({10,10,70,70}, paint);
Mike Klein5e31ec62018-09-12 18:04:49 -0400130 compare_pixel("drawRect P3 red ",
131 canvas, 10,10,
132 {1,0,0,1}, p3.get());
133 }
134
135 canvas->translate(0,80);
136
Mike Klein62bd12f2018-09-17 12:39:09 -0400137 // Draw a P3 red bitmap, using a draw.
138 {
139 SkBitmap bm;
140 bm.allocPixels(SkImageInfo::Make(60,60, kRGBA_F16_SkColorType, kPremul_SkAlphaType, p3));
141
142 SkPaint paint;
143 paint.setColor4f({1,0,0,1}, p3.get());
144 SkCanvas{bm}.drawPaint(paint);
145
Mike Reed607a3822021-01-24 19:49:21 -0500146 canvas->drawImage(bm.asImage(), 10,10);
Mike Klein62bd12f2018-09-17 12:39:09 -0400147 compare_pixel("drawBitmap P3 red, from drawPaint",
148 canvas, 10,10,
149 {1,0,0,1}, p3.get());
150 }
151
152 canvas->translate(0,80);
153
Mike Klein62bd12f2018-09-17 12:39:09 -0400154 // Draw a P3 red bitmap, using SkPixmap::erase().
155 {
156 SkBitmap bm;
157 bm.allocPixels(SkImageInfo::Make(60,60, kRGBA_F16_SkColorType, kPremul_SkAlphaType, p3));
158
159 // At the moment only SkPixmap has an erase() that takes an SkColor4f.
160 SkPixmap pm;
161 SkAssertResult(bm.peekPixels(&pm));
Mike Kleind5cba9d2020-04-24 07:44:50 -0500162 SkAssertResult(pm.erase({1,0,0,1}, p3.get()));
Mike Klein62bd12f2018-09-17 12:39:09 -0400163
Mike Reed607a3822021-01-24 19:49:21 -0500164 canvas->drawImage(bm.asImage(), 10,10);
Mike Klein62bd12f2018-09-17 12:39:09 -0400165 compare_pixel("drawBitmap P3 red, from SkPixmap::erase",
166 canvas, 10,10,
167 {1,0,0,1}, p3.get());
168 }
169
170 canvas->translate(0,80);
171
Brian Osman3f4602f2018-10-18 16:35:49 -0400172 // Draw a P3 red bitmap wrapped in a shader, using SkPixmap::erase().
173 {
174 SkBitmap bm;
175 bm.allocPixels(SkImageInfo::Make(60,60, kRGBA_F16_SkColorType, kPremul_SkAlphaType, p3));
176
177 // At the moment only SkPixmap has an erase() that takes an SkColor4f.
178 SkPixmap pm;
179 SkAssertResult(bm.peekPixels(&pm));
Mike Kleind5cba9d2020-04-24 07:44:50 -0500180 SkAssertResult(pm.erase({1,0,0,1}, p3.get()));
Brian Osman3f4602f2018-10-18 16:35:49 -0400181
182 SkPaint paint;
Mike Reed057fcbe2020-12-12 14:31:25 -0500183 paint.setShader(bm.makeShader(SkTileMode::kRepeat, SkTileMode::kRepeat,
184 SkSamplingOptions()));
Brian Osman3f4602f2018-10-18 16:35:49 -0400185
186 canvas->drawRect({10,10,70,70}, paint);
187 compare_pixel("drawBitmapAsShader P3 red, from SkPixmap::erase",
188 canvas, 10,10,
189 {1,0,0,1}, p3.get());
190 }
191
192 canvas->translate(0,80);
193
Mike Klein4dc70ec2019-03-01 09:06:22 -0600194 // TODO(mtklein): sample and check the middle points of these gradients too.
195
Mike Kleineee83152018-10-12 13:53:03 -0400196 // Draw a gradient from P3 red to P3 green interpolating in unpremul P3, checking the corners.
Mike Klein5e31ec62018-09-12 18:04:49 -0400197 {
198
199 SkPoint points[] = {{10.5,10.5}, {69.5,69.5}};
200 SkColor4f colors[] = {{1,0,0,1}, {0,1,0,1}};
201
202 SkPaint paint;
203 paint.setShader(SkGradientShader::MakeLinear(points, colors, p3,
204 nullptr, SK_ARRAY_COUNT(colors),
Mike Reedfae8fce2019-04-03 10:27:45 -0400205 SkTileMode::kClamp));
Mike Klein5e31ec62018-09-12 18:04:49 -0400206 canvas->drawRect({10,10,70,70}, paint);
Mike Klein5e31ec62018-09-12 18:04:49 -0400207 canvas->save();
Mike Kleineee83152018-10-12 13:53:03 -0400208 compare_pixel("UPM P3 gradient, P3 red",
Mike Klein5e31ec62018-09-12 18:04:49 -0400209 canvas, 10,10,
210 {1,0,0,1}, p3.get());
211
212 canvas->translate(180, 0);
213
Mike Kleineee83152018-10-12 13:53:03 -0400214 compare_pixel("UPM P3 gradient, P3 green",
Mike Klein5e31ec62018-09-12 18:04:49 -0400215 canvas, 69,69,
216 {0,1,0,1}, p3.get());
217 canvas->restore();
Mike Klein8f5a7a62018-09-11 12:11:46 -0400218 }
219
Mike Klein9fb5a532018-09-13 15:23:38 -0400220 canvas->translate(0,80);
221
Mike Kleineee83152018-10-12 13:53:03 -0400222 // Draw a gradient from P3 red to P3 green interpolating in premul P3, checking the corners.
Mike Klein983886e2018-09-20 14:10:33 -0400223 {
224
225 SkPoint points[] = {{10.5,10.5}, {69.5,69.5}};
226 SkColor4f colors[] = {{1,0,0,1}, {0,1,0,1}};
227
228 SkPaint paint;
229 paint.setShader(
230 SkGradientShader::MakeLinear(points, colors, p3,
231 nullptr, SK_ARRAY_COUNT(colors),
Mike Reedfae8fce2019-04-03 10:27:45 -0400232 SkTileMode::kClamp,
Mike Klein983886e2018-09-20 14:10:33 -0400233 SkGradientShader::kInterpolateColorsInPremul_Flag,
234 nullptr/*local matrix*/));
235 canvas->drawRect({10,10,70,70}, paint);
236 canvas->save();
Mike Kleineee83152018-10-12 13:53:03 -0400237 compare_pixel("PM P3 gradient, P3 red",
Mike Klein983886e2018-09-20 14:10:33 -0400238 canvas, 10,10,
239 {1,0,0,1}, p3.get());
240
241 canvas->translate(180, 0);
242
Mike Kleineee83152018-10-12 13:53:03 -0400243 compare_pixel("PM P3 gradient, P3 green",
244 canvas, 69,69,
245 {0,1,0,1}, p3.get());
246 canvas->restore();
247 }
248
249 canvas->translate(0,80);
250
251 // Draw a gradient from P3 red to P3 green interpolating in unpremul sRGB, checking the corners.
252 {
253
254 SkPoint points[] = {{10.5,10.5}, {69.5,69.5}};
255 SkColor4f colors[] = {p3_to_srgb({1,0,0,1}), p3_to_srgb({0,1,0,1})};
256
257 SkPaint paint;
258 paint.setShader(SkGradientShader::MakeLinear(points, colors, srgb,
259 nullptr, SK_ARRAY_COUNT(colors),
Mike Reedfae8fce2019-04-03 10:27:45 -0400260 SkTileMode::kClamp));
Mike Kleineee83152018-10-12 13:53:03 -0400261 canvas->drawRect({10,10,70,70}, paint);
262 canvas->save();
263 compare_pixel("UPM sRGB gradient, P3 red",
264 canvas, 10,10,
265 {1,0,0,1}, p3.get());
266
267 canvas->translate(180, 0);
268
269 compare_pixel("UPM sRGB gradient, P3 green",
270 canvas, 69,69,
271 {0,1,0,1}, p3.get());
272 canvas->restore();
273 }
274
275 canvas->translate(0,80);
276
277 // Draw a gradient from P3 red to P3 green interpolating in premul sRGB, checking the corners.
278 {
279
280 SkPoint points[] = {{10.5,10.5}, {69.5,69.5}};
281 SkColor4f colors[] = {p3_to_srgb({1,0,0,1}), p3_to_srgb({0,1,0,1})};
282
283 SkPaint paint;
284 paint.setShader(
285 SkGradientShader::MakeLinear(points, colors, srgb,
286 nullptr, SK_ARRAY_COUNT(colors),
Mike Reedfae8fce2019-04-03 10:27:45 -0400287 SkTileMode::kClamp,
Mike Kleineee83152018-10-12 13:53:03 -0400288 SkGradientShader::kInterpolateColorsInPremul_Flag,
289 nullptr/*local matrix*/));
290 canvas->drawRect({10,10,70,70}, paint);
291 canvas->save();
Mike Klein4dc70ec2019-03-01 09:06:22 -0600292 compare_pixel("PM sRGB gradient, P3 red",
Mike Kleineee83152018-10-12 13:53:03 -0400293 canvas, 10,10,
294 {1,0,0,1}, p3.get());
295
296 canvas->translate(180, 0);
297
Mike Klein4dc70ec2019-03-01 09:06:22 -0600298 compare_pixel("PM sRGB gradient, P3 green",
Mike Klein983886e2018-09-20 14:10:33 -0400299 canvas, 69,69,
300 {0,1,0,1}, p3.get());
301 canvas->restore();
302 }
303
304 canvas->translate(0,80);
305
Mike Kleinb0243b22019-01-30 11:43:47 -0500306 // Leon's blue -> green -> red gradient, interpolating in premul.
307 {
308 SkPoint points[] = {{10.5,10.5}, {10.5,69.5}};
309 SkColor4f colors[] = { {0,0,1,1}, {0,1,0,1}, {1,0,0,1} };
310
311 SkPaint paint;
312 paint.setShader(
313 SkGradientShader::MakeLinear(points, colors, p3,
314 nullptr, SK_ARRAY_COUNT(colors),
Mike Reedfae8fce2019-04-03 10:27:45 -0400315 SkTileMode::kClamp,
Mike Kleinb0243b22019-01-30 11:43:47 -0500316 SkGradientShader::kInterpolateColorsInPremul_Flag,
317 nullptr/*local matrix*/));
318 canvas->drawRect({10,10,70,70}, paint);
319 canvas->save();
320 compare_pixel("Leon's gradient, P3 blue",
321 canvas, 10,10,
322 {0,0,1,1}, p3.get());
323
324 canvas->translate(180, 0);
325
326 compare_pixel("Leon's gradient, P3 red",
327 canvas, 10,69,
328 {1,0,0,1}, p3.get());
329 canvas->restore();
330 }
331
332 canvas->translate(0,80);
333
Mike Kleinbe569492018-09-14 09:34:21 -0400334 // Draw an A8 image with a P3 red, scaled and not, as a shader or bitmap.
Mike Klein9fb5a532018-09-13 15:23:38 -0400335 {
336 uint8_t mask[256];
337 for (int i = 0; i < 256; i++) {
338 mask[i] = 255-i;
339 }
Mike Reed607a3822021-01-24 19:49:21 -0500340
Mike Klein9fb5a532018-09-13 15:23:38 -0400341 SkBitmap bm;
342 bm.installPixels(SkImageInfo::MakeA8(16,16), mask, 16);
343
Mike Kleinbe569492018-09-14 09:34:21 -0400344 SkPaint as_bitmap;
345 as_bitmap.setColor4f({1,0,0,1}, p3.get());
Mike Reed607a3822021-01-24 19:49:21 -0500346 SkSamplingOptions sampling(SkFilterMode::kLinear);
Mike Klein9fb5a532018-09-13 15:23:38 -0400347
Mike Kleinbe569492018-09-14 09:34:21 -0400348 SkPaint as_shader;
349 as_shader.setColor4f({1,0,0,1}, p3.get());
Mike Reed607a3822021-01-24 19:49:21 -0500350 as_shader.setShader(bm.makeShader(sampling));
Mike Kleinbe569492018-09-14 09:34:21 -0400351
Mike Reed607a3822021-01-24 19:49:21 -0500352 canvas->drawImage(bm.asImage(), 10,10, sampling, &as_bitmap);
Mike Kleinbe569492018-09-14 09:34:21 -0400353 compare_pixel("A8 sprite bitmap P3 red",
354 canvas, 10,10,
355 {1,0,0,1}, p3.get());
356
357 canvas->translate(0, 80);
358
359 canvas->save();
360 canvas->translate(10,10);
361 canvas->drawRect({0,0,16,16}, as_shader);
362 canvas->restore();
363 compare_pixel("A8 sprite shader P3 red",
Mike Klein9fb5a532018-09-13 15:23:38 -0400364 canvas, 10,10,
365 {1,0,0,1}, p3.get());
366
367 canvas->translate(0,80);
368
Mike Reed607a3822021-01-24 19:49:21 -0500369 canvas->drawImageRect(bm.asImage(), {10,10,70,70}, sampling, &as_bitmap);
Mike Kleinbe569492018-09-14 09:34:21 -0400370 compare_pixel("A8 scaled bitmap P3 red",
371 canvas, 10,10,
372 {1,0,0,1}, p3.get());
373
374 canvas->translate(0,80);
375
376 canvas->save();
377 canvas->translate(10,10);
378 canvas->scale(3.75,3.75);
379 canvas->drawRect({0,0,16,16}, as_shader);
380 canvas->restore();
381 compare_pixel("A8 scaled shader P3 red",
Mike Klein9fb5a532018-09-13 15:23:38 -0400382 canvas, 10,10,
383 {1,0,0,1}, p3.get());
384 }
385
Mike Klein8f5a7a62018-09-11 12:11:46 -0400386 // TODO: draw P3 colors more ways
387}
Brian Osmane3caf2d2018-11-21 13:48:36 -0500388
389DEF_SIMPLE_GM(p3_ovals, canvas, 450, 320) {
Mike Kleinb147ace2020-01-16 11:11:06 -0600390 auto p3 = SkColorSpace::MakeRGB(SkNamedTransferFn::kSRGB, SkNamedGamut::kDisplayP3);
Brian Osmane3caf2d2018-11-21 13:48:36 -0500391
392 // Test cases that exercise each Op in GrOvalOpFactory.cpp
393
394 // Draw a circle and check the center (CircleOp)
395 {
396 SkPaint paint;
397 paint.setAntiAlias(true);
398 paint.setColor4f({ 1,0,0,1 }, p3.get());
399
400 canvas->drawCircle(40, 40, 30, paint);
401 compare_pixel("drawCircle P3 red ",
402 canvas, 40, 40,
403 { 1,0,0,1 }, p3.get());
404 }
405
406 canvas->translate(0, 80);
407
408 // Draw an oval and check the center (EllipseOp)
409 {
410 SkPaint paint;
411 paint.setAntiAlias(true);
412 paint.setColor4f({ 1,0,0,1 }, p3.get());
413
414 canvas->drawOval({ 20,10,60,70 }, paint);
415 compare_pixel("drawOval P3 red ",
416 canvas, 40, 40,
417 { 1,0,0,1 }, p3.get());
418 }
419
420 canvas->translate(0, 80);
421
422 // Draw a butt-capped dashed circle and check the top of the stroke (ButtCappedDashedCircleOp)
423 {
424 SkPaint paint;
425 paint.setAntiAlias(true);
426 paint.setColor4f({ 1,0,0,1 }, p3.get());
427 paint.setStyle(SkPaint::kStroke_Style);
428 float intervals[] = { 70, 10 };
429 paint.setPathEffect(SkDashPathEffect::Make(intervals, 2, 0));
430 paint.setStrokeWidth(10);
431
432 canvas->drawCircle(40, 40, 30, paint);
433 compare_pixel("drawDashedCircle P3 red ",
Brian Osman975197c2018-11-21 15:47:38 -0500434 canvas, 40, 10,
Brian Osmane3caf2d2018-11-21 13:48:36 -0500435 { 1,0,0,1 }, p3.get());
436 }
437
438 canvas->translate(0, 80);
439
440 // Draw an oval with rotation and check the center (DIEllipseOp)
441 {
442 SkPaint paint;
443 paint.setAntiAlias(true);
444 paint.setColor4f({ 1,0,0,1 }, p3.get());
445
446 canvas->save();
447 canvas->translate(40, 40);
448 canvas->rotate(45);
449 canvas->drawOval({ -20,-30,20,30 }, paint);
450 canvas->restore();
451 compare_pixel("drawRotatedOval P3 red ",
452 canvas, 40, 40,
453 { 1,0,0,1 }, p3.get());
454 }
455
456 canvas->translate(0, 80);
457}