blob: 6eaf8b140c2502926a6b98743ed95f3b7aebe223 [file] [log] [blame]
Michael Ludwig4f94ef62018-09-12 15:22:16 -04001/*
2 * Copyright 2018 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8in half4x4 gradientMatrix;
9
10@coordTransform {
11 gradientMatrix
12}
13
14void main() {
Michael Ludwig8f685082018-09-12 15:23:01 -040015 half t = sk_TransformedCoords2D[0].x;
16 sk_OutColor = half4(t, 1, 0, 0); // y = 1 for always valid
Michael Ludwig4f94ef62018-09-12 15:22:16 -040017}
18
19//////////////////////////////////////////////////////////////////////////////
20
21@header {
22 #include "SkLinearGradient.h"
23}
24
Michael Ludwigb96cba32018-09-14 13:59:24 -040025// The linear gradient never rejects a pixel so it doesn't change opacity
26@optimizationFlags {
27 kPreservesOpaqueInput_OptimizationFlag
28}
29
Michael Ludwig4f94ef62018-09-12 15:22:16 -040030@make {
31 static std::unique_ptr<GrFragmentProcessor> Make(const SkLinearGradient& gradient,
32 const GrFPArgs& args);
33}
34
35@cppEnd {
36 std::unique_ptr<GrFragmentProcessor> GrLinearGradientLayout::Make(
37 const SkLinearGradient& grad, const GrFPArgs& args) {
38 SkMatrix matrix;
39 if (!grad.totalLocalMatrix(args.fPreLocalMatrix, args.fPostLocalMatrix)->invert(&matrix)) {
40 return nullptr;
41 }
42 matrix.postConcat(grad.getGradientMatrix());
43 return std::unique_ptr<GrFragmentProcessor>(new GrLinearGradientLayout(matrix));
44 }
45}