OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2015 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 |
| 8 #ifndef GrDrawVerticesBatch_DEFINED |
| 9 #define GrDrawVerticesBatch_DEFINED |
| 10 |
| 11 #include "GrBatch.h" |
| 12 #include "GrColor.h" |
| 13 #include "GrTypes.h" |
| 14 #include "SkMatrix.h" |
| 15 #include "SkRect.h" |
| 16 #include "SkTDArray.h" |
| 17 |
| 18 class GrBatch; |
| 19 class GrBatchTarget; |
| 20 struct GrInitInvariantOutput; |
| 21 |
| 22 class GrDrawVerticesBatch : public GrBatch { |
| 23 public: |
| 24 struct Geometry { |
| 25 GrColor fColor; |
| 26 SkTDArray<SkPoint> fPositions; |
| 27 SkTDArray<uint16_t> fIndices; |
| 28 SkTDArray<GrColor> fColors; |
| 29 SkTDArray<SkPoint> fLocalCoords; |
| 30 }; |
| 31 |
| 32 static GrBatch* Create(const Geometry& geometry, GrPrimitiveType primitiveTy
pe, |
| 33 const SkMatrix& viewMatrix, |
| 34 const SkPoint* positions, int vertexCount, |
| 35 const uint16_t* indices, int indexCount, |
| 36 const GrColor* colors, const SkPoint* localCoords, |
| 37 const SkRect& bounds) { |
| 38 return SkNEW_ARGS(GrDrawVerticesBatch, (geometry, primitiveType, viewMat
rix, positions, |
| 39 vertexCount, indices, indexCount
, colors, |
| 40 localCoords, bounds)); |
| 41 } |
| 42 |
| 43 const char* name() const override { return "DrawVerticesBatch"; } |
| 44 |
| 45 void getInvariantOutputColor(GrInitInvariantOutput* out) const override; |
| 46 |
| 47 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override; |
| 48 |
| 49 void initBatchTracker(const GrPipelineInfo& init) override; |
| 50 |
| 51 void generateGeometry(GrBatchTarget* batchTarget) override; |
| 52 |
| 53 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
| 54 |
| 55 private: |
| 56 GrDrawVerticesBatch(const Geometry& geometry, GrPrimitiveType primitiveType, |
| 57 const SkMatrix& viewMatrix, |
| 58 const SkPoint* positions, int vertexCount, |
| 59 const uint16_t* indices, int indexCount, |
| 60 const GrColor* colors, const SkPoint* localCoords, const
SkRect& bounds); |
| 61 |
| 62 GrPrimitiveType primitiveType() const { return fBatch.fPrimitiveType; } |
| 63 bool batchablePrimitiveType() const { |
| 64 return kTriangles_GrPrimitiveType == fBatch.fPrimitiveType || |
| 65 kLines_GrPrimitiveType == fBatch.fPrimitiveType || |
| 66 kPoints_GrPrimitiveType == fBatch.fPrimitiveType; |
| 67 } |
| 68 GrColor color() const { return fBatch.fColor; } |
| 69 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } |
| 70 bool colorIgnored() const { return fBatch.fColorIgnored; } |
| 71 const SkMatrix& viewMatrix() const { return fBatch.fViewMatrix; } |
| 72 bool hasColors() const { return fBatch.fHasColors; } |
| 73 bool hasIndices() const { return fBatch.fHasIndices; } |
| 74 bool hasLocalCoords() const { return fBatch.fHasLocalCoords; } |
| 75 int vertexCount() const { return fBatch.fVertexCount; } |
| 76 int indexCount() const { return fBatch.fIndexCount; } |
| 77 bool coverageIgnored() const { return fBatch.fCoverageIgnored; } |
| 78 |
| 79 bool onCombineIfPossible(GrBatch* t) override; |
| 80 |
| 81 struct BatchTracker { |
| 82 GrPrimitiveType fPrimitiveType; |
| 83 SkMatrix fViewMatrix; |
| 84 GrColor fColor; |
| 85 bool fUsesLocalCoords; |
| 86 bool fColorIgnored; |
| 87 bool fCoverageIgnored; |
| 88 bool fHasColors; |
| 89 bool fHasIndices; |
| 90 bool fHasLocalCoords; |
| 91 int fVertexCount; |
| 92 int fIndexCount; |
| 93 }; |
| 94 |
| 95 BatchTracker fBatch; |
| 96 SkSTArray<1, Geometry, true> fGeoData; |
| 97 }; |
| 98 |
| 99 #endif |
OLD | NEW |