| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 | 78 |
| 79 private: | 79 private: |
| 80 GrGLSLProgramDataManager::UniformHandle fKUni; | 80 GrGLSLProgramDataManager::UniformHandle fKUni; |
| 81 | 81 |
| 82 typedef GrGLSLFragmentProcessor INHERITED; | 82 typedef GrGLSLFragmentProcessor INHERITED; |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 /////////////////////////////////////////////////////////////////////////////// | 85 /////////////////////////////////////////////////////////////////////////////// |
| 86 | 86 |
| 87 GrArithmeticFP::GrArithmeticFP(float k1, float k2, float k3, float k4, bool enfo
rcePMColor, | 87 GrArithmeticFP::GrArithmeticFP(float k1, float k2, float k3, float k4, bool enfo
rcePMColor, |
| 88 const GrFragmentProcessor* dst) | 88 sk_sp<GrFragmentProcessor> dst) |
| 89 : fK1(k1), fK2(k2), fK3(k3), fK4(k4), fEnforcePMColor(enforcePMColor) { | 89 : fK1(k1), fK2(k2), fK3(k3), fK4(k4), fEnforcePMColor(enforcePMColor) { |
| 90 this->initClassID<GrArithmeticFP>(); | 90 this->initClassID<GrArithmeticFP>(); |
| 91 | 91 |
| 92 SkASSERT(dst); | 92 SkASSERT(dst); |
| 93 SkDEBUGCODE(int dstIndex = )this->registerChildProcessor(dst); | 93 SkDEBUGCODE(int dstIndex = )this->registerChildProcessor(std::move(dst)); |
| 94 SkASSERT(0 == dstIndex); | 94 SkASSERT(0 == dstIndex); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void GrArithmeticFP::onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKe
yBuilder* b) const { | 97 void GrArithmeticFP::onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKe
yBuilder* b) const { |
| 98 GLArithmeticFP::GenKey(*this, caps, b); | 98 GLArithmeticFP::GenKey(*this, caps, b); |
| 99 } | 99 } |
| 100 | 100 |
| 101 GrGLSLFragmentProcessor* GrArithmeticFP::onCreateGLSLInstance() const { | 101 GrGLSLFragmentProcessor* GrArithmeticFP::onCreateGLSLInstance() const { |
| 102 return new GLArithmeticFP; | 102 return new GLArithmeticFP; |
| 103 } | 103 } |
| 104 | 104 |
| 105 bool GrArithmeticFP::onIsEqual(const GrFragmentProcessor& fpBase) const { | 105 bool GrArithmeticFP::onIsEqual(const GrFragmentProcessor& fpBase) const { |
| 106 const GrArithmeticFP& fp = fpBase.cast<GrArithmeticFP>(); | 106 const GrArithmeticFP& fp = fpBase.cast<GrArithmeticFP>(); |
| 107 return fK1 == fp.fK1 && | 107 return fK1 == fp.fK1 && |
| 108 fK2 == fp.fK2 && | 108 fK2 == fp.fK2 && |
| 109 fK3 == fp.fK3 && | 109 fK3 == fp.fK3 && |
| 110 fK4 == fp.fK4 && | 110 fK4 == fp.fK4 && |
| 111 fEnforcePMColor == fp.fEnforcePMColor; | 111 fEnforcePMColor == fp.fEnforcePMColor; |
| 112 } | 112 } |
| 113 | 113 |
| 114 void GrArithmeticFP::onComputeInvariantOutput(GrInvariantOutput* inout) const { | 114 void GrArithmeticFP::onComputeInvariantOutput(GrInvariantOutput* inout) const { |
| 115 // TODO: optimize this | 115 // TODO: optimize this |
| 116 inout->setToUnknown(GrInvariantOutput::kWill_ReadInput); | 116 inout->setToUnknown(GrInvariantOutput::kWill_ReadInput); |
| 117 } | 117 } |
| 118 | 118 |
| 119 /////////////////////////////////////////////////////////////////////////////// | 119 /////////////////////////////////////////////////////////////////////////////// |
| 120 | 120 |
| 121 const GrFragmentProcessor* GrArithmeticFP::TestCreate(GrProcessorTestData* d) { | 121 sk_sp<GrFragmentProcessor> GrArithmeticFP::TestCreate(GrProcessorTestData* d) { |
| 122 float k1 = d->fRandom->nextF(); | 122 float k1 = d->fRandom->nextF(); |
| 123 float k2 = d->fRandom->nextF(); | 123 float k2 = d->fRandom->nextF(); |
| 124 float k3 = d->fRandom->nextF(); | 124 float k3 = d->fRandom->nextF(); |
| 125 float k4 = d->fRandom->nextF(); | 125 float k4 = d->fRandom->nextF(); |
| 126 bool enforcePMColor = d->fRandom->nextBool(); | 126 bool enforcePMColor = d->fRandom->nextBool(); |
| 127 | 127 |
| 128 SkAutoTUnref<const GrFragmentProcessor> dst(GrProcessorUnitTest::CreateChild
FP(d)); | 128 sk_sp<GrFragmentProcessor> dst(GrProcessorUnitTest::MakeChildFP(d)); |
| 129 return new GrArithmeticFP(k1, k2, k3, k4, enforcePMColor, dst); | 129 return GrArithmeticFP::Make(k1, k2, k3, k4, enforcePMColor, std::move(dst)); |
| 130 } | 130 } |
| 131 | 131 |
| 132 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrArithmeticFP); | 132 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrArithmeticFP); |
| 133 | 133 |
| 134 /////////////////////////////////////////////////////////////////////////////// | 134 /////////////////////////////////////////////////////////////////////////////// |
| 135 // Xfer Processor | 135 // Xfer Processor |
| 136 /////////////////////////////////////////////////////////////////////////////// | 136 /////////////////////////////////////////////////////////////////////////////// |
| 137 | 137 |
| 138 class ArithmeticXP : public GrXferProcessor { | 138 class ArithmeticXP : public GrXferProcessor { |
| 139 public: | 139 public: |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 blendedColor->fWillBlendWithDst = true; | 276 blendedColor->fWillBlendWithDst = true; |
| 277 | 277 |
| 278 // TODO: We could try to optimize this more. For example if fK1 and fK3 are
zero, then we won't | 278 // TODO: We could try to optimize this more. For example if fK1 and fK3 are
zero, then we won't |
| 279 // be blending the color with dst at all so we can know what the output colo
r is (up to the | 279 // be blending the color with dst at all so we can know what the output colo
r is (up to the |
| 280 // valid color components passed in). | 280 // valid color components passed in). |
| 281 blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; | 281 blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; |
| 282 } | 282 } |
| 283 | 283 |
| 284 GR_DEFINE_XP_FACTORY_TEST(GrArithmeticXPFactory); | 284 GR_DEFINE_XP_FACTORY_TEST(GrArithmeticXPFactory); |
| 285 | 285 |
| 286 const GrXPFactory* GrArithmeticXPFactory::TestCreate(GrProcessorTestData* d) { | 286 sk_sp<GrXPFactory> GrArithmeticXPFactory::TestCreate(GrProcessorTestData* d) { |
| 287 float k1 = d->fRandom->nextF(); | 287 float k1 = d->fRandom->nextF(); |
| 288 float k2 = d->fRandom->nextF(); | 288 float k2 = d->fRandom->nextF(); |
| 289 float k3 = d->fRandom->nextF(); | 289 float k3 = d->fRandom->nextF(); |
| 290 float k4 = d->fRandom->nextF(); | 290 float k4 = d->fRandom->nextF(); |
| 291 bool enforcePMColor = d->fRandom->nextBool(); | 291 bool enforcePMColor = d->fRandom->nextBool(); |
| 292 | 292 |
| 293 return GrArithmeticXPFactory::Create(k1, k2, k3, k4, enforcePMColor); | 293 return GrArithmeticXPFactory::Make(k1, k2, k3, k4, enforcePMColor); |
| 294 } | 294 } |
| 295 | 295 |
| 296 #endif | 296 #endif |
| OLD | NEW |