| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "GrAAFillRectBatch.h" | 8 #include "GrAAFillRectBatch.h" |
| 9 | 9 |
| 10 #include "GrColor.h" | 10 #include "GrColor.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 static void set_inset_fan(SkPoint* pts, size_t stride, | 21 static void set_inset_fan(SkPoint* pts, size_t stride, |
| 22 const SkRect& r, SkScalar dx, SkScalar dy) { | 22 const SkRect& r, SkScalar dx, SkScalar dy) { |
| 23 pts->setRectFan(r.fLeft + dx, r.fTop + dy, | 23 pts->setRectFan(r.fLeft + dx, r.fTop + dy, |
| 24 r.fRight - dx, r.fBottom - dy, stride); | 24 r.fRight - dx, r.fBottom - dy, stride); |
| 25 } | 25 } |
| 26 | 26 |
| 27 static const int kNumAAFillRectsInIndexBuffer = 256; | 27 static const int kNumAAFillRectsInIndexBuffer = 256; |
| 28 static const int kVertsPerAAFillRect = 8; | 28 static const int kVertsPerAAFillRect = 8; |
| 29 static const int kIndicesPerAAFillRect = 30; | 29 static const int kIndicesPerAAFillRect = 30; |
| 30 | 30 |
| 31 const GrIndexBuffer* get_index_buffer(GrResourceProvider* resourceProvider) { | 31 const GrBuffer* get_index_buffer(GrResourceProvider* resourceProvider) { |
| 32 GR_DEFINE_STATIC_UNIQUE_KEY(gAAFillRectIndexBufferKey); | 32 GR_DEFINE_STATIC_UNIQUE_KEY(gAAFillRectIndexBufferKey); |
| 33 | 33 |
| 34 static const uint16_t gFillAARectIdx[] = { | 34 static const uint16_t gFillAARectIdx[] = { |
| 35 0, 1, 5, 5, 4, 0, | 35 0, 1, 5, 5, 4, 0, |
| 36 1, 2, 6, 6, 5, 1, | 36 1, 2, 6, 6, 5, 1, |
| 37 2, 3, 7, 7, 6, 2, | 37 2, 3, 7, 7, 6, 2, |
| 38 3, 0, 4, 4, 7, 3, | 38 3, 0, 4, 4, 7, 3, |
| 39 4, 5, 6, 6, 7, 4, | 39 4, 5, 6, 6, 7, 4, |
| 40 }; | 40 }; |
| 41 GR_STATIC_ASSERT(SK_ARRAY_COUNT(gFillAARectIdx) == kIndicesPerAAFillRect); | 41 GR_STATIC_ASSERT(SK_ARRAY_COUNT(gFillAARectIdx) == kIndicesPerAAFillRect); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 // Common functions | 184 // Common functions |
| 185 class AAFillRectBatchBase { | 185 class AAFillRectBatchBase { |
| 186 public: | 186 public: |
| 187 static const int kVertsPerInstance = kVertsPerAAFillRect; | 187 static const int kVertsPerInstance = kVertsPerAAFillRect; |
| 188 static const int kIndicesPerInstance = kIndicesPerAAFillRect; | 188 static const int kIndicesPerInstance = kIndicesPerAAFillRect; |
| 189 | 189 |
| 190 static void InitInvariantOutputCoverage(GrInitInvariantOutput* out) { | 190 static void InitInvariantOutputCoverage(GrInitInvariantOutput* out) { |
| 191 out->setUnknownSingleComponent(); | 191 out->setUnknownSingleComponent(); |
| 192 } | 192 } |
| 193 | 193 |
| 194 static const GrIndexBuffer* GetIndexBuffer(GrResourceProvider* rp) { | 194 static const GrBuffer* GetIndexBuffer(GrResourceProvider* rp) { |
| 195 return get_index_buffer(rp); | 195 return get_index_buffer(rp); |
| 196 } | 196 } |
| 197 | 197 |
| 198 template <class Geometry> | 198 template <class Geometry> |
| 199 static void SetBounds(const Geometry& geo, SkRect* outBounds) { | 199 static void SetBounds(const Geometry& geo, SkRect* outBounds) { |
| 200 *outBounds = geo.fDevRect; | 200 *outBounds = geo.fDevRect; |
| 201 } | 201 } |
| 202 | 202 |
| 203 template <class Geometry> | 203 template <class Geometry> |
| 204 static void UpdateBoundsAfterAppend(const Geometry& geo, SkRect* outBounds)
{ | 204 static void UpdateBoundsAfterAppend(const Geometry& geo, SkRect* outBounds)
{ |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 DRAW_BATCH_TEST_DEFINE(AAFillRectBatchLocalMatrix) { | 412 DRAW_BATCH_TEST_DEFINE(AAFillRectBatchLocalMatrix) { |
| 413 GrColor color = GrRandomColor(random); | 413 GrColor color = GrRandomColor(random); |
| 414 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random); | 414 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random); |
| 415 SkMatrix localMatrix = GrTest::TestMatrix(random); | 415 SkMatrix localMatrix = GrTest::TestMatrix(random); |
| 416 SkRect rect = GrTest::TestRect(random); | 416 SkRect rect = GrTest::TestRect(random); |
| 417 SkRect devRect = GrTest::TestRect(random); | 417 SkRect devRect = GrTest::TestRect(random); |
| 418 return GrAAFillRectBatch::Create(color, viewMatrix, localMatrix, rect, devRe
ct); | 418 return GrAAFillRectBatch::Create(color, viewMatrix, localMatrix, rect, devRe
ct); |
| 419 } | 419 } |
| 420 | 420 |
| 421 #endif | 421 #endif |
| OLD | NEW |