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

Unified Diff: src/gpu/effects/GrCoverageSetOpXP.cpp

Issue 860383007: Move GrXferProcessor subclasses into cpp files (Closed) Base URL: https://skia.googlesource.com/skia.git@playDstCpy
Patch Set: Rebase Created 5 years, 10 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/effects/GrCoverageSetOpXP.h ('k') | src/gpu/effects/GrCustomXfermode.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/effects/GrCoverageSetOpXP.cpp
diff --git a/src/gpu/effects/GrCoverageSetOpXP.cpp b/src/gpu/effects/GrCoverageSetOpXP.cpp
index 7025d20395f2af1b71327506e6b64bbc50756178..f0ec1f9b00b4d7c74ce4431cb6dd551ab54c811e 100644
--- a/src/gpu/effects/GrCoverageSetOpXP.cpp
+++ b/src/gpu/effects/GrCoverageSetOpXP.cpp
@@ -15,22 +15,70 @@
#include "gl/builders/GrGLFragmentShaderBuilder.h"
#include "gl/builders/GrGLProgramBuilder.h"
-class GrGLCoverageSetOpXP : public GrGLXferProcessor {
+/**
+ * This xfer processor directly blends the the src coverage with the dst using a set operator. It is
+ * useful for rendering coverage masks using CSG. It can optionally invert the src coverage before
+ * applying the set operator.
+ * */
+class CoverageSetOpXP : public GrXferProcessor {
public:
- GrGLCoverageSetOpXP(const GrProcessor&) {}
+ static GrXferProcessor* Create(SkRegion::Op regionOp, bool invertCoverage) {
+ return SkNEW_ARGS(CoverageSetOpXP, (regionOp, invertCoverage));
+ }
+
+ ~CoverageSetOpXP() SK_OVERRIDE;
+
+ const char* name() const SK_OVERRIDE { return "Coverage Set Op"; }
+
+ GrGLXferProcessor* createGLInstance() const SK_OVERRIDE;
+
+ bool hasSecondaryOutput() const SK_OVERRIDE { return false; }
+
+ GrXferProcessor::OptFlags getOptimizations(const GrProcOptInfo& colorPOI,
+ const GrProcOptInfo& coveragePOI,
+ bool doesStencilWrite,
+ GrColor* color,
+ const GrDrawTargetCaps& caps) SK_OVERRIDE;
+
+ void getBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const SK_OVERRIDE;
+
+ bool invertCoverage() const { return fInvertCoverage; }
+
+private:
+ CoverageSetOpXP(SkRegion::Op regionOp, bool fInvertCoverage);
+
+ void onGetGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBuilder* b) const SK_OVERRIDE;
+
+ bool onIsEqual(const GrXferProcessor& xpBase) const SK_OVERRIDE {
+ const CoverageSetOpXP& xp = xpBase.cast<CoverageSetOpXP>();
+ return (fRegionOp == xp.fRegionOp &&
+ fInvertCoverage == xp.fInvertCoverage);
+ }
+
+ SkRegion::Op fRegionOp;
+ bool fInvertCoverage;
+
+ typedef GrXferProcessor INHERITED;
+};
+
+///////////////////////////////////////////////////////////////////////////////
+
+class GLCoverageSetOpXP : public GrGLXferProcessor {
+public:
+ GLCoverageSetOpXP(const GrProcessor&) {}
- ~GrGLCoverageSetOpXP() SK_OVERRIDE {}
+ ~GLCoverageSetOpXP() SK_OVERRIDE {}
static void GenKey(const GrProcessor& processor, const GrGLCaps& caps,
GrProcessorKeyBuilder* b) {
- const GrCoverageSetOpXP& xp = processor.cast<GrCoverageSetOpXP>();
+ const CoverageSetOpXP& xp = processor.cast<CoverageSetOpXP>();
uint32_t key = xp.invertCoverage() ? 0x0 : 0x1;
b->add32(key);
};
private:
void onEmitCode(const EmitArgs& args) SK_OVERRIDE {
- const GrCoverageSetOpXP& xp = args.fXP.cast<GrCoverageSetOpXP>();
+ const CoverageSetOpXP& xp = args.fXP.cast<CoverageSetOpXP>();
GrGLFPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
if (xp.invertCoverage()) {
@@ -47,34 +95,34 @@ private:
///////////////////////////////////////////////////////////////////////////////
-GrCoverageSetOpXP::GrCoverageSetOpXP(SkRegion::Op regionOp, bool invertCoverage)
+CoverageSetOpXP::CoverageSetOpXP(SkRegion::Op regionOp, bool invertCoverage)
: fRegionOp(regionOp)
, fInvertCoverage(invertCoverage) {
- this->initClassID<GrCoverageSetOpXP>();
+ this->initClassID<CoverageSetOpXP>();
}
-GrCoverageSetOpXP::~GrCoverageSetOpXP() {
+CoverageSetOpXP::~CoverageSetOpXP() {
}
-void GrCoverageSetOpXP::onGetGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBuilder* b) const {
- GrGLCoverageSetOpXP::GenKey(*this, caps, b);
+void CoverageSetOpXP::onGetGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBuilder* b) const {
+ GLCoverageSetOpXP::GenKey(*this, caps, b);
}
-GrGLXferProcessor* GrCoverageSetOpXP::createGLInstance() const {
- return SkNEW_ARGS(GrGLCoverageSetOpXP, (*this));
+GrGLXferProcessor* CoverageSetOpXP::createGLInstance() const {
+ return SkNEW_ARGS(GLCoverageSetOpXP, (*this));
}
GrXferProcessor::OptFlags
-GrCoverageSetOpXP::getOptimizations(const GrProcOptInfo& colorPOI,
- const GrProcOptInfo& coveragePOI,
- bool doesStencilWrite,
- GrColor* color,
- const GrDrawTargetCaps& caps) {
+CoverageSetOpXP::getOptimizations(const GrProcOptInfo& colorPOI,
+ const GrProcOptInfo& coveragePOI,
+ bool doesStencilWrite,
+ GrColor* color,
+ const GrDrawTargetCaps& caps) {
// We never look at the color input
return GrXferProcessor::kIgnoreColor_OptFlag;
}
-void GrCoverageSetOpXP::getBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const {
+void CoverageSetOpXP::getBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const {
switch (fRegionOp) {
case SkRegion::kReplace_Op:
blendInfo->fSrcBlend = kOne_GrBlendCoeff;
@@ -183,7 +231,7 @@ GrXferProcessor*
GrCoverageSetOpXPFactory::onCreateXferProcessor(const GrProcOptInfo& colorPOI,
const GrProcOptInfo& covPOI,
const GrDeviceCoordTexture* dstCopy) const {
- return GrCoverageSetOpXP::Create(fRegionOp, fInvertCoverage);
+ return CoverageSetOpXP::Create(fRegionOp, fInvertCoverage);
}
void GrCoverageSetOpXPFactory::getInvariantOutput(const GrProcOptInfo& colorPOI,
« no previous file with comments | « src/gpu/effects/GrCoverageSetOpXP.h ('k') | src/gpu/effects/GrCustomXfermode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698