Convert SkGlyphIDs to SkPaths
Change-Id: I26893e4055a5fa44914f5e7b8702b0c280d5866b Reviewed-on: https://skia-review.googlesource.com/c/skia/+/558916 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Herb Derby <herb@google.com>
This commit is contained in:
parent
c83c345971
commit
07769b152a
@ -14,6 +14,7 @@
|
||||
#include "src/core/SkEnumerate.h"
|
||||
#include "src/core/SkGlyphBuffer.h"
|
||||
#include "src/core/SkScalerContext.h"
|
||||
#include "src/text/StrikeForGPU.h"
|
||||
|
||||
static SkFontMetrics use_or_generate_metrics(
|
||||
const SkFontMetrics* metrics, SkScalerContext* context) {
|
||||
@ -173,6 +174,18 @@ std::tuple<SkSpan<const SkGlyph*>, size_t> SkScalerCache::preparePaths(
|
||||
return {glyphs, delta};
|
||||
}
|
||||
|
||||
size_t SkScalerCache::glyphIDsToPaths(SkSpan<sktext::IDOrPath> idsOrPaths) {
|
||||
size_t increase = 0;
|
||||
SkAutoMutexExclusive lock{fMu};
|
||||
for (sktext::IDOrPath& idOrPath : idsOrPaths) {
|
||||
auto [glyph, size] = this->glyph(SkPackedGlyphID{idOrPath.fGlyphID});
|
||||
increase += size;
|
||||
increase += this->preparePath(glyph);
|
||||
new (&idOrPath.fPath) SkPath{*glyph->path()};
|
||||
}
|
||||
return increase;
|
||||
}
|
||||
|
||||
std::tuple<SkSpan<const SkGlyph*>, size_t> SkScalerCache::prepareImages(
|
||||
SkSpan<const SkPackedGlyphID> glyphIDs, const SkGlyph* results[]) {
|
||||
const SkGlyph** cursor = results;
|
||||
|
@ -16,9 +16,13 @@
|
||||
#include "src/core/SkDescriptor.h"
|
||||
#include "src/core/SkGlyph.h"
|
||||
#include "src/core/SkGlyphRunPainter.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class SkScalerContext;
|
||||
namespace sktext {
|
||||
union IDOrPath;
|
||||
} // namespace sktext
|
||||
|
||||
// This class represents a strike: a specific combination of typeface, size, matrix, etc., and
|
||||
// holds the glyphs for that strike.
|
||||
@ -86,6 +90,9 @@ public:
|
||||
size_t prepareForDrawableDrawing(
|
||||
SkDrawableGlyphBuffer* accepted, SkSourceGlyphBuffer* rejected) SK_EXCLUDES(fMu);
|
||||
|
||||
// Convert all the IDs into SkPaths in the span.
|
||||
size_t glyphIDsToPaths(SkSpan<sktext::IDOrPath> idsOrPaths) SK_EXCLUDES(fMu);
|
||||
|
||||
std::tuple<SkScalar, size_t>
|
||||
findMaximumGlyphDimension(SkSpan<const SkGlyphID> glyphs) SK_EXCLUDES(fMu);
|
||||
|
||||
|
@ -157,6 +157,11 @@ public:
|
||||
this->updateDelta(increase);
|
||||
}
|
||||
|
||||
void glyphIDsToPaths(SkSpan<sktext::IDOrPath> idsOrPaths) {
|
||||
size_t increase = fScalerCache.glyphIDsToPaths(idsOrPaths);
|
||||
this->updateDelta(increase);
|
||||
}
|
||||
|
||||
void prepareForDrawableDrawing(
|
||||
SkDrawableGlyphBuffer* accepted, SkSourceGlyphBuffer* rejected) override {
|
||||
size_t increase = fScalerCache.prepareForDrawableDrawing(accepted, rejected);
|
||||
|
@ -69,6 +69,15 @@ public:
|
||||
// -- ScopedStrikeForGPU ---------------------------------------------------------------------------
|
||||
using ScopedStrikeForGPU = std::unique_ptr<StrikeForGPU, StrikeForGPU::Deleter>;
|
||||
|
||||
// prepareForPathDrawing uses this union to convert glyph ids to paths.
|
||||
union IDOrPath {
|
||||
SkGlyphID fGlyphID;
|
||||
SkPath fPath;
|
||||
|
||||
// PathOpSubmitter takes care of destroying the paths.
|
||||
~IDOrPath() {}
|
||||
};
|
||||
|
||||
// -- StrikeRef ------------------------------------------------------------------------------------
|
||||
// Hold a ref to either a RemoteStrike or an SkStrike. Use either to flatten a descriptor, but
|
||||
// when MakeFromBuffer runs look up the SkStrike associated with the descriptor.
|
||||
|
Loading…
Reference in New Issue
Block a user