simplify setMetricsAndImage API
Just return the amount allocated during the merge. Add TODO to simplify when I'm sure there are no collisions during the merge. Change-Id: Ieb568c4096fc547c54303689b232c68d78f3f36b Reviewed-on: https://skia-review.googlesource.com/c/skia/+/317382 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Herb Derby <herb@google.com>
This commit is contained in:
parent
2780656ef4
commit
ef3aadbd27
@ -102,7 +102,12 @@ bool SkGlyph::setImage(SkArenaAlloc* alloc, const void* image) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SkGlyph::setMetricsAndImage(SkArenaAlloc* alloc, const SkGlyph& from) {
|
size_t SkGlyph::setMetricsAndImage(SkArenaAlloc* alloc, const SkGlyph& from) {
|
||||||
|
// Since the code no longer tries to find replacement glyphs, the image should always be
|
||||||
|
// nullptr.
|
||||||
|
SkASSERT(fImage == nullptr);
|
||||||
|
|
||||||
|
// TODO(herb): remove "if" when we are sure there are no colliding glyphs.
|
||||||
if (fImage == nullptr) {
|
if (fImage == nullptr) {
|
||||||
fAdvanceX = from.fAdvanceX;
|
fAdvanceX = from.fAdvanceX;
|
||||||
fAdvanceY = from.fAdvanceY;
|
fAdvanceY = from.fAdvanceY;
|
||||||
@ -114,9 +119,11 @@ bool SkGlyph::setMetricsAndImage(SkArenaAlloc* alloc, const SkGlyph& from) {
|
|||||||
fMaskFormat = from.fMaskFormat;
|
fMaskFormat = from.fMaskFormat;
|
||||||
|
|
||||||
// From glyph may not have an image because the glyph is too large.
|
// From glyph may not have an image because the glyph is too large.
|
||||||
return from.fImage != nullptr && this->setImage(alloc, from.image());
|
if (from.fImage != nullptr && this->setImage(alloc, from.image())) {
|
||||||
|
return this->imageSize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SkGlyph::rowBytes() const {
|
size_t SkGlyph::rowBytes() const {
|
||||||
|
@ -211,11 +211,10 @@ public:
|
|||||||
bool setImage(SkArenaAlloc* alloc, SkScalerContext* scalerContext);
|
bool setImage(SkArenaAlloc* alloc, SkScalerContext* scalerContext);
|
||||||
bool setImage(SkArenaAlloc* alloc, const void* image);
|
bool setImage(SkArenaAlloc* alloc, const void* image);
|
||||||
|
|
||||||
// Merge the from glyph into this glyph using alloc to allocate image data. Return true if
|
// Merge the from glyph into this glyph using alloc to allocate image data. Return the number
|
||||||
// image data was allocated. If the image for this glyph has not been initialized, then copy
|
// of bytes allocated. Copy the width, height, top, left, format, and image into this glyph
|
||||||
// the width, height, top, left, format, and image into this glyph making a copy of the image
|
// making a copy of the image using the alloc.
|
||||||
// using the alloc.
|
size_t setMetricsAndImage(SkArenaAlloc* alloc, const SkGlyph& from);
|
||||||
bool setMetricsAndImage(SkArenaAlloc* alloc, const SkGlyph& from);
|
|
||||||
|
|
||||||
// Returns true if the image has been set.
|
// Returns true if the image has been set.
|
||||||
bool setImageHasBeenCalled() const {
|
bool setImageHasBeenCalled() const {
|
||||||
|
@ -113,7 +113,6 @@ std::tuple<SkGlyph*, size_t> SkScalerCache::mergeGlyphAndImage(
|
|||||||
SkPackedGlyphID toID, const SkGlyph& from) {
|
SkPackedGlyphID toID, const SkGlyph& from) {
|
||||||
SkAutoMutexExclusive lock{fMu};
|
SkAutoMutexExclusive lock{fMu};
|
||||||
size_t delta = 0;
|
size_t delta = 0;
|
||||||
size_t imageDelta = 0;
|
|
||||||
SkGlyphIndex* denseID = fIndexForPackedGlyphID.find(toID);
|
SkGlyphIndex* denseID = fIndexForPackedGlyphID.find(toID);
|
||||||
SkGlyph* glyph;
|
SkGlyph* glyph;
|
||||||
if (denseID != nullptr) {
|
if (denseID != nullptr) {
|
||||||
@ -121,10 +120,8 @@ std::tuple<SkGlyph*, size_t> SkScalerCache::mergeGlyphAndImage(
|
|||||||
} else {
|
} else {
|
||||||
std::tie(glyph, delta) = this->makeGlyph(toID);
|
std::tie(glyph, delta) = this->makeGlyph(toID);
|
||||||
}
|
}
|
||||||
if (glyph->setMetricsAndImage(&fAlloc, from)) {
|
delta += glyph->setMetricsAndImage(&fAlloc, from);
|
||||||
imageDelta= glyph->imageSize();
|
return {glyph, delta};
|
||||||
}
|
|
||||||
return {glyph, delta + imageDelta};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::tuple<SkSpan<const SkGlyph*>, size_t> SkScalerCache::metrics(
|
std::tuple<SkSpan<const SkGlyph*>, size_t> SkScalerCache::metrics(
|
||||||
|
Loading…
Reference in New Issue
Block a user