| 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 #ifndef GrDisableColorXP_DEFINED | 8 #ifndef GrDisableColorXP_DEFINED |
| 9 #define GrDisableColorXP_DEFINED | 9 #define GrDisableColorXP_DEFINED |
| 10 | 10 |
| 11 #include "GrTypes.h" | 11 #include "GrTypes.h" |
| 12 #include "GrXferProcessor.h" | 12 #include "GrXferProcessor.h" |
| 13 | 13 |
| 14 class GrProcOptInfo; | 14 class GrProcOptInfo; |
| 15 | 15 |
| 16 /** | 16 /** |
| 17 * This xfer processor disables color writing. Thus color and coverage and ignor
ed and no blending | 17 * This xfer processor disables color writing. Thus color and coverage and ignor
ed and no blending |
| 18 * occurs. This XP is usful for things like stenciling. | 18 * occurs. This XP is usful for things like stenciling. |
| 19 */ | 19 */ |
| 20 class GrDisableColorXP : public GrXferProcessor { | 20 class GrDisableColorXP : public GrXferProcessor { |
| 21 public: | 21 public: |
| 22 static GrXferProcessor* Create() { | 22 static GrXferProcessor* Create() { |
| 23 return SkNEW(GrDisableColorXP); | 23 return SkNEW(GrDisableColorXP); |
| 24 } | 24 } |
| 25 | 25 |
| 26 ~GrDisableColorXP() SK_OVERRIDE {}; | 26 ~GrDisableColorXP() SK_OVERRIDE {}; |
| 27 | 27 |
| 28 const char* name() const SK_OVERRIDE { return "Disable Color"; } | 28 const char* name() const SK_OVERRIDE { return "Disable Color"; } |
| 29 | 29 |
| 30 void getGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBuilder* b) const
SK_OVERRIDE; | |
| 31 | |
| 32 GrGLXferProcessor* createGLInstance() const SK_OVERRIDE; | 30 GrGLXferProcessor* createGLInstance() const SK_OVERRIDE; |
| 33 | 31 |
| 34 bool hasSecondaryOutput() const SK_OVERRIDE { return false; } | 32 bool hasSecondaryOutput() const SK_OVERRIDE { return false; } |
| 35 | 33 |
| 36 GrXferProcessor::OptFlags getOptimizations(const GrProcOptInfo& colorPOI, | 34 GrXferProcessor::OptFlags getOptimizations(const GrProcOptInfo& colorPOI, |
| 37 const GrProcOptInfo& coveragePOI, | 35 const GrProcOptInfo& coveragePOI, |
| 38 bool doesStencilWrite, | 36 bool doesStencilWrite, |
| 39 GrColor* color, | 37 GrColor* color, |
| 40 const GrDrawTargetCaps& caps) SK_
OVERRIDE { | 38 const GrDrawTargetCaps& caps) SK_
OVERRIDE { |
| 41 return GrXferProcessor::kIgnoreColor_OptFlag | GrXferProcessor::kIgnoreC
overage_OptFlag; | 39 return GrXferProcessor::kIgnoreColor_OptFlag | GrXferProcessor::kIgnoreC
overage_OptFlag; |
| 42 } | 40 } |
| 43 | 41 |
| 44 void getBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const SK_OVERRIDE; | 42 void getBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const SK_OVERRIDE; |
| 45 | 43 |
| 46 private: | 44 private: |
| 47 GrDisableColorXP(); | 45 GrDisableColorXP(); |
| 48 | 46 |
| 47 void onGetGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBuilder* b) con
st SK_OVERRIDE; |
| 48 |
| 49 bool onIsEqual(const GrXferProcessor& xpBase) const SK_OVERRIDE { | 49 bool onIsEqual(const GrXferProcessor& xpBase) const SK_OVERRIDE { |
| 50 return true; | 50 return true; |
| 51 } | 51 } |
| 52 | 52 |
| 53 typedef GrXferProcessor INHERITED; | 53 typedef GrXferProcessor INHERITED; |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 /////////////////////////////////////////////////////////////////////////////// | 56 /////////////////////////////////////////////////////////////////////////////// |
| 57 | 57 |
| 58 class GrDisableColorXPFactory : public GrXPFactory { | 58 class GrDisableColorXPFactory : public GrXPFactory { |
| 59 public: | 59 public: |
| 60 static GrXPFactory* Create() { | 60 static GrXPFactory* Create() { |
| 61 return SkNEW(GrDisableColorXPFactory); | 61 return SkNEW(GrDisableColorXPFactory); |
| 62 } | 62 } |
| 63 | 63 |
| 64 GrXferProcessor* createXferProcessor(const GrProcOptInfo& colorPOI, | |
| 65 const GrProcOptInfo& coveragePOI) const
SK_OVERRIDE; | |
| 66 | |
| 67 bool supportsRGBCoverage(GrColor knownColor, uint32_t knownColorFlags) const
SK_OVERRIDE { | 64 bool supportsRGBCoverage(GrColor knownColor, uint32_t knownColorFlags) const
SK_OVERRIDE { |
| 68 return true; | 65 return true; |
| 69 } | 66 } |
| 70 | 67 |
| 71 bool canApplyCoverage(const GrProcOptInfo& colorPOI, | 68 bool canApplyCoverage(const GrProcOptInfo& colorPOI, |
| 72 const GrProcOptInfo& coveragePOI) const SK_OVERRIDE { | 69 const GrProcOptInfo& coveragePOI) const SK_OVERRIDE { |
| 73 return true; | 70 return true; |
| 74 } | 71 } |
| 75 | 72 |
| 76 bool canTweakAlphaForCoverage() const SK_OVERRIDE { return true; } | 73 bool canTweakAlphaForCoverage() const SK_OVERRIDE { return true; } |
| 77 | 74 |
| 78 void getInvariantOutput(const GrProcOptInfo& colorPOI, const GrProcOptInfo&
coveragePOI, | 75 void getInvariantOutput(const GrProcOptInfo& colorPOI, const GrProcOptInfo&
coveragePOI, |
| 79 GrXPFactory::InvariantOutput* output) const SK_OVERR
IDE { | 76 GrXPFactory::InvariantOutput* output) const SK_OVERR
IDE { |
| 80 output->fBlendedColorFlags = 0; | 77 output->fBlendedColorFlags = 0; |
| 81 output->fWillBlendWithDst = 0; | 78 output->fWillBlendWithDst = 0; |
| 82 } | 79 } |
| 83 | 80 |
| 84 bool willReadDst() const SK_OVERRIDE { return false; } | |
| 85 | |
| 86 private: | 81 private: |
| 87 GrDisableColorXPFactory(); | 82 GrDisableColorXPFactory(); |
| 88 | 83 |
| 84 GrXferProcessor* onCreateXferProcessor(const GrProcOptInfo& colorPOI, |
| 85 const GrProcOptInfo& coveragePOI, |
| 86 const GrDeviceCoordTexture* dstCopy)
const SK_OVERRIDE; |
| 87 |
| 88 bool willReadDstColor() const SK_OVERRIDE { return false; } |
| 89 |
| 89 bool onIsEqual(const GrXPFactory& xpfBase) const SK_OVERRIDE { | 90 bool onIsEqual(const GrXPFactory& xpfBase) const SK_OVERRIDE { |
| 90 return true; | 91 return true; |
| 91 } | 92 } |
| 92 | 93 |
| 93 GR_DECLARE_XP_FACTORY_TEST; | 94 GR_DECLARE_XP_FACTORY_TEST; |
| 94 | 95 |
| 95 typedef GrXPFactory INHERITED; | 96 typedef GrXPFactory INHERITED; |
| 96 }; | 97 }; |
| 97 | 98 |
| 98 #endif | 99 #endif |
| 99 | 100 |
| OLD | NEW |