add API for Op creation
Introduce three calls on GrOp: Make, MakeWithExtraMemory,
and MakeWithProcessorSet. Instead of returning
unique_ptr<GrOp>, they return a type of GrOp::OpOwner.
GrOp::OpOwner safely deletes the op when it goes out
of scope for either new/delete or GrOpMemoryPool
allocations.
In order to make the code easier to refactor, I
eliminated MakeArg from the helpers.
Change-Id: Icfd697906f3147a8734575d08bd7195e7517383a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/323778
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Herb Derby <herb@google.com>
diff --git a/src/gpu/ops/GrDefaultPathRenderer.cpp b/src/gpu/ops/GrDefaultPathRenderer.cpp
index 95802c8..3f8113f 100644
--- a/src/gpu/ops/GrDefaultPathRenderer.cpp
+++ b/src/gpu/ops/GrDefaultPathRenderer.cpp
@@ -344,16 +344,16 @@
public:
DEFINE_OP_CLASS_ID
- static std::unique_ptr<GrDrawOp> Make(GrRecordingContext* context,
- GrPaint&& paint,
- const SkPath& path,
- SkScalar tolerance,
- uint8_t coverage,
- const SkMatrix& viewMatrix,
- bool isHairline,
- GrAAType aaType,
- const SkRect& devBounds,
- const GrUserStencilSettings* stencilSettings) {
+ static GrOp::Owner Make(GrRecordingContext* context,
+ GrPaint&& paint,
+ const SkPath& path,
+ SkScalar tolerance,
+ uint8_t coverage,
+ const SkMatrix& viewMatrix,
+ bool isHairline,
+ GrAAType aaType,
+ const SkRect& devBounds,
+ const GrUserStencilSettings* stencilSettings) {
return Helper::FactoryHelper<DefaultPathOp>(context, std::move(paint), path, tolerance,
coverage, viewMatrix, isHairline, aaType,
devBounds, stencilSettings);
@@ -369,12 +369,12 @@
}
}
- DefaultPathOp(const Helper::MakeArgs& helperArgs, const SkPMColor4f& color, const SkPath& path,
+ DefaultPathOp(GrProcessorSet* processorSet, const SkPMColor4f& color, const SkPath& path,
SkScalar tolerance, uint8_t coverage, const SkMatrix& viewMatrix, bool isHairline,
GrAAType aaType, const SkRect& devBounds,
const GrUserStencilSettings* stencilSettings)
: INHERITED(ClassID())
- , fHelper(helperArgs, aaType, stencilSettings)
+ , fHelper(processorSet, aaType, stencilSettings)
, fColor(color)
, fCoverage(coverage)
, fViewMatrix(viewMatrix)
@@ -661,7 +661,7 @@
GrAA(aaType == GrAAType::kMSAA), viewM, bounds, &localMatrix);
} else {
bool stencilPass = stencilOnly || passCount > 1;
- std::unique_ptr<GrDrawOp> op;
+ GrOp::Owner op;
if (stencilPass) {
GrPaint stencilPaint;
stencilPaint.setXPFactory(GrDisableColorXPFactory::Get());