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:
|
2016-06-09 15:01:03 +00:00
|
|
|
static sk_sp<GrXPFactory> Make(SkRegion::Op regionOp, bool invertCoverage = false);
|
2014-12-17 21:37:13 +00:00
|
|
|
|
2015-06-02 17:43:39 +00:00
|
|
|
void getInvariantBlendedColor(const GrProcOptInfo& colorPOI,
|
|
|
|
GrXPFactory::InvariantBlendedColor*) const override;
|
2014-12-17 21:37:13 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
GrCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage);
|
|
|
|
|
2015-05-19 16:29:46 +00:00
|
|
|
GrXferProcessor* onCreateXferProcessor(const GrCaps& caps,
|
2015-11-30 16:57:38 +00:00
|
|
|
const GrPipelineOptimizations& optimizations,
|
2015-06-08 22:11:04 +00:00
|
|
|
bool hasMixedSamples,
|
2015-05-26 16:49:05 +00:00
|
|
|
const DstTexture*) const override;
|
2015-02-06 15:02:37 +00:00
|
|
|
|
2016-05-06 16:41:16 +00:00
|
|
|
bool onWillReadDstColor(const GrCaps&, const GrPipelineOptimizations&) 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
|
|
|
|
|