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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 this->addCoordTransform(&fBackgroundTransform); | 111 this->addCoordTransform(&fBackgroundTransform); |
112 fBackgroundAccess.reset(background); | 112 fBackgroundAccess.reset(background); |
113 this->addTextureAccess(&fBackgroundAccess); | 113 this->addTextureAccess(&fBackgroundAccess); |
114 } | 114 } |
115 | 115 |
116 void GrArithmeticFP::onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyB
uilder* b) const { | 116 void GrArithmeticFP::onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyB
uilder* b) const { |
117 GLArithmeticFP::GenKey(*this, caps, b); | 117 GLArithmeticFP::GenKey(*this, caps, b); |
118 } | 118 } |
119 | 119 |
120 GrGLFragmentProcessor* GrArithmeticFP::onCreateGLInstance() const { | 120 GrGLFragmentProcessor* GrArithmeticFP::onCreateGLInstance() const { |
121 return SkNEW_ARGS(GLArithmeticFP, (*this)); | 121 return new GLArithmeticFP(*this); |
122 } | 122 } |
123 | 123 |
124 bool GrArithmeticFP::onIsEqual(const GrFragmentProcessor& fpBase) const { | 124 bool GrArithmeticFP::onIsEqual(const GrFragmentProcessor& fpBase) const { |
125 const GrArithmeticFP& fp = fpBase.cast<GrArithmeticFP>(); | 125 const GrArithmeticFP& fp = fpBase.cast<GrArithmeticFP>(); |
126 return fK1 == fp.fK1 && | 126 return fK1 == fp.fK1 && |
127 fK2 == fp.fK2 && | 127 fK2 == fp.fK2 && |
128 fK3 == fp.fK3 && | 128 fK3 == fp.fK3 && |
129 fK4 == fp.fK4 && | 129 fK4 == fp.fK4 && |
130 fEnforcePMColor == fp.fEnforcePMColor; | 130 fEnforcePMColor == fp.fEnforcePMColor; |
131 } | 131 } |
132 | 132 |
133 void GrArithmeticFP::onComputeInvariantOutput(GrInvariantOutput* inout) const { | 133 void GrArithmeticFP::onComputeInvariantOutput(GrInvariantOutput* inout) const { |
134 // TODO: optimize this | 134 // TODO: optimize this |
135 inout->setToUnknown(GrInvariantOutput::kWill_ReadInput); | 135 inout->setToUnknown(GrInvariantOutput::kWill_ReadInput); |
136 } | 136 } |
137 | 137 |
138 /////////////////////////////////////////////////////////////////////////////// | 138 /////////////////////////////////////////////////////////////////////////////// |
139 | 139 |
140 GrFragmentProcessor* GrArithmeticFP::TestCreate(GrProcessorTestData* d) { | 140 GrFragmentProcessor* GrArithmeticFP::TestCreate(GrProcessorTestData* d) { |
141 float k1 = d->fRandom->nextF(); | 141 float k1 = d->fRandom->nextF(); |
142 float k2 = d->fRandom->nextF(); | 142 float k2 = d->fRandom->nextF(); |
143 float k3 = d->fRandom->nextF(); | 143 float k3 = d->fRandom->nextF(); |
144 float k4 = d->fRandom->nextF(); | 144 float k4 = d->fRandom->nextF(); |
145 bool enforcePMColor = d->fRandom->nextBool(); | 145 bool enforcePMColor = d->fRandom->nextBool(); |
146 | 146 |
147 return SkNEW_ARGS(GrArithmeticFP, (d->fProcDataManager, k1, k2, k3, k4, enfo
rcePMColor, | 147 return new GrArithmeticFP(d->fProcDataManager, k1, k2, k3, k4, enforcePMColo
r, d->fTextures[0]); |
148 d->fTextures[0])); | |
149 } | 148 } |
150 | 149 |
151 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrArithmeticFP); | 150 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrArithmeticFP); |
152 | 151 |
153 /////////////////////////////////////////////////////////////////////////////// | 152 /////////////////////////////////////////////////////////////////////////////// |
154 // Xfer Processor | 153 // Xfer Processor |
155 /////////////////////////////////////////////////////////////////////////////// | 154 /////////////////////////////////////////////////////////////////////////////// |
156 | 155 |
157 class ArithmeticXP : public GrXferProcessor { | 156 class ArithmeticXP : public GrXferProcessor { |
158 public: | 157 public: |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 , fK3(k3) | 248 , fK3(k3) |
250 , fK4(k4) | 249 , fK4(k4) |
251 , fEnforcePMColor(enforcePMColor) { | 250 , fEnforcePMColor(enforcePMColor) { |
252 this->initClassID<ArithmeticXP>(); | 251 this->initClassID<ArithmeticXP>(); |
253 } | 252 } |
254 | 253 |
255 void ArithmeticXP::onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBui
lder* b) const { | 254 void ArithmeticXP::onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBui
lder* b) const { |
256 GLArithmeticXP::GenKey(*this, caps, b); | 255 GLArithmeticXP::GenKey(*this, caps, b); |
257 } | 256 } |
258 | 257 |
259 GrGLXferProcessor* ArithmeticXP::createGLInstance() const { | 258 GrGLXferProcessor* ArithmeticXP::createGLInstance() const { return new GLArithme
ticXP(*this); } |
260 return SkNEW_ARGS(GLArithmeticXP, (*this)); | |
261 } | |
262 | 259 |
263 GrXferProcessor::OptFlags ArithmeticXP::onGetOptimizations(const GrProcOptInfo&
colorPOI, | 260 GrXferProcessor::OptFlags ArithmeticXP::onGetOptimizations(const GrProcOptInfo&
colorPOI, |
264 const GrProcOptInfo&
coveragePOI, | 261 const GrProcOptInfo&
coveragePOI, |
265 bool doesStencilWrite
, | 262 bool doesStencilWrite
, |
266 GrColor* overrideColo
r, | 263 GrColor* overrideColo
r, |
267 const GrCaps& caps) { | 264 const GrCaps& caps) { |
268 return GrXferProcessor::kNone_OptFlags; | 265 return GrXferProcessor::kNone_OptFlags; |
269 } | 266 } |
270 | 267 |
271 /////////////////////////////////////////////////////////////////////////////// | 268 /////////////////////////////////////////////////////////////////////////////// |
272 | 269 |
273 GrArithmeticXPFactory::GrArithmeticXPFactory(float k1, float k2, float k3, float
k4, | 270 GrArithmeticXPFactory::GrArithmeticXPFactory(float k1, float k2, float k3, float
k4, |
274 bool enforcePMColor) | 271 bool enforcePMColor) |
275 : fK1(k1), fK2(k2), fK3(k3), fK4(k4), fEnforcePMColor(enforcePMColor) { | 272 : fK1(k1), fK2(k2), fK3(k3), fK4(k4), fEnforcePMColor(enforcePMColor) { |
276 this->initClassID<GrArithmeticXPFactory>(); | 273 this->initClassID<GrArithmeticXPFactory>(); |
277 } | 274 } |
278 | 275 |
279 GrXferProcessor* | 276 GrXferProcessor* |
280 GrArithmeticXPFactory::onCreateXferProcessor(const GrCaps& caps, | 277 GrArithmeticXPFactory::onCreateXferProcessor(const GrCaps& caps, |
281 const GrProcOptInfo& colorPOI, | 278 const GrProcOptInfo& colorPOI, |
282 const GrProcOptInfo& coveragePOI, | 279 const GrProcOptInfo& coveragePOI, |
283 bool hasMixedSamples, | 280 bool hasMixedSamples, |
284 const DstTexture* dstTexture) const
{ | 281 const DstTexture* dstTexture) const
{ |
285 return SkNEW_ARGS(ArithmeticXP, (dstTexture, hasMixedSamples, fK1, fK2, fK3,
fK4, | 282 return new ArithmeticXP(dstTexture, hasMixedSamples, fK1, fK2, fK3, fK4, fEn
forcePMColor); |
286 fEnforcePMColor)); | |
287 } | 283 } |
288 | 284 |
289 | 285 |
290 void GrArithmeticXPFactory::getInvariantBlendedColor(const GrProcOptInfo& colorP
OI, | 286 void GrArithmeticXPFactory::getInvariantBlendedColor(const GrProcOptInfo& colorP
OI, |
291 InvariantBlendedColor* blen
dedColor) const { | 287 InvariantBlendedColor* blen
dedColor) const { |
292 blendedColor->fWillBlendWithDst = true; | 288 blendedColor->fWillBlendWithDst = true; |
293 | 289 |
294 // TODO: We could try to optimize this more. For example if fK1 and fK3 are
zero, then we won't | 290 // TODO: We could try to optimize this more. For example if fK1 and fK3 are
zero, then we won't |
295 // be blending the color with dst at all so we can know what the output colo
r is (up to the | 291 // be blending the color with dst at all so we can know what the output colo
r is (up to the |
296 // valid color components passed in). | 292 // valid color components passed in). |
297 blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; | 293 blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; |
298 } | 294 } |
299 | 295 |
300 GR_DEFINE_XP_FACTORY_TEST(GrArithmeticXPFactory); | 296 GR_DEFINE_XP_FACTORY_TEST(GrArithmeticXPFactory); |
301 | 297 |
302 GrXPFactory* GrArithmeticXPFactory::TestCreate(GrProcessorTestData* d) { | 298 GrXPFactory* GrArithmeticXPFactory::TestCreate(GrProcessorTestData* d) { |
303 float k1 = d->fRandom->nextF(); | 299 float k1 = d->fRandom->nextF(); |
304 float k2 = d->fRandom->nextF(); | 300 float k2 = d->fRandom->nextF(); |
305 float k3 = d->fRandom->nextF(); | 301 float k3 = d->fRandom->nextF(); |
306 float k4 = d->fRandom->nextF(); | 302 float k4 = d->fRandom->nextF(); |
307 bool enforcePMColor = d->fRandom->nextBool(); | 303 bool enforcePMColor = d->fRandom->nextBool(); |
308 | 304 |
309 return GrArithmeticXPFactory::Create(k1, k2, k3, k4, enforcePMColor); | 305 return GrArithmeticXPFactory::Create(k1, k2, k3, k4, enforcePMColor); |
310 } | 306 } |
311 | 307 |
312 #endif | 308 #endif |
OLD | NEW |