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 #include "gm.h" | 8 #include "gm.h" |
9 #if SK_SUPPORT_GPU | 9 #if SK_SUPPORT_GPU |
10 #include "GrFragmentProcessor.h" | 10 #include "GrFragmentProcessor.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 class DCShader : public SkShader { | 28 class DCShader : public SkShader { |
29 public: | 29 public: |
30 DCShader(const SkMatrix& matrix) : fDeviceMatrix(matrix) {} | 30 DCShader(const SkMatrix& matrix) : fDeviceMatrix(matrix) {} |
31 | 31 |
32 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(DCShader); | 32 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(DCShader); |
33 | 33 |
34 void flatten(SkWriteBuffer& buf) const override { | 34 void flatten(SkWriteBuffer& buf) const override { |
35 buf.writeMatrix(fDeviceMatrix); | 35 buf.writeMatrix(fDeviceMatrix); |
36 } | 36 } |
37 | 37 |
38 const GrFragmentProcessor* asFragmentProcessor(GrContext*, | 38 sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*, |
39 const SkMatrix& viewM, | 39 const SkMatrix& viewM, |
40 const SkMatrix* localMatrix, | 40 const SkMatrix* localMatrix, |
41 SkFilterQuality, | 41 SkFilterQuality, |
42 SkSourceGammaTreatment) const
override; | 42 SkSourceGammaTreatment) const
override; |
43 | 43 |
44 #ifndef SK_IGNORE_TO_STRING | 44 #ifndef SK_IGNORE_TO_STRING |
45 void toString(SkString* str) const override { | 45 void toString(SkString* str) const override { |
46 str->appendf("DCShader: ()"); | 46 str->appendf("DCShader: ()"); |
47 } | 47 } |
48 #endif | 48 #endif |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 | 92 |
93 private: | 93 private: |
94 void onGetGLSLProcessorKey(const GrGLSLCaps& caps, | 94 void onGetGLSLProcessorKey(const GrGLSLCaps& caps, |
95 GrProcessorKeyBuilder* b) const override {} | 95 GrProcessorKeyBuilder* b) const override {} |
96 | 96 |
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 const GrFragmentProcessor* DCShader::asFragmentProcessor(GrContext*, | 102 sk_sp<GrFragmentProcessor> DCShader::asFragmentProcessor(GrContext*, |
103 const SkMatrix& viewM, | 103 const SkMatrix& viewM, |
104 const SkMatrix* localMa
trix, | 104 const SkMatrix* localMa
trix, |
105 SkFilterQuality, | 105 SkFilterQuality, |
106 SkSourceGammaTreatment)
const { | 106 SkSourceGammaTreatment)
const { |
107 SkAutoTUnref<const GrFragmentProcessor> inner(new DCFP(fDeviceMatrix)); | 107 sk_sp<GrFragmentProcessor> inner(new DCFP(fDeviceMatrix)); |
108 return GrFragmentProcessor::MulOutputByInputAlpha(inner); | 108 return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner)); |
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 |
117 ~DCShaderGM() override { | 117 ~DCShaderGM() override { |
118 for (int i = 0; i < fPrims.count(); ++i) { | 118 for (int i = 0; i < fPrims.count(); ++i) { |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 }; | 292 }; |
293 | 293 |
294 SkTArray<Prim*> fPrims; | 294 SkTArray<Prim*> fPrims; |
295 | 295 |
296 typedef GM INHERITED; | 296 typedef GM INHERITED; |
297 }; | 297 }; |
298 | 298 |
299 DEF_GM(return new DCShaderGM;) | 299 DEF_GM(return new DCShaderGM;) |
300 } | 300 } |
301 #endif | 301 #endif |
OLD | NEW |