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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 GR_DEFINE_STATIC_UNIQUE_KEY(gAAFillRectIndexBufferKey); | 155 GR_DEFINE_STATIC_UNIQUE_KEY(gAAFillRectIndexBufferKey); |
156 | 156 |
157 static const uint16_t gFillAARectIdx[] = { | 157 static const uint16_t gFillAARectIdx[] = { |
158 0, 1, 5, 5, 4, 0, | 158 0, 1, 5, 5, 4, 0, |
159 1, 2, 6, 6, 5, 1, | 159 1, 2, 6, 6, 5, 1, |
160 2, 3, 7, 7, 6, 2, | 160 2, 3, 7, 7, 6, 2, |
161 3, 0, 4, 4, 7, 3, | 161 3, 0, 4, 4, 7, 3, |
162 4, 5, 6, 6, 7, 4, | 162 4, 5, 6, 6, 7, 4, |
163 }; | 163 }; |
164 GR_STATIC_ASSERT(SK_ARRAY_COUNT(gFillAARectIdx) == kIndicesPerAAFillRect
); | 164 GR_STATIC_ASSERT(SK_ARRAY_COUNT(gFillAARectIdx) == kIndicesPerAAFillRect
); |
165 return resourceProvider->refOrCreateInstancedIndexBuffer(gFillAARectIdx, | 165 return resourceProvider->findOrCreateInstancedIndexBuffer(gFillAARectIdx
, |
166 kIndicesPerAAFillRect, kNumAAFillRectsInIndexBuffer, kVertsPerAAFill
Rect, | 166 kIndicesPerAAFillRect, kNumAAFillRectsInIndexBuffer, kVertsPerAAFill
Rect, |
167 gAAFillRectIndexBufferKey); | 167 gAAFillRectIndexBufferKey); |
168 } | 168 } |
169 | 169 |
170 GrColor color() const { return fBatch.fColor; } | 170 GrColor color() const { return fBatch.fColor; } |
171 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } | 171 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } |
172 bool canTweakAlphaForCoverage() const { return fBatch.fCanTweakAlphaForCover
age; } | 172 bool canTweakAlphaForCoverage() const { return fBatch.fCanTweakAlphaForCover
age; } |
173 bool colorIgnored() const { return fBatch.fColorIgnored; } | 173 bool colorIgnored() const { return fBatch.fColorIgnored; } |
174 const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; } | 174 const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; } |
175 bool coverageIgnored() const { return fBatch.fCoverageIgnored; } | 175 bool coverageIgnored() const { return fBatch.fCoverageIgnored; } |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 2 + 4, 3 + 4, 7 + 4, 7 + 4, 6 + 4, 2 + 4, | 536 2 + 4, 3 + 4, 7 + 4, 7 + 4, 6 + 4, 2 + 4, |
537 3 + 4, 0 + 4, 4 + 4, 4 + 4, 7 + 4, 3 + 4, | 537 3 + 4, 0 + 4, 4 + 4, 4 + 4, 7 + 4, 3 + 4, |
538 | 538 |
539 0 + 8, 1 + 8, 5 + 8, 5 + 8, 4 + 8, 0 + 8, | 539 0 + 8, 1 + 8, 5 + 8, 5 + 8, 4 + 8, 0 + 8, |
540 1 + 8, 2 + 8, 6 + 8, 6 + 8, 5 + 8, 1 + 8, | 540 1 + 8, 2 + 8, 6 + 8, 6 + 8, 5 + 8, 1 + 8, |
541 2 + 8, 3 + 8, 7 + 8, 7 + 8, 6 + 8, 2 + 8, | 541 2 + 8, 3 + 8, 7 + 8, 7 + 8, 6 + 8, 2 + 8, |
542 3 + 8, 0 + 8, 4 + 8, 4 + 8, 7 + 8, 3 + 8, | 542 3 + 8, 0 + 8, 4 + 8, 4 + 8, 7 + 8, 3 + 8, |
543 }; | 543 }; |
544 GR_STATIC_ASSERT(SK_ARRAY_COUNT(gMiterIndices) == kMiterIndexCnt); | 544 GR_STATIC_ASSERT(SK_ARRAY_COUNT(gMiterIndices) == kMiterIndexCnt); |
545 GR_DEFINE_STATIC_UNIQUE_KEY(gMiterIndexBufferKey); | 545 GR_DEFINE_STATIC_UNIQUE_KEY(gMiterIndexBufferKey); |
546 return resourceProvider->refOrCreateInstancedIndexBuffer(gMiterIndic
es, | 546 return resourceProvider->findOrCreateInstancedIndexBuffer(gMiterIndi
ces, |
547 kMiterIndexCnt, kNumMiterRectsInIndexBuffer, kMiterVertexCnt, | 547 kMiterIndexCnt, kNumMiterRectsInIndexBuffer, kMiterVertexCnt, |
548 gMiterIndexBufferKey); | 548 gMiterIndexBufferKey); |
549 } else { | 549 } else { |
550 /** | 550 /** |
551 * As in miter-stroke, index = a + b, and a is the current index, b
is the shift | 551 * As in miter-stroke, index = a + b, and a is the current index, b
is the shift |
552 * from the first index. The index layout: | 552 * from the first index. The index layout: |
553 * outer AA line: 0~3, 4~7 | 553 * outer AA line: 0~3, 4~7 |
554 * outer edge: 8~11, 12~15 | 554 * outer edge: 8~11, 12~15 |
555 * inner edge: 16~19 | 555 * inner edge: 16~19 |
556 * inner AA line: 20~23 | 556 * inner AA line: 20~23 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 | 599 |
600 // Draw the inner AA, from inner edge to inner AA line, shift is
16. | 600 // Draw the inner AA, from inner edge to inner AA line, shift is
16. |
601 0 + 16, 1 + 16, 5 + 16, 5 + 16, 4 + 16, 0 + 16, | 601 0 + 16, 1 + 16, 5 + 16, 5 + 16, 4 + 16, 0 + 16, |
602 1 + 16, 2 + 16, 6 + 16, 6 + 16, 5 + 16, 1 + 16, | 602 1 + 16, 2 + 16, 6 + 16, 6 + 16, 5 + 16, 1 + 16, |
603 2 + 16, 3 + 16, 7 + 16, 7 + 16, 6 + 16, 2 + 16, | 603 2 + 16, 3 + 16, 7 + 16, 7 + 16, 6 + 16, 2 + 16, |
604 3 + 16, 0 + 16, 4 + 16, 4 + 16, 7 + 16, 3 + 16, | 604 3 + 16, 0 + 16, 4 + 16, 4 + 16, 7 + 16, 3 + 16, |
605 }; | 605 }; |
606 GR_STATIC_ASSERT(SK_ARRAY_COUNT(gBevelIndices) == kBevelIndexCnt); | 606 GR_STATIC_ASSERT(SK_ARRAY_COUNT(gBevelIndices) == kBevelIndexCnt); |
607 | 607 |
608 GR_DEFINE_STATIC_UNIQUE_KEY(gBevelIndexBufferKey); | 608 GR_DEFINE_STATIC_UNIQUE_KEY(gBevelIndexBufferKey); |
609 return resourceProvider->refOrCreateInstancedIndexBuffer(gBevelIndic
es, | 609 return resourceProvider->findOrCreateInstancedIndexBuffer(gBevelIndi
ces, |
610 kBevelIndexCnt, kNumBevelRectsInIndexBuffer, kBevelVertexCnt, | 610 kBevelIndexCnt, kNumBevelRectsInIndexBuffer, kBevelVertexCnt, |
611 gBevelIndexBufferKey); | 611 gBevelIndexBufferKey); |
612 } | 612 } |
613 } | 613 } |
614 | 614 |
615 GrColor color() const { return fBatch.fColor; } | 615 GrColor color() const { return fBatch.fColor; } |
616 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } | 616 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } |
617 bool canTweakAlphaForCoverage() const { return fBatch.fCanTweakAlphaForCover
age; } | 617 bool canTweakAlphaForCoverage() const { return fBatch.fCanTweakAlphaForCover
age; } |
618 bool colorIgnored() const { return fBatch.fColorIgnored; } | 618 bool colorIgnored() const { return fBatch.fColorIgnored; } |
619 const SkMatrix& viewMatrix() const { return fBatch.fViewMatrix; } | 619 const SkMatrix& viewMatrix() const { return fBatch.fViewMatrix; } |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 geo.fColor = GrRandomColor(random); | 849 geo.fColor = GrRandomColor(random); |
850 geo.fDevOutside = outside; | 850 geo.fDevOutside = outside; |
851 geo.fDevOutsideAssist = outsideAssist; | 851 geo.fDevOutsideAssist = outsideAssist; |
852 geo.fDevInside = inside; | 852 geo.fDevInside = inside; |
853 geo.fMiterStroke = miterStroke; | 853 geo.fMiterStroke = miterStroke; |
854 | 854 |
855 return AAStrokeRectBatch::Create(geo, GrTest::TestMatrix(random)); | 855 return AAStrokeRectBatch::Create(geo, GrTest::TestMatrix(random)); |
856 } | 856 } |
857 | 857 |
858 #endif | 858 #endif |
OLD | NEW |