OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "GrAARectRenderer.h" | 8 #include "GrAARectRenderer.h" |
9 #include "GrBatch.h" | 9 #include "GrBatch.h" |
10 #include "GrBatchTarget.h" | 10 #include "GrBatchTarget.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 107 |
108 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) SK_OVERRIDE { | 108 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) SK_OVERRIDE { |
109 bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage(); | 109 bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage(); |
110 | 110 |
111 SkMatrix localMatrix; | 111 SkMatrix localMatrix; |
112 if (!this->viewMatrix().invert(&localMatrix)) { | 112 if (!this->viewMatrix().invert(&localMatrix)) { |
113 SkDebugf("Cannot invert\n"); | 113 SkDebugf("Cannot invert\n"); |
114 return; | 114 return; |
115 } | 115 } |
116 | 116 |
| 117 fBatchesGenerated++; |
117 const GrGeometryProcessor* gp = create_fill_rect_gp(canTweakAlphaForCove
rage, | 118 const GrGeometryProcessor* gp = create_fill_rect_gp(canTweakAlphaForCove
rage, |
118 localMatrix); | 119 localMatrix); |
119 | 120 |
120 batchTarget->initDraw(gp, pipeline); | 121 batchTarget->initDraw(gp, pipeline); |
121 gp->unref(); | 122 gp->unref(); |
122 | 123 |
123 // TODO this is hacky, but the only way we have to initialize the GP is
to use the | 124 // TODO this is hacky, but the only way we have to initialize the GP is
to use the |
124 // GrPipelineInfo struct so we can generate the correct shader. Once we
have GrBatch | 125 // GrPipelineInfo struct so we can generate the correct shader. Once we
have GrBatch |
125 // everywhere we can remove this nastiness | 126 // everywhere we can remove this nastiness |
126 GrPipelineInfo init; | 127 GrPipelineInfo init; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 bool onCombineIfPossible(GrBatch* t) SK_OVERRIDE { | 202 bool onCombineIfPossible(GrBatch* t) SK_OVERRIDE { |
202 AAFillRectBatch* that = t->cast<AAFillRectBatch>(); | 203 AAFillRectBatch* that = t->cast<AAFillRectBatch>(); |
203 if (this->canTweakAlphaForCoverage() != that->canTweakAlphaForCoverage()
) { | 204 if (this->canTweakAlphaForCoverage() != that->canTweakAlphaForCoverage()
) { |
204 return false; | 205 return false; |
205 } | 206 } |
206 | 207 |
207 if (this->colorIgnored() != that->colorIgnored()) { | 208 if (this->colorIgnored() != that->colorIgnored()) { |
208 return false; | 209 return false; |
209 } | 210 } |
210 | 211 |
211 if (this->usesLocalCoords() != that->usesLocalCoords()) { | 212 SkASSERT(this->usesLocalCoords() == that->usesLocalCoords()); |
212 return false; | |
213 } | |
214 | |
215 // We apply the viewmatrix to the rect points on the cpu. However, if t
he pipeline uses | 213 // We apply the viewmatrix to the rect points on the cpu. However, if t
he pipeline uses |
216 // local coords then we won't be able to batch. We could actually uploa
d the viewmatrix | 214 // local coords then we won't be able to batch. We could actually uploa
d the viewmatrix |
217 // using vertex attributes in these cases, but haven't investigated that | 215 // using vertex attributes in these cases, but haven't investigated that |
218 if (this->usesLocalCoords() && !this->viewMatrix().cheapEqualTo(that->vi
ewMatrix())) { | 216 if (this->usesLocalCoords() && !this->viewMatrix().cheapEqualTo(that->vi
ewMatrix())) { |
219 return false; | 217 return false; |
220 } | 218 } |
221 | 219 |
222 if (this->color() != that->color()) { | 220 if (this->color() != that->color()) { |
223 fBatch.fColor = GrColor_ILLEGAL; | 221 fBatch.fColor = GrColor_ILLEGAL; |
224 } | 222 } |
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 | 721 |
724 if (devInside.isEmpty()) { | 722 if (devInside.isEmpty()) { |
725 this->fillAARect(target, pipelineBuilder, color, viewMatrix, devOutside, | 723 this->fillAARect(target, pipelineBuilder, color, viewMatrix, devOutside, |
726 devOutside); | 724 devOutside); |
727 return; | 725 return; |
728 } | 726 } |
729 | 727 |
730 this->geometryStrokeAARect(target, pipelineBuilder, color, viewMatrix, devOu
tside, | 728 this->geometryStrokeAARect(target, pipelineBuilder, color, viewMatrix, devOu
tside, |
731 devOutsideAssist, devInside, true); | 729 devOutsideAssist, devInside, true); |
732 } | 730 } |
OLD | NEW |