From b5cb6835c449c1c292b1ab124691a45d3d113694 Mon Sep 17 00:00:00 2001 From: Brian Salomon Date: Fri, 24 Feb 2017 11:01:15 -0500 Subject: Use construct/init pattern with GrPipeline to replace CreateAt. Change-Id: Ic6c7432a9a298a143ce4f2431e94c89a0ea79793 Reviewed-on: https://skia-review.googlesource.com/8938 Commit-Queue: Brian Salomon Reviewed-by: Greg Daniel --- src/gpu/GrPipeline.h | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src/gpu/GrPipeline.h') diff --git a/src/gpu/GrPipeline.h b/src/gpu/GrPipeline.h index a9d34aea9c..7f2ac79b4f 100644 --- a/src/gpu/GrPipeline.h +++ b/src/gpu/GrPipeline.h @@ -55,27 +55,36 @@ public: kSnapVerticesToPixelCenters_Flag = 0x2, }; - struct CreateArgs { + struct InitArgs { uint32_t fFlags = 0; GrDrawFace fDrawFace = GrDrawFace::kBoth; const GrProcessorSet* fProcessors = nullptr; const GrProcessorSet::FragmentProcessorAnalysis* fAnalysis; const GrUserStencilSettings* fUserStencil = &GrUserStencilSettings::kUnused; - GrAppliedClip* fAppliedClip = nullptr; + const GrAppliedClip* fAppliedClip = nullptr; GrRenderTarget* fRenderTarget = nullptr; const GrCaps* fCaps = nullptr; GrXferProcessor::DstTexture fDstTexture; }; - /** Creates a pipeline into a pre-allocated buffer */ - static GrPipeline* CreateAt(void* memory, const CreateArgs&, GrPipelineOptimizations*); + /** + * A Default constructed pipeline is unusable until init() is called. + **/ + GrPipeline() = default; /** * Creates a simple pipeline with default settings and no processors. The provided blend mode - * must be "Porter Duff" (<= kLastCoeffMode). + * must be "Porter Duff" (<= kLastCoeffMode). This pipeline is initialized without requiring + * a call to init(). **/ GrPipeline(GrRenderTarget*, SkBlendMode); + /** (Re)initializes a pipeline. After initialization the pipeline can be used. */ + GrPipelineOptimizations init(const InitArgs&); + + /** True if the pipeline has been initialized. */ + bool isInitialized() const { return SkToBool(fRenderTarget.get()); } + /// @} /////////////////////////////////////////////////////////////////////////// @@ -195,8 +204,6 @@ public: GrDrawFace getDrawFace() const { return static_cast(fDrawFace); } private: - GrPipeline() { /** Initialized in factory function*/ } - /** This is a continuation of the public "Flags" enum. */ enum PrivateFlags { kDisableOutputConversionToSRGB_Flag = 0x4, -- cgit v1.2.3