OLD | NEW |
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 struct Geometry { |
20 GrColor fColor; | 20 GrColor fColor; |
21 SkTArray<uint8_t, true> fVerts; | 21 SkTArray<uint8_t, true> fVerts; |
22 }; | 22 }; |
23 | 23 |
24 static GrDrawBatch* Create(const Geometry& geometry, const SkMatrix& viewMat
rix, | 24 static GrDrawBatch* Create(const Geometry& geometry, const SkMatrix& viewMat
rix, |
25 int spriteCount, const SkRSXform* xforms, const S
kRect* rects, | 25 int spriteCount, const SkRSXform* xforms, const S
kRect* rects, |
26 const SkColor* colors) { | 26 const SkColor* colors) { |
27 return new GrDrawAtlasBatch(geometry, viewMatrix, spriteCount, xforms, r
ects, colors); | 27 return new GrDrawAtlasBatch(geometry, viewMatrix, spriteCount, xforms, r
ects, colors); |
28 } | 28 } |
29 | 29 |
30 const char* name() const override { return "DrawAtlasBatch"; } | 30 const char* name() const override { return "DrawAtlasBatch"; } |
31 | 31 |
32 void computePipelineOptimizations(GrInitInvariantOutput* color, | 32 void computePipelineOptimizations(GrInitInvariantOutput* color, |
33 GrInitInvariantOutput* coverage, | 33 GrInitInvariantOutput* coverage, |
34 GrBatchToXPOverrides* overrides) const ove
rride { | 34 GrBatchToXPOverrides* overrides) const ove
rride { |
35 // When this is called on a batch, there is only one geometry bundle | 35 // When this is called on a batch, there is only one geometry bundle |
36 if (this->hasColors()) { | 36 if (this->hasColors()) { |
37 color->setUnknownFourComponents(); | 37 color->setUnknownFourComponents(); |
38 } else { | 38 } else { |
39 color->setKnownFourComponents(fGeoData[0].fColor); | 39 color->setKnownFourComponents(fGeoData[0].fColor); |
40 } | 40 } |
41 coverage->setKnownSingleComponent(0xff); | 41 coverage->setKnownSingleComponent(0xff); |
42 } | 42 } |
43 | 43 |
44 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 44 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
45 | 45 |
46 private: | 46 private: |
47 void onPrepareDraws(Target*) const override; | 47 void onPrepareDraws(Target*) const override; |
48 | 48 |
49 void initBatchTracker(const GrXPOverridesForBatch&) override; | 49 void initBatchTracker(const GrXPOverridesForBatch&) override; |
50 | 50 |
51 GrDrawAtlasBatch(const Geometry& geometry, const SkMatrix& viewMatrix, int s
priteCount, | 51 GrDrawAtlasBatch(const Geometry& geometry, const SkMatrix& viewMatrix, int s
priteCount, |
52 const SkRSXform* xforms, const SkRect* rects, const SkColor
* colors); | 52 const SkRSXform* xforms, const SkRect* rects, const SkColor
* colors); |
53 | 53 |
54 GrColor color() const { return fColor; } | 54 GrColor color() const { return fColor; } |
55 bool colorIgnored() const { return fColorIgnored; } | 55 bool colorIgnored() const { return fColorIgnored; } |
56 const SkMatrix& viewMatrix() const { return fViewMatrix; } | 56 const SkMatrix& viewMatrix() const { return fViewMatrix; } |
57 bool hasColors() const { return fHasColors; } | 57 bool hasColors() const { return fHasColors; } |
58 int quadCount() const { return fQuadCount; } | 58 int quadCount() const { return fQuadCount; } |
59 bool coverageIgnored() const { return fCoverageIgnored; } | 59 bool coverageIgnored() const { return fCoverageIgnored; } |
60 | 60 |
61 bool onCombineIfPossible(GrBatch* t, const GrCaps&) override; | 61 bool onCombineIfPossible(GrBatch* t, const GrCaps&) override; |
62 SkSTArray<1, Geometry, true> fGeoData; | 62 SkSTArray<1, Geometry, true> fGeoData; |
63 | 63 |
64 SkMatrix fViewMatrix; | 64 SkMatrix fViewMatrix; |
65 GrColor fColor; | 65 GrColor fColor; |
66 int fQuadCount; | 66 int fQuadCount; |
67 bool fColorIgnored; | 67 bool fColorIgnored; |
68 bool fCoverageIgnored; | 68 bool fCoverageIgnored; |
69 bool fHasColors; | 69 bool fHasColors; |
70 | 70 |
71 typedef GrVertexBatch INHERITED; | 71 typedef GrVertexBatch INHERITED; |
72 }; | 72 }; |
73 | 73 |
74 #endif | 74 #endif |
OLD | NEW |