34#if defined(SK_GRAPHITE)
45 static constexpr uint32_t kOuterRingColor = 0xFFFF0000,
46 kInnerRingColor = 0xFF0000FF,
47 kCheckColor1 = 0xFF000000,
48 kCheckColor2 = 0xFFFFFFFF;
59 uint32_t* scanline =
bitmap.getAddr32(0, 0);
61 scanline[
x] = kOuterRingColor;
63 scanline =
bitmap.getAddr32(0, 1);
64 scanline[0] = kOuterRingColor;
65 for (
int x = 1;
x <
width - 1; ++
x) {
66 scanline[
x] = kInnerRingColor;
68 scanline[
width - 1] = kOuterRingColor;
71 scanline =
bitmap.getAddr32(0,
y);
72 scanline[0] = kOuterRingColor;
73 scanline[1] = kInnerRingColor;
74 for (
int x = 2;
x <
width / 2; ++
x) {
75 scanline[
x] = kCheckColor1;
78 scanline[
x] = kCheckColor2;
80 scanline[
width - 2] = kInnerRingColor;
81 scanline[
width - 1] = kOuterRingColor;
85 scanline =
bitmap.getAddr32(0,
y);
86 scanline[0] = kOuterRingColor;
87 scanline[1] = kInnerRingColor;
88 for (
int x = 2;
x <
width / 2; ++
x) {
89 scanline[
x] = kCheckColor2;
92 scanline[
x] = kCheckColor1;
94 scanline[
width - 2] = kInnerRingColor;
95 scanline[
width - 1] = kOuterRingColor;
99 scanline[0] = kOuterRingColor;
100 for (
int x = 1;
x <
width - 1; ++
x) {
101 scanline[
x] = kInnerRingColor;
103 scanline[
width - 1] = kOuterRingColor;
107 scanline[
x] = kOuterRingColor;
121 : fShortName(shortName)
122 , fConstraint(constraint)
151 paint.setAntiAlias(aa);
164 paint.setAntiAlias(aa);
174 fBigSrcRect.
width()/2,
181 paint.setAntiAlias(aa);
196 paint.setAntiAlias(aa);
211 paint.setAntiAlias(aa);
222 kSmallSize, kSmallSize);
226 std::vector<SkMatrix> matrices;
234 m.preRotate(15.f, 0,
kBottom + kBlockSpacing);
235 m.preScale(0.71f, 1.22f);
236 matrices.push_back(
m);
240 matrices.back().mapPoints(corners, 4);
241 m.setTranslate(
std::max({corners[0].
fX, corners[1].
fX, corners[2].
fX, corners[3].
fX}),
242 (corners[0].fY + corners[1].fY + corners[2].fY + corners[3].fY) / 4);
243 m.preScale(0.2f, 0.2f);
244 matrices.push_back(
m);
251 for (
bool antiAlias : {
false,
true}) {
259 this->
drawCase1(canvas, kCol0X, kRow0Y, antiAlias, none);
260 this->
drawCase2(canvas, kCol0X, kRow1Y, antiAlias, none);
261 this->
drawCase3(canvas, kCol0X, kRow2Y, antiAlias, none);
262 this->
drawCase4(canvas, kCol0X, kRow3Y, antiAlias, none);
263 this->
drawCase5(canvas, kCol0X, kRow4Y, antiAlias, none);
266 this->
drawCase1(canvas, kCol1X, kRow0Y, antiAlias, low);
267 this->
drawCase2(canvas, kCol1X, kRow1Y, antiAlias, low);
268 this->
drawCase3(canvas, kCol1X, kRow2Y, antiAlias, low);
269 this->
drawCase4(canvas, kCol1X, kRow3Y, antiAlias, low);
270 this->
drawCase5(canvas, kCol1X, kRow4Y, antiAlias, low);
278 this->
drawCase1(canvas, kCol2X, kRow0Y, antiAlias, high);
279 this->
drawCase2(canvas, kCol2X, kRow1Y, antiAlias, high);
280 this->
drawCase3(canvas, kCol2X, kRow2Y, antiAlias, high);
281 this->
drawCase4(canvas, kCol2X, kRow3Y, antiAlias, high);
282 this->
drawCase5(canvas, kCol2X, kRow4Y, antiAlias, high);
286 matrix.mapPoints(innerCorners, 4);
288 innerCorners[2].
fX, innerCorners[3].
fX});
297 options->fMaxTextureSizeOverride = kMaxTextureSize;
300#if defined(SK_GRAPHITE)
303 options->fOptionsPriv->fMaxTextureSizeOverride = kMaxTextureSize;
308 inline static constexpr int kBlockSize = 70;
309 inline static constexpr int kBlockSpacing = 12;
311 inline static constexpr int kCol0X = kBlockSpacing;
312 inline static constexpr int kCol1X = 2*kBlockSpacing + kBlockSize;
313 inline static constexpr int kCol2X = 3*kBlockSpacing + 2*kBlockSize;
314 inline static constexpr int kWidth = 4*kBlockSpacing + 3*kBlockSize;
316 inline static constexpr int kRow0Y = kBlockSpacing;
317 inline static constexpr int kRow1Y = 2*kBlockSpacing + kBlockSize;
318 inline static constexpr int kRow2Y = 3*kBlockSpacing + 2*kBlockSize;
319 inline static constexpr int kRow3Y = 4*kBlockSpacing + 3*kBlockSize;
320 inline static constexpr int kRow4Y = 5*kBlockSpacing + 4*kBlockSize;
322 inline static constexpr int kSmallSize = 6;
325 inline static constexpr int kMaxTextureSize = 1024;
334 using INHERITED =
GM;
369 const int N = 10 + 2 + 8 + 2 + 10;
383 return surface->makeImageSnapshot();
391 canvas->translate(10, 10);
401 for (
auto constraint : constraints) {
406 nullptr, constraint);
408 canvas->drawImageRect(surf->makeImageSnapshot(),
SkRect::MakeWH(100, 100),
410 canvas->translate(120, 0);
413 canvas->translate(0, 120);
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
static constexpr T SkAlign4(T x)
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
@ kOuter_SkBlurStyle
nothing inside, fuzzy outside
@ kNormal_SkBlurStyle
fuzzy inside and outside
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
constexpr SkColor SK_ColorGRAY
constexpr SkColor SK_ColorBLUE
constexpr SkColor SK_ColorRED
DEF_SIMPLE_GM(bleed_downscale, canvas, 360, 240)
std::tuple< sk_sp< SkImage >, SkRect > make_ringed_image(SkCanvas *canvas, int width, int height)
DEF_GM(return new SrcRectConstraintGM("strict_constraint_no_red_allowed", SkCanvas::kStrict_SrcRectConstraint, false);)
static sk_sp< SkImage > make_image(SkCanvas *canvas, SkRect *srcR)
static SkScalar SK_SPI ConvertRadiusToSigma(SkScalar radius)
void drawRect(const SkRect &rect, const SkPaint &paint)
void translate(SkScalar dx, SkScalar dy)
@ kStrict_SrcRectConstraint
sample only inside bounds; slower
@ kFast_SrcRectConstraint
sample outside bounds; faster
void clear(SkColor color)
void drawImageRect(const SkImage *, const SkRect &src, const SkRect &dst, const SkSamplingOptions &, const SkPaint *, SrcRectConstraint)
void concat(const SkMatrix &matrix)
static sk_sp< SkMaskFilter > MakeBlur(SkBlurStyle style, SkScalar sigma, bool respectCTM=true)
static const SkMatrix & I()
void drawImage(SkCanvas *canvas, sk_sp< SkImage > image, SkRect srcRect, SkRect dstRect, const SkSamplingOptions &sampling, SkPaint *paint)
SrcRectConstraintGM(const char *shortName, SkCanvas::SrcRectConstraint constraint, bool manual)
void drawCase4(SkCanvas *canvas, int transX, int transY, bool aa, const SkSamplingOptions &sampling)
void drawCase5(SkCanvas *canvas, int transX, int transY, bool aa, const SkSamplingOptions &sampling)
void drawCase1(SkCanvas *canvas, int transX, int transY, bool aa, const SkSamplingOptions &sampling)
void onDraw(SkCanvas *canvas) override
void drawCase3(SkCanvas *canvas, int transX, int transY, bool aa, const SkSamplingOptions &sampling)
SkString getName() const override
void modifyGrContextOptions(GrContextOptions *options) override
void drawCase2(SkCanvas *canvas, int transX, int transY, bool aa, const SkSamplingOptions &sampling)
SkISize getISize() override
GM(SkColor backgroundColor=SK_ColorWHITE)
virtual void modifyGraphiteContextOptions(skgpu::graphite::ContextOptions *) const
static float max(float r, float g, float b)
unsigned useCenter Optional< SkMatrix > matrix
sk_sp< const SkImage > image
SkSamplingOptions sampling
SK_API void DrawImageRect(SkCanvas *canvas, const SkImage *image, const SkRect &src, const SkRect &dst, const SkSamplingOptions &sampling={}, const SkPaint *paint=nullptr, SkCanvas::SrcRectConstraint constraint=SkCanvas::kFast_SrcRectConstraint)
SkSamplingOptions(SkFilterMode::kLinear))
static constexpr SkCubicResampler Mitchell()
static constexpr SkISize Make(int32_t w, int32_t h)
static SkImageInfo MakeN32Premul(int width, int height)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
static SkRect Make(const SkISize &size)
void inset(float dx, float dy)
SkScalar fLeft
smaller x-axis bounds
static SkRect MakeIWH(int w, int h)
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
SkRect makeInset(float dx, float dy) const
constexpr float height() const
constexpr float width() const
static constexpr SkRect MakeWH(float w, float h)
SkScalar fTop
smaller y-axis bounds