25 if (canvas->recordingContext() || (canvas->getSurface() && canvas->getSurface()->recorder())) {
26 *errorMsg =
"Test is only relevant to CPU backend";
37 uint32_t
colors[] {0xFFFF0000, 0xFF0000FF};
50 uint8_t alphas[] {0xFF, 0xAA};
64 auto surf = canvas->makeSurface(canvas->imageInfo().makeWH(80, 80));
66 *errorMsg =
"Test only works with SkSurface backed canvases";
69 auto* c = surf->getCanvas();
74 static const float kOffAxisScale = 4;
79 paint.setAlpha(alpha);
84 c->scale(
mirror ? -1 : 1, kOffAxisScale);
85 c->translate(
mirror ? -2.5 : 0.5, 0);
87 c->scale(kOffAxisScale,
mirror ? -1 : 1);
88 c->translate(0,
mirror ? -2.5 : 0.5);
99 for (
bool shader : {
false,
true})
100 for (uint8_t alpha : {0xFF , 0x70}) {
103 for (
auto mirror : {
false,
true}) {
109 c->translate(0, kOffAxisScale*2);
112 c->translate(kOffAxisScale*2, 0);
115 canvas->drawImage(surf->makeImageSnapshot(), 0, 0);
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
static unsigned mirror(SkFixed fx, int max)
@ kAlpha_8_SkColorType
pixel with alpha in 8-bit byte
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
constexpr SkColor SK_ColorWHITE
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
SkISize dimensions() const
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
std::array< MockImage, 3 > images
SK_API sk_sp< SkImage > RasterFromPixmapCopy(const SkPixmap &pixmap)
sk_sp< const SkImage > image
PODArray< SkColor > colors
DEF_SIMPLE_GM_CAN_FAIL(nearest_half_pixel_image, canvas, errorMsg, 264, 235)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
static SkRect Make(const SkISize &size)