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 GrAAFillRectBatch_DEFINED |
| 9 #define GrAAFillRectBatch_DEFINED |
| 10 |
| 11 #include "GrBatch.h" |
| 12 #include "GrColor.h" |
| 13 #include "GrTypes.h" |
| 14 #include "SkMatrix.h" |
| 15 #include "SkRect.h" |
| 16 |
| 17 class GrAAFillRectBatch : public GrBatch { |
| 18 public: |
| 19 struct Geometry { |
| 20 GrColor fColor; |
| 21 SkMatrix fViewMatrix; |
| 22 SkRect fRect; |
| 23 SkRect fDevRect; |
| 24 }; |
| 25 |
| 26 static GrBatch* Create(const Geometry& geometry) { |
| 27 return SkNEW_ARGS(GrAAFillRectBatch, (geometry)); |
| 28 } |
| 29 |
| 30 const char* name() const override { return "AAFillRectBatch"; } |
| 31 |
| 32 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { |
| 33 // When this is called on a batch, there is only one geometry bundle |
| 34 out->setKnownFourComponents(fGeoData[0].fColor); |
| 35 } |
| 36 |
| 37 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { |
| 38 out->setUnknownSingleComponent(); |
| 39 } |
| 40 |
| 41 void initBatchTracker(const GrPipelineInfo& init) override; |
| 42 |
| 43 void generateGeometry(GrBatchTarget* batchTarget) override; |
| 44 |
| 45 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
| 46 |
| 47 private: |
| 48 GrAAFillRectBatch(const Geometry& geometry) { |
| 49 this->initClassID<GrAAFillRectBatch>(); |
| 50 fGeoData.push_back(geometry); |
| 51 |
| 52 this->setBounds(geometry.fDevRect); |
| 53 } |
| 54 |
| 55 static const int kNumAAFillRectsInIndexBuffer = 256; |
| 56 static const int kVertsPerAAFillRect = 8; |
| 57 static const int kIndicesPerAAFillRect = 30; |
| 58 |
| 59 const GrIndexBuffer* getIndexBuffer(GrResourceProvider* resourceProvider); |
| 60 |
| 61 GrColor color() const { return fBatch.fColor; } |
| 62 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } |
| 63 bool canTweakAlphaForCoverage() const { return fBatch.fCanTweakAlphaForCover
age; } |
| 64 bool colorIgnored() const { return fBatch.fColorIgnored; } |
| 65 const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; } |
| 66 bool coverageIgnored() const { return fBatch.fCoverageIgnored; } |
| 67 |
| 68 bool onCombineIfPossible(GrBatch* t) override; |
| 69 |
| 70 void generateAAFillRectGeometry(void* vertices, |
| 71 size_t offset, |
| 72 size_t vertexStride, |
| 73 GrColor color, |
| 74 const SkMatrix& viewMatrix, |
| 75 const SkRect& rect, |
| 76 const SkRect& devRect, |
| 77 bool tweakAlphaForCoverage) const; |
| 78 |
| 79 struct BatchTracker { |
| 80 GrColor fColor; |
| 81 bool fUsesLocalCoords; |
| 82 bool fColorIgnored; |
| 83 bool fCoverageIgnored; |
| 84 bool fCanTweakAlphaForCoverage; |
| 85 }; |
| 86 |
| 87 BatchTracker fBatch; |
| 88 SkSTArray<1, Geometry, true> fGeoData; |
| 89 }; |
| 90 |
| 91 #endif |
OLD | NEW |