OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "effects/GrConstColorProcessor.h" | 8 #include "effects/GrConstColorProcessor.h" |
9 #include "gl/GrGLFragmentProcessor.h" | 9 #include "gl/GrGLFragmentProcessor.h" |
10 #include "gl/builders/GrGLProgramBuilder.h" | 10 #include "gl/builders/GrGLProgramBuilder.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 fsBuilder->codeAppendf("%s = %s * %s;", args.fOutputColor, args.
fInputColor, | 27 fsBuilder->codeAppendf("%s = %s * %s;", args.fOutputColor, args.
fInputColor, |
28 colorUni); | 28 colorUni); |
29 break; | 29 break; |
30 case GrConstColorProcessor::kModulateA_InputMode: | 30 case GrConstColorProcessor::kModulateA_InputMode: |
31 fsBuilder->codeAppendf("%s = %s.a * %s;", args.fOutputColor, arg
s.fInputColor, | 31 fsBuilder->codeAppendf("%s = %s.a * %s;", args.fOutputColor, arg
s.fInputColor, |
32 colorUni); | 32 colorUni); |
33 break; | 33 break; |
34 } | 34 } |
35 } | 35 } |
36 | 36 |
37 void setData(const GrGLProgramDataManager& pdm, const GrProcessor& processor
) override { | 37 protected: |
| 38 void onSetData(const GrGLProgramDataManager& pdm, const GrProcessor& process
or) override { |
38 GrColor color = processor.cast<GrConstColorProcessor>().color(); | 39 GrColor color = processor.cast<GrConstColorProcessor>().color(); |
39 // We use the "illegal" color value as an uninit sentinel. However, ut i
sn't inherently | 40 // We use the "illegal" color value as an uninit sentinel. However, ut i
sn't inherently |
40 // illegal to use this processor with unpremul colors. So we correctly h
andle the case | 41 // illegal to use this processor with unpremul colors. So we correctly h
andle the case |
41 // when the "illegal" color is used but we will always upload it. | 42 // when the "illegal" color is used but we will always upload it. |
42 if (GrColor_ILLEGAL == color || fPrevColor != color) { | 43 if (GrColor_ILLEGAL == color || fPrevColor != color) { |
43 static const GrGLfloat scale = 1.f / 255.f; | 44 static const GrGLfloat scale = 1.f / 255.f; |
44 GrGLfloat floatColor[4] = { | 45 GrGLfloat floatColor[4] = { |
45 GrColorUnpackR(color) * scale, | 46 GrColorUnpackR(color) * scale, |
46 GrColorUnpackG(color) * scale, | 47 GrColorUnpackG(color) * scale, |
47 GrColorUnpackB(color) * scale, | 48 GrColorUnpackB(color) * scale, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 inout->mulAlphaByKnownFourComponents(fColor); | 83 inout->mulAlphaByKnownFourComponents(fColor); |
83 } | 84 } |
84 } | 85 } |
85 } | 86 } |
86 } | 87 } |
87 | 88 |
88 void GrConstColorProcessor::onGetGLProcessorKey(const GrGLSLCaps&, GrProcessorKe
yBuilder* b) const { | 89 void GrConstColorProcessor::onGetGLProcessorKey(const GrGLSLCaps&, GrProcessorKe
yBuilder* b) const { |
89 b->add32(fMode); | 90 b->add32(fMode); |
90 } | 91 } |
91 | 92 |
92 GrGLFragmentProcessor* GrConstColorProcessor::createGLInstance() const { | 93 GrGLFragmentProcessor* GrConstColorProcessor::onCreateGLInstance() const { |
93 return SkNEW(GLConstColorProcessor); | 94 return SkNEW(GLConstColorProcessor); |
94 } | 95 } |
95 | 96 |
96 bool GrConstColorProcessor::onIsEqual(const GrFragmentProcessor& other) const { | 97 bool GrConstColorProcessor::onIsEqual(const GrFragmentProcessor& other) const { |
97 const GrConstColorProcessor& that = other.cast<GrConstColorProcessor>(); | 98 const GrConstColorProcessor& that = other.cast<GrConstColorProcessor>(); |
98 return fMode == that.fMode && fColor == that.fColor; | 99 return fMode == that.fMode && fColor == that.fColor; |
99 } | 100 } |
100 | 101 |
101 /////////////////////////////////////////////////////////////////////////////// | 102 /////////////////////////////////////////////////////////////////////////////// |
102 | 103 |
(...skipping 15 matching lines...) Expand all Loading... |
118 color = 0; | 119 color = 0; |
119 break; | 120 break; |
120 case 2: | 121 case 2: |
121 color = d->fRandom->nextULessThan(0x100); | 122 color = d->fRandom->nextULessThan(0x100); |
122 color = color | (color << 8) | (color << 16) | (color << 24); | 123 color = color | (color << 8) | (color << 16) | (color << 24); |
123 break; | 124 break; |
124 } | 125 } |
125 InputMode mode = static_cast<InputMode>(d->fRandom->nextULessThan(kInputMode
Cnt)); | 126 InputMode mode = static_cast<InputMode>(d->fRandom->nextULessThan(kInputMode
Cnt)); |
126 return GrConstColorProcessor::Create(color, mode); | 127 return GrConstColorProcessor::Create(color, mode); |
127 } | 128 } |
OLD | NEW |