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

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

Issue 1278643006: Make GrBatch carry its own GrPipeline (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more 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/GrInOrderCommandBuilder.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 "GrGpu.h" 10 #include "GrGpu.h"
11 #include "GrPipeline.h" 11 #include "GrPipeline.h"
12 #include "GrRenderTarget.h" 12 #include "GrRenderTarget.h"
13 #include "SkRect.h" 13 #include "SkRect.h"
14 #include "SkTypes.h" 14 #include "SkTypes.h"
15 15
16 #include "batches/GrBatch.h" 16 #include "batches/GrBatch.h"
17 17
18 GrImmediateDrawTarget::GrImmediateDrawTarget(GrContext* context) 18 GrImmediateDrawTarget::GrImmediateDrawTarget(GrContext* context)
19 : INHERITED(context) 19 : INHERITED(context)
20 , fBatchTarget(this->getGpu()) 20 , fBatchTarget(this->getGpu())
21 , fDrawID(0) { 21 , fDrawID(0) {
22 } 22 }
23 23
24 GrImmediateDrawTarget::~GrImmediateDrawTarget() { 24 GrImmediateDrawTarget::~GrImmediateDrawTarget() {
25 this->reset(); 25 this->reset();
26 } 26 }
27 27
28 void GrImmediateDrawTarget::onDrawBatch(GrBatch* batch, 28 void GrImmediateDrawTarget::onDrawBatch(GrBatch* batch) {
29 const PipelineInfo& pipelineInfo) { 29 const GrXferProcessor& xp = *batch->pipeline()->getXferProcessor();
30 GrPipelineOptimizations opts; 30 GrRenderTarget* rt = batch->pipeline()->getRenderTarget();
31 SkAlignedSStorage<sizeof(GrPipeline)> pipelineStorage;
32 bool shouldDraw = this->setupPipelineAndShouldDraw(pipelineStorage.get(), pi pelineInfo, &opts);
33 GrPipeline* pipeline = reinterpret_cast<GrPipeline*>(pipelineStorage.get());
34 31
35 if (!shouldDraw) { 32 GrXferBarrierType barrierType;
36 pipeline->~GrPipeline(); 33 if (xp.willNeedXferBarrier(rt, *this->caps(), &barrierType)) {
37 return; 34 this->getGpu()->xferBarrier(rt, barrierType);
38 } 35 }
39 36
40 fBatchTarget.resetNumberOfDraws(); 37 fBatchTarget.resetNumberOfDraws();
41 38
42 batch->generateGeometry(&fBatchTarget); 39 batch->generateGeometry(&fBatchTarget);
43 batch->setNumberOfDraws(fBatchTarget.numberOfDraws()); 40 batch->setNumberOfDraws(fBatchTarget.numberOfDraws());
44 41
45 fBatchTarget.preFlush(); 42 fBatchTarget.preFlush();
46 fBatchTarget.flushNext(batch->numberOfDraws()); 43 fBatchTarget.flushNext(batch->numberOfDraws());
47 fBatchTarget.postFlush(); 44 fBatchTarget.postFlush();
48
49 pipeline->~GrPipeline();
50 } 45 }
51 46
52 void GrImmediateDrawTarget::onClear(const SkIRect& rect, GrColor color, 47 void GrImmediateDrawTarget::onClear(const SkIRect& rect, GrColor color,
53 GrRenderTarget* renderTarget) { 48 GrRenderTarget* renderTarget) {
54 this->getGpu()->clear(rect, color, renderTarget); 49 this->getGpu()->clear(rect, color, renderTarget);
55 } 50 }
56 51
57 void GrImmediateDrawTarget::onCopySurface(GrSurface* dst, 52 void GrImmediateDrawTarget::onCopySurface(GrSurface* dst,
58 GrSurface* src, 53 GrSurface* src,
59 const SkIRect& srcRect, 54 const SkIRect& srcRect,
(...skipping 15 matching lines...) Expand all
75 this->getGpu()->discard(renderTarget); 70 this->getGpu()->discard(renderTarget);
76 } 71 }
77 72
78 void GrImmediateDrawTarget::onReset() { 73 void GrImmediateDrawTarget::onReset() {
79 fBatchTarget.reset(); 74 fBatchTarget.reset();
80 } 75 }
81 76
82 void GrImmediateDrawTarget::onFlush() { 77 void GrImmediateDrawTarget::onFlush() {
83 ++fDrawID; 78 ++fDrawID;
84 } 79 }
85
86 bool
87 GrImmediateDrawTarget::setupPipelineAndShouldDraw(void* pipelineAddr,
88 const GrDrawTarget::PipelineIn fo& pipelineInfo,
89 GrPipelineOptimizations* opts) {
90 const GrPipeline* pipeline = this->setupPipeline(pipelineInfo, pipelineAddr, opts);
91
92 if (pipeline->mustSkip()) {
93 return false;
94 }
95
96 this->recordXferBarrierIfNecessary(pipeline);
97 return true;
98 }
99
100 void GrImmediateDrawTarget::recordXferBarrierIfNecessary(const GrPipeline* pipel ine) {
101 const GrXferProcessor& xp = *pipeline->getXferProcessor();
102 GrRenderTarget* rt = pipeline->getRenderTarget();
103
104 GrXferBarrierType barrierType;
105 if (xp.willNeedXferBarrier(rt, *this->caps(), &barrierType)) {
106 this->getGpu()->xferBarrier(rt, barrierType);
107 }
108 }
OLDNEW
« no previous file with comments | « src/gpu/GrImmediateDrawTarget.h ('k') | src/gpu/GrInOrderCommandBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698