| 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 "effects/GrPorterDuffXferProcessor.h" | 8 #include "effects/GrPorterDuffXferProcessor.h" |
| 9 | 9 |
| 10 #include "GrBlend.h" | 10 #include "GrBlend.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 GrColor* overrideColor, | 90 GrColor* overrideColor, |
| 91 const GrDrawTargetCaps& caps) ove
rride; | 91 const GrDrawTargetCaps& caps) ove
rride; |
| 92 | 92 |
| 93 GrBlendCoeff getSrcBlend() const { return fSrcBlend; } | 93 GrBlendCoeff getSrcBlend() const { return fSrcBlend; } |
| 94 GrBlendCoeff getDstBlend() const { return fDstBlend; } | 94 GrBlendCoeff getDstBlend() const { return fDstBlend; } |
| 95 | 95 |
| 96 private: | 96 private: |
| 97 PorterDuffXferProcessor(GrBlendCoeff srcBlend, GrBlendCoeff dstBlend, GrColo
r constant, | 97 PorterDuffXferProcessor(GrBlendCoeff srcBlend, GrBlendCoeff dstBlend, GrColo
r constant, |
| 98 const GrDeviceCoordTexture* dstCopy, bool willReadDs
tColor); | 98 const GrDeviceCoordTexture* dstCopy, bool willReadDs
tColor); |
| 99 | 99 |
| 100 void onGetGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBuilder* b) con
st override; | 100 void onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) c
onst override; |
| 101 | 101 |
| 102 void onGetBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const override { | 102 void onGetBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const override { |
| 103 if (!this->willReadDstColor()) { | 103 if (!this->willReadDstColor()) { |
| 104 blendInfo->fSrcBlend = fSrcBlend; | 104 blendInfo->fSrcBlend = fSrcBlend; |
| 105 blendInfo->fDstBlend = fDstBlend; | 105 blendInfo->fDstBlend = fDstBlend; |
| 106 } else { | 106 } else { |
| 107 blendInfo->fSrcBlend = kOne_GrBlendCoeff; | 107 blendInfo->fSrcBlend = kOne_GrBlendCoeff; |
| 108 blendInfo->fDstBlend = kZero_GrBlendCoeff; | 108 blendInfo->fDstBlend = kZero_GrBlendCoeff; |
| 109 } | 109 } |
| 110 blendInfo->fBlendConstant = fBlendConstant; | 110 blendInfo->fBlendConstant = fBlendConstant; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 return true; | 183 return true; |
| 184 } | 184 } |
| 185 } | 185 } |
| 186 | 186 |
| 187 class GLPorterDuffXferProcessor : public GrGLXferProcessor { | 187 class GLPorterDuffXferProcessor : public GrGLXferProcessor { |
| 188 public: | 188 public: |
| 189 GLPorterDuffXferProcessor(const GrProcessor&) {} | 189 GLPorterDuffXferProcessor(const GrProcessor&) {} |
| 190 | 190 |
| 191 virtual ~GLPorterDuffXferProcessor() {} | 191 virtual ~GLPorterDuffXferProcessor() {} |
| 192 | 192 |
| 193 static void GenKey(const GrProcessor& processor, const GrGLCaps& caps, | 193 static void GenKey(const GrProcessor& processor, const GrGLSLCaps& caps, |
| 194 GrProcessorKeyBuilder* b) { | 194 GrProcessorKeyBuilder* b) { |
| 195 const PorterDuffXferProcessor& xp = processor.cast<PorterDuffXferProcess
or>(); | 195 const PorterDuffXferProcessor& xp = processor.cast<PorterDuffXferProcess
or>(); |
| 196 b->add32(xp.primaryOutputType()); | 196 b->add32(xp.primaryOutputType()); |
| 197 b->add32(xp.secondaryOutputType()); | 197 b->add32(xp.secondaryOutputType()); |
| 198 if (xp.willReadDstColor()) { | 198 if (xp.willReadDstColor()) { |
| 199 b->add32(xp.getSrcBlend()); | 199 b->add32(xp.getSrcBlend()); |
| 200 b->add32(xp.getDstBlend()); | 200 b->add32(xp.getDstBlend()); |
| 201 } | 201 } |
| 202 }; | 202 }; |
| 203 | 203 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 , fDstBlend(dstBlend) | 284 , fDstBlend(dstBlend) |
| 285 , fBlendConstant(constant) | 285 , fBlendConstant(constant) |
| 286 , fPrimaryOutputType(kModulate_PrimaryOutputType) | 286 , fPrimaryOutputType(kModulate_PrimaryOutputType) |
| 287 , fSecondaryOutputType(kNone_SecondaryOutputType) { | 287 , fSecondaryOutputType(kNone_SecondaryOutputType) { |
| 288 this->initClassID<PorterDuffXferProcessor>(); | 288 this->initClassID<PorterDuffXferProcessor>(); |
| 289 } | 289 } |
| 290 | 290 |
| 291 PorterDuffXferProcessor::~PorterDuffXferProcessor() { | 291 PorterDuffXferProcessor::~PorterDuffXferProcessor() { |
| 292 } | 292 } |
| 293 | 293 |
| 294 void PorterDuffXferProcessor::onGetGLProcessorKey(const GrGLCaps& caps, | 294 void PorterDuffXferProcessor::onGetGLProcessorKey(const GrGLSLCaps& caps, |
| 295 GrProcessorKeyBuilder* b) cons
t { | 295 GrProcessorKeyBuilder* b) cons
t { |
| 296 GLPorterDuffXferProcessor::GenKey(*this, caps, b); | 296 GLPorterDuffXferProcessor::GenKey(*this, caps, b); |
| 297 } | 297 } |
| 298 | 298 |
| 299 GrGLXferProcessor* PorterDuffXferProcessor::createGLInstance() const { | 299 GrGLXferProcessor* PorterDuffXferProcessor::createGLInstance() const { |
| 300 return SkNEW_ARGS(GLPorterDuffXferProcessor, (*this)); | 300 return SkNEW_ARGS(GLPorterDuffXferProcessor, (*this)); |
| 301 } | 301 } |
| 302 | 302 |
| 303 GrXferProcessor::OptFlags | 303 GrXferProcessor::OptFlags |
| 304 PorterDuffXferProcessor::getOptimizations(const GrProcOptInfo& colorPOI, | 304 PorterDuffXferProcessor::getOptimizations(const GrProcOptInfo& colorPOI, |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 GR_DEFINE_XP_FACTORY_TEST(GrPorterDuffXPFactory); | 700 GR_DEFINE_XP_FACTORY_TEST(GrPorterDuffXPFactory); |
| 701 | 701 |
| 702 GrXPFactory* GrPorterDuffXPFactory::TestCreate(SkRandom* random, | 702 GrXPFactory* GrPorterDuffXPFactory::TestCreate(SkRandom* random, |
| 703 GrContext*, | 703 GrContext*, |
| 704 const GrDrawTargetCaps&, | 704 const GrDrawTargetCaps&, |
| 705 GrTexture*[]) { | 705 GrTexture*[]) { |
| 706 SkXfermode::Mode mode = SkXfermode::Mode(random->nextULessThan(SkXfermode::k
LastCoeffMode)); | 706 SkXfermode::Mode mode = SkXfermode::Mode(random->nextULessThan(SkXfermode::k
LastCoeffMode)); |
| 707 return GrPorterDuffXPFactory::Create(mode); | 707 return GrPorterDuffXPFactory::Create(mode); |
| 708 } | 708 } |
| 709 | 709 |
| OLD | NEW |