• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2014 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 GrPorterDuffXferProcessor_DEFINED
9 #define GrPorterDuffXferProcessor_DEFINED
10 
11 #include "GrTypes.h"
12 #include "GrXferProcessor.h"
13 #include "SkXfermode.h"
14 
15 class GrProcOptInfo;
16 
17 class GrPorterDuffXPFactory : public GrXPFactory {
18 public:
19     static GrXPFactory* Create(SkXfermode::Mode mode);
20 
21     bool supportsRGBCoverage(GrColor knownColor, uint32_t knownColorFlags) const override;
22 
23     void getInvariantOutput(const GrProcOptInfo& colorPOI, const GrProcOptInfo& coveragePOI,
24                             GrXPFactory::InvariantOutput*) const override;
25 
26 private:
27     GrPorterDuffXPFactory(GrBlendCoeff src, GrBlendCoeff dst);
28 
29     GrXferProcessor* onCreateXferProcessor(const GrDrawTargetCaps& caps,
30                                            const GrProcOptInfo& colorPOI,
31                                            const GrProcOptInfo& coveragePOI,
32                                            const GrDeviceCoordTexture* dstCopy) const override;
33 
34     bool willReadDstColor(const GrDrawTargetCaps& caps,
35                           const GrProcOptInfo& colorPOI,
36                           const GrProcOptInfo& coveragePOI) const override;
37 
onIsEqual(const GrXPFactory & xpfBase)38     bool onIsEqual(const GrXPFactory& xpfBase) const override {
39         const GrPorterDuffXPFactory& xpf = xpfBase.cast<GrPorterDuffXPFactory>();
40         return (fSrcCoeff == xpf.fSrcCoeff && fDstCoeff == xpf.fDstCoeff);
41     }
42 
43     GR_DECLARE_XP_FACTORY_TEST;
44 
45     GrBlendCoeff fSrcCoeff;
46     GrBlendCoeff fDstCoeff;
47 
48     typedef GrXPFactory INHERITED;
49 };
50 
51 #endif
52