Michael Ludwig | 4f94ef6 | 2018-09-12 15:22:16 -0400 | [diff] [blame] | 1 | /* |
| 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 | |
| 8 | in half4x4 gradientMatrix; |
| 9 | |
| 10 | @coordTransform { |
| 11 | gradientMatrix |
| 12 | } |
| 13 | |
| 14 | void main() { |
Michael Ludwig | 8f68508 | 2018-09-12 15:23:01 -0400 | [diff] [blame^] | 15 | half t = sk_TransformedCoords2D[0].x; |
| 16 | sk_OutColor = half4(t, 1, 0, 0); // y = 1 for always valid |
Michael Ludwig | 4f94ef6 | 2018-09-12 15:22:16 -0400 | [diff] [blame] | 17 | } |
| 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 | } |