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 "SkArithmeticMode_gpu.h" | 8 #include "SkArithmeticMode_gpu.h" |
9 | 9 |
10 #if SK_SUPPORT_GPU | 10 #if SK_SUPPORT_GPU |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 | 90 |
91 private: | 91 private: |
92 GrGLSLProgramDataManager::UniformHandle fKUni; | 92 GrGLSLProgramDataManager::UniformHandle fKUni; |
93 bool fEnforcePMColor; | 93 bool fEnforcePMColor; |
94 | 94 |
95 typedef GrGLFragmentProcessor INHERITED; | 95 typedef GrGLFragmentProcessor INHERITED; |
96 }; | 96 }; |
97 | 97 |
98 /////////////////////////////////////////////////////////////////////////////// | 98 /////////////////////////////////////////////////////////////////////////////// |
99 | 99 |
100 GrArithmeticFP::GrArithmeticFP(float k1, float k2, float k3, float k4, bool enfo
rcePMColor, | 100 GrArithmeticFP::GrArithmeticFP(float k1, float k2, float k3, float k4, |
101 const GrFragmentProcessor* dst) | 101 bool enforcePMColor, const GrFragmentProcessor* d
st, GrRenderTarget* dstRT) |
102 : fK1(k1), fK2(k2), fK3(k3), fK4(k4), fEnforcePMColor(enforcePMColor) { | 102 : fK1(k1), fK2(k2), fK3(k3), fK4(k4), fEnforcePMColor(enforcePMColor) { |
103 this->initClassID<GrArithmeticFP>(); | 103 this->initClassID<GrArithmeticFP>(); |
104 | 104 |
105 SkASSERT(dst); | 105 SkASSERT(dst); |
106 SkDEBUGCODE(int dstIndex = )this->registerChildProcessor(dst); | 106 SkDEBUGCODE(int dstIndex = )this->registerChildProcessor(dst); |
107 SkASSERT(0 == dstIndex); | 107 SkASSERT(0 == dstIndex); |
108 } | 108 } |
109 | 109 |
110 void GrArithmeticFP::onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyB
uilder* b) const { | 110 void GrArithmeticFP::onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyB
uilder* b) const { |
111 GLArithmeticFP::GenKey(*this, caps, b); | 111 GLArithmeticFP::GenKey(*this, caps, b); |
(...skipping 20 matching lines...) Expand all Loading... |
132 /////////////////////////////////////////////////////////////////////////////// | 132 /////////////////////////////////////////////////////////////////////////////// |
133 | 133 |
134 const GrFragmentProcessor* GrArithmeticFP::TestCreate(GrProcessorTestData* d) { | 134 const GrFragmentProcessor* GrArithmeticFP::TestCreate(GrProcessorTestData* d) { |
135 float k1 = d->fRandom->nextF(); | 135 float k1 = d->fRandom->nextF(); |
136 float k2 = d->fRandom->nextF(); | 136 float k2 = d->fRandom->nextF(); |
137 float k3 = d->fRandom->nextF(); | 137 float k3 = d->fRandom->nextF(); |
138 float k4 = d->fRandom->nextF(); | 138 float k4 = d->fRandom->nextF(); |
139 bool enforcePMColor = d->fRandom->nextBool(); | 139 bool enforcePMColor = d->fRandom->nextBool(); |
140 | 140 |
141 SkAutoTUnref<const GrFragmentProcessor> dst(GrProcessorUnitTest::CreateChild
FP(d)); | 141 SkAutoTUnref<const GrFragmentProcessor> dst(GrProcessorUnitTest::CreateChild
FP(d)); |
142 return new GrArithmeticFP(k1, k2, k3, k4, enforcePMColor, dst); | 142 return new GrArithmeticFP(k1, k2, k3, k4, enforcePMColor, dst, NULL); |
143 } | 143 } |
144 | 144 |
145 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrArithmeticFP); | 145 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrArithmeticFP); |
146 | 146 |
147 /////////////////////////////////////////////////////////////////////////////// | 147 /////////////////////////////////////////////////////////////////////////////// |
148 // Xfer Processor | 148 // Xfer Processor |
149 /////////////////////////////////////////////////////////////////////////////// | 149 /////////////////////////////////////////////////////////////////////////////// |
150 | 150 |
151 class ArithmeticXP : public GrXferProcessor { | 151 class ArithmeticXP : public GrXferProcessor { |
152 public: | 152 public: |
153 ArithmeticXP(const DstTexture*, bool hasMixedSamples, | 153 ArithmeticXP(const DstTexture*, bool hasMixedSamples, |
154 float k1, float k2, float k3, float k4, bool enforcePMColor); | 154 float k1, float k2, float k3, float k4, bool enforcePMColor, Gr
RenderTarget* dst); |
155 | 155 |
156 const char* name() const override { return "Arithmetic"; } | 156 const char* name() const override { return "Arithmetic"; } |
157 | 157 |
158 GrGLXferProcessor* createGLInstance() const override; | 158 GrGLXferProcessor* createGLInstance() const override; |
159 | 159 |
160 float k1() const { return fK1; } | 160 float k1() const { return fK1; } |
161 float k2() const { return fK2; } | 161 float k2() const { return fK2; } |
162 float k3() const { return fK3; } | 162 float k3() const { return fK3; } |
163 float k4() const { return fK4; } | 163 float k4() const { return fK4; } |
164 bool enforcePMColor() const { return fEnforcePMColor; } | 164 bool enforcePMColor() const { return fEnforcePMColor; } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 | 229 |
230 GrGLSLProgramDataManager::UniformHandle fKUni; | 230 GrGLSLProgramDataManager::UniformHandle fKUni; |
231 bool fEnforcePMColor; | 231 bool fEnforcePMColor; |
232 | 232 |
233 typedef GrGLXferProcessor INHERITED; | 233 typedef GrGLXferProcessor INHERITED; |
234 }; | 234 }; |
235 | 235 |
236 /////////////////////////////////////////////////////////////////////////////// | 236 /////////////////////////////////////////////////////////////////////////////// |
237 | 237 |
238 ArithmeticXP::ArithmeticXP(const DstTexture* dstTexture, bool hasMixedSamples, | 238 ArithmeticXP::ArithmeticXP(const DstTexture* dstTexture, bool hasMixedSamples, |
239 float k1, float k2, float k3, float k4, bool enforceP
MColor) | 239 float k1, float k2, float k3, float k4, bool enforceP
MColor, GrRenderTarget* dst) |
240 : INHERITED(dstTexture, true, hasMixedSamples) | 240 : INHERITED(dstTexture, true, hasMixedSamples, dst) |
241 , fK1(k1) | 241 , fK1(k1) |
242 , fK2(k2) | 242 , fK2(k2) |
243 , fK3(k3) | 243 , fK3(k3) |
244 , fK4(k4) | 244 , fK4(k4) |
245 , fEnforcePMColor(enforcePMColor) { | 245 , fEnforcePMColor(enforcePMColor) { |
246 this->initClassID<ArithmeticXP>(); | 246 this->initClassID<ArithmeticXP>(); |
247 } | 247 } |
248 | 248 |
249 void ArithmeticXP::onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBui
lder* b) const { | 249 void ArithmeticXP::onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBui
lder* b) const { |
250 GLArithmeticXP::GenKey(*this, caps, b); | 250 GLArithmeticXP::GenKey(*this, caps, b); |
(...skipping 15 matching lines...) Expand all Loading... |
266 bool enforcePMColor) | 266 bool enforcePMColor) |
267 : fK1(k1), fK2(k2), fK3(k3), fK4(k4), fEnforcePMColor(enforcePMColor) { | 267 : fK1(k1), fK2(k2), fK3(k3), fK4(k4), fEnforcePMColor(enforcePMColor) { |
268 this->initClassID<GrArithmeticXPFactory>(); | 268 this->initClassID<GrArithmeticXPFactory>(); |
269 } | 269 } |
270 | 270 |
271 GrXferProcessor* | 271 GrXferProcessor* |
272 GrArithmeticXPFactory::onCreateXferProcessor(const GrCaps& caps, | 272 GrArithmeticXPFactory::onCreateXferProcessor(const GrCaps& caps, |
273 const GrProcOptInfo& colorPOI, | 273 const GrProcOptInfo& colorPOI, |
274 const GrProcOptInfo& coveragePOI, | 274 const GrProcOptInfo& coveragePOI, |
275 bool hasMixedSamples, | 275 bool hasMixedSamples, |
276 const DstTexture* dstTexture) const
{ | 276 const DstTexture* dstTexture, GrRen
derTarget* dst) const { |
277 return new ArithmeticXP(dstTexture, hasMixedSamples, fK1, fK2, fK3, fK4, fEn
forcePMColor); | 277 return new ArithmeticXP(dstTexture, hasMixedSamples, fK1, fK2, fK3, fK4, fEn
forcePMColor, dst); |
278 } | 278 } |
279 | 279 |
280 | 280 |
281 void GrArithmeticXPFactory::getInvariantBlendedColor(const GrProcOptInfo& colorP
OI, | 281 void GrArithmeticXPFactory::getInvariantBlendedColor(const GrProcOptInfo& colorP
OI, |
282 InvariantBlendedColor* blen
dedColor) const { | 282 InvariantBlendedColor* blen
dedColor) const { |
283 blendedColor->fWillBlendWithDst = true; | 283 blendedColor->fWillBlendWithDst = true; |
284 | 284 |
285 // TODO: We could try to optimize this more. For example if fK1 and fK3 are
zero, then we won't | 285 // TODO: We could try to optimize this more. For example if fK1 and fK3 are
zero, then we won't |
286 // be blending the color with dst at all so we can know what the output colo
r is (up to the | 286 // be blending the color with dst at all so we can know what the output colo
r is (up to the |
287 // valid color components passed in). | 287 // valid color components passed in). |
288 blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; | 288 blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; |
289 } | 289 } |
290 | 290 |
291 GR_DEFINE_XP_FACTORY_TEST(GrArithmeticXPFactory); | 291 GR_DEFINE_XP_FACTORY_TEST(GrArithmeticXPFactory); |
292 | 292 |
293 const GrXPFactory* GrArithmeticXPFactory::TestCreate(GrProcessorTestData* d) { | 293 const GrXPFactory* GrArithmeticXPFactory::TestCreate(GrProcessorTestData* d) { |
294 float k1 = d->fRandom->nextF(); | 294 float k1 = d->fRandom->nextF(); |
295 float k2 = d->fRandom->nextF(); | 295 float k2 = d->fRandom->nextF(); |
296 float k3 = d->fRandom->nextF(); | 296 float k3 = d->fRandom->nextF(); |
297 float k4 = d->fRandom->nextF(); | 297 float k4 = d->fRandom->nextF(); |
298 bool enforcePMColor = d->fRandom->nextBool(); | 298 bool enforcePMColor = d->fRandom->nextBool(); |
299 | 299 |
300 return GrArithmeticXPFactory::Create(k1, k2, k3, k4, enforcePMColor); | 300 return GrArithmeticXPFactory::Create(k1, k2, k3, k4, enforcePMColor); |
301 } | 301 } |
302 | 302 |
303 #endif | 303 #endif |
OLD | NEW |