Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(191)

Side by Side Diff: src/gpu/effects/GrCoverageSetOpXP.h

Issue 808813002: Add Coverage Drawing XP (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Clean up Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 GrCoverageSetOpXP_DEFINED
9 #define GrCoverageSetOpXP_DEFINED
10
11 #include "GrTypes.h"
12 #include "GrXferProcessor.h"
13 #include "SkRegion.h"
14
15 class GrInvariantOutput;
16 class GrProcOptInfo;
17
18 /**
19 * This Xfer Processor is used to blend the coverage together with the Dst given a specific set
bsalomon 2014/12/16 17:35:56 "This xfer processor directly blends the src cover
egdaniel 2014/12/17 21:12:37 Done.
20 * operation. This XP will never use the output of the color stages. It is also legal to have the XP
21 * use the inverse coverage (1 - cov) as the Src to the blend instead of simply using coverage.
22 */
23 class GrCoverageSetOpXP : public GrXferProcessor {
24 public:
25 static GrXferProcessor* Create(SkRegion::Op regionOp, bool invertCoverage) {
26 return SkNEW_ARGS(GrCoverageSetOpXP, (regionOp, invertCoverage));
27 }
28
29 virtual ~GrCoverageSetOpXP();
30
31 virtual const char* name() const { return "Coverage Set Op"; }
32
33 void getGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBuilder* b) const SK_OVERRIDE;
34
35 GrGLXferProcessor* createGLInstance() const SK_OVERRIDE;
36
37 bool hasSecondaryOutput() const SK_OVERRIDE { return false; }
38
39 GrXferProcessor::OptFlags getOptimizations(const GrProcOptInfo& colorPOI,
40 const GrProcOptInfo& coveragePOI,
41 bool colorWriteDisabled,
42 bool doesStencilWrite,
43 GrColor* color,
44 const GrDrawTargetCaps& caps) SK_ OVERRIDE;
45
46 void getBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const SK_OVERRIDE;
47
48 bool invertCoverage() const { return fInvertCoverage; }
49
50 private:
51 GrCoverageSetOpXP(SkRegion::Op regionOp, bool fInvertCoverage);
52
53 bool onIsEqual(const GrXferProcessor& xpBase) const SK_OVERRIDE {
54 const GrCoverageSetOpXP& xp = xpBase.cast<GrCoverageSetOpXP>();
55 return (fRegionOp == xp.fRegionOp &&
56 fInvertCoverage == xp.fInvertCoverage);
57 }
58
59 SkRegion::Op fRegionOp;
60 bool fInvertCoverage;
61
62 typedef GrXferProcessor INHERITED;
63 };
64
65 ///////////////////////////////////////////////////////////////////////////////
66
67 class GrCoverageSetOpXPFactory : public GrXPFactory {
68 public:
69 static GrXPFactory* Create(SkRegion::Op regionOp, bool invertCoverage = fals e);
70
71 GrXferProcessor* createXferProcessor(const GrProcOptInfo& colorPOI,
72 const GrProcOptInfo& coveragePOI) const SK_OVERRIDE;
73
74 bool supportsRGBCoverage(GrColor knownColor, uint32_t knownColorFlags) const SK_OVERRIDE {
75 return false;
bsalomon 2014/12/16 17:35:56 seems like it does, right? It uses the color varia
egdaniel 2014/12/17 21:12:37 Done.
76 }
77
78 bool canApplyCoverage(const GrProcOptInfo& colorPOI, const GrProcOptInfo& co veragePOI,
79 bool colorWriteDisabled) const SK_OVERRIDE {
80 return true;
81 }
82
83 bool willBlendWithDst(const GrProcOptInfo& colorPOI, const GrProcOptInfo& co veragePOI,
84 bool colorWriteDisabled) const SK_OVERRIDE;
85
86 bool canTweakAlphaForCoverage() const SK_OVERRIDE { return false; }
bsalomon 2014/12/16 17:35:56 can't wait to kill this guy
egdaniel 2014/12/17 21:12:37 you are not alone...
87
88 bool getOpaqueAndKnownColor(const GrProcOptInfo& colorPOI,
89 const GrProcOptInfo& coveragePOI,
90 GrColor* solidColor,
91 uint32_t* solidColorKnownComponents) const SK_OV ERRIDE;
92
93 private:
94 GrCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage);
95
96 bool onIsEqual(const GrXPFactory& xpfBase) const SK_OVERRIDE {
97 const GrCoverageSetOpXPFactory& xpf = xpfBase.cast<GrCoverageSetOpXPFact ory>();
98 return fRegionOp == xpf.fRegionOp;
99 }
100
101 GR_DECLARE_XP_FACTORY_TEST;
102
103 SkRegion::Op fRegionOp;
104 bool fInvertCoverage;
105
106 typedef GrXPFactory INHERITED;
107 };
108 #endif
109
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698