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 "gl/builders/GrGLProgramBuilder.h" | 8 #include "gl/builders/GrGLProgramBuilder.h" |
9 #include "GrAARectRenderer.h" | 9 #include "GrAARectRenderer.h" |
10 #include "GrGpu.h" | 10 #include "GrGpu.h" |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 static const int kVertsPerAAFillRect = 8; | 308 static const int kVertsPerAAFillRect = 8; |
309 static const int kNumAAFillRectsInIndexBuffer = 256; | 309 static const int kNumAAFillRectsInIndexBuffer = 256; |
310 | 310 |
311 GrIndexBuffer* GrAARectRenderer::aaFillRectIndexBuffer(GrGpu* gpu) { | 311 GrIndexBuffer* GrAARectRenderer::aaFillRectIndexBuffer(GrGpu* gpu) { |
312 static const size_t kAAFillRectIndexBufferSize = kIndicesPerAAFillRect * | 312 static const size_t kAAFillRectIndexBufferSize = kIndicesPerAAFillRect * |
313 sizeof(uint16_t) * | 313 sizeof(uint16_t) * |
314 kNumAAFillRectsInIndexBuffe
r; | 314 kNumAAFillRectsInIndexBuffe
r; |
315 | 315 |
316 if (NULL == fAAFillRectIndexBuffer) { | 316 if (NULL == fAAFillRectIndexBuffer) { |
317 fAAFillRectIndexBuffer = gpu->createIndexBuffer(kAAFillRectIndexBufferSi
ze, false); | 317 fAAFillRectIndexBuffer = gpu->createIndexBuffer(kAAFillRectIndexBufferSi
ze, false); |
318 if (NULL != fAAFillRectIndexBuffer) { | 318 if (fAAFillRectIndexBuffer) { |
319 uint16_t* data = (uint16_t*) fAAFillRectIndexBuffer->map(); | 319 uint16_t* data = (uint16_t*) fAAFillRectIndexBuffer->map(); |
320 bool useTempData = (NULL == data); | 320 bool useTempData = (NULL == data); |
321 if (useTempData) { | 321 if (useTempData) { |
322 data = SkNEW_ARRAY(uint16_t, kNumAAFillRectsInIndexBuffer * kInd
icesPerAAFillRect); | 322 data = SkNEW_ARRAY(uint16_t, kNumAAFillRectsInIndexBuffer * kInd
icesPerAAFillRect); |
323 } | 323 } |
324 for (int i = 0; i < kNumAAFillRectsInIndexBuffer; ++i) { | 324 for (int i = 0; i < kNumAAFillRectsInIndexBuffer; ++i) { |
325 // Each AA filled rect is drawn with 8 vertices and 10 triangles
(8 around | 325 // Each AA filled rect is drawn with 8 vertices and 10 triangles
(8 around |
326 // the inner rect (for AA) and 2 for the inner rect. | 326 // the inner rect (for AA) and 2 for the inner rect. |
327 int baseIdx = i * kIndicesPerAAFillRect; | 327 int baseIdx = i * kIndicesPerAAFillRect; |
328 uint16_t baseVert = (uint16_t)(i * kVertsPerAAFillRect); | 328 uint16_t baseVert = (uint16_t)(i * kVertsPerAAFillRect); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 int GrAARectRenderer::aaStrokeRectIndexCount(bool miterStroke) { | 421 int GrAARectRenderer::aaStrokeRectIndexCount(bool miterStroke) { |
422 return miterStroke ? SK_ARRAY_COUNT(gMiterStrokeAARectIdx) : | 422 return miterStroke ? SK_ARRAY_COUNT(gMiterStrokeAARectIdx) : |
423 SK_ARRAY_COUNT(gBevelStrokeAARectIdx); | 423 SK_ARRAY_COUNT(gBevelStrokeAARectIdx); |
424 } | 424 } |
425 | 425 |
426 GrIndexBuffer* GrAARectRenderer::aaStrokeRectIndexBuffer(GrGpu* gpu, bool miterS
troke) { | 426 GrIndexBuffer* GrAARectRenderer::aaStrokeRectIndexBuffer(GrGpu* gpu, bool miterS
troke) { |
427 if (miterStroke) { | 427 if (miterStroke) { |
428 if (NULL == fAAMiterStrokeRectIndexBuffer) { | 428 if (NULL == fAAMiterStrokeRectIndexBuffer) { |
429 fAAMiterStrokeRectIndexBuffer = | 429 fAAMiterStrokeRectIndexBuffer = |
430 gpu->createIndexBuffer(sizeof(gMiterStrokeAARectIdx), false); | 430 gpu->createIndexBuffer(sizeof(gMiterStrokeAARectIdx), false); |
431 if (NULL != fAAMiterStrokeRectIndexBuffer) { | 431 if (fAAMiterStrokeRectIndexBuffer) { |
432 #ifdef SK_DEBUG | 432 #ifdef SK_DEBUG |
433 bool updated = | 433 bool updated = |
434 #endif | 434 #endif |
435 fAAMiterStrokeRectIndexBuffer->updateData(gMiterStrokeAARectIdx, | 435 fAAMiterStrokeRectIndexBuffer->updateData(gMiterStrokeAARectIdx, |
436 sizeof(gMiterStrokeAAR
ectIdx)); | 436 sizeof(gMiterStrokeAAR
ectIdx)); |
437 GR_DEBUGASSERT(updated); | 437 GR_DEBUGASSERT(updated); |
438 } | 438 } |
439 } | 439 } |
440 return fAAMiterStrokeRectIndexBuffer; | 440 return fAAMiterStrokeRectIndexBuffer; |
441 } else { | 441 } else { |
442 if (NULL == fAABevelStrokeRectIndexBuffer) { | 442 if (NULL == fAABevelStrokeRectIndexBuffer) { |
443 fAABevelStrokeRectIndexBuffer = | 443 fAABevelStrokeRectIndexBuffer = |
444 gpu->createIndexBuffer(sizeof(gBevelStrokeAARectIdx), false); | 444 gpu->createIndexBuffer(sizeof(gBevelStrokeAARectIdx), false); |
445 if (NULL != fAABevelStrokeRectIndexBuffer) { | 445 if (fAABevelStrokeRectIndexBuffer) { |
446 #ifdef SK_DEBUG | 446 #ifdef SK_DEBUG |
447 bool updated = | 447 bool updated = |
448 #endif | 448 #endif |
449 fAABevelStrokeRectIndexBuffer->updateData(gBevelStrokeAARectIdx, | 449 fAABevelStrokeRectIndexBuffer->updateData(gBevelStrokeAARectIdx, |
450 sizeof(gBevelStrokeAAR
ectIdx)); | 450 sizeof(gBevelStrokeAAR
ectIdx)); |
451 GR_DEBUGASSERT(updated); | 451 GR_DEBUGASSERT(updated); |
452 } | 452 } |
453 } | 453 } |
454 return fAABevelStrokeRectIndexBuffer; | 454 return fAABevelStrokeRectIndexBuffer; |
455 } | 455 } |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
949 // can't call mapRect for devInside since it calls sort | 949 // can't call mapRect for devInside since it calls sort |
950 combinedMatrix.mapPoints((SkPoint*)&devInside, (const SkPoint*)&rects[1], 2)
; | 950 combinedMatrix.mapPoints((SkPoint*)&devInside, (const SkPoint*)&rects[1], 2)
; |
951 | 951 |
952 if (devInside.isEmpty()) { | 952 if (devInside.isEmpty()) { |
953 this->fillAARect(gpu, target, devOutside, SkMatrix::I(), devOutside); | 953 this->fillAARect(gpu, target, devOutside, SkMatrix::I(), devOutside); |
954 return; | 954 return; |
955 } | 955 } |
956 | 956 |
957 this->geometryStrokeAARect(gpu, target, devOutside, devOutsideAssist, devIns
ide, true); | 957 this->geometryStrokeAARect(gpu, target, devOutside, devOutsideAssist, devIns
ide, true); |
958 } | 958 } |
OLD | NEW |