From 85cd78dd6ca93cc5bd4a504b201c3215426d885b Mon Sep 17 00:00:00 2001 From: bsalomon Date: Fri, 31 Jul 2015 12:15:50 -0700 Subject: [PATCH] Speculative fix for http://crbug.com/515966 BUG=chromium:515966 Review URL: https://codereview.chromium.org/1268723005 --- src/gpu/GrDrawTarget.cpp | 16 ++++++++-------- src/gpu/GrDrawTarget.h | 2 +- src/gpu/GrImmediateDrawTarget.cpp | 8 +++++--- src/gpu/GrImmediateDrawTarget.h | 2 +- src/gpu/GrTargetCommands.h | 2 +- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp index 37faacf383..60dd58693a 100644 --- a/src/gpu/GrDrawTarget.cpp +++ b/src/gpu/GrDrawTarget.cpp @@ -445,14 +445,14 @@ void GrDrawTarget::copySurface(GrSurface* dst, this->onCopySurface(dst, src, clippedSrcRect, clippedDstPoint); } -void GrDrawTarget::setupPipeline(const PipelineInfo& pipelineInfo, - GrPipeline* pipeline) { - SkNEW_PLACEMENT_ARGS(pipeline, GrPipeline, (*pipelineInfo.fPipelineBuilder, - pipelineInfo.fColorPOI, - pipelineInfo.fCoveragePOI, - *this->caps(), - *pipelineInfo.fScissor, - &pipelineInfo.fDstTexture)); +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)); } /////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/GrDrawTarget.h b/src/gpu/GrDrawTarget.h index 753ea85881..022c6b3e2d 100644 --- a/src/gpu/GrDrawTarget.h +++ b/src/gpu/GrDrawTarget.h @@ -244,7 +244,7 @@ protected: GrXferProcessor::DstTexture fDstTexture; }; - void setupPipeline(const PipelineInfo& pipelineInfo, GrPipeline* pipeline); + const GrPipeline* setupPipeline(const PipelineInfo& pipelineInfo, void* pipelineAddr); private: virtual void onReset() = 0; diff --git a/src/gpu/GrImmediateDrawTarget.cpp b/src/gpu/GrImmediateDrawTarget.cpp index 0c4210ad70..0099b1dc8c 100644 --- a/src/gpu/GrImmediateDrawTarget.cpp +++ b/src/gpu/GrImmediateDrawTarget.cpp @@ -27,8 +27,10 @@ GrImmediateDrawTarget::~GrImmediateDrawTarget() { void GrImmediateDrawTarget::onDrawBatch(GrBatch* batch, const PipelineInfo& pipelineInfo) { SkAlignedSStorage pipelineStorage; + bool shouldDraw = this->setupPipelineAndShouldDraw(pipelineStorage.get(), pipelineInfo); GrPipeline* pipeline = reinterpret_cast(pipelineStorage.get()); - if (!this->setupPipelineAndShouldDraw(pipeline, pipelineInfo)) { + + if (!shouldDraw) { pipeline->~GrPipeline(); return; } @@ -82,9 +84,9 @@ void GrImmediateDrawTarget::onFlush() { } bool -GrImmediateDrawTarget::setupPipelineAndShouldDraw(GrPipeline* pipeline, +GrImmediateDrawTarget::setupPipelineAndShouldDraw(void* pipelineAddr, const GrDrawTarget::PipelineInfo& pipelineInfo) { - this->setupPipeline(pipelineInfo, pipeline); + const GrPipeline* pipeline = this->setupPipeline(pipelineInfo, pipelineAddr); if (pipeline->mustSkip()) { return false; diff --git a/src/gpu/GrImmediateDrawTarget.h b/src/gpu/GrImmediateDrawTarget.h index c7f4163739..b6fda07599 100644 --- a/src/gpu/GrImmediateDrawTarget.h +++ b/src/gpu/GrImmediateDrawTarget.h @@ -74,7 +74,7 @@ private: bool isIssued(uint32_t drawID) override { return drawID != fDrawID; } - bool SK_WARN_UNUSED_RESULT setupPipelineAndShouldDraw(GrPipeline*, + bool SK_WARN_UNUSED_RESULT setupPipelineAndShouldDraw(void* pipelineAddr, const GrDrawTarget::PipelineInfo&); void recordXferBarrierIfNecessary(const GrPipeline*); diff --git a/src/gpu/GrTargetCommands.h b/src/gpu/GrTargetCommands.h index 8b47cfdfa6..9be1210ba8 100644 --- a/src/gpu/GrTargetCommands.h +++ b/src/gpu/GrTargetCommands.h @@ -83,7 +83,7 @@ private: // This function is only for getting the location in memory where we will create our // pipeline object. - GrPipeline* pipelineLocation() { return reinterpret_cast(fPipeline.get()); } + void* pipelineLocation() { return fPipeline.get(); } const GrPipeline* getPipeline() const { return reinterpret_cast(fPipeline.get()); -- 2.34.1