Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(708)

Side by Side Diff: src/gpu/GrImmediateDrawTarget.cpp

Issue 1268723005: Speculative fix for http://crbug.com/515966 (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address comment Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/GrImmediateDrawTarget.h ('k') | src/gpu/GrTargetCommands.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrImmediateDrawTarget.h" 8 #include "GrImmediateDrawTarget.h"
9 9
10 #include "GrBatch.h" 10 #include "GrBatch.h"
11 #include "GrGpu.h" 11 #include "GrGpu.h"
12 #include "GrPipeline.h" 12 #include "GrPipeline.h"
13 #include "GrRenderTarget.h" 13 #include "GrRenderTarget.h"
14 #include "SkRect.h" 14 #include "SkRect.h"
15 #include "SkTypes.h" 15 #include "SkTypes.h"
16 16
17 GrImmediateDrawTarget::GrImmediateDrawTarget(GrContext* context) 17 GrImmediateDrawTarget::GrImmediateDrawTarget(GrContext* context)
18 : INHERITED(context) 18 : INHERITED(context)
19 , fBatchTarget(this->getGpu()) 19 , fBatchTarget(this->getGpu())
20 , fDrawID(0) { 20 , fDrawID(0) {
21 } 21 }
22 22
23 GrImmediateDrawTarget::~GrImmediateDrawTarget() { 23 GrImmediateDrawTarget::~GrImmediateDrawTarget() {
24 this->reset(); 24 this->reset();
25 } 25 }
26 26
27 void GrImmediateDrawTarget::onDrawBatch(GrBatch* batch, 27 void GrImmediateDrawTarget::onDrawBatch(GrBatch* batch,
28 const PipelineInfo& pipelineInfo) { 28 const PipelineInfo& pipelineInfo) {
29 SkAlignedSStorage<sizeof(GrPipeline)> pipelineStorage; 29 SkAlignedSStorage<sizeof(GrPipeline)> pipelineStorage;
30 bool shouldDraw = this->setupPipelineAndShouldDraw(pipelineStorage.get(), pi pelineInfo);
30 GrPipeline* pipeline = reinterpret_cast<GrPipeline*>(pipelineStorage.get()); 31 GrPipeline* pipeline = reinterpret_cast<GrPipeline*>(pipelineStorage.get());
31 if (!this->setupPipelineAndShouldDraw(pipeline, pipelineInfo)) { 32
33 if (!shouldDraw) {
32 pipeline->~GrPipeline(); 34 pipeline->~GrPipeline();
33 return; 35 return;
34 } 36 }
35 37
36 batch->initBatchTracker(pipeline->infoForPrimitiveProcessor()); 38 batch->initBatchTracker(pipeline->infoForPrimitiveProcessor());
37 39
38 fBatchTarget.resetNumberOfDraws(); 40 fBatchTarget.resetNumberOfDraws();
39 41
40 batch->generateGeometry(&fBatchTarget, pipeline); 42 batch->generateGeometry(&fBatchTarget, pipeline);
41 batch->setNumberOfDraws(fBatchTarget.numberOfDraws()); 43 batch->setNumberOfDraws(fBatchTarget.numberOfDraws());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 77
76 void GrImmediateDrawTarget::onReset() { 78 void GrImmediateDrawTarget::onReset() {
77 fBatchTarget.reset(); 79 fBatchTarget.reset();
78 } 80 }
79 81
80 void GrImmediateDrawTarget::onFlush() { 82 void GrImmediateDrawTarget::onFlush() {
81 ++fDrawID; 83 ++fDrawID;
82 } 84 }
83 85
84 bool 86 bool
85 GrImmediateDrawTarget::setupPipelineAndShouldDraw(GrPipeline* pipeline, 87 GrImmediateDrawTarget::setupPipelineAndShouldDraw(void* pipelineAddr,
86 const GrDrawTarget::PipelineIn fo& pipelineInfo) { 88 const GrDrawTarget::PipelineIn fo& pipelineInfo) {
87 this->setupPipeline(pipelineInfo, pipeline); 89 const GrPipeline* pipeline = this->setupPipeline(pipelineInfo, pipelineAddr) ;
88 90
89 if (pipeline->mustSkip()) { 91 if (pipeline->mustSkip()) {
90 return false; 92 return false;
91 } 93 }
92 94
93 this->recordXferBarrierIfNecessary(pipeline); 95 this->recordXferBarrierIfNecessary(pipeline);
94 return true; 96 return true;
95 } 97 }
96 98
97 void GrImmediateDrawTarget::recordXferBarrierIfNecessary(const GrPipeline* pipel ine) { 99 void GrImmediateDrawTarget::recordXferBarrierIfNecessary(const GrPipeline* pipel ine) {
98 const GrXferProcessor& xp = *pipeline->getXferProcessor(); 100 const GrXferProcessor& xp = *pipeline->getXferProcessor();
99 GrRenderTarget* rt = pipeline->getRenderTarget(); 101 GrRenderTarget* rt = pipeline->getRenderTarget();
100 102
101 GrXferBarrierType barrierType; 103 GrXferBarrierType barrierType;
102 if (xp.willNeedXferBarrier(rt, *this->caps(), &barrierType)) { 104 if (xp.willNeedXferBarrier(rt, *this->caps(), &barrierType)) {
103 this->getGpu()->xferBarrier(rt, barrierType); 105 this->getGpu()->xferBarrier(rt, barrierType);
104 } 106 }
105 } 107 }
OLDNEW
« no previous file with comments | « src/gpu/GrImmediateDrawTarget.h ('k') | src/gpu/GrTargetCommands.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698