2014-12-17 21:37:13 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2014 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GrCoverageSetOpXP_DEFINED
|
|
|
|
#define GrCoverageSetOpXP_DEFINED
|
|
|
|
|
|
|
|
#include "GrTypes.h"
|
|
|
|
#include "GrXferProcessor.h"
|
|
|
|
#include "SkRegion.h"
|
|
|
|
|
|
|
|
class GrProcOptInfo;
|
|
|
|
|
2015-02-17 15:34:43 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2014-12-17 21:37:13 +00:00
|
|
|
class GrCoverageSetOpXPFactory : public GrXPFactory {
|
|
|
|
public:
|
|
|
|
static GrXPFactory* Create(SkRegion::Op regionOp, bool invertCoverage = false);
|
|
|
|
|
2015-02-17 15:34:43 +00:00
|
|
|
bool supportsRGBCoverage(GrColor /*knownColor*/,
|
2015-03-26 01:17:31 +00:00
|
|
|
uint32_t /*knownColorFlags*/) const override {
|
2014-12-17 21:37:13 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-03-26 01:17:31 +00:00
|
|
|
bool canTweakAlphaForCoverage() const override { return false; }
|
2014-12-17 21:37:13 +00:00
|
|
|
|
2014-12-18 20:44:55 +00:00
|
|
|
void getInvariantOutput(const GrProcOptInfo& colorPOI, const GrProcOptInfo& coveragePOI,
|
2015-03-26 01:17:31 +00:00
|
|
|
GrXPFactory::InvariantOutput*) const override;
|
2014-12-17 21:37:13 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
GrCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage);
|
|
|
|
|
2015-02-17 19:15:47 +00:00
|
|
|
GrXferProcessor* onCreateXferProcessor(const GrDrawTargetCaps& caps,
|
|
|
|
const GrProcOptInfo& colorPOI,
|
2015-02-06 15:02:37 +00:00
|
|
|
const GrProcOptInfo& coveragePOI,
|
2015-03-26 01:17:31 +00:00
|
|
|
const GrDeviceCoordTexture* dstCopy) const override;
|
2015-02-06 15:02:37 +00:00
|
|
|
|
2015-02-17 19:15:47 +00:00
|
|
|
bool willReadDstColor(const GrDrawTargetCaps& /*caps*/,
|
|
|
|
const GrProcOptInfo& /*colorPOI*/,
|
2015-03-26 01:17:31 +00:00
|
|
|
const GrProcOptInfo& /*coveragePOI*/) const override {
|
2015-02-13 17:00:33 +00:00
|
|
|
return false;
|
|
|
|
}
|
2015-02-06 15:02:37 +00:00
|
|
|
|
2015-03-26 01:17:31 +00:00
|
|
|
bool onIsEqual(const GrXPFactory& xpfBase) const override {
|
2014-12-17 21:37:13 +00:00
|
|
|
const GrCoverageSetOpXPFactory& xpf = xpfBase.cast<GrCoverageSetOpXPFactory>();
|
|
|
|
return fRegionOp == xpf.fRegionOp;
|
|
|
|
}
|
|
|
|
|
|
|
|
GR_DECLARE_XP_FACTORY_TEST;
|
|
|
|
|
|
|
|
SkRegion::Op fRegionOp;
|
|
|
|
bool fInvertCoverage;
|
|
|
|
|
|
|
|
typedef GrXPFactory INHERITED;
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|