diff options
author | 2017-08-11 09:40:37 -0400 | |
---|---|---|
committer | 2017-08-11 14:13:26 +0000 | |
commit | aff329b8e9b239bca1d93b13a914fbef45ccf7fe (patch) | |
tree | 06ba42a557c6695f145bcf4956c981fc87af55ff /src/gpu/GrFragmentProcessor.h | |
parent | e2cbd0451832ec71d1b498e0f64d02b7d096b2b7 (diff) |
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>
Diffstat (limited to 'src/gpu/GrFragmentProcessor.h')
-rw-r--r-- | src/gpu/GrFragmentProcessor.h | 44 |
1 files changed, 20 insertions, 24 deletions
diff --git a/src/gpu/GrFragmentProcessor.h b/src/gpu/GrFragmentProcessor.h index 0784031d30..29a302b100 100644 --- a/src/gpu/GrFragmentProcessor.h +++ b/src/gpu/GrFragmentProcessor.h @@ -23,7 +23,7 @@ class GrSwizzle; GrCoordTransforms to receive a transformation of the local coordinates that map from local space to the fragment being processed. */ -class GrFragmentProcessor : public GrResourceIOProcessor, public GrProgramElement { +class GrFragmentProcessor : public GrResourceIOProcessor { public: /** * In many instances (e.g. SkShader::asFragmentProcessor() implementations) it is desirable to @@ -33,7 +33,8 @@ public: * does so by returning a parent FP that multiplies the passed in FPs output by the parent's * input alpha. The passed in FP will not receive an input color. */ - static sk_sp<GrFragmentProcessor> MulOutputByInputAlpha(sk_sp<GrFragmentProcessor>); + static std::unique_ptr<GrFragmentProcessor> MulOutputByInputAlpha( + std::unique_ptr<GrFragmentProcessor>); /** * This assumes that the input color to the returned processor will be unpremul and that the @@ -41,38 +42,42 @@ public: * The result of the returned processor is a premul of its input color modulated by the child * processor's premul output. */ - static sk_sp<GrFragmentProcessor> MakeInputPremulAndMulByOutput(sk_sp<GrFragmentProcessor>); + static std::unique_ptr<GrFragmentProcessor> MakeInputPremulAndMulByOutput( + std::unique_ptr<GrFragmentProcessor>); /** * Returns a parent fragment processor that adopts the passed fragment processor as a child. * The parent will ignore its input color and instead feed the passed in color as input to the * child. */ - static sk_sp<GrFragmentProcessor> OverrideInput(sk_sp<GrFragmentProcessor>, GrColor4f); + static std::unique_ptr<GrFragmentProcessor> OverrideInput(std::unique_ptr<GrFragmentProcessor>, + GrColor4f); /** * Returns a fragment processor that premuls the input before calling the passed in fragment * processor. */ - static sk_sp<GrFragmentProcessor> PremulInput(sk_sp<GrFragmentProcessor>); + static std::unique_ptr<GrFragmentProcessor> PremulInput(std::unique_ptr<GrFragmentProcessor>); /** * Returns a fragment processor that calls the passed in fragment processor, and then premuls * the output. */ - static sk_sp<GrFragmentProcessor> PremulOutput(sk_sp<GrFragmentProcessor>); + static std::unique_ptr<GrFragmentProcessor> PremulOutput(std::unique_ptr<GrFragmentProcessor>); /** * Returns a fragment processor that calls the passed in fragment processor, and then unpremuls * the output. */ - static sk_sp<GrFragmentProcessor> UnpremulOutput(sk_sp<GrFragmentProcessor>); + static std::unique_ptr<GrFragmentProcessor> UnpremulOutput( + std::unique_ptr<GrFragmentProcessor>); /** * Returns a fragment processor that calls the passed in fragment processor, and then swizzles * the output. */ - static sk_sp<GrFragmentProcessor> SwizzleOutput(sk_sp<GrFragmentProcessor>, const GrSwizzle&); + static std::unique_ptr<GrFragmentProcessor> SwizzleOutput(std::unique_ptr<GrFragmentProcessor>, + const GrSwizzle&); /** * Returns a fragment processor that runs the passed in array of fragment processors in a @@ -82,15 +87,14 @@ public: * * The array elements with be moved. */ - static sk_sp<GrFragmentProcessor> RunInSeries(sk_sp<GrFragmentProcessor>*, int cnt); - - ~GrFragmentProcessor() override; + static std::unique_ptr<GrFragmentProcessor> RunInSeries(std::unique_ptr<GrFragmentProcessor>*, + int cnt); /** * Makes a copy of this fragment processor that draws equivalently to the original. * If the processor has child processors they are cloned as well. */ - virtual sk_sp<GrFragmentProcessor> clone() const = 0; + virtual std::unique_ptr<GrFragmentProcessor> clone() const = 0; GrGLSLFragmentProcessor* createGLSLInstance() const; @@ -117,6 +121,8 @@ public: bool instantiate(GrResourceProvider*) const; + void markPendingExecution() const; + /** Do any of the coordtransforms for this processor require local coords? */ bool usesLocalCoords() const { return SkToBool(fFlags & kUsesLocalCoords_Flag); } @@ -309,15 +315,9 @@ protected: * processors will allow the ProgramBuilder to automatically handle their transformed coords and * texture accesses and mangle their uniform and output color names. */ - int registerChildProcessor(sk_sp<GrFragmentProcessor> child); + int registerChildProcessor(std::unique_ptr<GrFragmentProcessor> child); private: - void addPendingIOs() const override { GrResourceIOProcessor::addPendingIOs(); } - void removeRefs() const override { GrResourceIOProcessor::removeRefs(); } - void pendingIOComplete() const override { GrResourceIOProcessor::pendingIOComplete(); } - - void notifyRefCntIsZero() const final; - virtual GrColor4f constantOutputForConstantInput(GrColor4f /* inputColor */) const { SkFAIL("Subclass must override this if advertising this optimization."); return GrColor4f::TransparentBlack(); @@ -350,11 +350,7 @@ private: SkSTArray<4, const GrCoordTransform*, true> fCoordTransforms; - /** - * This is not SkSTArray<1, sk_sp<GrFragmentProcessor>> because this class holds strong - * references until notifyRefCntIsZero and then it holds pending executions. - */ - SkSTArray<1, GrFragmentProcessor*, true> fChildProcessors; + SkSTArray<1, std::unique_ptr<GrFragmentProcessor>, true> fChildProcessors; typedef GrResourceIOProcessor INHERITED; }; |