Index: src/core/SkPaint.cpp |
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp |
index b9f5cedc1531c7115b64f31eaef5d9b46f6c67b5..cea3d0fc8dde623e16bfa8a538166438a43ea264 100644 |
--- a/src/core/SkPaint.cpp |
+++ b/src/core/SkPaint.cpp |
@@ -1259,6 +1259,23 @@ void SkPaint::getTextPath(const void* textData, size_t length, |
} |
} |
+int SkPaint::getTextIntercepts(const void* textData, size_t length, |
+ SkScalar x, SkScalar y, const SkScalar bounds[2], |
+ SkScalar* array) const { |
+ SkASSERT(length == 0 || textData != nullptr); |
+ if (!length) { |
+ return 0; |
+ } |
+ |
+ const char* text = (const char*) textData; |
+ SkTextInterceptsIter iter(text, length, *this, bounds, x, y, |
+ SkTextInterceptsIter::TextType::kText); |
+ int count = 0; |
+ while (iter.next(array, &count)) { |
+ } |
+ return count; |
+} |
+ |
void SkPaint::getPosTextPath(const void* textData, size_t length, |
const SkPoint pos[], SkPath* path) const { |
SkASSERT(length == 0 || textData != nullptr); |
@@ -1288,6 +1305,25 @@ void SkPaint::getPosTextPath(const void* textData, size_t length, |
} |
} |
+int SkPaint::getPosTextIntercepts(const void* textData, size_t length, const SkPoint pos[], |
+ const SkScalar bounds[2], SkScalar* array) const { |
+ SkASSERT(length == 0 || textData != nullptr); |
+ if (!length) { |
+ return 0; |
+ } |
+ |
+ const char* text = (const char*) textData; |
+ SkTextInterceptsIter iter(text, length, *this, bounds, pos[0].fX, pos[0].fY, |
+ SkTextInterceptsIter::TextType::kPosText); |
+ int i = 0; |
+ int count = 0; |
+ while (iter.next(array, &count)) { |
+ i++; |
+ iter.setPosition(pos[i].fX, pos[i].fY); |
+ } |
+ return count; |
+} |
+ |
SkRect SkPaint::getFontBounds() const { |
SkMatrix m; |
m.setScale(fTextSize * fTextScaleX, fTextSize); |
@@ -2352,7 +2388,7 @@ static bool has_thick_frame(const SkPaint& paint) { |
paint.getStyle() != SkPaint::kFill_Style; |
} |
-SkTextToPathIter::SkTextToPathIter(const char text[], size_t length, |
+SkTextBaseIter::SkTextBaseIter(const char text[], size_t length, |
const SkPaint& paint, |
bool applyStrokeAndPathEffects) |
: fPaint(paint) { |
@@ -2415,7 +2451,7 @@ SkTextToPathIter::SkTextToPathIter(const char text[], size_t length, |
fXYIndex = paint.isVerticalText() ? 1 : 0; |
} |
-SkTextToPathIter::~SkTextToPathIter() { |
+SkTextBaseIter::~SkTextBaseIter() { |
SkGlyphCache::AttachCache(fCache); |
} |
@@ -2443,6 +2479,17 @@ bool SkTextToPathIter::next(const SkPath** path, SkScalar* xpos) { |
return false; |
} |
+bool SkTextInterceptsIter::next(SkScalar* array, int* count) { |
+ const SkGlyph& glyph = fGlyphCacheProc(fCache, &fText); |
+ fXPos += SkScalarMul(SkFixedToScalar(fPrevAdvance + fAutoKern.adjust(glyph)), fScale); |
+ fPrevAdvance = advance(glyph, fXYIndex); // + fPaint.getTextTracking(); |
+ if (fCache->findPath(glyph)) { |
+ fCache->findIntercepts(fBounds, fScale, fXPos, SkToBool(fXYIndex), |
+ const_cast<SkGlyph*>(&glyph), array, count); |
+ } |
+ return fText < fStop; |
+} |
+ |
/////////////////////////////////////////////////////////////////////////////// |
// return true if the filter exists, and may affect alpha |