46 paint.setDither(
true);
70 : fPowerOfTwoSize(powerOfTwoSize) {
84 if (!fPowerOfTwoSize) {
94 for (
size_t i = 0; i < std::size(
gColorTypes); i++) {
107 const char* gConfigNames[] = {
"8888",
"565" };
110 static const char* gFilterNames[] = {
"point",
"bilinear" };
114 static const char* gModeNames[] = {
"C",
"R",
"M" };
119 for (
size_t kx = 0; kx < std::size(
gModes); kx++) {
120 for (
size_t ky = 0; ky < std::size(
gModes); ky++) {
124 str.
printf(
"[%s,%s]", gModeNames[kx], gModeNames[ky]);
135 for (
size_t i = 0; i < std::size(
gColorTypes); i++) {
136 for (
size_t j = 0; j < std::size(gFilters); j++) {
138 for (
size_t kx = 0; kx < std::size(
gModes); kx++) {
139 for (
size_t ky = 0; ky < std::size(
gModes); ky++) {
143 if (!fPowerOfTwoSize) {
148 paint.setDither(
true);
159 x,
y + r.
height() * 2 / 3, font, textPaint);
167 bool fPowerOfTwoSize;
196 std::size(colors), tx, 135, 225, 0,
nullptr);
225 const char* gModeNames[] = {
226 "Clamp",
"Repeat",
"Mirror"
234 for (
size_t kx = 0; kx < std::size(
gModes); kx++) {
243 for (
size_t ky = 0; ky < std::size(
gModes); ky++) {
251 for (
size_t kx = 0; kx < std::size(
gModes); kx++) {
277 SkRect r = { -20, -20, img->
width() + 20.0f, img->height() + 20.0f };
278 canvas->translate(45, 45);
295 const SkPoint pts[] = {{ 0, 0 }, {img->width()*1.0f, img->height()*1.0f }};
297 const int count = std::size(colors);
303 const int count = std::size(colors);
305 img->width()*0.5f, colors,
pos,
count, tx));
318 for (
const auto& p : pairs) {
321 for (
const auto& proc : shader_procs) {
326 canvas->drawRect(r, bgpaint);
327 proc(&
paint, p.fX, p.fY);
328 canvas->drawRect(r,
paint);
330 canvas->translate(0, r.
height() + 20);
333 canvas->translate(r.
width() + 10, 0);
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
@ kRGB_565_SkColorType
pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
constexpr SkColor SK_ColorYELLOW
constexpr SkColor SK_ColorTRANSPARENT
constexpr SkColor SK_ColorBLUE
constexpr SkColor SK_ColorRED
constexpr SkColor SK_ColorGREEN
SK_API SkString static SkString SkStringPrintf()
static SkScalar center(float pos0, float pos1)
constexpr SkBlendMode gModes[]
Type::kYUV Type::kRGBA() int(0.7 *637)
static sk_sp< SkImage > make_bm()
void allocPixels(const SkImageInfo &info, size_t rowBytes)
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
void eraseColor(SkColor4f) const
void drawRect(const SkRect &rect, const SkPaint &paint)
void translate(SkScalar dx, SkScalar dy)
void drawPaint(const SkPaint &paint)
void scale(SkScalar sx, SkScalar sy)
void drawString(const char str[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
static sk_sp< SkShader > MakeSweep(SkScalar cx, SkScalar cy, const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, SkScalar startAngle, SkScalar endAngle, uint32_t flags, const SkMatrix *localMatrix)
static sk_sp< SkShader > MakeRadial(const SkPoint ¢er, SkScalar radius, const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, uint32_t flags=0, const SkMatrix *localMatrix=nullptr)
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)
void setColor(SkColor color)
void printf(const char format[],...) SK_PRINTF_LIKE(2
const char * c_str() const
static void DrawString(SkCanvas *canvas, const char text[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint, Align align=kLeft_Align)
SkString getName() const override
void onDraw(SkCanvas *canvas) override
SkISize getISize() override
Tiling2GM(ShaderProc proc, const char name[])
void onDraw(SkCanvas *canvas) override
SkString getName() const override
SkBitmap fTexture[std::size(gColorTypes)]
void onOnceBeforeDraw() override
SkISize getISize() override
TilingGM(bool powerOfTwoSize)
#define DEF_SIMPLE_GM(NAME, CANVAS, W, H)
SK_API sk_sp< SkImage > RasterFromBitmap(const SkBitmap &bitmap)
static constexpr SkCubicResampler Mitchell()
static constexpr SkISize Make(int32_t w, int32_t h)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
constexpr float height() const
constexpr float width() const
static sk_sp< SkShader > make_grad(SkTileMode tx, SkTileMode ty)
static void makebm(SkBitmap *bm, SkColorType ct, int w, int h)
constexpr SkColorType gColorTypes[]
sk_sp< SkShader >(* ShaderProc)(SkTileMode, SkTileMode)