michael@0: From 27a914815e757ed12523edf968c9da134dabeaf8 Mon Sep 17 00:00:00 2001 michael@0: From: George Wright michael@0: Date: Fri, 18 May 2012 14:10:44 -0400 michael@0: Subject: [PATCH 01/10] Bug 755869 - [4] Re-apply bug 687189 - Implement michael@0: SkPaint::getPosTextPath r=mattwoodrow michael@0: michael@0: --- michael@0: gfx/skia/include/core/SkPaint.h | 3 +++ michael@0: gfx/skia/src/core/SkPaint.cpp | 27 +++++++++++++++++++++++++++ michael@0: 2 files changed, 30 insertions(+), 0 deletions(-) michael@0: michael@0: diff --git a/gfx/skia/include/core/SkPaint.h b/gfx/skia/include/core/SkPaint.h michael@0: index 1930db1..ff37d77 100644 michael@0: --- a/gfx/skia/include/core/SkPaint.h michael@0: +++ b/gfx/skia/include/core/SkPaint.h michael@0: @@ -813,6 +813,9 @@ public: michael@0: void getTextPath(const void* text, size_t length, SkScalar x, SkScalar y, michael@0: SkPath* path) const; michael@0: michael@0: + void getPosTextPath(const void* text, size_t length, michael@0: + const SkPoint pos[], SkPath* path) const; michael@0: + michael@0: #ifdef SK_BUILD_FOR_ANDROID michael@0: const SkGlyph& getUnicharMetrics(SkUnichar); michael@0: const SkGlyph& getGlyphMetrics(uint16_t); michael@0: diff --git a/gfx/skia/src/core/SkPaint.cpp b/gfx/skia/src/core/SkPaint.cpp michael@0: index 1b74fa1..4c119aa 100644 michael@0: --- a/gfx/skia/src/core/SkPaint.cpp michael@0: +++ b/gfx/skia/src/core/SkPaint.cpp michael@0: @@ -1355,6 +1355,33 @@ void SkPaint::getTextPath(const void* textData, size_t length, michael@0: } michael@0: } michael@0: michael@0: +void SkPaint::getPosTextPath(const void* textData, size_t length, michael@0: + const SkPoint pos[], SkPath* path) const { michael@0: + SkASSERT(length == 0 || textData != NULL); michael@0: + michael@0: + const char* text = (const char*)textData; michael@0: + if (text == NULL || length == 0 || path == NULL) { michael@0: + return; michael@0: + } michael@0: + michael@0: + SkTextToPathIter iter(text, length, *this, false); michael@0: + SkMatrix matrix; michael@0: + SkPoint prevPos; michael@0: + prevPos.set(0, 0); michael@0: + michael@0: + matrix.setScale(iter.getPathScale(), iter.getPathScale()); michael@0: + path->reset(); michael@0: + michael@0: + unsigned int i = 0; michael@0: + const SkPath* iterPath; michael@0: + while ((iterPath = iter.next(NULL)) != NULL) { michael@0: + matrix.postTranslate(pos[i].fX - prevPos.fX, pos[i].fY - prevPos.fY); michael@0: + path->addPath(*iterPath, matrix); michael@0: + prevPos = pos[i]; michael@0: + i++; michael@0: + } michael@0: +} michael@0: + michael@0: static void add_flattenable(SkDescriptor* desc, uint32_t tag, michael@0: SkFlattenableWriteBuffer* buffer) { michael@0: buffer->flatten(desc->addEntry(tag, buffer->size(), NULL)); michael@0: -- michael@0: 1.7.5.4 michael@0: