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

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

Issue 1279343004: Revise DrawAtlasBatch to get rid of one copy when generating the batch. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Picky picky Windows 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/GrDrawContext.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 "GrBatch.h" 11 #include "GrBatch.h"
12 #include "GrColor.h" 12 #include "GrColor.h"
13 #include "GrDefaultGeoProcFactory.h" 13 #include "GrDefaultGeoProcFactory.h"
14 14
15 class GrDrawAtlasBatch : public GrBatch { 15 class GrDrawAtlasBatch : public GrBatch {
16 public: 16 public:
17 struct Geometry { 17 struct Geometry {
18 GrColor fColor; 18 GrColor fColor;
19 SkTDArray<SkPoint> fPositions; 19 SkTArray<uint8_t, true> fVerts;
20 SkTDArray<GrColor> fColors;
21 SkTDArray<SkPoint> fLocalCoords;
22 }; 20 };
23 21
24 static GrBatch* Create(const Geometry& geometry, const SkMatrix& viewMatrix, 22 static GrBatch* Create(const Geometry& geometry, const SkMatrix& viewMatrix, int spriteCount,
25 const SkPoint* positions, int vertexCount, 23 const SkRSXform* xforms, const SkRect* rects, const S kColor* colors) {
26 const GrColor* colors, const SkPoint* localCoords, 24 return SkNEW_ARGS(GrDrawAtlasBatch, (geometry, viewMatrix, spriteCount,
27 const SkRect& bounds) { 25 xforms, rects, colors));
28 return SkNEW_ARGS(GrDrawAtlasBatch, (geometry, viewMatrix, positions,
29 vertexCount, colors, localCoords, bou nds));
30 } 26 }
31 27
32 const char* name() const override { return "DrawAtlasBatch"; } 28 const char* name() const override { return "DrawAtlasBatch"; }
33 29
34 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { 30 void getInvariantOutputColor(GrInitInvariantOutput* out) const override {
35 // When this is called on a batch, there is only one geometry bundle 31 // When this is called on a batch, there is only one geometry bundle
36 if (this->hasColors()) { 32 if (this->hasColors()) {
37 out->setUnknownFourComponents(); 33 out->setUnknownFourComponents();
38 } else { 34 } else {
39 out->setKnownFourComponents(fGeoData[0].fColor); 35 out->setKnownFourComponents(fGeoData[0].fColor);
40 } 36 }
41 } 37 }
42 38
43 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { 39 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override {
44 out->setKnownSingleComponent(0xff); 40 out->setKnownSingleComponent(0xff);
45 } 41 }
46 42
47 void initBatchTracker(const GrPipelineOptimizations&) override; 43 void initBatchTracker(const GrPipelineOptimizations&) override;
48 void generateGeometry(GrBatchTarget* batchTarget) override; 44 void generateGeometry(GrBatchTarget* batchTarget) override;
49 45
50 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } 46 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
51 47
52 private: 48 private:
53 GrDrawAtlasBatch(const Geometry& geometry, const SkMatrix& viewMatrix, 49 GrDrawAtlasBatch(const Geometry& geometry, const SkMatrix& viewMatrix, int s priteCount,
54 const SkPoint* positions, int vertexCount, 50 const SkRSXform* xforms, const SkRect* rects, const SkColor * colors);
55 const GrColor* colors, const SkPoint* localCoords, const Sk Rect& bounds);
56 51
57 GrColor color() const { return fColor; } 52 GrColor color() const { return fColor; }
58 bool colorIgnored() const { return fColorIgnored; } 53 bool colorIgnored() const { return fColorIgnored; }
59 const SkMatrix& viewMatrix() const { return fViewMatrix; } 54 const SkMatrix& viewMatrix() const { return fViewMatrix; }
60 bool hasColors() const { return fHasColors; } 55 bool hasColors() const { return fHasColors; }
61 int vertexCount() const { return fVertexCount; } 56 int quadCount() const { return fQuadCount; }
62 bool coverageIgnored() const { return fCoverageIgnored; } 57 bool coverageIgnored() const { return fCoverageIgnored; }
63 58
64 bool onCombineIfPossible(GrBatch* t) override; 59 bool onCombineIfPossible(GrBatch* t) override;
65 SkSTArray<1, Geometry, true> fGeoData; 60 SkSTArray<1, Geometry, true> fGeoData;
66 61
67 SkMatrix fViewMatrix; 62 SkMatrix fViewMatrix;
68 GrColor fColor; 63 GrColor fColor;
69 int fVertexCount; 64 int fQuadCount;
70 bool fColorIgnored; 65 bool fColorIgnored;
71 bool fCoverageIgnored; 66 bool fCoverageIgnored;
72 bool fHasColors; 67 bool fHasColors;
73 }; 68 };
74 69
75 #endif 70 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrDrawContext.cpp ('k') | src/gpu/batches/GrDrawAtlasBatch.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698