1272 {
1273 {
1277 };
1278 static const Varying kVaryings[] = {
1280 };
1281 static constexpr char kVS[] = R"(
1282 Varyings main(const in Attributes attributes) {
1283 Varyings varyings;
1284 varyings.uv = attributes.uv;
1285 varyings.position = attributes.position;
1286 return varyings;
1287 }
1288 )";
1289 static constexpr char kFS[] = R"(
1290 uniform shader myShader1;
1291 uniform shader myShader2;
1292 uniform colorFilter myColorFilter;
1293 uniform blender myBlend;
1294
1295 float2 main(const in Varyings varyings, out half4 color) {
1296 half4 color1 = myShader1.eval(varyings.uv);
1297 half4 color2 = myShader2.eval(varyings.uv);
1298
1299 // Apply a inverse color filter to the first image.
1300 color1 = myColorFilter.eval(color1);
1301
1302 // Fade in the second image horizontally, leveraging the UVs.
1303 color2 *= varyings.uv.x / 128.0;
1304
1305 // Combine the two images by using a blender (set to dst-over).
1306 color = myBlend.eval(color1, color2);
1307
1308 return varyings.uv;
1309 }
1310 )";
1313 kVaryings,
1316 if (!spec) {
1318 }
1319 fSpec = std::move(spec);
1320 }
1321
1322
1323 switch (fType) {
1327 fShader2 = nullptr;
1328 fColorFilter = nullptr;
1329 fBlender = nullptr;
1330 fPaintShader = nullptr;
1331 break;
1332 }
1334 uint8_t inverseTable[256];
1335 for (int index = 0; index < 256; ++index) {
1336 inverseTable[index] = 255 - index;
1337 }
1338
1344 inverseTable,
1345 inverseTable,
1346 inverseTable);
1348 fPaintShader = nullptr;
1349 break;
1350 }
1352 fShader1 = nullptr;
1355 fColorFilter = nullptr;
1358 break;
1359 }
1363 fShader2 = nullptr;
1364 fColorFilter = nullptr;
1365 fBlender = nullptr;
1368 break;
1369 }
1370 default:
1372 }
1373 }
constexpr SkColor SK_ColorGREEN
static sk_sp< SkColorFilter > TableARGB(const uint8_t tableA[256], const uint8_t tableR[256], const uint8_t tableG[256], const uint8_t tableB[256])
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
static Result Make(SkSpan< const Attribute > attributes, size_t vertexStride, SkSpan< const Varying > varyings, const SkString &vs, const SkString &fs)
const uint8_t uint32_t uint32_t GError ** error
SK_API sk_sp< SkShader > Color(SkColor)
static const std::map< std::string, VerticesBuilder::AttributeType > kAttributes
SkSamplingOptions(SkFilterMode::kLinear))