| 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 GrDrawVerticesBatch_DEFINED | 8 #ifndef GrDrawVerticesBatch_DEFINED |
| 9 #define GrDrawVerticesBatch_DEFINED | 9 #define GrDrawVerticesBatch_DEFINED |
| 10 | 10 |
| 11 #include "GrColor.h" | 11 #include "GrColor.h" |
| 12 #include "GrTypes.h" | 12 #include "GrTypes.h" |
| 13 #include "GrVertexBatch.h" | 13 #include "GrVertexBatch.h" |
| 14 #include "SkMatrix.h" | 14 #include "SkMatrix.h" |
| 15 #include "SkRect.h" | 15 #include "SkRect.h" |
| 16 #include "SkTDArray.h" | 16 #include "SkTDArray.h" |
| 17 | 17 |
| 18 class GrBatchFlushState; | 18 class GrBatchFlushState; |
| 19 struct GrInitInvariantOutput; | 19 struct GrInitInvariantOutput; |
| 20 | 20 |
| 21 class GrDrawVerticesBatch : public GrVertexBatch { | 21 class GrDrawVerticesBatch : public GrVertexBatch { |
| 22 public: | 22 public: |
| 23 DEFINE_BATCH_CLASS_ID | 23 DEFINE_BATCH_CLASS_ID |
| 24 | 24 |
| 25 struct Geometry { | 25 struct Geometry { |
| 26 GrColor fColor; | 26 GrColor fColor; // Only used if there are no per-vertex colors |
| 27 SkTDArray<SkPoint> fPositions; | 27 SkTDArray<SkPoint> fPositions; |
| 28 SkTDArray<uint16_t> fIndices; | 28 SkTDArray<uint16_t> fIndices; |
| 29 SkTDArray<GrColor> fColors; | 29 SkTDArray<GrColor> fColors; |
| 30 SkTDArray<SkPoint> fLocalCoords; | 30 SkTDArray<SkPoint> fLocalCoords; |
| 31 }; | 31 }; |
| 32 | 32 |
| 33 static GrDrawBatch* Create(const Geometry& geometry, GrPrimitiveType primiti
veType, | 33 static GrDrawBatch* Create(const Geometry& geometry, GrPrimitiveType primiti
veType, |
| 34 const SkMatrix& viewMatrix, | 34 const SkMatrix& viewMatrix, |
| 35 const SkPoint* positions, int vertexCount, | 35 const SkPoint* positions, int vertexCount, |
| 36 const uint16_t* indices, int indexCount, | 36 const uint16_t* indices, int indexCount, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 51 private: | 51 private: |
| 52 void onPrepareDraws(Target*) override; | 52 void onPrepareDraws(Target*) override; |
| 53 void initBatchTracker(const GrPipelineOptimizations&) override; | 53 void initBatchTracker(const GrPipelineOptimizations&) override; |
| 54 | 54 |
| 55 GrDrawVerticesBatch(const Geometry& geometry, GrPrimitiveType primitiveType, | 55 GrDrawVerticesBatch(const Geometry& geometry, GrPrimitiveType primitiveType, |
| 56 const SkMatrix& viewMatrix, | 56 const SkMatrix& viewMatrix, |
| 57 const SkPoint* positions, int vertexCount, | 57 const SkPoint* positions, int vertexCount, |
| 58 const uint16_t* indices, int indexCount, | 58 const uint16_t* indices, int indexCount, |
| 59 const GrColor* colors, const SkPoint* localCoords, const
SkRect& bounds); | 59 const GrColor* colors, const SkPoint* localCoords, const
SkRect& bounds); |
| 60 | 60 |
| 61 GrPrimitiveType primitiveType() const { return fBatch.fPrimitiveType; } | 61 GrPrimitiveType primitiveType() const { return fPrimitiveType; } |
| 62 bool batchablePrimitiveType() const { | 62 bool batchablePrimitiveType() const { |
| 63 return kTriangles_GrPrimitiveType == fBatch.fPrimitiveType || | 63 return kTriangles_GrPrimitiveType == fPrimitiveType || |
| 64 kLines_GrPrimitiveType == fBatch.fPrimitiveType || | 64 kLines_GrPrimitiveType == fPrimitiveType || |
| 65 kPoints_GrPrimitiveType == fBatch.fPrimitiveType; | 65 kPoints_GrPrimitiveType == fPrimitiveType; |
| 66 } | 66 } |
| 67 GrColor color() const { return fBatch.fColor; } | |
| 68 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } | |
| 69 bool colorIgnored() const { return fBatch.fColorIgnored; } | |
| 70 const SkMatrix& viewMatrix() const { return fBatch.fViewMatrix; } | |
| 71 bool hasColors() const { return fBatch.fHasColors; } | |
| 72 bool hasIndices() const { return fBatch.fHasIndices; } | |
| 73 bool hasLocalCoords() const { return fBatch.fHasLocalCoords; } | |
| 74 int vertexCount() const { return fBatch.fVertexCount; } | |
| 75 int indexCount() const { return fBatch.fIndexCount; } | |
| 76 bool coverageIgnored() const { return fBatch.fCoverageIgnored; } | |
| 77 | 67 |
| 78 bool onCombineIfPossible(GrBatch* t, const GrCaps&) override; | 68 bool onCombineIfPossible(GrBatch* t, const GrCaps&) override; |
| 79 | 69 |
| 80 struct BatchTracker { | 70 GrPrimitiveType fPrimitiveType; |
| 81 GrPrimitiveType fPrimitiveType; | 71 SkMatrix fViewMatrix; |
| 82 SkMatrix fViewMatrix; | 72 bool fVariableColor; |
| 83 GrColor fColor; | 73 int fVertexCount; |
| 84 bool fUsesLocalCoords; | 74 int fIndexCount; |
| 85 bool fColorIgnored; | 75 bool fCoverageIgnored; // comes from initBatchTracker. |
| 86 bool fCoverageIgnored; | |
| 87 bool fHasColors; | |
| 88 bool fHasIndices; | |
| 89 bool fHasLocalCoords; | |
| 90 int fVertexCount; | |
| 91 int fIndexCount; | |
| 92 }; | |
| 93 | 76 |
| 94 BatchTracker fBatch; | |
| 95 SkSTArray<1, Geometry, true> fGeoData; | 77 SkSTArray<1, Geometry, true> fGeoData; |
| 96 | 78 |
| 97 typedef GrVertexBatch INHERITED; | 79 typedef GrVertexBatch INHERITED; |
| 98 }; | 80 }; |
| 99 | 81 |
| 100 #endif | 82 #endif |
| OLD | NEW |