aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkFindAndPlaceGlyph.h
diff options
context:
space:
mode:
authorGravatar Hal Canary <halcanary@google.com>2018-07-24 11:33:21 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-07-25 17:21:56 +0000
commit4014ba6ec7a7825495ac0a6ed591c5dadd30751d (patch)
tree7439f79dce6e1768d7cdf3e36d4952fd9ed8ef1b /src/core/SkFindAndPlaceGlyph.h
parentba5c439809fb2be3b1db159b29aeffaa39f786df (diff)
SkUtils: remove some versions of UTF routines.
Change-Id: Ib1f776ae472117c23d2145253adf25fceb412b32 Reviewed-on: https://skia-review.googlesource.com/143111 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Hal Canary <halcanary@google.com>
Diffstat (limited to 'src/core/SkFindAndPlaceGlyph.h')
-rw-r--r--src/core/SkFindAndPlaceGlyph.h49
1 files changed, 28 insertions, 21 deletions
diff --git a/src/core/SkFindAndPlaceGlyph.h b/src/core/SkFindAndPlaceGlyph.h
index ae98faa1e5..f602e8d931 100644
--- a/src/core/SkFindAndPlaceGlyph.h
+++ b/src/core/SkFindAndPlaceGlyph.h
@@ -115,8 +115,9 @@ private:
class GlyphFinderInterface {
public:
virtual ~GlyphFinderInterface() {}
- virtual const SkGlyph& lookupGlyph(const char** text) = 0;
- virtual const SkGlyph& lookupGlyphXY(const char** text, SkFixed x, SkFixed y) = 0;
+ virtual const SkGlyph& lookupGlyph(const char** text, const char* stop) = 0;
+ virtual const SkGlyph& lookupGlyphXY(const char** text, const char* stop,
+ SkFixed x, SkFixed y) = 0;
};
class UtfNGlyphFinder : public GlyphFinderInterface {
@@ -126,17 +127,17 @@ private:
SkASSERT(cache != nullptr);
}
- const SkGlyph& lookupGlyph(const char** text) override {
+ const SkGlyph& lookupGlyph(const char** text, const char* stop) override {
SkASSERT(text != nullptr);
- return fCache->getUnicharMetrics(nextUnichar(text));
+ return fCache->getUnicharMetrics(nextUnichar(text, stop));
}
- const SkGlyph& lookupGlyphXY(const char** text, SkFixed x, SkFixed y) override {
+ const SkGlyph& lookupGlyphXY(const char** text, const char* stop, SkFixed x, SkFixed y) override {
SkASSERT(text != nullptr);
- return fCache->getUnicharMetrics(nextUnichar(text), x, y);
+ return fCache->getUnicharMetrics(nextUnichar(text, stop), x, y);
}
private:
- virtual SkUnichar nextUnichar(const char** text) = 0;
+ virtual SkUnichar nextUnichar(const char** text, const char* stop) = 0;
SkGlyphCache* fCache;
};
@@ -145,7 +146,9 @@ private:
explicit Utf8GlyphFinder(SkGlyphCache* cache) : UtfNGlyphFinder(cache) { }
private:
- SkUnichar nextUnichar(const char** text) override { return SkUTF8_NextUnichar(text); }
+ SkUnichar nextUnichar(const char** text, const char* stop) override {
+ return SkUTF8_NextUnichar(text, stop);
+ }
};
class Utf16GlyphFinder final : public UtfNGlyphFinder {
@@ -153,8 +156,8 @@ private:
explicit Utf16GlyphFinder(SkGlyphCache* cache) : UtfNGlyphFinder(cache) { }
private:
- SkUnichar nextUnichar(const char** text) override {
- return SkUTF16_NextUnichar((const uint16_t**)text);
+ SkUnichar nextUnichar(const char** text, const char* stop) override {
+ return SkUTF16_NextUnichar((const uint16_t**)text, (const uint16_t*)stop);
}
};
@@ -163,7 +166,7 @@ private:
explicit Utf32GlyphFinder(SkGlyphCache* cache) : UtfNGlyphFinder(cache) { }
private:
- SkUnichar nextUnichar(const char** text) override {
+ SkUnichar nextUnichar(const char** text, const char* stop) override {
const int32_t* ptr = *(const int32_t**)text;
SkUnichar uni = *ptr++;
*text = (const char*)ptr;
@@ -178,10 +181,11 @@ private:
SkASSERT(cache != nullptr);
}
- const SkGlyph& lookupGlyph(const char** text) override {
+ const SkGlyph& lookupGlyph(const char** text, const char*) override {
return fCache->getGlyphIDMetrics(nextGlyphId(text));
}
- const SkGlyph& lookupGlyphXY(const char** text, SkFixed x, SkFixed y) override {
+ const SkGlyph& lookupGlyphXY(const char** text, const char*,
+ SkFixed x, SkFixed y) override {
return fCache->getGlyphIDMetrics(nextGlyphId(text), x, y);
}
@@ -319,7 +323,8 @@ private:
// compile error.
// See GCC bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60277
virtual SkPoint findAndPositionGlyph(
- const char** text, SkPoint position, ProcessOneGlyph&& processOneGlyph) {
+ const char** text, const char* stop, SkPoint position,
+ ProcessOneGlyph&& processOneGlyph) {
SK_ABORT("Should never get here.");
return {0.0f, 0.0f};
}
@@ -335,12 +340,13 @@ private:
: fGlyphFinder(glyphFinder) { }
SkPoint findAndPositionGlyph(
- const char** text, SkPoint position, ProcessOneGlyph&& processOneGlyph) override {
+ const char** text, const char* stop, SkPoint position,
+ ProcessOneGlyph&& processOneGlyph) override {
// Find the glyph.
SkIPoint lookupPosition = SubpixelAlignment(kAxisAlignment, position);
const SkGlyph& renderGlyph =
- fGlyphFinder->lookupGlyphXY(text, lookupPosition.fX, lookupPosition.fY);
+ fGlyphFinder->lookupGlyphXY(text, stop, lookupPosition.fX, lookupPosition.fY);
// If the glyph has no width (no pixels) then don't bother processing it.
if (renderGlyph.fWidth > 0) {
@@ -365,9 +371,10 @@ private:
}
SkPoint findAndPositionGlyph(
- const char** text, SkPoint position, ProcessOneGlyph&& processOneGlyph) override {
+ const char** text, const char* stop, SkPoint position,
+ ProcessOneGlyph&& processOneGlyph) override {
SkPoint finalPosition = position;
- const SkGlyph& glyph = fGlyphFinder->lookupGlyph(text);
+ const SkGlyph& glyph = fGlyphFinder->lookupGlyph(text, stop);
if (glyph.fWidth > 0) {
processOneGlyph(glyph, finalPosition, {SK_ScalarHalf, SK_ScalarHalf});
@@ -407,7 +414,7 @@ private:
while (text < stop) {
// don't need x, y here, since all subpixel variants will have the
// same advance
- const SkGlyph& glyph = glyphFinder->lookupGlyph(&text);
+ const SkGlyph& glyph = glyphFinder->lookupGlyph(&text, stop);
x += SkFloatToScalar(glyph.fAdvanceX);
y += SkFloatToScalar(glyph.fAdvanceY);
@@ -451,7 +458,7 @@ inline void SkFindAndPlaceGlyph::ProcessPosText(
while (cursor < stop) {
SkPoint mappedPoint = mapper.TranslationMapper::map(positions->nextPoint());
positioner.Positioner::findAndPositionGlyph(
- &cursor, mappedPoint, std::forward<ProcessOneGlyph>(processOneGlyph));
+ &cursor, stop, mappedPoint, std::forward<ProcessOneGlyph>(processOneGlyph));
}
return;
}
@@ -479,7 +486,7 @@ inline void SkFindAndPlaceGlyph::ProcessPosText(
while (text < stop) {
SkPoint mappedPoint = mapper->map(positionReader->nextPoint());
findAndPosition->findAndPositionGlyph(
- &text, mappedPoint, std::forward<ProcessOneGlyph>(processOneGlyph));
+ &text, stop, mappedPoint, std::forward<ProcessOneGlyph>(processOneGlyph));
}
}