From 47dfc36e460356ef624ab90b82921ac6c8cc8e48 Mon Sep 17 00:00:00 2001 From: bsalomon Date: Mon, 10 Aug 2015 08:23:11 -0700 Subject: [PATCH] Use a factory function to create GrPipeline and remove unused member Review URL: https://codereview.chromium.org/1273803004 --- src/gpu/GrDrawTarget.cpp | 13 +++++++------ src/gpu/GrPipeline.h | 25 ++++++++++++++++++------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp index ca2d2d9005..21a80deb31 100644 --- a/src/gpu/GrDrawTarget.cpp +++ b/src/gpu/GrDrawTarget.cpp @@ -460,13 +460,14 @@ void GrDrawTarget::copySurface(GrSurface* dst, const GrPipeline* GrDrawTarget::setupPipeline(const PipelineInfo& pipelineInfo, void* pipelineAddr) { - return SkNEW_PLACEMENT_ARGS(pipelineAddr, GrPipeline, (*pipelineInfo.fPipelineBuilder, - pipelineInfo.fColorPOI, - pipelineInfo.fCoveragePOI, - *this->caps(), - *pipelineInfo.fScissor, - &pipelineInfo.fDstTexture)); + return GrPipeline::CreateAt(pipelineAddr, *pipelineInfo.fPipelineBuilder, + pipelineInfo.fColorPOI, + pipelineInfo.fCoveragePOI, + *this->caps(), + *pipelineInfo.fScissor, + &pipelineInfo.fDstTexture); } + /////////////////////////////////////////////////////////////////////////////// GrDrawTarget::PipelineInfo::PipelineInfo(const GrPipelineBuilder& pipelineBuilder, diff --git a/src/gpu/GrPipeline.h b/src/gpu/GrPipeline.h index 77adb368d7..61e6e9247d 100644 --- a/src/gpu/GrPipeline.h +++ b/src/gpu/GrPipeline.h @@ -29,12 +29,17 @@ class GrPipelineBuilder; */ class GrPipeline : public GrNonAtomicRef { public: - GrPipeline(const GrPipelineBuilder&, - const GrProcOptInfo& colorPOI, - const GrProcOptInfo& coveragePOI, - const GrCaps&, - const GrScissorState&, - const GrXferProcessor::DstTexture*); + /** Creates a pipeline into a pre-allocated buffer */ + static GrPipeline* CreateAt(void* memory, + const GrPipelineBuilder& pb, + const GrProcOptInfo& colorPOI, + const GrProcOptInfo& coveragePOI, + const GrCaps& caps, + const GrScissorState& scissor, + const GrXferProcessor::DstTexture* dst) { + return SkNEW_PLACEMENT_ARGS(memory, GrPipeline, (pb, colorPOI, coveragePOI, caps, scissor, + dst)); + } /* * Returns true if these pipelines are equivalent. Coord transforms may be applied either on @@ -108,6 +113,13 @@ public: } private: + GrPipeline(const GrPipelineBuilder&, + const GrProcOptInfo& colorPOI, + const GrProcOptInfo& coveragePOI, + const GrCaps&, + const GrScissorState&, + const GrXferProcessor::DstTexture*); + /** * Alter the program desc and inputs (attribs and processors) based on the blend optimization. */ @@ -149,7 +161,6 @@ private: int fNumColorStages; SkSTArray<8, const GrCoordTransform*, true> fCoordTransforms; - int fNumCoordTransforms; GrProgramDesc fDesc; typedef SkRefCnt INHERITED;