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

Side by Side Diff: src/gpu/GrTestBatch.h

Issue 865313004: GMs now use batch (Closed) Base URL: https://skia.googlesource.com/skia.git@oval
Patch Set: fix Created 5 years, 10 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/GrInOrderDrawBuffer.cpp ('k') | no next file » | 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 #ifndef GrTestBatch_DEFINED
9 #define GrTestBatch_DEFINED
10
11 #include "GrBatch.h"
12
13 /*
14 * A simple batch only for testing purposes which actually doesn't batch at all, but can fit into
15 * the batch pipeline and generate arbitrary geometry
16 */
17 class GrTestBatch : public GrBatch {
18 public:
19 struct Geometry {
20 GrColor fColor;
21 };
22
23 virtual const char* name() const SK_OVERRIDE = 0;
24
25 void getInvariantOutputColor(GrInitInvariantOutput* out) const SK_OVERRIDE {
26 // When this is called on a batch, there is only one geometry bundle
27 if (fGeometryProcessor->hasVertexColor()) {
28 out->setUnknownFourComponents();
29 } else {
30 out->setKnownFourComponents(fGeometryProcessor->color());
31 }
32 }
33
34 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRID E {
35 out->setUnknownSingleComponent();
36 }
37
38 void initBatchOpt(const GrBatchOpt& batchOpt) {}
39
40 void initBatchTracker(const GrPipelineInfo& init) SK_OVERRIDE {
41 // Handle any color overrides
42 if (init.fColorIgnored) {
43 this->geoData(0)->fColor = GrColor_ILLEGAL;
44 } else if (GrColor_ILLEGAL != init.fOverrideColor) {
45 this->geoData(0)->fColor = init.fOverrideColor;
46 }
47
48 // setup batch properties
49 fBatch.fColorIgnored = init.fColorIgnored;
50 fBatch.fColor = this->geoData(0)->fColor;
51 fBatch.fUsesLocalCoords = init.fUsesLocalCoords;
52 fBatch.fCoverageIgnored = init.fCoverageIgnored;
53 }
54
55 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline ) SK_OVERRIDE {
56 batchTarget->initDraw(fGeometryProcessor, pipeline);
57
58 // TODO this is hacky, but the only way we have to initialize the GP is to use the
59 // GrPipelineInfo struct so we can generate the correct shader. Once we have GrBatch
60 // everywhere we can remove this nastiness
61 GrPipelineInfo init;
62 init.fColorIgnored = fBatch.fColorIgnored;
63 init.fOverrideColor = GrColor_ILLEGAL;
64 init.fCoverageIgnored = fBatch.fCoverageIgnored;
65 init.fUsesLocalCoords = fBatch.fUsesLocalCoords;
66 fGeometryProcessor->initBatchTracker(batchTarget->currentBatchTracker(), init);
67
68 this->onGenerateGeometry(batchTarget, pipeline);
69 }
70
71 protected:
72 GrTestBatch(const GrGeometryProcessor* gp) {
73 fGeometryProcessor.reset(SkRef(gp));
74 }
75
76 const GrGeometryProcessor* geometryProcessor() const { return fGeometryProce ssor; }
77
78 private:
79 virtual Geometry* geoData(int index) = 0;
80
81 bool onCombineIfPossible(GrBatch* t) SK_OVERRIDE {
82 return false;
83 }
84
85 virtual void onGenerateGeometry(GrBatchTarget* batchTarget, const GrPipeline * pipeline) = 0;
86
87 struct BatchTracker {
88 GrColor fColor;
89 bool fUsesLocalCoords;
90 bool fColorIgnored;
91 bool fCoverageIgnored;
92 };
93
94 SkAutoTUnref<const GrGeometryProcessor> fGeometryProcessor;
95 BatchTracker fBatch;
96 };
97
98 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrInOrderDrawBuffer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698