Index: src/core/SkCanvas.cpp |
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp |
index 7e2609b22d133c60c3ca2ab06fc2fb2f7dc9708b..77b669769858a1054a78c58361dc70bd2b36cbf8 100644 |
--- a/src/core/SkCanvas.cpp |
+++ b/src/core/SkCanvas.cpp |
@@ -22,6 +22,7 @@ |
#include "SkSmallAllocator.h" |
#include "SkSurface_Base.h" |
#include "SkTemplates.h" |
+#include "SkTextBlob.h" |
#include "SkTextFormatParams.h" |
#include "SkTLazy.h" |
#include "SkUtils.h" |
@@ -2222,6 +2223,40 @@ void SkCanvas::onDrawTextOnPath(const void* text, size_t byteLength, const SkPat |
LOOPER_END |
} |
+void SkCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, |
+ const SkPaint& paint) { |
+ SkASSERT(blob); |
+ |
+ // FIXME: dispatch to the device instead |
+ |
+ if (x || y) { |
+ this->translate(x, y); |
+ } |
+ |
+ for (unsigned i = 0; i < blob->runs(); ++i) { |
+ SkTextBlob::RunInfo runInfo = blob->runInfo(i); |
+ size_t textLen = runInfo.glyphCount * sizeof(uint16_t); |
+ |
+ switch (runInfo.positioning) { |
+ case SkTextBlob::kDefault_Positioning: |
+ this->drawText(runInfo.glyphs, textLen, 0, 0, paint); |
+ break; |
+ case SkTextBlob::kHorizontal_Positioning: |
+ this->drawPosTextH(runInfo.glyphs, textLen, runInfo.pos, 0, paint); |
+ break; |
+ case SkTextBlob::kFull_Positioning: |
+ this->drawPosText(runInfo.glyphs, textLen, (const SkPoint*)runInfo.pos, paint); |
+ break; |
+ default: |
+ SkFAIL("unhandled positioning mode"); |
+ } |
+ } |
+ |
+ if (x || y) { |
+ this->translate(-x, -y); |
+ } |
+} |
+ |
// These will become non-virtual, so they always call the (virtual) onDraw... method |
void SkCanvas::drawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, |
const SkPaint& paint) { |
@@ -2239,6 +2274,12 @@ void SkCanvas::drawTextOnPath(const void* text, size_t byteLength, const SkPath& |
const SkMatrix* matrix, const SkPaint& paint) { |
this->onDrawTextOnPath(text, byteLength, path, matrix, paint); |
} |
+void SkCanvas::drawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, |
+ const SkPaint& paint) { |
+ if (NULL != blob) { |
+ this->onDrawTextBlob(blob, x, y, paint); |
+ } |
+} |
void SkCanvas::drawVertices(VertexMode vmode, int vertexCount, |
const SkPoint verts[], const SkPoint texs[], |