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 GrPorterDuffXferProcessor_DEFINED | 8 #ifndef GrPorterDuffXferProcessor_DEFINED |
9 #define GrPorterDuffXferProcessor_DEFINED | 9 #define GrPorterDuffXferProcessor_DEFINED |
10 | 10 |
11 #include "GrTypes.h" | 11 #include "GrTypes.h" |
12 #include "GrXferProcessor.h" | 12 #include "GrXferProcessor.h" |
13 #include "SkXfermode.h" | 13 #include "SkXfermode.h" |
14 | 14 |
15 class GrProcOptInfo; | 15 class GrProcOptInfo; |
16 | 16 |
17 class GrPorterDuffXPFactory : public GrXPFactory { | 17 class GrPorterDuffXPFactory : public GrXPFactory { |
18 public: | 18 public: |
19 static GrXPFactory* Create(SkXfermode::Mode mode); | 19 static GrXPFactory* Create(SkXfermode::Mode mode); |
20 | 20 |
21 bool supportsRGBCoverage(GrColor /*knownColor*/, uint32_t /*knownColorFlags*
/) const override { | |
22 return true; | |
23 } | |
24 | |
25 void getInvariantBlendedColor(const GrProcOptInfo& colorPOI, | 21 void getInvariantBlendedColor(const GrProcOptInfo& colorPOI, |
26 GrXPFactory::InvariantBlendedColor*) const ove
rride; | 22 GrXPFactory::InvariantBlendedColor*) const ove
rride; |
27 | 23 |
| 24 static GrXferProcessor* CreateSrcOverXferProcessor(const GrCaps& caps, |
| 25 const GrProcOptInfo& colo
rPOI, |
| 26 const GrProcOptInfo& cove
ragePOI, |
| 27 bool hasMixedSamples, |
| 28 const GrXferProcessor::Ds
tTexture*); |
| 29 |
| 30 static inline void SrcOverInvariantBlendedColor( |
| 31 GrColor inputColor, |
| 32 GrColorComponentFlags validColor
Flags, |
| 33 bool isOpaque, |
| 34 GrXPFactory::InvariantBlendedCol
or* blendedColor) { |
| 35 if (!isOpaque) { |
| 36 blendedColor->fWillBlendWithDst = true; |
| 37 blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; |
| 38 return; |
| 39 } |
| 40 blendedColor->fWillBlendWithDst = false; |
| 41 |
| 42 blendedColor->fKnownColor = inputColor; |
| 43 blendedColor->fKnownColorFlags = validColorFlags; |
| 44 } |
| 45 |
| 46 static bool SrcOverWillNeedDstTexture(const GrCaps& caps, |
| 47 const GrProcOptInfo& colorPOI, |
| 48 const GrProcOptInfo& coveragePOI, |
| 49 bool hasMixedSamples); |
| 50 |
28 private: | 51 private: |
29 GrPorterDuffXPFactory(SkXfermode::Mode); | 52 GrPorterDuffXPFactory(SkXfermode::Mode); |
30 | 53 |
31 GrXferProcessor* onCreateXferProcessor(const GrCaps& caps, | 54 GrXferProcessor* onCreateXferProcessor(const GrCaps& caps, |
32 const GrProcOptInfo& colorPOI, | 55 const GrProcOptInfo& colorPOI, |
33 const GrProcOptInfo& coveragePOI, | 56 const GrProcOptInfo& coveragePOI, |
34 bool hasMixedSamples, | 57 bool hasMixedSamples, |
35 const DstTexture*) const override; | 58 const DstTexture*) const override; |
36 | 59 |
37 bool willReadDstColor(const GrCaps& caps, | 60 bool willReadDstColor(const GrCaps& caps, |
38 const GrProcOptInfo& colorPOI, | 61 const GrProcOptInfo& colorPOI, |
39 const GrProcOptInfo& coveragePOI, | 62 const GrProcOptInfo& coveragePOI, |
40 bool hasMixedSamples) const override; | 63 bool hasMixedSamples) const override; |
41 | 64 |
42 bool onIsEqual(const GrXPFactory& xpfBase) const override { | 65 bool onIsEqual(const GrXPFactory& xpfBase) const override { |
43 const GrPorterDuffXPFactory& xpf = xpfBase.cast<GrPorterDuffXPFactory>()
; | 66 const GrPorterDuffXPFactory& xpf = xpfBase.cast<GrPorterDuffXPFactory>()
; |
44 return fXfermode == xpf.fXfermode; | 67 return fXfermode == xpf.fXfermode; |
45 } | 68 } |
46 | 69 |
47 GR_DECLARE_XP_FACTORY_TEST; | 70 GR_DECLARE_XP_FACTORY_TEST; |
48 static void TestGetXPOutputTypes(const GrXferProcessor*, int* outPrimary, in
t* outSecondary); | 71 static void TestGetXPOutputTypes(const GrXferProcessor*, int* outPrimary, in
t* outSecondary); |
49 | 72 |
50 SkXfermode::Mode fXfermode; | 73 SkXfermode::Mode fXfermode; |
51 | 74 |
52 friend class GrPorterDuffTest; // for TestGetXPOutputTypes() | 75 friend class GrPorterDuffTest; // for TestGetXPOutputTypes() |
53 typedef GrXPFactory INHERITED; | 76 typedef GrXPFactory INHERITED; |
54 }; | 77 }; |
55 | 78 |
56 #endif | 79 #endif |
OLD | NEW |