Chromium Code Reviews| 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 #if SK_SUPPORT_GPU | |
| 16 #include "GrFragmentProcessor.h" | |
|
bungeman-skia
2016/06/08 21:55:39
Should be a forward declaration.
| |
| 17 #endif | |
| 18 | |
| 15 class SkLocalMatrixShader : public SkShader { | 19 class SkLocalMatrixShader : public SkShader { |
| 16 public: | 20 public: |
| 17 SkLocalMatrixShader(SkShader* proxy, const SkMatrix& localMatrix) | 21 SkLocalMatrixShader(SkShader* proxy, const SkMatrix& localMatrix) |
| 18 : INHERITED(&localMatrix) | 22 : INHERITED(&localMatrix) |
| 19 , fProxyShader(SkRef(proxy)) | 23 , fProxyShader(SkRef(proxy)) |
| 20 {} | 24 {} |
| 21 | 25 |
| 22 GradientType asAGradient(GradientInfo* info) const override { | 26 GradientType asAGradient(GradientInfo* info) const override { |
| 23 return fProxyShader->asAGradient(info); | 27 return fProxyShader->asAGradient(info); |
| 24 } | 28 } |
| 25 | 29 |
| 26 #if SK_SUPPORT_GPU | 30 #if SK_SUPPORT_GPU |
| 27 const GrFragmentProcessor* asFragmentProcessor( | 31 sk_sp<GrFragmentProcessor> asFragmentProcessor( |
| 28 GrContext* context, const SkMatrix& viewM, | 32 GrContext* context, const SkMatrix& viewM, |
| 29 const SkMatrix* localMatrix, SkFilte rQuality fq, | 33 const SkMatrix* localMatrix, SkFilte rQuality fq, |
| 30 SkSourceGammaTreatment gammaTreatmen t) const override { | 34 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 | 35 #endif |
| 38 | 36 |
| 39 SkShader* refAsALocalMatrixShader(SkMatrix* localMatrix) const override { | 37 SkShader* refAsALocalMatrixShader(SkMatrix* localMatrix) const override { |
| 40 if (localMatrix) { | 38 if (localMatrix) { |
| 41 *localMatrix = this->getLocalMatrix(); | 39 *localMatrix = this->getLocalMatrix(); |
| 42 } | 40 } |
| 43 return SkRef(fProxyShader.get()); | 41 return SkRef(fProxyShader.get()); |
| 44 } | 42 } |
| 45 | 43 |
| 46 SK_TO_STRING_OVERRIDE() | 44 SK_TO_STRING_OVERRIDE() |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 58 return fProxyShader->isABitmap(bitmap, matrix, mode); | 56 return fProxyShader->isABitmap(bitmap, matrix, mode); |
| 59 } | 57 } |
| 60 | 58 |
| 61 private: | 59 private: |
| 62 SkAutoTUnref<SkShader> fProxyShader; | 60 SkAutoTUnref<SkShader> fProxyShader; |
| 63 | 61 |
| 64 typedef SkShader INHERITED; | 62 typedef SkShader INHERITED; |
| 65 }; | 63 }; |
| 66 | 64 |
| 67 #endif | 65 #endif |
| OLD | NEW |