35#include <initializer_list>
52 return shaderScale == 1 ? grad
70 0, 1, 2, 5, 8, 7, 6, 3, 0
90 texs[1].set(shaderSize / 2, 0);
91 texs[2].set(shaderSize, 0);
92 texs[3].set(0, shaderSize / 2);
93 texs[4].set(shaderSize / 2, shaderSize / 2);
94 texs[5].set(shaderSize, shaderSize / 2);
95 texs[6].set(0, shaderSize);
96 texs[7].set(shaderSize / 2, shaderSize);
97 texs[8].set(shaderSize, shaderSize);
101 colors[i] = rand.
nextU() | 0xFF000000;
128 if (fShaderScale != 1) {
129 name.append(
"_scaled_shader");
172 for (
auto mode : modes) {
174 for (
float alpha : {1.0f, 0.5f}) {
176 for (
const auto& shader : {fShader1, fShader2}) {
177 static constexpr struct {
180 } kAttrs[] = {{
true,
false}, {
false,
true}, {
true,
true}};
181 for (
auto attrs : kAttrs) {
182 paint.setShader(shader);
183 paint.setColorFilter(cf);
184 paint.setAlphaf(alpha);
186 const SkColor* colors = attrs.fHasColors ? fColors :
nullptr;
187 const SkPoint* texs = attrs.fHasTexs ? fTexs :
nullptr;
218 SkPoint* pts = builder.positions();
219 SkPoint* texs = builder.texCoords();
220 SkColor* colors = builder.colors();
224 matrices.
append()->reset();
225 matrices.
append()->setTranslate(0, 40);
229 .postTranslate(0, 80);
233 uint16_t* indices = builder.indices();
234 for (
size_t i = 0; i < kNumTris; ++i) {
236 indices[3 * i + 1] =
kMeshFan[i + 1];
237 indices[3 * i + 2] =
kMeshFan[i + 2];
243 for (
bool useShader : {
false,
true}) {
244 for (
bool useTex : {
false,
true}) {
245 for (
const auto& m : matrices) {
249 paint.setShader(useShader ? shader :
nullptr);
252 const SkPoint* t = useTex ? texs :
nullptr;
254 pts, t, colors, kNumTris * 3, indices);
316 SkPoint verts[] = {{0, 0}, {200, 0}, {200, 200}, {0, 200}};
318 uint16_t indices[] = {0, 1, 2, 2, 3, 0};
335 SkPoint verts[] = {{5, 5}, {45, 5}, {45, 45}, {5, 45}};
336 SkPoint texs[] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}};
337 uint16_t indices[] = {0, 1, 2, 2, 3, 0};
346 paint.setShader(shader);
@ kExclusion
rc = s + d - two(s*d), ra = kSrcOver
@ kSaturation
saturation of source with hue and luminosity of destination
@ kColorBurn
darken destination to reflect source
@ kLighten
rc = s + d - min(s*da, d*sa), ra = kSrcOver
@ kHue
hue of source with saturation and luminosity of destination
@ kMultiply
r = s*(1-da) + d*(1-sa) + s*d
@ kColorDodge
brighten destination to reflect source
@ kSrcOver
r = s + (1-sa)*d
@ kXor
r = s*(1-da) + d*(1-sa)
@ kLuminosity
luminosity of source with hue and saturation of destination
@ kSoftLight
lighten or darken, depending on source
@ kDifference
rc = s + d - 2*(min(s*da, d*sa)), ra = kSrcOver
@ kOverlay
multiply or screen, depending on destination
@ kSrcATop
r = s*da + d*(1-sa)
@ kDstATop
r = d*sa + s*(1-da)
@ kDstOver
r = d + (1-da)*s
@ kColor
hue and saturation of source with luminosity of destination
@ kHardLight
multiply or screen, depending on source
@ kDarken
rc = s + d - max(s*da, d*sa), ra = kSrcOver
constexpr SkColor SK_ColorYELLOW
constexpr SkColor SK_ColorMAGENTA
constexpr SkColor SK_ColorCYAN
constexpr SkColor SK_ColorBLUE
constexpr SkColor SK_ColorRED
constexpr SkColor SK_ColorBLACK
constexpr SkColor SK_ColorGREEN
constexpr SkColor SK_ColorWHITE
Type::kYUV Type::kRGBA() int(0.7 *637)
void drawRect(const SkRect &rect, const SkPaint &paint)
void translate(SkScalar dx, SkScalar dy)
void concat(const SkMatrix &matrix)
void drawVertices(const SkVertices *vertices, SkBlendMode mode, const SkPaint &paint)
static sk_sp< SkColorFilter > Blend(const SkColor4f &c, sk_sp< SkColorSpace >, SkBlendMode mode)
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)
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
static SkMatrix Scale(SkScalar sx, SkScalar sy)
static SkMatrix Translate(SkScalar dx, SkScalar dy)
SkMatrix & setPerspY(SkScalar v)
@ kHasTexCoords_BuilderFlag
static sk_sp< SkVertices > MakeCopy(VertexMode mode, int vertexCount, const SkPoint positions[], const SkPoint texs[], const SkColor colors[], int indexCount, const uint16_t indices[])
@ kTriangleFan_VertexMode
VerticesGM(SkScalar shaderScale)
SkISize getISize() override
void onOnceBeforeDraw() override
void onDraw(SkCanvas *canvas) override
SkString getName() const override
#define DEF_SIMPLE_GM_BG(NAME, CANVAS, W, H, BGCOLOR)
#define DEF_SIMPLE_GM(NAME, CANVAS, W, H)
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
static constexpr SkISize Make(int32_t w, int32_t h)
static SkImageInfo MakeN32Premul(int width, int height)
void toQuad(SkPoint quad[4]) const
constexpr float height() const
constexpr float width() const
static constexpr SkRect MakeWH(float w, float h)
static sk_sp< SkShader > make_shader1(SkScalar shaderScale)
static sk_sp< SkShader > make_shader2()
static const int kMeshIndexCnt
static void fill_mesh(SkPoint pts[kMeshVertexCnt], SkPoint texs[kMeshVertexCnt], SkColor colors[kMeshVertexCnt], SkScalar shaderScale)
static const int kMeshVertexCnt
static constexpr SkScalar kShaderSize
static constexpr SkScalar kMeshSize
static constexpr uint16_t kMeshFan[]
static sk_sp< SkColorFilter > make_color_filter()
static void draw_batching(SkCanvas *canvas)