OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 #include "GrInOrderDrawBuffer.h" | 8 #include "GrInOrderDrawBuffer.h" |
9 | 9 |
10 #include "GrDefaultGeoProcFactory.h" | 10 #include "GrDefaultGeoProcFactory.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 bool fHasLocalRect; | 63 bool fHasLocalRect; |
64 bool fHasLocalMatrix; | 64 bool fHasLocalMatrix; |
65 SkRect fLocalRect; | 65 SkRect fLocalRect; |
66 SkMatrix fLocalMatrix; | 66 SkMatrix fLocalMatrix; |
67 }; | 67 }; |
68 | 68 |
69 static GrBatch* Create(const Geometry& geometry) { | 69 static GrBatch* Create(const Geometry& geometry) { |
70 return SkNEW_ARGS(RectBatch, (geometry)); | 70 return SkNEW_ARGS(RectBatch, (geometry)); |
71 } | 71 } |
72 | 72 |
73 const char* name() const SK_OVERRIDE { return "RectBatch"; } | 73 const char* name() const override { return "RectBatch"; } |
74 | 74 |
75 void getInvariantOutputColor(GrInitInvariantOutput* out) const SK_OVERRIDE { | 75 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { |
76 // When this is called on a batch, there is only one geometry bundle | 76 // When this is called on a batch, there is only one geometry bundle |
77 out->setKnownFourComponents(fGeoData[0].fColor); | 77 out->setKnownFourComponents(fGeoData[0].fColor); |
78 } | 78 } |
79 | 79 |
80 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRID
E { | 80 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { |
81 out->setKnownSingleComponent(0xff); | 81 out->setKnownSingleComponent(0xff); |
82 } | 82 } |
83 | 83 |
84 void initBatchTracker(const GrPipelineInfo& init) SK_OVERRIDE { | 84 void initBatchTracker(const GrPipelineInfo& init) override { |
85 // Handle any color overrides | 85 // Handle any color overrides |
86 if (init.fColorIgnored) { | 86 if (init.fColorIgnored) { |
87 fGeoData[0].fColor = GrColor_ILLEGAL; | 87 fGeoData[0].fColor = GrColor_ILLEGAL; |
88 } else if (GrColor_ILLEGAL != init.fOverrideColor) { | 88 } else if (GrColor_ILLEGAL != init.fOverrideColor) { |
89 fGeoData[0].fColor = init.fOverrideColor; | 89 fGeoData[0].fColor = init.fOverrideColor; |
90 } | 90 } |
91 | 91 |
92 // setup batch properties | 92 // setup batch properties |
93 fBatch.fColorIgnored = init.fColorIgnored; | 93 fBatch.fColorIgnored = init.fColorIgnored; |
94 fBatch.fColor = fGeoData[0].fColor; | 94 fBatch.fColor = fGeoData[0].fColor; |
95 fBatch.fUsesLocalCoords = init.fUsesLocalCoords; | 95 fBatch.fUsesLocalCoords = init.fUsesLocalCoords; |
96 fBatch.fCoverageIgnored = init.fCoverageIgnored; | 96 fBatch.fCoverageIgnored = init.fCoverageIgnored; |
97 } | 97 } |
98 | 98 |
99 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) SK_OVERRIDE { | 99 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) override { |
100 // Go to device coords to allow batching across matrix changes | 100 // Go to device coords to allow batching across matrix changes |
101 SkMatrix invert = SkMatrix::I(); | 101 SkMatrix invert = SkMatrix::I(); |
102 | 102 |
103 // if we have a local rect, then we apply the localMatrix directly to th
e localRect to | 103 // if we have a local rect, then we apply the localMatrix directly to th
e localRect to |
104 // generate vertex local coords | 104 // generate vertex local coords |
105 bool hasExplicitLocalCoords = this->hasLocalRect(); | 105 bool hasExplicitLocalCoords = this->hasLocalRect(); |
106 if (!hasExplicitLocalCoords) { | 106 if (!hasExplicitLocalCoords) { |
107 if (!this->viewMatrix().isIdentity() && !this->viewMatrix().invert(&
invert)) { | 107 if (!this->viewMatrix().isIdentity() && !this->viewMatrix().invert(&
invert)) { |
108 SkDebugf("Could not invert\n"); | 108 SkDebugf("Could not invert\n"); |
109 return; | 109 return; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 } | 215 } |
216 | 216 |
217 GrColor color() const { return fBatch.fColor; } | 217 GrColor color() const { return fBatch.fColor; } |
218 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } | 218 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } |
219 bool colorIgnored() const { return fBatch.fColorIgnored; } | 219 bool colorIgnored() const { return fBatch.fColorIgnored; } |
220 const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; } | 220 const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; } |
221 const SkMatrix& localMatrix() const { return fGeoData[0].fLocalMatrix; } | 221 const SkMatrix& localMatrix() const { return fGeoData[0].fLocalMatrix; } |
222 bool hasLocalRect() const { return fGeoData[0].fHasLocalRect; } | 222 bool hasLocalRect() const { return fGeoData[0].fHasLocalRect; } |
223 bool hasLocalMatrix() const { return fGeoData[0].fHasLocalMatrix; } | 223 bool hasLocalMatrix() const { return fGeoData[0].fHasLocalMatrix; } |
224 | 224 |
225 bool onCombineIfPossible(GrBatch* t) SK_OVERRIDE { | 225 bool onCombineIfPossible(GrBatch* t) override { |
226 RectBatch* that = t->cast<RectBatch>(); | 226 RectBatch* that = t->cast<RectBatch>(); |
227 | 227 |
228 if (this->hasLocalRect() != that->hasLocalRect()) { | 228 if (this->hasLocalRect() != that->hasLocalRect()) { |
229 return false; | 229 return false; |
230 } | 230 } |
231 | 231 |
232 SkASSERT(this->usesLocalCoords() == that->usesLocalCoords()); | 232 SkASSERT(this->usesLocalCoords() == that->usesLocalCoords()); |
233 if (!this->hasLocalRect() && this->usesLocalCoords()) { | 233 if (!this->hasLocalRect() && this->usesLocalCoords()) { |
234 if (!this->viewMatrix().cheapEqualTo(that->viewMatrix())) { | 234 if (!this->viewMatrix().cheapEqualTo(that->viewMatrix())) { |
235 return false; | 235 return false; |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 } | 408 } |
409 } | 409 } |
410 | 410 |
411 void GrInOrderDrawBuffer::willReserveVertexAndIndexSpace(int vertexCount, | 411 void GrInOrderDrawBuffer::willReserveVertexAndIndexSpace(int vertexCount, |
412 size_t vertexStride, | 412 size_t vertexStride, |
413 int indexCount) { | 413 int indexCount) { |
414 fCommands.closeBatch(); | 414 fCommands.closeBatch(); |
415 | 415 |
416 this->INHERITED::willReserveVertexAndIndexSpace(vertexCount, vertexStride, i
ndexCount); | 416 this->INHERITED::willReserveVertexAndIndexSpace(vertexCount, vertexStride, i
ndexCount); |
417 } | 417 } |
OLD | NEW |