| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "GrAndroidPathRenderer.h" | 9 #include "GrAndroidPathRenderer.h" |
| 10 #include "AndroidPathRenderer.h" | 10 #include "AndroidPathRenderer.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 // allocate our vert buffer | 55 // allocate our vert buffer |
| 56 int vertCount = vertices.getSize(); | 56 int vertCount = vertices.getSize(); |
| 57 GrDrawTarget::AutoReleaseGeometry geo(target, vertCount, 0); | 57 GrDrawTarget::AutoReleaseGeometry geo(target, vertCount, 0); |
| 58 if (!geo.succeeded()) { | 58 if (!geo.succeeded()) { |
| 59 GrPrintf("Failed to get space for vertices!\n"); | 59 GrPrintf("Failed to get space for vertices!\n"); |
| 60 return false; | 60 return false; |
| 61 } | 61 } |
| 62 | 62 |
| 63 // copy android verts to our vertex buffer | 63 // copy android verts to our vertex buffer |
| 64 if (antiAlias) { | 64 if (antiAlias) { |
| 65 GrAssert(sizeof(ColorVertex) == drawState->getVertexSize()); | 65 SkASSERT(sizeof(ColorVertex) == drawState->getVertexSize()); |
| 66 ColorVertex* outVert = reinterpret_cast<ColorVertex*>(geo.vertices()); | 66 ColorVertex* outVert = reinterpret_cast<ColorVertex*>(geo.vertices()); |
| 67 android::uirenderer::AlphaVertex* inVert = | 67 android::uirenderer::AlphaVertex* inVert = |
| 68 reinterpret_cast<android::uirenderer::AlphaVertex*>(vertices.getBuff
er()); | 68 reinterpret_cast<android::uirenderer::AlphaVertex*>(vertices.getBuff
er()); |
| 69 | 69 |
| 70 for (int i = 0; i < vertCount; ++i) { | 70 for (int i = 0; i < vertCount; ++i) { |
| 71 // copy vertex position | 71 // copy vertex position |
| 72 outVert->pos.set(inVert->position[0], inVert->position[1]); | 72 outVert->pos.set(inVert->position[0], inVert->position[1]); |
| 73 // copy alpha | 73 // copy alpha |
| 74 int coverage = static_cast<int>(inVert->alpha * 0xff); | 74 int coverage = static_cast<int>(inVert->alpha * 0xff); |
| 75 outVert->color = GrColorPackRGBA(coverage, coverage, coverage, cover
age); | 75 outVert->color = GrColorPackRGBA(coverage, coverage, coverage, cover
age); |
| 76 ++outVert; | 76 ++outVert; |
| 77 ++inVert; | 77 ++inVert; |
| 78 } | 78 } |
| 79 } else { | 79 } else { |
| 80 size_t vsize = drawState->getVertexSize(); | 80 size_t vsize = drawState->getVertexSize(); |
| 81 size_t copySize = vsize*vertCount; | 81 size_t copySize = vsize*vertCount; |
| 82 memcpy(geo.vertices(), vertices.getBuffer(), copySize); | 82 memcpy(geo.vertices(), vertices.getBuffer(), copySize); |
| 83 } | 83 } |
| 84 | 84 |
| 85 // render it | 85 // render it |
| 86 target->drawNonIndexed(kTriangleStrip_GrPrimitiveType, 0, vertCount); | 86 target->drawNonIndexed(kTriangleStrip_GrPrimitiveType, 0, vertCount); |
| 87 | 87 |
| 88 return true; | 88 return true; |
| 89 } | 89 } |
| OLD | NEW |