drawGlyphs API for SkCanvas
Change-Id: Ieecbb3ec130b2598d21fbe12ab4830046ae95e4f Reviewed-on: https://skia-review.googlesource.com/c/skia/+/394216 Commit-Queue: Herb Derby <herb@google.com> Reviewed-by: Mike Reed <reed@google.com>
This commit is contained in:
parent
e4454aaf23
commit
ffef19c51e
@ -1737,6 +1737,54 @@ public:
|
||||
this->drawSimpleText(str.c_str(), str.size(), SkTextEncoding::kUTF8, x, y, font, paint);
|
||||
}
|
||||
|
||||
/** Draws count glyphs, at positions relative to origin styled with font and paint with
|
||||
supporting utf8 and cluster information.
|
||||
|
||||
This function draw glyphs at the given positions relative to the given origin.
|
||||
It does not perform typeface fallback for glyphs not found in the SkTypeface in font.
|
||||
|
||||
The drawing obeys the current transform matrix and clipping.
|
||||
|
||||
All elements of paint: SkPathEffect, SkMaskFilter, SkShader,
|
||||
SkColorFilter, and SkImageFilter; apply to text. By
|
||||
default, draws filled black glyphs.
|
||||
|
||||
@param count number of glyphs to draw
|
||||
@param glyphs the array of glyphIDs to draw
|
||||
@param positions where to draw each glyph relative to origin
|
||||
@param clusters array of size count of cluster information
|
||||
@param textByteCount size of the utf8text
|
||||
@param utf8text utf8text supporting information for the glyphs
|
||||
@param origin the origin of all the positions
|
||||
@param font typeface, text size and so, used to describe the text
|
||||
@param paint blend, color, and so on, used to draw
|
||||
*/
|
||||
void drawGlyphs(int count, const SkGlyphID glyphs[], const SkPoint positions[],
|
||||
const uint32_t clusters[], int textByteCount, const char utf8text[],
|
||||
SkPoint origin, const SkFont& font, const SkPaint& paint);
|
||||
|
||||
/** Draws count glyphs, at positions relative to origin styled with font and paint.
|
||||
|
||||
This function draw glyphs at the given positions relative to the given origin.
|
||||
It does not perform typeface fallback for glyphs not found in the SkTypeface in font.
|
||||
|
||||
The drawing obeys the current transform matrix and clipping.
|
||||
|
||||
All elements of paint: SkPathEffect, SkMaskFilter, SkShader,
|
||||
SkColorFilter, and SkImageFilter; apply to text. By
|
||||
default, draws filled black glyphs.
|
||||
|
||||
@param count number of glyphs to draw
|
||||
@param glyphs the array of glyphIDs to draw
|
||||
@param positions where to draw each glyph relative to origin
|
||||
@param origin the origin of all the positions
|
||||
@param font typeface, text size and so, used to describe the text
|
||||
@param paint blend, color, and so on, used to draw
|
||||
*/
|
||||
|
||||
void drawGlyphs(int count, const SkGlyphID glyphs[], const SkPoint positions[],
|
||||
SkPoint origin, const SkFont& font, const SkPaint& paint);
|
||||
|
||||
/** Draws SkTextBlob blob at (x, y), using clip, SkMatrix, and SkPaint paint.
|
||||
|
||||
blob contains glyphs, their positions, and paint attributes specific to text:
|
||||
|
@ -2298,6 +2298,29 @@ void SkCanvas::drawSimpleText(const void* text, size_t byteLength, SkTextEncodin
|
||||
}
|
||||
}
|
||||
|
||||
void SkCanvas::drawGlyphs(int count, const SkGlyphID glyphs[], const SkPoint positions[],
|
||||
SkPoint origin, const SkFont& font, const SkPaint& paint) {
|
||||
if (count <= 0) { return; }
|
||||
SkTextBlobBuilder builder;
|
||||
auto buffer = builder.allocRunPos(font, count);
|
||||
memcpy(buffer.glyphs, glyphs, count * sizeof(SkGlyphID));
|
||||
memcpy(buffer.points(), positions, count * sizeof(SkPoint));
|
||||
this->drawTextBlob(builder.make(), origin.x(), origin.y(), paint);
|
||||
}
|
||||
|
||||
void SkCanvas::drawGlyphs(int count, const SkGlyphID* glyphs, const SkPoint* positions,
|
||||
const uint32_t* clusters, int textByteCount, const char* utf8text,
|
||||
SkPoint origin, const SkFont& font, const SkPaint& paint) {
|
||||
if (count <= 0) { return; }
|
||||
SkTextBlobBuilder builder;
|
||||
auto buffer = builder.allocRunTextPos(font, count, textByteCount);
|
||||
memcpy(buffer.glyphs, glyphs, count * sizeof(SkGlyphID));
|
||||
memcpy(buffer.points(), positions, count * sizeof(SkPoint));
|
||||
memcpy(buffer.clusters, clusters, count * sizeof(uint32_t));
|
||||
memcpy(buffer.utf8text, utf8text, textByteCount);
|
||||
this->drawTextBlob(builder.make(), origin.x(), origin.y(), paint);
|
||||
}
|
||||
|
||||
void SkCanvas::drawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
|
||||
const SkPaint& paint) {
|
||||
TRACE_EVENT0("skia", TRACE_FUNC);
|
||||
|
Loading…
Reference in New Issue
Block a user