|
1 diff --git a/gfx/skia/include/core/SkPaint.h b/gfx/skia/include/core/SkPaint.h |
|
2 --- a/gfx/skia/include/core/SkPaint.h |
|
3 +++ b/gfx/skia/include/core/SkPaint.h |
|
4 @@ -836,16 +836,19 @@ public: |
|
5 |
|
6 /** Return the path (outline) for the specified text. |
|
7 Note: just like SkCanvas::drawText, this will respect the Align setting |
|
8 in the paint. |
|
9 */ |
|
10 void getTextPath(const void* text, size_t length, SkScalar x, SkScalar y, |
|
11 SkPath* path) const; |
|
12 |
|
13 + void getPosTextPath(const void* text, size_t length, |
|
14 + const SkPoint pos[], SkPath* path) const; |
|
15 + |
|
16 #ifdef SK_BUILD_FOR_ANDROID |
|
17 const SkGlyph& getUnicharMetrics(SkUnichar); |
|
18 const void* findImage(const SkGlyph&); |
|
19 |
|
20 uint32_t getGenerationID() const; |
|
21 #endif |
|
22 |
|
23 // returns true if the paint's settings (e.g. xfermode + alpha) resolve to |
|
24 diff --git a/gfx/skia/src/core/SkPaint.cpp b/gfx/skia/src/core/SkPaint.cpp |
|
25 --- a/gfx/skia/src/core/SkPaint.cpp |
|
26 +++ b/gfx/skia/src/core/SkPaint.cpp |
|
27 @@ -1242,16 +1242,43 @@ void SkPaint::getTextPath(const void* te |
|
28 const SkPath* iterPath; |
|
29 while ((iterPath = iter.next(&xpos)) != NULL) { |
|
30 matrix.postTranslate(xpos - prevXPos, 0); |
|
31 path->addPath(*iterPath, matrix); |
|
32 prevXPos = xpos; |
|
33 } |
|
34 } |
|
35 |
|
36 +void SkPaint::getPosTextPath(const void* textData, size_t length, |
|
37 + const SkPoint pos[], SkPath* path) const { |
|
38 + SkASSERT(length == 0 || textData != NULL); |
|
39 + |
|
40 + const char* text = (const char*)textData; |
|
41 + if (text == NULL || length == 0 || path == NULL) { |
|
42 + return; |
|
43 + } |
|
44 + |
|
45 + SkTextToPathIter iter(text, length, *this, false, true); |
|
46 + SkMatrix matrix; |
|
47 + SkPoint prevPos; |
|
48 + prevPos.set(0, 0); |
|
49 + |
|
50 + matrix.setScale(iter.getPathScale(), iter.getPathScale()); |
|
51 + path->reset(); |
|
52 + |
|
53 + unsigned int i = 0; |
|
54 + const SkPath* iterPath; |
|
55 + while ((iterPath = iter.next(NULL)) != NULL) { |
|
56 + matrix.postTranslate(pos[i].fX - prevPos.fX, pos[i].fY - prevPos.fY); |
|
57 + path->addPath(*iterPath, matrix); |
|
58 + prevPos = pos[i]; |
|
59 + i++; |
|
60 + } |
|
61 +} |
|
62 + |
|
63 static void add_flattenable(SkDescriptor* desc, uint32_t tag, |
|
64 SkFlattenableWriteBuffer* buffer) { |
|
65 buffer->flatten(desc->addEntry(tag, buffer->size(), NULL)); |
|
66 } |
|
67 |
|
68 // SkFontHost can override this choice in FilterRec() |
|
69 static SkMask::Format computeMaskFormat(const SkPaint& paint) { |
|
70 uint32_t flags = paint.getFlags(); |