| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright 2015 Google Inc. | |
| 3 * | |
| 4 * Use of this source code is governed by a BSD-style license that can be | |
| 5 * found in the LICENSE file. | |
| 6 */ | |
| 7 | |
| 8 #ifndef GrCustomXfermodePriv_DEFINED | |
| 9 #define GrCustomXfermodePriv_DEFINED | |
| 10 | |
| 11 #include "GrCaps.h" | |
| 12 #include "GrCoordTransform.h" | |
| 13 #include "GrFragmentProcessor.h" | |
| 14 #include "GrTextureAccess.h" | |
| 15 #include "GrXferProcessor.h" | |
| 16 #include "SkXfermode.h" | |
| 17 | |
| 18 class GrGLCaps; | |
| 19 class GrGLFragmentProcessor; | |
| 20 class GrInvariantOutput; | |
| 21 class GrProcessorKeyBuilder; | |
| 22 class GrTexture; | |
| 23 | |
| 24 /////////////////////////////////////////////////////////////////////////////// | |
| 25 // Fragment Processor | |
| 26 /////////////////////////////////////////////////////////////////////////////// | |
| 27 | |
| 28 class GrCustomXferFP : public GrFragmentProcessor { | |
| 29 public: | |
| 30 GrCustomXferFP(GrProcessorDataManager*, SkXfermode::Mode mode, GrTexture* ba
ckground); | |
| 31 | |
| 32 const char* name() const override { return "Custom Xfermode"; } | |
| 33 | |
| 34 SkXfermode::Mode mode() const { return fMode; } | |
| 35 const GrTextureAccess& backgroundAccess() const { return fBackgroundAccess;
} | |
| 36 | |
| 37 private: | |
| 38 GrGLFragmentProcessor* onCreateGLInstance() const override; | |
| 39 | |
| 40 void onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) c
onst override; | |
| 41 | |
| 42 bool onIsEqual(const GrFragmentProcessor& other) const override; | |
| 43 | |
| 44 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; | |
| 45 | |
| 46 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | |
| 47 | |
| 48 SkXfermode::Mode fMode; | |
| 49 GrCoordTransform fBackgroundTransform; | |
| 50 GrTextureAccess fBackgroundAccess; | |
| 51 | |
| 52 typedef GrFragmentProcessor INHERITED; | |
| 53 }; | |
| 54 | |
| 55 /////////////////////////////////////////////////////////////////////////////// | |
| 56 // Xfer Processor | |
| 57 /////////////////////////////////////////////////////////////////////////////// | |
| 58 | |
| 59 class GrCustomXPFactory : public GrXPFactory { | |
| 60 public: | |
| 61 GrCustomXPFactory(SkXfermode::Mode mode); | |
| 62 | |
| 63 bool supportsRGBCoverage(GrColor knownColor, uint32_t knownColorFlags) const
override { | |
| 64 return true; | |
| 65 } | |
| 66 | |
| 67 void getInvariantBlendedColor(const GrProcOptInfo& colorPOI, | |
| 68 GrXPFactory::InvariantBlendedColor*) const ove
rride; | |
| 69 | |
| 70 private: | |
| 71 GrXferProcessor* onCreateXferProcessor(const GrCaps& caps, | |
| 72 const GrProcOptInfo& colorPOI, | |
| 73 const GrProcOptInfo& coveragePOI, | |
| 74 bool hasMixedSamples, | |
| 75 const DstTexture*) const override; | |
| 76 | |
| 77 bool willReadDstColor(const GrCaps& caps, | |
| 78 const GrProcOptInfo& colorPOI, | |
| 79 const GrProcOptInfo& coveragePOI, | |
| 80 bool hasMixedSamples) const override; | |
| 81 | |
| 82 bool onIsEqual(const GrXPFactory& xpfBase) const override { | |
| 83 const GrCustomXPFactory& xpf = xpfBase.cast<GrCustomXPFactory>(); | |
| 84 return fMode == xpf.fMode; | |
| 85 } | |
| 86 | |
| 87 GR_DECLARE_XP_FACTORY_TEST; | |
| 88 | |
| 89 SkXfermode::Mode fMode; | |
| 90 GrBlendEquation fHWBlendEquation; | |
| 91 | |
| 92 typedef GrXPFactory INHERITED; | |
| 93 }; | |
| 94 #endif | |
| 95 | |
| OLD | NEW |