OLD | NEW |
| (Empty) |
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 GrDrawState; | |
16 class GrInvariantOutput; | |
17 | |
18 class GrPorterDuffXferProcessor : public GrXferProcessor { | |
19 public: | |
20 static GrXferProcessor* Create(GrBlendCoeff srcBlend, GrBlendCoeff dstBlend)
{ | |
21 return SkNEW_ARGS(GrPorterDuffXferProcessor, (srcBlend, dstBlend)); | |
22 } | |
23 | |
24 virtual ~GrPorterDuffXferProcessor(); | |
25 | |
26 virtual const char* name() const { return "Porter Duff"; } | |
27 | |
28 virtual void getGLProcessorKey(const GrGLCaps& caps, | |
29 GrProcessorKeyBuilder* b) const SK_OVERRIDE; | |
30 | |
31 virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE; | |
32 | |
33 private: | |
34 GrPorterDuffXferProcessor(GrBlendCoeff srcBlend, GrBlendCoeff dstBlend); | |
35 | |
36 virtual bool onIsEqual(const GrFragmentProcessor& fpBase) const SK_OVERRIDE
{ | |
37 const GrPorterDuffXferProcessor& xp = fpBase.cast<GrPorterDuffXferProces
sor>(); | |
38 if (fSrcBlend != xp.fSrcBlend || fDstBlend != xp.fDstBlend) { | |
39 return false; | |
40 } | |
41 return true; | |
42 } | |
43 | |
44 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVE
RRIDE; | |
45 | |
46 GrBlendCoeff fSrcBlend; | |
47 GrBlendCoeff fDstBlend; | |
48 | |
49 typedef GrXferProcessor INHERITED; | |
50 }; | |
51 | |
52 /////////////////////////////////////////////////////////////////////////////// | |
53 | |
54 class GrPorterDuffXPFactory : public GrXPFactory { | |
55 public: | |
56 static GrXPFactory* Create(SkXfermode::Mode mode); | |
57 | |
58 static GrXPFactory* Create(SkXfermode::Coeff src, SkXfermode::Coeff dst) { | |
59 return SkNEW_ARGS(GrPorterDuffXPFactory, ((GrBlendCoeff)(src), (GrBlendC
oeff)(dst))); | |
60 } | |
61 | |
62 static GrXPFactory* Create(GrBlendCoeff src, GrBlendCoeff dst) { | |
63 return SkNEW_ARGS(GrPorterDuffXPFactory, (src, dst)); | |
64 } | |
65 | |
66 const GrXferProcessor* createXferProcessor() const SK_OVERRIDE; | |
67 | |
68 bool supportsRGBCoverage(GrColor knownColor, uint32_t knownColorFlags) const
SK_OVERRIDE; | |
69 | |
70 private: | |
71 GrPorterDuffXPFactory(GrBlendCoeff src, GrBlendCoeff dst) | |
72 : fSrc(src), fDst(dst) {} | |
73 | |
74 GrBlendCoeff fSrc; | |
75 GrBlendCoeff fDst; | |
76 | |
77 typedef GrXPFactory INHERITED; | |
78 }; | |
79 | |
80 #endif | |
OLD | NEW |