| 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 "GrGpu.h" | 9 #include "GrGpu.h" |
| 10 #include "gl/GrGLEffect.h" | 10 #include "gl/GrGLEffect.h" |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 static const int kNumAAFillRectsInIndexBuffer = 256; | 304 static const int kNumAAFillRectsInIndexBuffer = 256; |
| 305 | 305 |
| 306 GrIndexBuffer* GrAARectRenderer::aaFillRectIndexBuffer(GrGpu* gpu) { | 306 GrIndexBuffer* GrAARectRenderer::aaFillRectIndexBuffer(GrGpu* gpu) { |
| 307 static const size_t kAAFillRectIndexBufferSize = kIndicesPerAAFillRect * | 307 static const size_t kAAFillRectIndexBufferSize = kIndicesPerAAFillRect * |
| 308 sizeof(uint16_t) * | 308 sizeof(uint16_t) * |
| 309 kNumAAFillRectsInIndexBuffe
r; | 309 kNumAAFillRectsInIndexBuffe
r; |
| 310 | 310 |
| 311 if (NULL == fAAFillRectIndexBuffer) { | 311 if (NULL == fAAFillRectIndexBuffer) { |
| 312 fAAFillRectIndexBuffer = gpu->createIndexBuffer(kAAFillRectIndexBufferSi
ze, false); | 312 fAAFillRectIndexBuffer = gpu->createIndexBuffer(kAAFillRectIndexBufferSi
ze, false); |
| 313 if (NULL != fAAFillRectIndexBuffer) { | 313 if (NULL != fAAFillRectIndexBuffer) { |
| 314 uint16_t* data = (uint16_t*) fAAFillRectIndexBuffer->lock(); | 314 uint16_t* data = (uint16_t*) fAAFillRectIndexBuffer->map(); |
| 315 bool useTempData = (NULL == data); | 315 bool useTempData = (NULL == data); |
| 316 if (useTempData) { | 316 if (useTempData) { |
| 317 data = SkNEW_ARRAY(uint16_t, kNumAAFillRectsInIndexBuffer * kInd
icesPerAAFillRect); | 317 data = SkNEW_ARRAY(uint16_t, kNumAAFillRectsInIndexBuffer * kInd
icesPerAAFillRect); |
| 318 } | 318 } |
| 319 for (int i = 0; i < kNumAAFillRectsInIndexBuffer; ++i) { | 319 for (int i = 0; i < kNumAAFillRectsInIndexBuffer; ++i) { |
| 320 // Each AA filled rect is drawn with 8 vertices and 10 triangles
(8 around | 320 // Each AA filled rect is drawn with 8 vertices and 10 triangles
(8 around |
| 321 // the inner rect (for AA) and 2 for the inner rect. | 321 // the inner rect (for AA) and 2 for the inner rect. |
| 322 int baseIdx = i * kIndicesPerAAFillRect; | 322 int baseIdx = i * kIndicesPerAAFillRect; |
| 323 uint16_t baseVert = (uint16_t)(i * kVertsPerAAFillRect); | 323 uint16_t baseVert = (uint16_t)(i * kVertsPerAAFillRect); |
| 324 for (int j = 0; j < kIndicesPerAAFillRect; ++j) { | 324 for (int j = 0; j < kIndicesPerAAFillRect; ++j) { |
| 325 data[baseIdx+j] = baseVert + gFillAARectIdx[j]; | 325 data[baseIdx+j] = baseVert + gFillAARectIdx[j]; |
| 326 } | 326 } |
| 327 } | 327 } |
| 328 if (useTempData) { | 328 if (useTempData) { |
| 329 if (!fAAFillRectIndexBuffer->updateData(data, kAAFillRectIndexBu
fferSize)) { | 329 if (!fAAFillRectIndexBuffer->updateData(data, kAAFillRectIndexBu
fferSize)) { |
| 330 SkFAIL("Can't get AA Fill Rect indices into buffer!"); | 330 SkFAIL("Can't get AA Fill Rect indices into buffer!"); |
| 331 } | 331 } |
| 332 SkDELETE_ARRAY(data); | 332 SkDELETE_ARRAY(data); |
| 333 } else { | 333 } else { |
| 334 fAAFillRectIndexBuffer->unlock(); | 334 fAAFillRectIndexBuffer->unmap(); |
| 335 } | 335 } |
| 336 } | 336 } |
| 337 } | 337 } |
| 338 | 338 |
| 339 return fAAFillRectIndexBuffer; | 339 return fAAFillRectIndexBuffer; |
| 340 } | 340 } |
| 341 | 341 |
| 342 static const uint16_t gMiterStrokeAARectIdx[] = { | 342 static const uint16_t gMiterStrokeAARectIdx[] = { |
| 343 0 + 0, 1 + 0, 5 + 0, 5 + 0, 4 + 0, 0 + 0, | 343 0 + 0, 1 + 0, 5 + 0, 5 + 0, 4 + 0, 0 + 0, |
| 344 1 + 0, 2 + 0, 6 + 0, 6 + 0, 5 + 0, 1 + 0, | 344 1 + 0, 2 + 0, 6 + 0, 6 + 0, 5 + 0, 1 + 0, |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 923 combinedMatrix.mapPoints((SkPoint*)&devInside, (const SkPoint*)&rects[1], 2)
; | 923 combinedMatrix.mapPoints((SkPoint*)&devInside, (const SkPoint*)&rects[1], 2)
; |
| 924 | 924 |
| 925 if (devInside.isEmpty()) { | 925 if (devInside.isEmpty()) { |
| 926 this->fillAARect(gpu, target, devOutside, SkMatrix::I(), devOutside, use
VertexCoverage); | 926 this->fillAARect(gpu, target, devOutside, SkMatrix::I(), devOutside, use
VertexCoverage); |
| 927 return; | 927 return; |
| 928 } | 928 } |
| 929 | 929 |
| 930 this->geometryStrokeAARect(gpu, target, devOutside, devOutsideAssist, | 930 this->geometryStrokeAARect(gpu, target, devOutside, devOutsideAssist, |
| 931 devInside, useVertexCoverage, true); | 931 devInside, useVertexCoverage, true); |
| 932 } | 932 } |
| OLD | NEW |