blob: e1d62f7d59f7eae4579737137d70ebcb1815e42f [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
25@make {
26 static std::unique_ptr<GrFragmentProcessor> Make(const SkLinearGradient& gradient,
27 const GrFPArgs& args);
28}
29
30@cppEnd {
31 std::unique_ptr<GrFragmentProcessor> GrLinearGradientLayout::Make(
32 const SkLinearGradient& grad, const GrFPArgs& args) {
33 SkMatrix matrix;
34 if (!grad.totalLocalMatrix(args.fPreLocalMatrix, args.fPostLocalMatrix)->invert(&matrix)) {
35 return nullptr;
36 }
37 matrix.postConcat(grad.getGradientMatrix());
38 return std::unique_ptr<GrFragmentProcessor>(new GrLinearGradientLayout(matrix));
39 }
40}