Index: src/gpu/SkGpuDevice.cpp |
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp |
index d0f8d46ee89b87a10be354e11031c344950f67b9..8cae0b742c8634b5b14d18480a69d51bee081c27 100644 |
--- a/src/gpu/SkGpuDevice.cpp |
+++ b/src/gpu/SkGpuDevice.cpp |
@@ -1639,6 +1639,57 @@ void SkGpuDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode, |
/////////////////////////////////////////////////////////////////////////////// |
+static void to_quad(SkPoint quad[], const SkRect& r) { |
bsalomon
2015/06/25 21:31:38
SkRect already has toQuad().
reed1
2015/06/25 21:47:51
Done.
|
+ quad[0].set(r.fLeft, r.fTop); |
+ quad[1].set(r.fRight, r.fTop); |
+ quad[2].set(r.fRight, r.fBottom); |
+ quad[3].set(r.fLeft, r.fBottom); |
+} |
+ |
+static void append_quad_indices(uint16_t indices[], int quadIndex) { |
+ int i = quadIndex * 4; |
+ indices[0] = i + 0; indices[1] = i + 1; indices[2] = i + 2; |
+ indices[3] = i + 2; indices[4] = i + 3; indices[5] = i + 0; |
+} |
+ |
+void SkGpuDevice::drawAtlas(const SkDraw& d, const SkImage* atlas, const SkRSXform xform[], |
+ const SkRect texRect[], const SkColor colors[], int count, |
+ SkXfermode::Mode mode, const SkPaint& paint) { |
+ if (paint.isAntiAlias()) { |
+ this->INHERITED::drawAtlas(d, atlas, xform, texRect, colors, count, mode, paint); |
+ return; |
+ } |
+ |
+ SkPaint p(paint); |
+ p.setShader(atlas->newShader(SkShader::kClamp_TileMode, SkShader::kClamp_TileMode))->unref(); |
+ |
+ const int vertCount = count * 4; |
+ const int indexCount = count * 6; |
+ SkAutoTMalloc<SkPoint> vertStorage(vertCount * 2); |
+ SkPoint* verts = vertStorage.get(); |
+ SkPoint* texs = verts + vertCount; |
+ SkAutoTMalloc<uint16_t> indexStorage(indexCount); |
+ uint16_t* indices = indexStorage.get(); |
+ SkAutoTUnref<SkXfermode> xfer(SkXfermode::Create(mode)); |
+ |
+ for (int i = 0; i < count; ++i) { |
+ xform[i].toQuad(texRect[i].width(), texRect[i].height(), verts); |
+ to_quad(texs, texRect[i]); |
+ append_quad_indices(indices, i); |
+ verts += 4; |
+ texs += 4; |
+ indices += 6; |
+ } |
+ |
+ verts = vertStorage.get(); |
+ texs = verts + vertCount; |
+ indices = indexStorage.get(); |
+ this->drawVertices(d, SkCanvas::kTriangles_VertexMode, vertCount, verts, texs, colors, xfer, |
+ indices, indexCount, p); |
+} |
+ |
+/////////////////////////////////////////////////////////////////////////////// |
+ |
void SkGpuDevice::drawText(const SkDraw& draw, const void* text, |
size_t byteLength, SkScalar x, SkScalar y, |
const SkPaint& paint) { |