| 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 | 160 |
| 161 GrGLSLXferProcessor* createGLSLInstance() const override; | 161 GrGLSLXferProcessor* createGLSLInstance() const override; |
| 162 | 162 |
| 163 float k1() const { return fK1; } | 163 float k1() const { return fK1; } |
| 164 float k2() const { return fK2; } | 164 float k2() const { return fK2; } |
| 165 float k3() const { return fK3; } | 165 float k3() const { return fK3; } |
| 166 float k4() const { return fK4; } | 166 float k4() const { return fK4; } |
| 167 bool enforcePMColor() const { return fEnforcePMColor; } | 167 bool enforcePMColor() const { return fEnforcePMColor; } |
| 168 | 168 |
| 169 private: | 169 private: |
| 170 GrXferProcessor::OptFlags onGetOptimizations(const GrProcOptInfo& colorPOI, | 170 GrXferProcessor::OptFlags onGetOptimizations(const GrPipelineOptimizations&
optimizations, |
| 171 const GrProcOptInfo& coveragePO
I, | |
| 172 bool doesStencilWrite, | 171 bool doesStencilWrite, |
| 173 GrColor* overrideColor, | 172 GrColor* overrideColor, |
| 174 const GrCaps& caps) override; | 173 const GrCaps& caps) override; |
| 175 | 174 |
| 176 void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b)
const override; | 175 void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b)
const override; |
| 177 | 176 |
| 178 bool onIsEqual(const GrXferProcessor& xpBase) const override { | 177 bool onIsEqual(const GrXferProcessor& xpBase) const override { |
| 179 const ArithmeticXP& xp = xpBase.cast<ArithmeticXP>(); | 178 const ArithmeticXP& xp = xpBase.cast<ArithmeticXP>(); |
| 180 if (fK1 != xp.fK1 || | 179 if (fK1 != xp.fK1 || |
| 181 fK2 != xp.fK2 || | 180 fK2 != xp.fK2 || |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 , fEnforcePMColor(enforcePMColor) { | 249 , fEnforcePMColor(enforcePMColor) { |
| 251 this->initClassID<ArithmeticXP>(); | 250 this->initClassID<ArithmeticXP>(); |
| 252 } | 251 } |
| 253 | 252 |
| 254 void ArithmeticXP::onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyB
uilder* b) const { | 253 void ArithmeticXP::onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyB
uilder* b) const { |
| 255 GLArithmeticXP::GenKey(*this, caps, b); | 254 GLArithmeticXP::GenKey(*this, caps, b); |
| 256 } | 255 } |
| 257 | 256 |
| 258 GrGLSLXferProcessor* ArithmeticXP::createGLSLInstance() const { return new GLAri
thmeticXP(*this); } | 257 GrGLSLXferProcessor* ArithmeticXP::createGLSLInstance() const { return new GLAri
thmeticXP(*this); } |
| 259 | 258 |
| 260 GrXferProcessor::OptFlags ArithmeticXP::onGetOptimizations(const GrProcOptInfo&
colorPOI, | 259 GrXferProcessor::OptFlags ArithmeticXP::onGetOptimizations( |
| 261 const GrProcOptInfo&
coveragePOI, | 260 const GrPipelineOptimizat
ions& optimizations, |
| 262 bool doesStencilWrite
, | 261 bool doesStencilWrite, |
| 263 GrColor* overrideColo
r, | 262 GrColor* overrideColor, |
| 264 const GrCaps& caps) { | 263 const GrCaps& caps) { |
| 265 return GrXferProcessor::kNone_OptFlags; | 264 return GrXferProcessor::kNone_OptFlags; |
| 266 } | 265 } |
| 267 | 266 |
| 268 /////////////////////////////////////////////////////////////////////////////// | 267 /////////////////////////////////////////////////////////////////////////////// |
| 269 | 268 |
| 270 GrArithmeticXPFactory::GrArithmeticXPFactory(float k1, float k2, float k3, float
k4, | 269 GrArithmeticXPFactory::GrArithmeticXPFactory(float k1, float k2, float k3, float
k4, |
| 271 bool enforcePMColor) | 270 bool enforcePMColor) |
| 272 : fK1(k1), fK2(k2), fK3(k3), fK4(k4), fEnforcePMColor(enforcePMColor) { | 271 : fK1(k1), fK2(k2), fK3(k3), fK4(k4), fEnforcePMColor(enforcePMColor) { |
| 273 this->initClassID<GrArithmeticXPFactory>(); | 272 this->initClassID<GrArithmeticXPFactory>(); |
| 274 } | 273 } |
| 275 | 274 |
| 276 GrXferProcessor* | 275 GrXferProcessor* |
| 277 GrArithmeticXPFactory::onCreateXferProcessor(const GrCaps& caps, | 276 GrArithmeticXPFactory::onCreateXferProcessor(const GrCaps& caps, |
| 278 const GrProcOptInfo& colorPOI, | 277 const GrPipelineOptimizations& opti
mizations, |
| 279 const GrProcOptInfo& coveragePOI, | |
| 280 bool hasMixedSamples, | 278 bool hasMixedSamples, |
| 281 const DstTexture* dstTexture) const
{ | 279 const DstTexture* dstTexture) const
{ |
| 282 return new ArithmeticXP(dstTexture, hasMixedSamples, fK1, fK2, fK3, fK4, fEn
forcePMColor); | 280 return new ArithmeticXP(dstTexture, hasMixedSamples, fK1, fK2, fK3, fK4, fEn
forcePMColor); |
| 283 } | 281 } |
| 284 | 282 |
| 285 | 283 |
| 286 void GrArithmeticXPFactory::getInvariantBlendedColor(const GrProcOptInfo& colorP
OI, | 284 void GrArithmeticXPFactory::getInvariantBlendedColor(const GrProcOptInfo& colorP
OI, |
| 287 InvariantBlendedColor* blen
dedColor) const { | 285 InvariantBlendedColor* blen
dedColor) const { |
| 288 blendedColor->fWillBlendWithDst = true; | 286 blendedColor->fWillBlendWithDst = true; |
| 289 | 287 |
| 290 // TODO: We could try to optimize this more. For example if fK1 and fK3 are
zero, then we won't | 288 // TODO: We could try to optimize this more. For example if fK1 and fK3 are
zero, then we won't |
| 291 // be blending the color with dst at all so we can know what the output colo
r is (up to the | 289 // be blending the color with dst at all so we can know what the output colo
r is (up to the |
| 292 // valid color components passed in). | 290 // valid color components passed in). |
| 293 blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; | 291 blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; |
| 294 } | 292 } |
| 295 | 293 |
| 296 GR_DEFINE_XP_FACTORY_TEST(GrArithmeticXPFactory); | 294 GR_DEFINE_XP_FACTORY_TEST(GrArithmeticXPFactory); |
| 297 | 295 |
| 298 const GrXPFactory* GrArithmeticXPFactory::TestCreate(GrProcessorTestData* d) { | 296 const GrXPFactory* GrArithmeticXPFactory::TestCreate(GrProcessorTestData* d) { |
| 299 float k1 = d->fRandom->nextF(); | 297 float k1 = d->fRandom->nextF(); |
| 300 float k2 = d->fRandom->nextF(); | 298 float k2 = d->fRandom->nextF(); |
| 301 float k3 = d->fRandom->nextF(); | 299 float k3 = d->fRandom->nextF(); |
| 302 float k4 = d->fRandom->nextF(); | 300 float k4 = d->fRandom->nextF(); |
| 303 bool enforcePMColor = d->fRandom->nextBool(); | 301 bool enforcePMColor = d->fRandom->nextBool(); |
| 304 | 302 |
| 305 return GrArithmeticXPFactory::Create(k1, k2, k3, k4, enforcePMColor); | 303 return GrArithmeticXPFactory::Create(k1, k2, k3, k4, enforcePMColor); |
| 306 } | 304 } |
| 307 | 305 |
| 308 #endif | 306 #endif |
| OLD | NEW |