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

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

Issue 2110853004: Even more hiding of Geometry structs in GrBatch subclasses. (Closed) Base URL: https://chromium.googlesource.com/skia.git@moregeom
Patch Set: Address comments Created 4 years, 5 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/GrDefaultPathRenderer.cpp ('k') | src/gpu/batches/GrDrawAtlasBatch.cpp » ('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 GrDrawAtlasBatch_DEFINED 8 #ifndef GrDrawAtlasBatch_DEFINED
9 #define GrDrawAtlasBatch_DEFINED 9 #define GrDrawAtlasBatch_DEFINED
10 10
11 #include "GrColor.h" 11 #include "GrColor.h"
12 #include "GrDefaultGeoProcFactory.h" 12 #include "GrDefaultGeoProcFactory.h"
13 #include "GrVertexBatch.h" 13 #include "GrVertexBatch.h"
14 14
15 class GrDrawAtlasBatch : public GrVertexBatch { 15 class GrDrawAtlasBatch : public GrVertexBatch {
16 public: 16 public:
17 DEFINE_BATCH_CLASS_ID 17 DEFINE_BATCH_CLASS_ID
18 18
19 struct Geometry { 19 GrDrawAtlasBatch(GrColor color, const SkMatrix& viewMatrix, int spriteCount,
20 GrColor fColor; 20 const SkRSXform* xforms, const SkRect* rects, const SkColor * colors);
21 SkTArray<uint8_t, true> fVerts;
22 };
23
24 static GrDrawBatch* Create(const Geometry& geometry, const SkMatrix& viewMat rix,
25 int spriteCount, const SkRSXform* xforms, const S kRect* rects,
26 const SkColor* colors) {
27 return new GrDrawAtlasBatch(geometry, viewMatrix, spriteCount, xforms, r ects, colors);
28 }
29 21
30 const char* name() const override { return "DrawAtlasBatch"; } 22 const char* name() const override { return "DrawAtlasBatch"; }
31 23
32 void computePipelineOptimizations(GrInitInvariantOutput* color, 24 void computePipelineOptimizations(GrInitInvariantOutput* color,
33 GrInitInvariantOutput* coverage, 25 GrInitInvariantOutput* coverage,
34 GrBatchToXPOverrides* overrides) const ove rride { 26 GrBatchToXPOverrides* overrides) const ove rride {
35 // 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
36 if (this->hasColors()) { 28 if (this->hasColors()) {
37 color->setUnknownFourComponents(); 29 color->setUnknownFourComponents();
38 } else { 30 } else {
39 color->setKnownFourComponents(fGeoData[0].fColor); 31 color->setKnownFourComponents(fGeoData[0].fColor);
40 } 32 }
41 coverage->setKnownSingleComponent(0xff); 33 coverage->setKnownSingleComponent(0xff);
42 } 34 }
43 35
44 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
45
46 private: 36 private:
47 void onPrepareDraws(Target*) const override; 37 void onPrepareDraws(Target*) const override;
48 38
49 void initBatchTracker(const GrXPOverridesForBatch&) override; 39 void initBatchTracker(const GrXPOverridesForBatch&) override;
50 40
51 GrDrawAtlasBatch(const Geometry& geometry, const SkMatrix& viewMatrix, int s priteCount,
52 const SkRSXform* xforms, const SkRect* rects, const SkColor * colors);
53
54 GrColor color() const { return fColor; } 41 GrColor color() const { return fColor; }
55 bool colorIgnored() const { return fColorIgnored; } 42 bool colorIgnored() const { return fColorIgnored; }
56 const SkMatrix& viewMatrix() const { return fViewMatrix; } 43 const SkMatrix& viewMatrix() const { return fViewMatrix; }
57 bool hasColors() const { return fHasColors; } 44 bool hasColors() const { return fHasColors; }
58 int quadCount() const { return fQuadCount; } 45 int quadCount() const { return fQuadCount; }
59 bool coverageIgnored() const { return fCoverageIgnored; } 46 bool coverageIgnored() const { return fCoverageIgnored; }
60 47
61 bool onCombineIfPossible(GrBatch* t, const GrCaps&) override; 48 bool onCombineIfPossible(GrBatch* t, const GrCaps&) override;
49
50 struct Geometry {
51 GrColor fColor;
52 SkTArray<uint8_t, true> fVerts;
53 };
54
62 SkSTArray<1, Geometry, true> fGeoData; 55 SkSTArray<1, Geometry, true> fGeoData;
63 56
64 SkMatrix fViewMatrix; 57 SkMatrix fViewMatrix;
65 GrColor fColor; 58 GrColor fColor;
66 int fQuadCount; 59 int fQuadCount;
67 bool fColorIgnored; 60 bool fColorIgnored;
68 bool fCoverageIgnored; 61 bool fCoverageIgnored;
69 bool fHasColors; 62 bool fHasColors;
70 63
71 typedef GrVertexBatch INHERITED; 64 typedef GrVertexBatch INHERITED;
72 }; 65 };
73 66
74 #endif 67 #endif
OLDNEW
« no previous file with comments | « src/gpu/batches/GrDefaultPathRenderer.cpp ('k') | src/gpu/batches/GrDrawAtlasBatch.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698