Index: src/core/SkDevice.cpp |
diff --git a/src/core/SkDevice.cpp b/src/core/SkDevice.cpp |
index f4ae7b138173cf7132b67bda531ffc022ac83d61..d22b22752d23852e676fd18b4c8e0f445ba40fb3 100644 |
--- a/src/core/SkDevice.cpp |
+++ b/src/core/SkDevice.cpp |
@@ -9,6 +9,7 @@ |
#include "SkDraw.h" |
#include "SkMetaData.h" |
#include "SkPatchUtils.h" |
+#include "SkTextBlob.h" |
SkBaseDevice::SkBaseDevice() |
: fLeakyProperties(SkDeviceProperties::MakeDefault()) |
@@ -94,6 +95,44 @@ void SkBaseDevice::drawPatch(const SkDraw& draw, const SkPoint cubics[12], const |
} |
} |
+void SkBaseDevice::drawTextBlob(const SkDraw& draw, const SkTextBlob* blob, SkScalar x, SkScalar y, |
+ const SkPaint &paint) { |
+ |
+ SkMatrix localMatrix; |
+ SkDraw localDraw(draw); |
+ |
+ if (x || y) { |
+ localMatrix = *draw.fMatrix; |
+ localMatrix.preTranslate(x, y); |
+ localDraw.fMatrix = &localMatrix; |
+ } |
+ |
+ SkPaint runPaint = paint; |
+ SkTextBlob::RunIterator it(blob); |
+ while (!it.done()) { |
+ size_t textLen = it.glyphCount() * sizeof(uint16_t); |
+ const SkPoint& offset = it.offset(); |
+ // applyFontToPaint() always overwrites the exact same attributes, |
+ // so it is safe to not re-seed the paint. |
+ it.applyFontToPaint(&runPaint); |
+ |
+ switch (it.positioning()) { |
+ case SkTextBlob::kDefault_Positioning: |
+ this->drawText(localDraw, it.glyphs(), textLen, offset.x(), offset.y(), runPaint); |
+ break; |
+ case SkTextBlob::kHorizontal_Positioning: |
+ case SkTextBlob::kFull_Positioning: |
+ this->drawPosText(localDraw, it.glyphs(), textLen, it.pos(), offset.y(), |
+ SkTextBlob::ScalarsPerGlyph(it.positioning()), runPaint); |
+ break; |
+ default: |
+ SkFAIL("unhandled positioning mode"); |
+ } |
+ |
+ it.next(); |
+ } |
+} |
+ |
bool SkBaseDevice::readPixels(const SkImageInfo& info, void* dstP, size_t rowBytes, int x, int y) { |
#ifdef SK_DEBUG |
SkASSERT(info.width() > 0 && info.height() > 0); |