OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkLocalMatrixShader_DEFINED | 8 #ifndef SkLocalMatrixShader_DEFINED |
9 #define SkLocalMatrixShader_DEFINED | 9 #define SkLocalMatrixShader_DEFINED |
10 | 10 |
11 #include "SkShader.h" | 11 #include "SkShader.h" |
12 #include "SkReadBuffer.h" | 12 #include "SkReadBuffer.h" |
13 #include "SkWriteBuffer.h" | 13 #include "SkWriteBuffer.h" |
14 | 14 |
| 15 class GrFragmentProcessor; |
| 16 |
15 class SkLocalMatrixShader : public SkShader { | 17 class SkLocalMatrixShader : public SkShader { |
16 public: | 18 public: |
17 SkLocalMatrixShader(SkShader* proxy, const SkMatrix& localMatrix) | 19 SkLocalMatrixShader(SkShader* proxy, const SkMatrix& localMatrix) |
18 : INHERITED(&localMatrix) | 20 : INHERITED(&localMatrix) |
19 , fProxyShader(SkRef(proxy)) | 21 , fProxyShader(SkRef(proxy)) |
20 {} | 22 {} |
21 | 23 |
22 GradientType asAGradient(GradientInfo* info) const override { | 24 GradientType asAGradient(GradientInfo* info) const override { |
23 return fProxyShader->asAGradient(info); | 25 return fProxyShader->asAGradient(info); |
24 } | 26 } |
25 | 27 |
26 #if SK_SUPPORT_GPU | 28 #if SK_SUPPORT_GPU |
27 const GrFragmentProcessor* asFragmentProcessor( | 29 sk_sp<GrFragmentProcessor> asFragmentProcessor( |
28 GrContext* context, const SkMatrix&
viewM, | 30 GrContext* context, const SkMatrix&
viewM, |
29 const SkMatrix* localMatrix, SkFilte
rQuality fq, | 31 const SkMatrix* localMatrix, SkFilte
rQuality fq, |
30 SkSourceGammaTreatment gammaTreatmen
t) const override { | 32 SkSourceGammaTreatment gammaTreatmen
t) const override; |
31 SkMatrix tmp = this->getLocalMatrix(); | |
32 if (localMatrix) { | |
33 tmp.preConcat(*localMatrix); | |
34 } | |
35 return fProxyShader->asFragmentProcessor(context, viewM, &tmp, fq, gamma
Treatment); | |
36 } | |
37 #endif | 33 #endif |
38 | 34 |
39 SkShader* refAsALocalMatrixShader(SkMatrix* localMatrix) const override { | 35 SkShader* refAsALocalMatrixShader(SkMatrix* localMatrix) const override { |
40 if (localMatrix) { | 36 if (localMatrix) { |
41 *localMatrix = this->getLocalMatrix(); | 37 *localMatrix = this->getLocalMatrix(); |
42 } | 38 } |
43 return SkRef(fProxyShader.get()); | 39 return SkRef(fProxyShader.get()); |
44 } | 40 } |
45 | 41 |
46 SK_TO_STRING_OVERRIDE() | 42 SK_TO_STRING_OVERRIDE() |
(...skipping 11 matching lines...) Expand all Loading... |
58 return fProxyShader->isABitmap(bitmap, matrix, mode); | 54 return fProxyShader->isABitmap(bitmap, matrix, mode); |
59 } | 55 } |
60 | 56 |
61 private: | 57 private: |
62 SkAutoTUnref<SkShader> fProxyShader; | 58 SkAutoTUnref<SkShader> fProxyShader; |
63 | 59 |
64 typedef SkShader INHERITED; | 60 typedef SkShader INHERITED; |
65 }; | 61 }; |
66 | 62 |
67 #endif | 63 #endif |
OLD | NEW |