| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "gm.h" | 9 #include "gm.h" |
| 10 #if SK_SUPPORT_GPU | 10 #if SK_SUPPORT_GPU |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 public: | 27 public: |
| 28 DCShader(const SkMatrix& matrix) : fDeviceMatrix(matrix) {} | 28 DCShader(const SkMatrix& matrix) : fDeviceMatrix(matrix) {} |
| 29 | 29 |
| 30 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(DCShader); | 30 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(DCShader); |
| 31 | 31 |
| 32 void flatten(SkWriteBuffer& buf) const override { | 32 void flatten(SkWriteBuffer& buf) const override { |
| 33 buf.writeMatrix(fDeviceMatrix); | 33 buf.writeMatrix(fDeviceMatrix); |
| 34 } | 34 } |
| 35 | 35 |
| 36 bool asFragmentProcessor(GrContext*, const SkPaint& paint, const SkMatrix& v
iewM, | 36 bool asFragmentProcessor(GrContext*, const SkPaint& paint, const SkMatrix& v
iewM, |
| 37 const SkMatrix* localMatrix, GrColor* color, GrShad
erDataManager*, | 37 const SkMatrix* localMatrix, GrColor* color, GrProc
essorDataManager*, |
| 38 GrFragmentProcessor** fp) const override; | 38 GrFragmentProcessor** fp) const override; |
| 39 | 39 |
| 40 #ifndef SK_IGNORE_TO_STRING | 40 #ifndef SK_IGNORE_TO_STRING |
| 41 void toString(SkString* str) const override { | 41 void toString(SkString* str) const override { |
| 42 str->appendf("DCShader: ()"); | 42 str->appendf("DCShader: ()"); |
| 43 } | 43 } |
| 44 #endif | 44 #endif |
| 45 | 45 |
| 46 private: | 46 private: |
| 47 const SkMatrix fDeviceMatrix; | 47 const SkMatrix fDeviceMatrix; |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 SkFlattenable* DCShader::CreateProc(SkReadBuffer& buf) { | 50 SkFlattenable* DCShader::CreateProc(SkReadBuffer& buf) { |
| 51 SkMatrix matrix; | 51 SkMatrix matrix; |
| 52 buf.readMatrix(&matrix); | 52 buf.readMatrix(&matrix); |
| 53 return SkNEW_ARGS(DCShader, (matrix)); | 53 return SkNEW_ARGS(DCShader, (matrix)); |
| 54 } | 54 } |
| 55 | 55 |
| 56 class DCFP : public GrFragmentProcessor { | 56 class DCFP : public GrFragmentProcessor { |
| 57 public: | 57 public: |
| 58 DCFP(GrShaderDataManager*, const SkMatrix& m) : fDeviceTransform(kDevice_GrC
oordSet, m) { | 58 DCFP(GrProcessorDataManager*, const SkMatrix& m) : fDeviceTransform(kDevice_
GrCoordSet, m) { |
| 59 this->addCoordTransform(&fDeviceTransform); | 59 this->addCoordTransform(&fDeviceTransform); |
| 60 this->initClassID<DCFP>(); | 60 this->initClassID<DCFP>(); |
| 61 } | 61 } |
| 62 | 62 |
| 63 void getGLProcessorKey(const GrGLSLCaps& caps, | 63 void getGLProcessorKey(const GrGLSLCaps& caps, |
| 64 GrProcessorKeyBuilder* b) const override {} | 64 GrProcessorKeyBuilder* b) const override {} |
| 65 | 65 |
| 66 GrGLFragmentProcessor* createGLInstance() const override { | 66 GrGLFragmentProcessor* createGLInstance() const override { |
| 67 class DCGLFP : public GrGLFragmentProcessor { | 67 class DCGLFP : public GrGLFragmentProcessor { |
| 68 void emitCode(GrGLFPBuilder* builder, | 68 void emitCode(GrGLFPBuilder* builder, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 94 } | 94 } |
| 95 | 95 |
| 96 private: | 96 private: |
| 97 bool onIsEqual(const GrFragmentProcessor&) const override { return true; } | 97 bool onIsEqual(const GrFragmentProcessor&) const override { return true; } |
| 98 | 98 |
| 99 GrCoordTransform fDeviceTransform; | 99 GrCoordTransform fDeviceTransform; |
| 100 }; | 100 }; |
| 101 | 101 |
| 102 bool DCShader::asFragmentProcessor(GrContext*, const SkPaint& paint, const SkMat
rix& viewM, | 102 bool DCShader::asFragmentProcessor(GrContext*, const SkPaint& paint, const SkMat
rix& viewM, |
| 103 const SkMatrix* localMatrix, GrColor* color, | 103 const SkMatrix* localMatrix, GrColor* color, |
| 104 GrShaderDataManager* shaderDataManager, | 104 GrProcessorDataManager* procDataManager, |
| 105 GrFragmentProcessor** fp) const { | 105 GrFragmentProcessor** fp) const { |
| 106 *fp = SkNEW_ARGS(DCFP, (shaderDataManager, fDeviceMatrix)); | 106 *fp = SkNEW_ARGS(DCFP, (procDataManager, fDeviceMatrix)); |
| 107 *color = GrColorPackA4(paint.getAlpha()); | 107 *color = GrColorPackA4(paint.getAlpha()); |
| 108 return true; | 108 return true; |
| 109 } | 109 } |
| 110 | 110 |
| 111 class DCShaderGM : public GM { | 111 class DCShaderGM : public GM { |
| 112 public: | 112 public: |
| 113 DCShaderGM() { | 113 DCShaderGM() { |
| 114 this->setBGColor(sk_tool_utils::color_to_565(0xFFAABBCC)); | 114 this->setBGColor(sk_tool_utils::color_to_565(0xFFAABBCC)); |
| 115 } | 115 } |
| 116 | 116 |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 }; | 305 }; |
| 306 | 306 |
| 307 SkTArray<Prim*> fPrims; | 307 SkTArray<Prim*> fPrims; |
| 308 | 308 |
| 309 typedef GM INHERITED; | 309 typedef GM INHERITED; |
| 310 }; | 310 }; |
| 311 | 311 |
| 312 DEF_GM( return SkNEW(DCShaderGM); ) | 312 DEF_GM( return SkNEW(DCShaderGM); ) |
| 313 } | 313 } |
| 314 #endif | 314 #endif |
| OLD | NEW |