2018-09-11 16:11:46 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2018 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "gm.h"
|
2019-01-08 14:38:02 +00:00
|
|
|
|
2018-09-11 16:11:46 +00:00
|
|
|
#include "SkColorSpace.h"
|
2018-09-12 17:03:06 +00:00
|
|
|
#include "SkColorSpaceXformSteps.h"
|
2018-11-21 18:48:36 +00:00
|
|
|
#include "SkDashPathEffect.h"
|
2019-01-08 14:38:02 +00:00
|
|
|
#include "SkFont.h"
|
2018-09-12 22:04:49 +00:00
|
|
|
#include "SkGradientShader.h"
|
2018-09-11 16:11:46 +00:00
|
|
|
#include "SkString.h"
|
|
|
|
|
2018-09-12 17:03:06 +00:00
|
|
|
static bool nearly_equal(SkColor4f x, SkColor4f y) {
|
|
|
|
const float K = 0.01f;
|
|
|
|
return fabsf(x.fR - y.fR) < K
|
|
|
|
&& fabsf(x.fG - y.fG) < K
|
|
|
|
&& fabsf(x.fB - y.fB) < K
|
|
|
|
&& fabsf(x.fA - y.fA) < K;
|
|
|
|
}
|
|
|
|
|
|
|
|
static SkString fmt(SkColor4f c) {
|
|
|
|
return SkStringPrintf("%.2g %.2g %.2g %.2g", c.fR, c.fG, c.fB, c.fA);
|
|
|
|
}
|
|
|
|
|
|
|
|
static SkColor4f transform(SkColor4f c, SkColorSpace* src, SkColorSpace* dst) {
|
|
|
|
SkColorSpaceXformSteps(src, kUnpremul_SkAlphaType,
|
|
|
|
dst, kUnpremul_SkAlphaType).apply(c.vec());
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
2018-09-12 22:04:49 +00:00
|
|
|
static void compare_pixel(const char* label,
|
|
|
|
SkCanvas* canvas, int x, int y,
|
|
|
|
SkColor4f color, SkColorSpace* cs) {
|
2019-01-08 14:38:02 +00:00
|
|
|
SkPaint paint;
|
|
|
|
SkFont font;
|
2018-09-12 22:04:49 +00:00
|
|
|
auto canvas_cs = canvas->imageInfo().refColorSpace();
|
2018-09-11 16:11:46 +00:00
|
|
|
|
2018-09-12 22:04:49 +00:00
|
|
|
// I'm not really sure if this makes things easier or harder to follow,
|
|
|
|
// but we sniff the canvas to grab its current y-translate, so that (x,y)
|
|
|
|
// can be written in sort of chunk-relative terms.
|
|
|
|
const SkMatrix& m = canvas->getTotalMatrix();
|
|
|
|
SkASSERT(m.isTranslate());
|
|
|
|
SkScalar dy = m.getTranslateY();
|
|
|
|
SkASSERT(dy == (int)dy);
|
|
|
|
y += (int)dy;
|
2018-09-11 16:11:46 +00:00
|
|
|
|
2018-09-12 17:03:06 +00:00
|
|
|
SkBitmap bm;
|
2018-09-12 22:04:49 +00:00
|
|
|
bm.allocPixels(SkImageInfo::Make(1,1, kRGBA_F32_SkColorType, kUnpremul_SkAlphaType, canvas_cs));
|
|
|
|
if (!canvas->readPixels(bm, x,y)) {
|
2018-10-31 14:49:38 +00:00
|
|
|
MarkGMGood(canvas, 140,40);
|
2019-01-08 14:38:02 +00:00
|
|
|
canvas->drawString("can't readPixels() on this canvas :(", 100,20, font, paint);
|
2018-09-12 17:03:06 +00:00
|
|
|
return;
|
|
|
|
}
|
2018-09-11 16:11:46 +00:00
|
|
|
|
2018-09-12 17:03:06 +00:00
|
|
|
SkColor4f pixel;
|
2018-09-12 22:04:49 +00:00
|
|
|
memcpy(&pixel, bm.getAddr(0,0), sizeof(pixel));
|
2018-09-11 16:11:46 +00:00
|
|
|
|
2018-09-12 22:04:49 +00:00
|
|
|
SkColor4f expected = transform(color,cs, canvas_cs.get());
|
2018-09-12 17:03:06 +00:00
|
|
|
if (canvas->imageInfo().colorType() < kRGBA_F16_SkColorType) {
|
|
|
|
// We can't expect normalized formats to hold values outside [0,1].
|
2018-10-31 19:59:49 +00:00
|
|
|
for (int i = 0; i < 4; ++i) {
|
|
|
|
expected[i] = SkTPin(expected[i], 0.0f, 1.0f);
|
|
|
|
}
|
2018-09-12 17:03:06 +00:00
|
|
|
}
|
|
|
|
if (canvas->imageInfo().colorType() == kGray_8_SkColorType) {
|
|
|
|
// Drawing into Gray8 is known to be maybe-totally broken.
|
|
|
|
// TODO: update expectation here to be {lum,lum,lum,1} if we fix Gray8.
|
|
|
|
expected = SkColor4f{NAN, NAN, NAN, 1};
|
|
|
|
}
|
2018-09-11 16:11:46 +00:00
|
|
|
|
2018-09-12 17:03:06 +00:00
|
|
|
if (nearly_equal(pixel, expected)) {
|
2018-10-31 14:49:38 +00:00
|
|
|
MarkGMGood(canvas, 140,40);
|
2018-09-11 16:11:46 +00:00
|
|
|
} else {
|
2018-10-31 14:49:38 +00:00
|
|
|
MarkGMBad(canvas, 140,40);
|
2018-09-12 17:03:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct {
|
|
|
|
const char* label;
|
|
|
|
SkColor4f color;
|
|
|
|
} lines[] = {
|
2018-09-12 22:04:49 +00:00
|
|
|
{"Pixel:" , pixel },
|
|
|
|
{"Expected:", expected},
|
2018-09-12 17:03:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
SkAutoCanvasRestore saveRestore(canvas, true);
|
2019-01-08 14:38:02 +00:00
|
|
|
canvas->drawString(label, 80,20, font, paint);
|
2018-09-12 17:03:06 +00:00
|
|
|
for (auto l : lines) {
|
2018-09-12 22:04:49 +00:00
|
|
|
canvas->translate(0,20);
|
2019-01-08 14:38:02 +00:00
|
|
|
canvas->drawString(l.label, 80,20, font, paint);
|
|
|
|
canvas->drawString(fmt(l.color).c_str(), 140,20, font, paint);
|
2018-09-12 22:04:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-18 20:35:49 +00:00
|
|
|
DEF_SIMPLE_GM(p3, canvas, 450, 1300) {
|
2019-01-04 22:03:00 +00:00
|
|
|
auto p3 = SkColorSpace::MakeRGB(SkNamedTransferFn::kSRGB, SkNamedGamut::kDCIP3);
|
2018-10-12 17:53:03 +00:00
|
|
|
auto srgb = SkColorSpace::MakeSRGB();
|
|
|
|
|
|
|
|
auto p3_to_srgb = [&](SkColor4f c) {
|
|
|
|
SkPaint p;
|
|
|
|
p.setColor4f(c, p3.get());
|
|
|
|
return p.getColor4f();
|
|
|
|
};
|
2018-09-12 22:04:49 +00:00
|
|
|
|
|
|
|
// Draw a P3 red rectangle and check the corner.
|
|
|
|
{
|
|
|
|
SkPaint paint;
|
|
|
|
paint.setColor4f({1,0,0,1}, p3.get());
|
|
|
|
|
2018-09-17 16:39:09 +00:00
|
|
|
canvas->drawRect({10,10,70,70}, paint);
|
2018-09-12 22:04:49 +00:00
|
|
|
compare_pixel("drawRect P3 red ",
|
|
|
|
canvas, 10,10,
|
|
|
|
{1,0,0,1}, p3.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
canvas->translate(0,80);
|
|
|
|
|
2018-09-17 16:39:09 +00:00
|
|
|
// Draw a P3 red bitmap, using a draw.
|
|
|
|
{
|
|
|
|
SkBitmap bm;
|
|
|
|
bm.allocPixels(SkImageInfo::Make(60,60, kRGBA_F16_SkColorType, kPremul_SkAlphaType, p3));
|
|
|
|
|
|
|
|
SkPaint paint;
|
|
|
|
paint.setColor4f({1,0,0,1}, p3.get());
|
|
|
|
SkCanvas{bm}.drawPaint(paint);
|
|
|
|
|
|
|
|
canvas->drawBitmap(bm, 10,10);
|
|
|
|
compare_pixel("drawBitmap P3 red, from drawPaint",
|
|
|
|
canvas, 10,10,
|
|
|
|
{1,0,0,1}, p3.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
canvas->translate(0,80);
|
|
|
|
|
2019-01-08 13:34:05 +00:00
|
|
|
// Draw a P3 red bitmap, using SkBitmap::eraseColor().
|
|
|
|
{
|
|
|
|
SkBitmap bm;
|
|
|
|
bm.allocPixels(SkImageInfo::Make(60,60, kRGBA_F16_SkColorType, kPremul_SkAlphaType, p3));
|
|
|
|
|
|
|
|
bm.eraseColor(0xffff0000/*in P3*/);
|
|
|
|
|
|
|
|
canvas->drawBitmap(bm, 10,10);
|
|
|
|
compare_pixel("drawBitmap P3 red, from SkBitmap::eraseColor()",
|
|
|
|
canvas, 10,10,
|
|
|
|
{1,0,0,1}, p3.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
canvas->translate(0,80);
|
|
|
|
|
2018-09-17 16:39:09 +00:00
|
|
|
// Draw a P3 red bitmap, using SkPixmap::erase().
|
|
|
|
{
|
|
|
|
SkBitmap bm;
|
|
|
|
bm.allocPixels(SkImageInfo::Make(60,60, kRGBA_F16_SkColorType, kPremul_SkAlphaType, p3));
|
|
|
|
|
|
|
|
// At the moment only SkPixmap has an erase() that takes an SkColor4f.
|
|
|
|
SkPixmap pm;
|
|
|
|
SkAssertResult(bm.peekPixels(&pm));
|
2019-01-08 13:34:05 +00:00
|
|
|
SkAssertResult(pm.erase({1,0,0,1} /*in p3*/));
|
2018-09-17 16:39:09 +00:00
|
|
|
|
|
|
|
canvas->drawBitmap(bm, 10,10);
|
|
|
|
compare_pixel("drawBitmap P3 red, from SkPixmap::erase",
|
|
|
|
canvas, 10,10,
|
|
|
|
{1,0,0,1}, p3.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
canvas->translate(0,80);
|
|
|
|
|
2018-10-18 20:35:49 +00:00
|
|
|
// Draw a P3 red bitmap wrapped in a shader, using SkPixmap::erase().
|
|
|
|
{
|
|
|
|
SkBitmap bm;
|
|
|
|
bm.allocPixels(SkImageInfo::Make(60,60, kRGBA_F16_SkColorType, kPremul_SkAlphaType, p3));
|
|
|
|
|
|
|
|
// At the moment only SkPixmap has an erase() that takes an SkColor4f.
|
|
|
|
SkPixmap pm;
|
|
|
|
SkAssertResult(bm.peekPixels(&pm));
|
2019-01-08 13:34:05 +00:00
|
|
|
SkAssertResult(pm.erase({1,0,0,1} /*in p3*/));
|
2018-10-18 20:35:49 +00:00
|
|
|
|
|
|
|
SkPaint paint;
|
|
|
|
paint.setShader(SkShader::MakeBitmapShader(bm, SkShader::kRepeat_TileMode,
|
|
|
|
SkShader::kRepeat_TileMode));
|
|
|
|
|
|
|
|
canvas->drawRect({10,10,70,70}, paint);
|
|
|
|
compare_pixel("drawBitmapAsShader P3 red, from SkPixmap::erase",
|
|
|
|
canvas, 10,10,
|
|
|
|
{1,0,0,1}, p3.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
canvas->translate(0,80);
|
|
|
|
|
2018-10-12 17:53:03 +00:00
|
|
|
// Draw a gradient from P3 red to P3 green interpolating in unpremul P3, checking the corners.
|
2018-09-12 22:04:49 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
SkPoint points[] = {{10.5,10.5}, {69.5,69.5}};
|
|
|
|
SkColor4f colors[] = {{1,0,0,1}, {0,1,0,1}};
|
|
|
|
|
|
|
|
SkPaint paint;
|
|
|
|
paint.setShader(SkGradientShader::MakeLinear(points, colors, p3,
|
|
|
|
nullptr, SK_ARRAY_COUNT(colors),
|
|
|
|
SkShader::kClamp_TileMode));
|
|
|
|
canvas->drawRect({10,10,70,70}, paint);
|
|
|
|
canvas->save();
|
2018-10-12 17:53:03 +00:00
|
|
|
compare_pixel("UPM P3 gradient, P3 red",
|
2018-09-12 22:04:49 +00:00
|
|
|
canvas, 10,10,
|
|
|
|
{1,0,0,1}, p3.get());
|
|
|
|
|
|
|
|
canvas->translate(180, 0);
|
2018-09-20 18:10:33 +00:00
|
|
|
|
2018-10-12 17:53:03 +00:00
|
|
|
compare_pixel("UPM P3 gradient, P3 green",
|
2018-09-20 18:10:33 +00:00
|
|
|
canvas, 69,69,
|
|
|
|
{0,1,0,1}, p3.get());
|
|
|
|
canvas->restore();
|
|
|
|
}
|
|
|
|
|
|
|
|
canvas->translate(0,80);
|
|
|
|
|
2018-10-12 17:53:03 +00:00
|
|
|
// Draw a gradient from P3 red to P3 green interpolating in premul P3, checking the corners.
|
2018-09-20 18:10:33 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
SkPoint points[] = {{10.5,10.5}, {69.5,69.5}};
|
|
|
|
SkColor4f colors[] = {{1,0,0,1}, {0,1,0,1}};
|
|
|
|
|
|
|
|
SkPaint paint;
|
|
|
|
paint.setShader(
|
|
|
|
SkGradientShader::MakeLinear(points, colors, p3,
|
|
|
|
nullptr, SK_ARRAY_COUNT(colors),
|
|
|
|
SkShader::kClamp_TileMode,
|
|
|
|
SkGradientShader::kInterpolateColorsInPremul_Flag,
|
|
|
|
nullptr/*local matrix*/));
|
|
|
|
canvas->drawRect({10,10,70,70}, paint);
|
|
|
|
canvas->save();
|
2018-10-12 17:53:03 +00:00
|
|
|
compare_pixel("PM P3 gradient, P3 red",
|
|
|
|
canvas, 10,10,
|
|
|
|
{1,0,0,1}, p3.get());
|
|
|
|
|
|
|
|
canvas->translate(180, 0);
|
|
|
|
|
|
|
|
compare_pixel("PM P3 gradient, P3 green",
|
|
|
|
canvas, 69,69,
|
|
|
|
{0,1,0,1}, p3.get());
|
|
|
|
canvas->restore();
|
|
|
|
}
|
|
|
|
|
|
|
|
canvas->translate(0,80);
|
|
|
|
|
|
|
|
// Draw a gradient from P3 red to P3 green interpolating in unpremul sRGB, checking the corners.
|
|
|
|
{
|
|
|
|
|
|
|
|
SkPoint points[] = {{10.5,10.5}, {69.5,69.5}};
|
|
|
|
SkColor4f colors[] = {p3_to_srgb({1,0,0,1}), p3_to_srgb({0,1,0,1})};
|
|
|
|
|
|
|
|
SkPaint paint;
|
|
|
|
paint.setShader(SkGradientShader::MakeLinear(points, colors, srgb,
|
|
|
|
nullptr, SK_ARRAY_COUNT(colors),
|
|
|
|
SkShader::kClamp_TileMode));
|
|
|
|
canvas->drawRect({10,10,70,70}, paint);
|
|
|
|
canvas->save();
|
|
|
|
compare_pixel("UPM sRGB gradient, P3 red",
|
|
|
|
canvas, 10,10,
|
|
|
|
{1,0,0,1}, p3.get());
|
|
|
|
|
|
|
|
canvas->translate(180, 0);
|
|
|
|
|
|
|
|
compare_pixel("UPM sRGB gradient, P3 green",
|
|
|
|
canvas, 69,69,
|
|
|
|
{0,1,0,1}, p3.get());
|
|
|
|
canvas->restore();
|
|
|
|
}
|
|
|
|
|
|
|
|
canvas->translate(0,80);
|
|
|
|
|
|
|
|
// Draw a gradient from P3 red to P3 green interpolating in premul sRGB, checking the corners.
|
|
|
|
{
|
|
|
|
|
|
|
|
SkPoint points[] = {{10.5,10.5}, {69.5,69.5}};
|
|
|
|
SkColor4f colors[] = {p3_to_srgb({1,0,0,1}), p3_to_srgb({0,1,0,1})};
|
|
|
|
|
|
|
|
SkPaint paint;
|
|
|
|
paint.setShader(
|
|
|
|
SkGradientShader::MakeLinear(points, colors, srgb,
|
|
|
|
nullptr, SK_ARRAY_COUNT(colors),
|
|
|
|
SkShader::kClamp_TileMode,
|
|
|
|
SkGradientShader::kInterpolateColorsInPremul_Flag,
|
|
|
|
nullptr/*local matrix*/));
|
|
|
|
canvas->drawRect({10,10,70,70}, paint);
|
|
|
|
canvas->save();
|
|
|
|
compare_pixel("PM P3 gradient, P3 red",
|
2018-09-20 18:10:33 +00:00
|
|
|
canvas, 10,10,
|
|
|
|
{1,0,0,1}, p3.get());
|
|
|
|
|
|
|
|
canvas->translate(180, 0);
|
2018-09-12 22:04:49 +00:00
|
|
|
|
2018-10-12 17:53:03 +00:00
|
|
|
compare_pixel("PM P3 gradient, P3 green",
|
2018-09-12 22:04:49 +00:00
|
|
|
canvas, 69,69,
|
|
|
|
{0,1,0,1}, p3.get());
|
|
|
|
canvas->restore();
|
2018-09-11 16:11:46 +00:00
|
|
|
}
|
|
|
|
|
2018-09-13 19:23:38 +00:00
|
|
|
canvas->translate(0,80);
|
|
|
|
|
2019-01-30 16:43:47 +00:00
|
|
|
// Leon's blue -> green -> red gradient, interpolating in premul.
|
|
|
|
{
|
|
|
|
SkPoint points[] = {{10.5,10.5}, {10.5,69.5}};
|
|
|
|
SkColor4f colors[] = { {0,0,1,1}, {0,1,0,1}, {1,0,0,1} };
|
|
|
|
|
|
|
|
SkPaint paint;
|
|
|
|
paint.setShader(
|
|
|
|
SkGradientShader::MakeLinear(points, colors, p3,
|
|
|
|
nullptr, SK_ARRAY_COUNT(colors),
|
|
|
|
SkShader::kClamp_TileMode,
|
|
|
|
SkGradientShader::kInterpolateColorsInPremul_Flag,
|
|
|
|
nullptr/*local matrix*/));
|
|
|
|
canvas->drawRect({10,10,70,70}, paint);
|
|
|
|
canvas->save();
|
|
|
|
compare_pixel("Leon's gradient, P3 blue",
|
|
|
|
canvas, 10,10,
|
|
|
|
{0,0,1,1}, p3.get());
|
|
|
|
|
|
|
|
canvas->translate(180, 0);
|
|
|
|
|
|
|
|
compare_pixel("Leon's gradient, P3 red",
|
|
|
|
canvas, 10,69,
|
|
|
|
{1,0,0,1}, p3.get());
|
|
|
|
canvas->restore();
|
|
|
|
}
|
|
|
|
|
|
|
|
canvas->translate(0,80);
|
|
|
|
|
2018-09-14 13:34:21 +00:00
|
|
|
// Draw an A8 image with a P3 red, scaled and not, as a shader or bitmap.
|
2018-09-13 19:23:38 +00:00
|
|
|
{
|
|
|
|
uint8_t mask[256];
|
|
|
|
for (int i = 0; i < 256; i++) {
|
|
|
|
mask[i] = 255-i;
|
|
|
|
}
|
|
|
|
SkBitmap bm;
|
|
|
|
bm.installPixels(SkImageInfo::MakeA8(16,16), mask, 16);
|
|
|
|
|
2018-09-14 13:34:21 +00:00
|
|
|
SkPaint as_bitmap;
|
|
|
|
as_bitmap.setColor4f({1,0,0,1}, p3.get());
|
|
|
|
as_bitmap.setFilterQuality(kLow_SkFilterQuality);
|
|
|
|
|
|
|
|
SkPaint as_shader;
|
|
|
|
as_shader.setColor4f({1,0,0,1}, p3.get());
|
|
|
|
as_shader.setFilterQuality(kLow_SkFilterQuality);
|
|
|
|
as_shader.setShader(SkShader::MakeBitmapShader(bm, SkShader::kClamp_TileMode
|
|
|
|
, SkShader::kClamp_TileMode));
|
|
|
|
|
|
|
|
canvas->drawBitmap(bm, 10,10, &as_bitmap);
|
|
|
|
compare_pixel("A8 sprite bitmap P3 red",
|
|
|
|
canvas, 10,10,
|
|
|
|
{1,0,0,1}, p3.get());
|
|
|
|
|
|
|
|
canvas->translate(0, 80);
|
|
|
|
|
|
|
|
canvas->save();
|
|
|
|
canvas->translate(10,10);
|
|
|
|
canvas->drawRect({0,0,16,16}, as_shader);
|
|
|
|
canvas->restore();
|
|
|
|
compare_pixel("A8 sprite shader P3 red",
|
|
|
|
canvas, 10,10,
|
|
|
|
{1,0,0,1}, p3.get());
|
2018-09-13 19:23:38 +00:00
|
|
|
|
2018-09-14 13:34:21 +00:00
|
|
|
canvas->translate(0,80);
|
|
|
|
|
|
|
|
canvas->drawBitmapRect(bm, {10,10,70,70}, &as_bitmap);
|
|
|
|
compare_pixel("A8 scaled bitmap P3 red",
|
2018-09-13 19:23:38 +00:00
|
|
|
canvas, 10,10,
|
|
|
|
{1,0,0,1}, p3.get());
|
|
|
|
|
|
|
|
canvas->translate(0,80);
|
|
|
|
|
2018-09-14 13:34:21 +00:00
|
|
|
canvas->save();
|
|
|
|
canvas->translate(10,10);
|
|
|
|
canvas->scale(3.75,3.75);
|
|
|
|
canvas->drawRect({0,0,16,16}, as_shader);
|
|
|
|
canvas->restore();
|
|
|
|
compare_pixel("A8 scaled shader P3 red",
|
2018-09-13 19:23:38 +00:00
|
|
|
canvas, 10,10,
|
|
|
|
{1,0,0,1}, p3.get());
|
|
|
|
}
|
|
|
|
|
2018-09-11 16:11:46 +00:00
|
|
|
// TODO: draw P3 colors more ways
|
|
|
|
}
|
2018-11-21 18:48:36 +00:00
|
|
|
|
|
|
|
DEF_SIMPLE_GM(p3_ovals, canvas, 450, 320) {
|
2019-01-04 22:03:00 +00:00
|
|
|
auto p3 = SkColorSpace::MakeRGB(SkNamedTransferFn::kSRGB, SkNamedGamut::kDCIP3);
|
2018-11-21 18:48:36 +00:00
|
|
|
|
|
|
|
// Test cases that exercise each Op in GrOvalOpFactory.cpp
|
|
|
|
|
|
|
|
// Draw a circle and check the center (CircleOp)
|
|
|
|
{
|
|
|
|
SkPaint paint;
|
|
|
|
paint.setAntiAlias(true);
|
|
|
|
paint.setColor4f({ 1,0,0,1 }, p3.get());
|
|
|
|
|
|
|
|
canvas->drawCircle(40, 40, 30, paint);
|
|
|
|
compare_pixel("drawCircle P3 red ",
|
|
|
|
canvas, 40, 40,
|
|
|
|
{ 1,0,0,1 }, p3.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
canvas->translate(0, 80);
|
|
|
|
|
|
|
|
// Draw an oval and check the center (EllipseOp)
|
|
|
|
{
|
|
|
|
SkPaint paint;
|
|
|
|
paint.setAntiAlias(true);
|
|
|
|
paint.setColor4f({ 1,0,0,1 }, p3.get());
|
|
|
|
|
|
|
|
canvas->drawOval({ 20,10,60,70 }, paint);
|
|
|
|
compare_pixel("drawOval P3 red ",
|
|
|
|
canvas, 40, 40,
|
|
|
|
{ 1,0,0,1 }, p3.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
canvas->translate(0, 80);
|
|
|
|
|
|
|
|
// Draw a butt-capped dashed circle and check the top of the stroke (ButtCappedDashedCircleOp)
|
|
|
|
{
|
|
|
|
SkPaint paint;
|
|
|
|
paint.setAntiAlias(true);
|
|
|
|
paint.setColor4f({ 1,0,0,1 }, p3.get());
|
|
|
|
paint.setStyle(SkPaint::kStroke_Style);
|
|
|
|
float intervals[] = { 70, 10 };
|
|
|
|
paint.setPathEffect(SkDashPathEffect::Make(intervals, 2, 0));
|
|
|
|
paint.setStrokeWidth(10);
|
|
|
|
|
|
|
|
canvas->drawCircle(40, 40, 30, paint);
|
|
|
|
compare_pixel("drawDashedCircle P3 red ",
|
2018-11-21 20:47:38 +00:00
|
|
|
canvas, 40, 10,
|
2018-11-21 18:48:36 +00:00
|
|
|
{ 1,0,0,1 }, p3.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
canvas->translate(0, 80);
|
|
|
|
|
|
|
|
// Draw an oval with rotation and check the center (DIEllipseOp)
|
|
|
|
{
|
|
|
|
SkPaint paint;
|
|
|
|
paint.setAntiAlias(true);
|
|
|
|
paint.setColor4f({ 1,0,0,1 }, p3.get());
|
|
|
|
|
|
|
|
canvas->save();
|
|
|
|
canvas->translate(40, 40);
|
|
|
|
canvas->rotate(45);
|
|
|
|
canvas->drawOval({ -20,-30,20,30 }, paint);
|
|
|
|
canvas->restore();
|
|
|
|
compare_pixel("drawRotatedOval P3 red ",
|
|
|
|
canvas, 40, 40,
|
|
|
|
{ 1,0,0,1 }, p3.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
canvas->translate(0, 80);
|
|
|
|
}
|