Make GrFragmentProcessor be non-refcounted and use std::unique_ptr.
Change-Id: I985e54a071338e99292a5aa2f42c92bc115b4008
Reviewed-on: https://skia-review.googlesource.com/32760
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/src/gpu/GrProcessorSet.h b/src/gpu/GrProcessorSet.h
index d3aaf6d..023c4df 100644
--- a/src/gpu/GrProcessorSet.h
+++ b/src/gpu/GrProcessorSet.h
@@ -25,7 +25,7 @@
public:
GrProcessorSet(GrPaint&&);
GrProcessorSet(SkBlendMode);
- GrProcessorSet(sk_sp<GrFragmentProcessor> colorFP);
+ GrProcessorSet(std::unique_ptr<GrFragmentProcessor> colorFP);
GrProcessorSet(GrProcessorSet&&);
GrProcessorSet(const GrProcessorSet&) = delete;
GrProcessorSet& operator=(const GrProcessorSet&) = delete;
@@ -42,10 +42,11 @@
const GrFragmentProcessor* colorFragmentProcessor(int idx) const {
SkASSERT(idx < fColorFragmentProcessorCnt);
- return fFragmentProcessors[idx + fFragmentProcessorOffset];
+ return fFragmentProcessors[idx + fFragmentProcessorOffset].get();
}
const GrFragmentProcessor* coverageFragmentProcessor(int idx) const {
- return fFragmentProcessors[idx + fColorFragmentProcessorCnt + fFragmentProcessorOffset];
+ return fFragmentProcessors[idx + fColorFragmentProcessorCnt +
+ fFragmentProcessorOffset].get();
}
const GrXferProcessor* xferProcessor() const {
@@ -57,6 +58,16 @@
return sk_ref_sp(fXP.fProcessor);
}
+ std::unique_ptr<const GrFragmentProcessor> detachColorFragmentProcessor(int idx) {
+ SkASSERT(idx < fColorFragmentProcessorCnt);
+ return std::move(fFragmentProcessors[idx + fFragmentProcessorOffset]);
+ }
+
+ std::unique_ptr<const GrFragmentProcessor> detachCoverageFragmentProcessor(int idx) {
+ return std::move(
+ fFragmentProcessors[idx + fFragmentProcessorOffset + fColorFragmentProcessorCnt]);
+ }
+
/** Comparisons are only legal on finalized processor sets. */
bool operator==(const GrProcessorSet& that) const;
bool operator!=(const GrProcessorSet& that) const { return !(*this == that); }
@@ -168,7 +179,7 @@
return fXP.fFactory;
}
- SkAutoSTArray<4, const GrFragmentProcessor*> fFragmentProcessors;
+ SkAutoSTArray<4, std::unique_ptr<const GrFragmentProcessor>> fFragmentProcessors;
XP fXP;
uint8_t fColorFragmentProcessorCnt = 0;
uint8_t fFragmentProcessorOffset = 0;