Allow RegionOp to be used for stenciling

Change-Id: I03473573bfe3da1a2d0fff40205094f7ba9e13af
Reviewed-on: https://skia-review.googlesource.com/29320
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
Brian Salomon 2017-08-01 11:09:09 -04:00 committed by Skia Commit-Bot
parent e779ab17b6
commit 8514ebfb19

View File

@ -52,19 +52,23 @@ namespace {
class RegionOp final : public GrMeshDrawOp { class RegionOp final : public GrMeshDrawOp {
private: private:
using Helper = GrSimpleMeshDrawOpHelper; using Helper = GrSimpleMeshDrawOpHelperWithStencil;
public: public:
DEFINE_OP_CLASS_ID DEFINE_OP_CLASS_ID
static std::unique_ptr<GrDrawOp> Make(GrPaint&& paint, const SkMatrix& viewMatrix, static std::unique_ptr<GrDrawOp> Make(GrPaint&& paint, const SkMatrix& viewMatrix,
const SkRegion& region, GrAAType aaType) { const SkRegion& region, GrAAType aaType,
return Helper::FactoryHelper<RegionOp>(std::move(paint), viewMatrix, region, aaType); const GrUserStencilSettings* stencilSettings = nullptr) {
return Helper::FactoryHelper<RegionOp>(std::move(paint), viewMatrix, region, aaType,
stencilSettings);
} }
RegionOp(const Helper::MakeArgs& helperArgs, GrColor color, const SkMatrix& viewMatrix, RegionOp(const Helper::MakeArgs& helperArgs, GrColor color, const SkMatrix& viewMatrix,
const SkRegion& region, GrAAType aaType) const SkRegion& region, GrAAType aaType, const GrUserStencilSettings* stencilSettings)
: INHERITED(ClassID()), fHelper(helperArgs, aaType), fViewMatrix(viewMatrix) { : INHERITED(ClassID())
, fHelper(helperArgs, aaType, stencilSettings)
, fViewMatrix(viewMatrix) {
RegionInfo& info = fRegions.push_back(); RegionInfo& info = fRegions.push_back();
info.fColor = color; info.fColor = color;
info.fRegion = region; info.fRegion = region;
@ -200,7 +204,8 @@ GR_DRAW_OP_TEST_DEFINE(RegionOp) {
if (GrFSAAType::kUnifiedMSAA == fsaaType && random->nextBool()) { if (GrFSAAType::kUnifiedMSAA == fsaaType && random->nextBool()) {
aaType = GrAAType::kMSAA; aaType = GrAAType::kMSAA;
} }
return RegionOp::Make(std::move(paint), viewMatrix, region, aaType); return RegionOp::Make(std::move(paint), viewMatrix, region, aaType,
GrGetRandomStencil(random, context));
} }
#endif #endif