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

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

Issue 1835283002: Simplify GrDrawBatch uploads and token uage. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 4 years, 8 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/batches/GrTessellatingPathRenderer.cpp ('k') | src/gpu/batches/GrVertexBatch.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 #ifndef GrTestBatch_DEFINED 8 #ifndef GrTestBatch_DEFINED
9 #define GrTestBatch_DEFINED 9 #define GrTestBatch_DEFINED
10 10
11 #include "GrBatchFlushState.h" 11 #include "GrBatchFlushState.h"
12 #include "GrGeometryProcessor.h" 12 #include "GrGeometryProcessor.h"
13 13
14 #include "batches/GrVertexBatch.h" 14 #include "batches/GrVertexBatch.h"
15 15
16 /* 16 /*
17 * A simple batch only for testing purposes which actually doesn't batch at all, but can fit into 17 * A simple solid color batch only for testing purposes which actually doesn't b atch at all. It
18 * the batch pipeline and generate arbitrary geometry 18 * saves having to fill out some boiler plate methods.
19 */ 19 */
20 class GrTestBatch : public GrVertexBatch { 20 class GrTestBatch : public GrVertexBatch {
21 public: 21 public:
22 struct Geometry {
23 GrColor fColor;
24 };
25
26 virtual const char* name() const override = 0; 22 virtual const char* name() const override = 0;
27 23
28 void computePipelineOptimizations(GrInitInvariantOutput* color, 24 void computePipelineOptimizations(GrInitInvariantOutput* color,
29 GrInitInvariantOutput* coverage, 25 GrInitInvariantOutput* coverage,
30 GrBatchToXPOverrides* overrides) const ove rride { 26 GrBatchToXPOverrides* overrides) const ove rride {
31 // When this is called on a batch, there is only one geometry bundle 27 // When this is called on a batch, there is only one geometry bundle
32 color->setKnownFourComponents(this->geoData(0)->fColor); 28 color->setKnownFourComponents(fColor);
33 coverage->setUnknownSingleComponent(); 29 coverage->setUnknownSingleComponent();
34 } 30 }
35 31
36 void initBatchTracker(const GrXPOverridesForBatch& overrides) override { 32 void initBatchTracker(const GrXPOverridesForBatch& overrides) override {
37 // Handle any color overrides 33 overrides.getOverrideColorIfSet(&fColor);
38 if (!overrides.readsColor()) {
39 this->geoData(0)->fColor = GrColor_ILLEGAL;
40 }
41 overrides.getOverrideColorIfSet(&this->geoData(0)->fColor);
42 34
43 // setup batch properties 35 fOptimizations.fColorIgnored = !overrides.readsColor();
44 fBatch.fColorIgnored = !overrides.readsColor(); 36 fOptimizations.fUsesLocalCoords = overrides.readsLocalCoords();
45 fBatch.fColor = this->geoData(0)->fColor; 37 fOptimizations.fCoverageIgnored = !overrides.readsCoverage();
46 fBatch.fUsesLocalCoords = overrides.readsLocalCoords();
47 fBatch.fCoverageIgnored = !overrides.readsCoverage();
48 } 38 }
49 39
50 protected: 40 protected:
51 GrTestBatch(uint32_t classID, const GrGeometryProcessor* gp, const SkRect& b ounds) 41 GrTestBatch(uint32_t classID, const SkRect& bounds, GrColor color)
52 : INHERITED(classID) { 42 : INHERITED(classID)
53 fGeometryProcessor.reset(SkRef(gp)); 43 , fColor(color) {
54
55 this->setBounds(bounds); 44 this->setBounds(bounds);
56 } 45 }
57 46
58 const GrGeometryProcessor* geometryProcessor() const { return fGeometryProce ssor; } 47 struct Optimizations {
48 bool fColorIgnored = false;
49 bool fUsesLocalCoords = false;
50 bool fCoverageIgnored = false;
51 };
52
53 GrColor color() const { return fColor; }
54 const Optimizations optimizations() const { return fOptimizations; }
59 55
60 private: 56 private:
61 void onPrepareDraws(Target* target) const override {
62 target->initDraw(fGeometryProcessor);
63 this->generateGeometry(target);
64 }
65
66 virtual Geometry* geoData(int index) = 0;
67 virtual const Geometry* geoData(int index) const = 0;
68
69 bool onCombineIfPossible(GrBatch* t, const GrCaps&) override { 57 bool onCombineIfPossible(GrBatch* t, const GrCaps&) override {
70 return false; 58 return false;
71 } 59 }
72 60
73 virtual void generateGeometry(Target*) const = 0; 61 GrColor fColor;
74 62 Optimizations fOptimizations;
75 struct BatchTracker {
76 GrColor fColor;
77 bool fUsesLocalCoords;
78 bool fColorIgnored;
79 bool fCoverageIgnored;
80 };
81
82 SkAutoTUnref<const GrGeometryProcessor> fGeometryProcessor;
83 BatchTracker fBatch;
84 63
85 typedef GrVertexBatch INHERITED; 64 typedef GrVertexBatch INHERITED;
86 }; 65 };
87 66
88 #endif 67 #endif
OLDNEW
« no previous file with comments | « src/gpu/batches/GrTessellatingPathRenderer.cpp ('k') | src/gpu/batches/GrVertexBatch.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698