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

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

Issue 1126043007: Adding immediate mode draw target for debug (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tweaks Created 5 years, 7 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/GrInOrderDrawBuffer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "GrImmediateDrawTarget.h"
9
10 #include "GrBatch.h"
11 #include "GrGpu.h"
12 #include "GrPipeline.h"
13 #include "GrRenderTarget.h"
14 #include "SkRect.h"
15 #include "SkTypes.h"
16
17 GrImmediateDrawTarget::GrImmediateDrawTarget(GrContext* context)
18 : INHERITED(context)
19 , fBatchTarget(this->getGpu())
20 , fDrawID(0) {
21 }
22
23 GrImmediateDrawTarget::~GrImmediateDrawTarget() {
24 this->reset();
25 }
26
27 void GrImmediateDrawTarget::onDrawBatch(GrBatch* batch,
28 const PipelineInfo& pipelineInfo) {
29 SkAlignedSStorage<sizeof(GrPipeline)> pipelineStorage;
30 GrPipeline* pipeline = reinterpret_cast<GrPipeline*>(pipelineStorage.get());
31 if (!this->setupPipelineAndShouldDraw(pipeline, pipelineInfo)) {
32 pipeline->~GrPipeline();
33 return;
34 }
35
36 batch->initBatchTracker(pipeline->getInitBatchTracker());
37
38 fBatchTarget.resetNumberOfDraws();
39
40 batch->generateGeometry(&fBatchTarget, pipeline);
41 batch->setNumberOfDraws(fBatchTarget.numberOfDraws());
42
43 fBatchTarget.preFlush();
44 fBatchTarget.flushNext(batch->numberOfDraws());
45 fBatchTarget.postFlush();
46
47 pipeline->~GrPipeline();
48 }
49
50 void GrImmediateDrawTarget::onClear(const SkIRect* rect, GrColor color,
51 bool canIgnoreRect, GrRenderTarget* renderTa rget) {
52 this->getGpu()->clear(rect, color, canIgnoreRect, renderTarget);
53 }
54
55 void GrImmediateDrawTarget::onCopySurface(GrSurface* dst,
56 GrSurface* src,
57 const SkIRect& srcRect,
58 const SkIPoint& dstPoint) {
59 SkASSERT(this->getGpu()->canCopySurface(dst, src, srcRect, dstPoint));
60 this->getGpu()->copySurface(dst, src, srcRect, dstPoint);
61 }
62
63 void GrImmediateDrawTarget::clearStencilClip(const SkIRect& rect,
64 bool insideClip,
65 GrRenderTarget* renderTarget) {
66 this->getGpu()->clearStencilClip(rect, insideClip, renderTarget);
67 }
68
69 void GrImmediateDrawTarget::discard(GrRenderTarget* renderTarget) {
70 if (!this->caps()->discardRenderTargetSupport()) {
71 return;
72 }
73
74 this->getGpu()->discard(renderTarget);
75 }
76
77 void GrImmediateDrawTarget::onReset() {
78 fBatchTarget.reset();
79 }
80
81 void GrImmediateDrawTarget::onFlush() {
82 ++fDrawID;
83 }
84
85 bool
86 GrImmediateDrawTarget::setupPipelineAndShouldDraw(GrPipeline* pipeline,
87 const GrDrawTarget::PipelineIn fo& pipelineInfo) {
88 this->setupPipeline(pipelineInfo, pipeline);
89
90 if (pipeline->mustSkip()) {
91 return false;
92 }
93
94 this->recordXferBarrierIfNecessary(pipeline);
95 return true;
96 }
97
98 void GrImmediateDrawTarget::recordXferBarrierIfNecessary(const GrPipeline* pipel ine) {
99 const GrXferProcessor& xp = *pipeline->getXferProcessor();
100 GrRenderTarget* rt = pipeline->getRenderTarget();
101
102 GrXferBarrierType barrierType;
103 if (xp.willNeedXferBarrier(rt, *this->caps(), &barrierType)) {
104 this->getGpu()->xferBarrier(rt, barrierType);
105 }
106 }
OLDNEW
« no previous file with comments | « src/gpu/GrImmediateDrawTarget.h ('k') | src/gpu/GrInOrderDrawBuffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698