34#include <initializer_list>
40 const int w = tileW * m;
41 const int h = tileH * n;
44 surf->getCanvas()->clear(
bgColor);
46 static constexpr SkScalar kStripeW = 10;
47 static constexpr SkScalar kStripeSpacing = 30;
52 paint.setShader(std::move(grad));
53 paint.setAntiAlias(
true);
55 paint.setStrokeWidth(kStripeW);
56 SkPoint stripePts[] = {{-
w - kStripeW, -kStripeW}, {kStripeW,
h + kStripeW}};
57 while (stripePts[0].fX <=
w) {
59 stripePts[0].
fX += kStripeSpacing;
60 stripePts[1].
fX += kStripeSpacing;
65 paint.setShader(std::move(grad));
67 stripePts[0] = {-
w - kStripeW,
h + kStripeW};
68 stripePts[1] = {kStripeW, -kStripeW};
69 while (stripePts[0].fX <=
w) {
71 stripePts[0].
fX += kStripeSpacing;
72 stripePts[1].
fX += kStripeSpacing;
74 auto fullImage = surf->makeImageSnapshot();
75 for (
int y = 0;
y < n; ++
y) {
76 for (
int x = 0;
x < m; ++
x) {
96 set[
y * m +
x].fImage = fullImage->makeSubset(
nullptr, subset);
97 set[
y * m +
x].fSrcRect =
100 set[
y * m +
x].fAlpha = 1.f;
128 {kM * kTileW + 10.f, -5.f},
129 {kM * kTileW - 28.f, kN * kTileH + 40.f},
130 {45.f, kN * kTileH - 25.f}};
139 dst[1] = {-.25 * kM * kTileW, 0};
140 dst[0] = {5.f / 4.f * kM * kTileW, 0};
141 dst[3] = {2.f / 3.f * kM * kTileW, 1 / 2.f * kN * kTileH};
142 dst[2] = {1.f / 3.f * kM * kTileW, 1 / 2.f * kN * kTileH - 0.1f * kTileH};
150 for (
size_t m = 0; m < std::size(matrices); ++m) {
152 static constexpr SkScalar kLineOutset = 10.f;
154 paint.setAntiAlias(
true);
157 paint.setStrokeWidth(0.f);
158 for (
int x = 1;
x < kM; ++
x) {
159 SkPoint pts[] = {{
x * kTileW, 0}, {
x * kTileW, kN * kTileH}};
165 for (
int y = 1;
y < kN; ++
y) {
166 SkPoint pts[] = {{0,
y * kTileH}, {kTileW * kM,
y * kTileH}};
173 canvas->
concat(matrices[m]);
202 inline static constexpr int kM = 4;
203 inline static constexpr int kN = 3;
204 inline static constexpr SkScalar kTileW = 30;
205 inline static constexpr SkScalar kTileH = 60;
244 static constexpr SkScalar kTranslate = std::max(
kW,
kH) * 2.f + 10.f;
250 for (
size_t m = 0; m < std::size(matrices); ++m) {
252 canvas->
concat(matrices[m]);
266 std::copy_n(fSet, kM * kN, scaledSet);
267 for (
int i = 0; i < kM * kN; ++i) {
272 scaledSet[i].
fAlpha = 0 == (i % 3) ? 0.4f : 1.f;
274 for (
size_t m = 0; m < std::size(matrices); ++m) {
276 canvas->
concat(matrices[m]);
288 inline static constexpr int kM = 2;
289 inline static constexpr int kN = 2;
290 inline static constexpr int kTileW = 40;
291 inline static constexpr int kTileH = 50;
303#if defined(SK_GRAPHITE)
314 for (
int y = 0;
y < kN; ++
y) {
315 for (
int x = 0;
x < kM; ++
x) {
317 fSet[i].
fAlpha = (kM -
x) / (
float) kM;
319#if defined(SK_GRAPHITE)
340 paint.setColor4f({0.2f, 0.8f, 0.4f, 1.f});
350 for (
int y = 0;
y < kN; ++
y) {
351 for (
int x = 0;
x < kM; ++
x) {
357 fSet[i].fSrcRect, fSet[i].fDstRect,
364 inline static constexpr int kM = 4;
365 inline static constexpr int kN = 4;
366 inline static constexpr int kTileW = 50;
367 inline static constexpr int kTileH = 50;
371DEF_GM(
return new DrawImageSetGM();)
372DEF_GM(
return new DrawImageSetRectToRectGM();)
373DEF_GM(
return new DrawImageSetAlphaOnlyGM();)
static const SkColor bgColor
static GrDirectContext * GrAsDirectContext(GrContext_Base *base)
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
#define SkAssertResult(cond)
@ kExclusion
rc = s + d - two(s*d), ra = kSrcOver
@ kMultiply
r = s*(1-da) + d*(1-sa) + s*d
@ kSrcOver
r = s + (1-sa)*d
@ 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_ColorLTGRAY
constexpr SkColor SK_ColorMAGENTA
constexpr SkColor SK_ColorCYAN
constexpr SkColor SK_ColorTRANSPARENT
constexpr SkColor SK_ColorGRAY
constexpr SkColor SK_ColorBLUE
constexpr SkColor SK_ColorRED
static constexpr SkColor SkColorSetARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
constexpr SkColor SK_ColorBLACK
constexpr SkColor SK_ColorWHITE
constexpr SkColor SK_ColorDKGRAY
sk_sp< T > sk_ref_sp(T *obj)
constexpr SkColor kBGColor
void translate(SkScalar dx, SkScalar dy)
virtual GrRecordingContext * recordingContext() const
virtual skgpu::graphite::Recorder * recorder() const
void drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, const SkPaint &paint)
@ kFast_SrcRectConstraint
sample outside bounds; faster
void experimental_DrawEdgeAAImageSet(const ImageSetEntry imageSet[], int cnt, const SkPoint dstClips[], const SkMatrix preViewMatrices[], const SkSamplingOptions &, const SkPaint *paint=nullptr, SrcRectConstraint constraint=kStrict_SrcRectConstraint)
void rotate(SkScalar degrees)
void drawImageRect(const SkImage *, const SkRect &src, const SkRect &dst, const SkSamplingOptions &, const SkPaint *, SrcRectConstraint)
void concat(const SkMatrix &matrix)
@ kLines_PointMode
draw each pair of points as a line segment
static sk_sp< SkColorFilter > LinearToSRGBGamma()
static sk_sp< SkColorSpace > MakeSRGB()
static sk_sp< SkShader > MakeLinear(const SkPoint pts[2], const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, uint32_t flags=0, const SkMatrix *localMatrix=nullptr)
virtual sk_sp< SkImage > makeColorTypeAndColorSpace(GrDirectContext *direct, SkColorType targetColorType, sk_sp< SkColorSpace > targetCS) const =0
SkMatrix & postTranslate(SkScalar dx, SkScalar dy)
SkMatrix & postRotate(SkScalar degrees, SkScalar px, SkScalar py)
SkMatrix & postScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
void mapPoints(SkPoint dst[], const SkPoint src[], int count) const
SkMatrix & setScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
SkMatrix & postSkew(SkScalar kx, SkScalar ky, SkScalar px, SkScalar py)
SkMatrix & setRotate(SkScalar degrees, SkScalar px, SkScalar py)
@ kStroke_Style
set to stroke geometry
void setBlendMode(SkBlendMode mode)
void setColorFilter(sk_sp< SkColorFilter > colorFilter)
void onDraw(SkCanvas *canvas) override
SkISize getISize() override
SkString getName() const override
DrawResult onGpuSetup(SkCanvas *canvas, SkString *, GraphiteTestContext *) override
SkISize getISize() override
void onOnceBeforeDraw() override
void onDraw(SkCanvas *canvas) override
SkString getName() const override
SkISize getISize() override
void onOnceBeforeDraw() override
void onDraw(SkCanvas *canvas) override
SkString getName() const override
static void make_image_tiles(int tileW, int tileH, int m, int n, const SkColor colors[4], SkCanvas::ImageSetEntry set[], const SkColor bgColor=SK_ColorLTGRAY)
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
sk_sp< const SkImage > fImage
int32_t fBottom
larger y-axis bounds
int32_t fTop
smaller y-axis bounds
static constexpr SkIRect MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)
int32_t fLeft
smaller x-axis bounds
int32_t fRight
larger x-axis bounds
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
bool setLength(float length)
SkScalar fBottom
larger y-axis bounds
void toQuad(SkPoint quad[4]) const
constexpr SkRect makeOffset(float dx, float dy) const
SkScalar fLeft
smaller x-axis bounds
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
SkRect makeInset(float dx, float dy) const
SkScalar fRight
larger x-axis bounds
constexpr float width() const
static constexpr SkRect MakeWH(float w, float h)
SkScalar fTop
smaller y-axis bounds