29 half4 main(half4 color) {
35 half4 main(half4 color) {
36 return dot(color.rgb, half3(0.3, 0.6, 0.1)).000r;
45 half4 main(half4 color) {
46 half luma = dot(color.rgb, half3(0.3, 0.6, 0.1));
48 half scale = luma < 0.33333 ? 0.5
49 : luma < 0.66666 ? (0.166666 + 2.0 * (luma - 0.33333)) / luma
50 : /* else */ (0.833333 + 0.5 * (luma - 0.66666)) / luma;
51 return half4(color.rgb * scale, color.a);
57 half4 main(half4 color) {
58 half luma = dot(color.rgb, half3(0.3, 0.6, 0.1));
63 } else if (luma < 0.66666) {
64 scale = (0.166666 + 2.0 * (luma - 0.33333)) / luma;
66 scale = (0.833333 + 0.5 * (luma - 0.66666)) / luma;
68 return half4(color.rgb * scale, color.a);
74 half4 main(half4 color) {
75 half luma = dot(color.rgb, half3(0.3, 0.6, 0.1));
79 return half4(color.rgb * 0.5, color.a);
80 } else if (luma < 0.66666) {
81 scale = 0.166666 + 2.0 * (luma - 0.33333);
83 scale = 0.833333 + 0.5 * (luma - 0.66666);
85 return half4(color.rgb * (scale/luma), color.a);
103 auto draw_filter = [&](
const char* src) {
106 SkDebugf(
"%s\n%s\n", src, err.c_str());
110 p.setColorFilter(effect->makeColorFilter(
nullptr));
128DEF_SIMPLE_GM(runtimecolorfilter_vertices_atlas_and_patch, canvas, 404, 404) {
141 canvas->imageInfo().refColorSpace());
144 auto atlas = surf->makeImageSnapshot();
166 auto makePaint = [&](
bool useCF,
bool useShader) {
168 paint.setColorFilter(useCF ? colorfilter :
nullptr);
173 auto drawVertices = [&](
float x,
bool useCF,
bool useShader) {
175 canvas->translate(
x, 0);
178 canvas->drawVertices(verts, mode, makePaint(useCF, useShader));
181 auto drawAtlas = [&](
float x,
bool useCF) {
183 canvas->translate(
x, 0);
186 canvas->drawAtlas(atlas.
get(),
197 auto drawPatch = [&](
float x,
bool useCF) {
199 canvas->translate(
x, 0);
204 drawVertices( 0,
false,
false);
205 drawVertices( r.
width() + 10,
true,
false);
206 drawVertices(2*(r.
width() + 10),
true,
true);
208 canvas->translate(0, r.
height() + 10);
209 drawAtlas( 0,
false);
210 drawAtlas(r.
width() + 10,
true);
212 canvas->translate(0, r.
height() + 10);
213 drawPatch( 0,
false);
214 drawPatch(r.
width() + 10,
true);
static constexpr SkColor kColor
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
constexpr SkColor SK_ColorYELLOW
constexpr SkColor SK_ColorCYAN
constexpr SkColor SK_ColorBLUE
constexpr SkColor SK_ColorGREEN
constexpr SkColor SK_ColorWHITE
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
void onOnceBeforeDraw() override
SkString getName() const override
RuntimeColorFilterGM()=default
SkISize getISize() override
void onDraw(SkCanvas *canvas) override
void translate(SkScalar dx, SkScalar dy)
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
static Result MakeForColorFilter(SkString sksl, const Options &)
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
#define DEF_SIMPLE_GM(NAME, CANVAS, W, H)
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
const char * gEarlyReturn
static constexpr SkISize Make(int32_t w, int32_t h)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
bool setLength(float length)
void toQuad(SkPoint quad[4]) const
constexpr float height() const
constexpr float width() const
static constexpr SkRect MakeWH(float w, float h)