Remove SkRemoteGlyphCacheImpl.h
Move everything to SkRemoteGlyphCache.cpp. Add a call to SkStrikeServer (AddGlyphForTest), to make tests work. * Misc cleanups Change-Id: I22bea686838f60cf96d097e1ea025cb5399903e7 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/235096 Reviewed-by: Ben Wagner <bungeman@google.com> Commit-Queue: Herb Derby <herb@google.com>
This commit is contained in:
parent
d18c98cd86
commit
82963a3c97
@ -310,7 +310,6 @@ skia_core_sources = [
|
||||
"$_src/core/SkRegion_path.cpp",
|
||||
"$_src/core/SkRemoteGlyphCache.h",
|
||||
"$_src/core/SkRemoteGlyphCache.cpp",
|
||||
"$_src/core/SkRemoteGlyphCacheImpl.h",
|
||||
"$_src/core/SkResourceCache.cpp",
|
||||
"$_src/core/SkRRect.cpp",
|
||||
"$_src/core/SkRRectPriv.h",
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include "src/core/SkFontPriv.h"
|
||||
#include "src/core/SkPaintPriv.h"
|
||||
#include "src/core/SkRasterClip.h"
|
||||
#include "src/core/SkRemoteGlyphCacheImpl.h"
|
||||
#include "src/core/SkStrike.h"
|
||||
#include "src/core/SkStrikeCache.h"
|
||||
#include "src/core/SkStrikeInterface.h"
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include "src/core/SkDevice.h"
|
||||
#include "src/core/SkDraw.h"
|
||||
#include "src/core/SkGlyphRun.h"
|
||||
#include "src/core/SkRemoteGlyphCacheImpl.h"
|
||||
#include "src/core/SkStrike.h"
|
||||
#include "src/core/SkStrikeCache.h"
|
||||
#include "src/core/SkTLazy.h"
|
||||
@ -65,8 +64,7 @@ static const SkDescriptor* create_descriptor(
|
||||
return SkScalerContext::AutoDescriptorGivenRecAndEffects(rec, *effects, ad);
|
||||
}
|
||||
|
||||
// -- Serializer ----------------------------------------------------------------------------------
|
||||
|
||||
// -- Serializer -----------------------------------------------------------------------------------
|
||||
size_t pad(size_t size, size_t alignment) { return (size + (alignment - 1)) & ~(alignment - 1); }
|
||||
|
||||
// Alignment between x86 and x64 differs for some types, in particular
|
||||
@ -183,8 +181,9 @@ bool SkDescriptorMapOperators::operator()(const SkDescriptor* lhs, const SkDescr
|
||||
return *lhs == *rhs;
|
||||
}
|
||||
|
||||
// -- StrikeSpec -----------------------------------------------------------------------------------
|
||||
struct StrikeSpec {
|
||||
StrikeSpec() {}
|
||||
StrikeSpec() = default;
|
||||
StrikeSpec(SkFontID typefaceID_, SkDiscardableHandleId discardableHandleId_)
|
||||
: typefaceID{typefaceID_}, discardableHandleId(discardableHandleId_) {}
|
||||
SkFontID typefaceID = 0u;
|
||||
@ -193,27 +192,150 @@ struct StrikeSpec {
|
||||
/* n X (glyphs ids) */
|
||||
};
|
||||
|
||||
// -- SkGlyphCacheState ----------------------------------------------------------------------------
|
||||
class SkStrikeServer::SkGlyphCacheState : public SkStrikeInterface {
|
||||
public:
|
||||
// N.B. SkGlyphCacheState is not valid until ensureScalerContext is called.
|
||||
SkGlyphCacheState(const SkDescriptor& descriptor,
|
||||
std::unique_ptr<SkScalerContext> context,
|
||||
SkDiscardableHandleId discardableHandleId);
|
||||
~SkGlyphCacheState() override;
|
||||
|
||||
void addGlyph(SkPackedGlyphID, bool asPath);
|
||||
void writePendingGlyphs(Serializer* serializer);
|
||||
SkDiscardableHandleId discardableHandleId() const { return fDiscardableHandleId; }
|
||||
|
||||
bool isSubpixel() const { return fIsSubpixel; }
|
||||
|
||||
const SkDescriptor& getDescriptor() const override {
|
||||
return *fDescriptor.getDesc();
|
||||
}
|
||||
|
||||
void setTypefaceAndEffects(const SkTypeface* typeface, SkScalerContextEffects effects);
|
||||
|
||||
SkVector rounding() const override;
|
||||
|
||||
SkIPoint subpixelMask() const override {
|
||||
return SkIPoint::Make((!fIsSubpixel || fAxisAlignment == kY_SkAxisAlignment) ? 0 : ~0u,
|
||||
(!fIsSubpixel || fAxisAlignment == kX_SkAxisAlignment) ? 0 : ~0u);
|
||||
}
|
||||
|
||||
SkSpan<const SkGlyphPos>
|
||||
prepareForDrawingRemoveEmpty(
|
||||
const SkPackedGlyphID packedGlyphIDs[],
|
||||
const SkPoint positions[], size_t n,
|
||||
int maxDimension, PreparationDetail detail,
|
||||
SkGlyphPos results[]) override;
|
||||
|
||||
void onAboutToExitScope() override {}
|
||||
|
||||
private:
|
||||
bool hasPendingGlyphs() const {
|
||||
return !fPendingGlyphImages.empty() || !fPendingGlyphPaths.empty();
|
||||
}
|
||||
void writeGlyphPath(const SkPackedGlyphID& glyphID, Serializer* serializer) const;
|
||||
|
||||
void ensureScalerContext();
|
||||
void resetScalerContext();
|
||||
|
||||
// The set of glyphs cached on the remote client.
|
||||
SkTHashSet<SkPackedGlyphID> fCachedGlyphImages;
|
||||
SkTHashSet<SkPackedGlyphID> fCachedGlyphPaths;
|
||||
|
||||
// The set of glyphs which has not yet been serialized and sent to the
|
||||
// remote client.
|
||||
std::vector<SkPackedGlyphID> fPendingGlyphImages;
|
||||
std::vector<SkPackedGlyphID> fPendingGlyphPaths;
|
||||
|
||||
const SkAutoDescriptor fDescriptor;
|
||||
|
||||
const SkDiscardableHandleId fDiscardableHandleId;
|
||||
|
||||
// Values saved from the initial context.
|
||||
const bool fIsSubpixel;
|
||||
const SkAxisAlignment fAxisAlignment;
|
||||
|
||||
// The context built using fDescriptor
|
||||
std::unique_ptr<SkScalerContext> fContext;
|
||||
|
||||
// These fields are set every time getOrCreateCache. This allows the code to maintain the
|
||||
// fContext as lazy as possible.
|
||||
const SkTypeface* fTypeface{nullptr};
|
||||
SkScalerContextEffects fEffects;
|
||||
|
||||
class GlyphMapHashTraits {
|
||||
public:
|
||||
static SkPackedGlyphID GetKey(const SkGlyph* glyph) {
|
||||
return glyph->getPackedID();
|
||||
}
|
||||
static uint32_t Hash(SkPackedGlyphID glyphId) {
|
||||
return glyphId.hash();
|
||||
}
|
||||
};
|
||||
|
||||
// FallbackTextHelper cases require glyph metrics when analyzing a glyph run, in which case
|
||||
// we cache them here.
|
||||
SkTHashTable<SkGlyph*, SkPackedGlyphID, GlyphMapHashTraits> fGlyphMap;
|
||||
|
||||
SkArenaAlloc fAlloc{256};
|
||||
};
|
||||
|
||||
SkStrikeServer::SkGlyphCacheState::SkGlyphCacheState(
|
||||
const SkDescriptor& descriptor,
|
||||
std::unique_ptr<SkScalerContext> context,
|
||||
uint32_t discardableHandleId)
|
||||
: fDescriptor{descriptor}
|
||||
, fDiscardableHandleId(discardableHandleId)
|
||||
, fIsSubpixel{context->isSubpixel()}
|
||||
, fAxisAlignment{context->computeAxisAlignmentForHText()}
|
||||
// N.B. context must come last because it is used above.
|
||||
, fContext{std::move(context)} {
|
||||
SkASSERT(fDescriptor.getDesc() != nullptr);
|
||||
SkASSERT(fContext != nullptr);
|
||||
}
|
||||
|
||||
SkStrikeServer::SkGlyphCacheState::~SkGlyphCacheState() = default;
|
||||
|
||||
void SkStrikeServer::SkGlyphCacheState::addGlyph(SkPackedGlyphID glyph, bool asPath) {
|
||||
auto* cache = asPath ? &fCachedGlyphPaths : &fCachedGlyphImages;
|
||||
auto* pending = asPath ? &fPendingGlyphPaths : &fPendingGlyphImages;
|
||||
|
||||
// Already cached.
|
||||
if (cache->contains(glyph)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// A glyph is going to be sent. Make sure we have a scaler context to send it.
|
||||
this->ensureScalerContext();
|
||||
|
||||
// Serialize and cache. Also create the scalar context to use when serializing
|
||||
// this glyph.
|
||||
cache->add(glyph);
|
||||
pending->push_back(glyph);
|
||||
}
|
||||
|
||||
|
||||
// -- TrackLayerDevice -----------------------------------------------------------------------------
|
||||
SkTextBlobCacheDiffCanvas::TrackLayerDevice::TrackLayerDevice(
|
||||
class SkTextBlobCacheDiffCanvas::TrackLayerDevice final : public SkNoPixelsDevice {
|
||||
public:
|
||||
TrackLayerDevice(
|
||||
const SkIRect& bounds, const SkSurfaceProps& props, SkStrikeServer* server,
|
||||
sk_sp<SkColorSpace> colorSpace, const SkTextBlobCacheDiffCanvas::Settings& settings)
|
||||
: SkNoPixelsDevice(bounds, props, std::move(colorSpace))
|
||||
, fStrikeServer(server)
|
||||
, fSettings(settings)
|
||||
, fPainter{props, kUnknown_SkColorType, imageInfo().colorSpace(), fStrikeServer} {
|
||||
SkASSERT(fStrikeServer);
|
||||
SkASSERT(fStrikeServer != nullptr);
|
||||
}
|
||||
|
||||
SkBaseDevice* SkTextBlobCacheDiffCanvas::TrackLayerDevice::onCreateDevice(
|
||||
const CreateInfo& cinfo, const SkPaint*) {
|
||||
SkBaseDevice* onCreateDevice(const CreateInfo& cinfo, const SkPaint*) override {
|
||||
const SkSurfaceProps surfaceProps(this->surfaceProps().flags(), cinfo.fPixelGeometry);
|
||||
return new TrackLayerDevice(this->getGlobalBounds(), surfaceProps, fStrikeServer,
|
||||
cinfo.fInfo.refColorSpace(), fSettings);
|
||||
}
|
||||
|
||||
void SkTextBlobCacheDiffCanvas::TrackLayerDevice::drawGlyphRunList(
|
||||
const SkGlyphRunList& glyphRunList) {
|
||||
|
||||
protected:
|
||||
void drawGlyphRunList(const SkGlyphRunList& glyphRunList) override {
|
||||
#if SK_SUPPORT_GPU
|
||||
GrTextContext::Options options;
|
||||
options.fMinDistanceFieldFontSize = fSettings.fMinDistanceFieldFontSize;
|
||||
@ -227,9 +349,14 @@ void SkTextBlobCacheDiffCanvas::TrackLayerDevice::drawGlyphRunList(
|
||||
options,
|
||||
nullptr);
|
||||
#endif // SK_SUPPORT_GPU
|
||||
|
||||
}
|
||||
|
||||
private:
|
||||
SkStrikeServer* const fStrikeServer;
|
||||
const SkTextBlobCacheDiffCanvas::Settings fSettings;
|
||||
SkGlyphRunListPainter fPainter;
|
||||
};
|
||||
|
||||
// -- SkTextBlobCacheDiffCanvas -------------------------------------------------------------------
|
||||
SkTextBlobCacheDiffCanvas::Settings::Settings() = default;
|
||||
|
||||
@ -260,23 +387,22 @@ bool SkTextBlobCacheDiffCanvas::onDoSaveBehind(const SkRect*) {
|
||||
|
||||
void SkTextBlobCacheDiffCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
|
||||
const SkPaint& paint) {
|
||||
///
|
||||
SkCanvas::onDrawTextBlob(blob, x, y, paint);
|
||||
}
|
||||
|
||||
// -- WireTypeface ---------------------------------------------------------------------------------
|
||||
struct WireTypeface {
|
||||
WireTypeface() = default;
|
||||
WireTypeface(SkFontID typeface_id, int glyph_count, SkFontStyle style, bool is_fixed)
|
||||
: typefaceID(typeface_id), glyphCount(glyph_count), style(style), isFixed(is_fixed) {}
|
||||
|
||||
SkFontID typefaceID;
|
||||
int glyphCount;
|
||||
SkFontID typefaceID{0};
|
||||
int glyphCount{0};
|
||||
SkFontStyle style;
|
||||
bool isFixed;
|
||||
bool isFixed{false};
|
||||
};
|
||||
|
||||
// SkStrikeServer -----------------------------------------
|
||||
|
||||
// SkStrikeServer ----------------------------------------------------------------------------------
|
||||
SkStrikeServer::SkStrikeServer(DiscardableHandleManager* discardableHandleManager)
|
||||
: fDiscardableHandleManager(discardableHandleManager) {
|
||||
SkASSERT(fDiscardableHandleManager);
|
||||
@ -336,6 +462,11 @@ SkScopedStrike SkStrikeServer::findOrCreateScopedStrike(const SkDescriptor& desc
|
||||
return SkScopedStrike{this->getOrCreateCache(desc, typeface, effects)};
|
||||
}
|
||||
|
||||
void SkStrikeServer::AddGlyphForTesting(
|
||||
SkGlyphCacheState* cache, SkPackedGlyphID glyphID, bool asPath) {
|
||||
cache->addGlyph(glyphID, asPath);
|
||||
}
|
||||
|
||||
void SkStrikeServer::checkForDeletedEntries() {
|
||||
auto it = fRemoteGlyphStateMap.begin();
|
||||
while (fRemoteGlyphStateMap.size() > fMaxEntriesInDescriptorMap &&
|
||||
@ -414,41 +545,6 @@ SkStrikeServer::SkGlyphCacheState* SkStrikeServer::getOrCreateCache(
|
||||
return cacheStatePtr;
|
||||
}
|
||||
|
||||
// -- SkGlyphCacheState ----------------------------------------------------------------------------
|
||||
SkStrikeServer::SkGlyphCacheState::SkGlyphCacheState(
|
||||
const SkDescriptor& descriptor,
|
||||
std::unique_ptr<SkScalerContext> context,
|
||||
uint32_t discardableHandleId)
|
||||
: fDescriptor{descriptor}
|
||||
, fDiscardableHandleId(discardableHandleId)
|
||||
, fIsSubpixel{context->isSubpixel()}
|
||||
, fAxisAlignment{context->computeAxisAlignmentForHText()}
|
||||
// N.B. context must come last because it is used above.
|
||||
, fContext{std::move(context)} {
|
||||
SkASSERT(fDescriptor.getDesc() != nullptr);
|
||||
SkASSERT(fContext != nullptr);
|
||||
}
|
||||
|
||||
SkStrikeServer::SkGlyphCacheState::~SkGlyphCacheState() = default;
|
||||
|
||||
void SkStrikeServer::SkGlyphCacheState::addGlyph(SkPackedGlyphID glyph, bool asPath) {
|
||||
auto* cache = asPath ? &fCachedGlyphPaths : &fCachedGlyphImages;
|
||||
auto* pending = asPath ? &fPendingGlyphPaths : &fPendingGlyphImages;
|
||||
|
||||
// Already cached.
|
||||
if (cache->contains(glyph)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// A glyph is going to be sent. Make sure we have a scaler context to send it.
|
||||
this->ensureScalerContext();
|
||||
|
||||
// Serialize and cache. Also create the scalar context to use when serializing
|
||||
// this glyph.
|
||||
cache->add(glyph);
|
||||
pending->push_back(glyph);
|
||||
}
|
||||
|
||||
// No need to write fForceBW because it is a flag private to SkScalerContext_DW, which will never
|
||||
// be called on the GPU side.
|
||||
static void writeGlyph(SkGlyph* glyph, Serializer* serializer) {
|
||||
@ -552,12 +648,9 @@ void SkStrikeServer::SkGlyphCacheState::writeGlyphPath(const SkPackedGlyphID& gl
|
||||
SkSpan<const SkGlyphPos>
|
||||
SkStrikeServer::SkGlyphCacheState::prepareForDrawingRemoveEmpty(
|
||||
const SkPackedGlyphID packedGlyphIDs[],
|
||||
const SkPoint positions[],
|
||||
size_t n,
|
||||
int maxDimension,
|
||||
PreparationDetail detail,
|
||||
const SkPoint positions[], size_t n,
|
||||
int maxDimension, PreparationDetail detail,
|
||||
SkGlyphPos results[]) {
|
||||
|
||||
size_t drawableGlyphCount = 0;
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
SkPoint glyphPos = positions[i];
|
||||
@ -605,7 +698,7 @@ SkStrikeServer::SkGlyphCacheState::prepareForDrawingRemoveEmpty(
|
||||
return SkMakeSpan(results, drawableGlyphCount);
|
||||
}
|
||||
|
||||
// SkStrikeClient -----------------------------------------
|
||||
// SkStrikeClient ----------------------------------------------------------------------------------
|
||||
class SkStrikeClient::DiscardableStrikePinner : public SkStrikePinner {
|
||||
public:
|
||||
DiscardableStrikePinner(SkDiscardableHandleId discardableHandleId,
|
||||
|
@ -51,7 +51,7 @@ using SkDescriptorSet =
|
||||
std::unordered_set<const SkDescriptor*, SkDescriptorMapOperators, SkDescriptorMapOperators>;
|
||||
|
||||
// A SkTextBlobCacheDiffCanvas is used to populate the SkStrikeServer with ops
|
||||
// which will be serialized and renderered using the SkStrikeClient.
|
||||
// which will be serialized and rendered using the SkStrikeClient.
|
||||
class SK_API SkTextBlobCacheDiffCanvas : public SkNoDrawCanvas {
|
||||
public:
|
||||
struct SK_API Settings {
|
||||
@ -81,8 +81,6 @@ protected:
|
||||
|
||||
private:
|
||||
class TrackLayerDevice;
|
||||
|
||||
static SkScalar SetupForPath(SkPaint* paint, SkFont* font);
|
||||
};
|
||||
|
||||
using SkDiscardableHandleId = uint32_t;
|
||||
@ -117,7 +115,7 @@ public:
|
||||
explicit SkStrikeServer(DiscardableHandleManager* discardableHandleManager);
|
||||
~SkStrikeServer() override;
|
||||
|
||||
// Serializes the typeface to be remoted using this server.
|
||||
// Serializes the typeface to be transmitted using this server.
|
||||
sk_sp<SkData> serializeTypeface(SkTypeface*);
|
||||
|
||||
// Serializes the strike data captured using a SkTextBlobCacheDiffCanvas. Any
|
||||
@ -125,7 +123,7 @@ public:
|
||||
// unlocked after this call.
|
||||
void writeStrikeData(std::vector<uint8_t>* memory);
|
||||
|
||||
// Methods used internally in skia ------------------------------------------
|
||||
// Methods used internally in Skia ------------------------------------------
|
||||
class SkGlyphCacheState;
|
||||
|
||||
SkGlyphCacheState* getOrCreateCache(const SkPaint&,
|
||||
@ -139,6 +137,9 @@ public:
|
||||
const SkScalerContextEffects& effects,
|
||||
const SkTypeface& typeface) override;
|
||||
|
||||
static void AddGlyphForTesting(
|
||||
SkGlyphCacheState* cache, SkPackedGlyphID glyphID, bool asPath);
|
||||
|
||||
void setMaxEntriesInDescriptorMapForTesting(size_t count) {
|
||||
fMaxEntriesInDescriptorMap = count;
|
||||
}
|
||||
@ -187,7 +188,7 @@ public:
|
||||
// An interface to delete handles that may be pinned by the remote server.
|
||||
class DiscardableHandleManager : public SkRefCnt {
|
||||
public:
|
||||
virtual ~DiscardableHandleManager() = default;
|
||||
~DiscardableHandleManager() override = default;
|
||||
|
||||
// Returns true if the handle was unlocked and can be safely deleted. Once
|
||||
// successful, subsequent attempts to delete the same handle are invalid.
|
||||
|
@ -1,122 +0,0 @@
|
||||
/*
|
||||
* Copyright 2018 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkRemoteGlyphCacheImpl_DEFINED
|
||||
#define SkRemoteGlyphCacheImpl_DEFINED
|
||||
|
||||
#include "src/core/SkArenaAlloc.h"
|
||||
#include "src/core/SkDescriptor.h"
|
||||
#include "src/core/SkGlyphRun.h"
|
||||
#include "src/core/SkGlyphRunPainter.h"
|
||||
#include "src/core/SkRemoteGlyphCache.h"
|
||||
|
||||
class SkStrikeServer::SkGlyphCacheState : public SkStrikeInterface {
|
||||
public:
|
||||
// N.B. SkGlyphCacheState is not valid until ensureScalerContext is called.
|
||||
SkGlyphCacheState(const SkDescriptor& descriptor,
|
||||
std::unique_ptr<SkScalerContext> context,
|
||||
SkDiscardableHandleId discardableHandleId);
|
||||
~SkGlyphCacheState() override;
|
||||
|
||||
void addGlyph(SkPackedGlyphID, bool pathOnly);
|
||||
void writePendingGlyphs(Serializer* serializer);
|
||||
SkDiscardableHandleId discardableHandleId() const { return fDiscardableHandleId; }
|
||||
|
||||
bool isSubpixel() const { return fIsSubpixel; }
|
||||
|
||||
const SkDescriptor& getDescriptor() const override {
|
||||
return *fDescriptor.getDesc();
|
||||
}
|
||||
|
||||
void setTypefaceAndEffects(const SkTypeface* typeface, SkScalerContextEffects effects);
|
||||
|
||||
SkVector rounding() const override;
|
||||
|
||||
SkIPoint subpixelMask() const override {
|
||||
return SkIPoint::Make((!fIsSubpixel || fAxisAlignment == kY_SkAxisAlignment) ? 0 : ~0u,
|
||||
(!fIsSubpixel || fAxisAlignment == kX_SkAxisAlignment) ? 0 : ~0u);
|
||||
}
|
||||
|
||||
SkSpan<const SkGlyphPos>
|
||||
prepareForDrawingRemoveEmpty(const SkPackedGlyphID packedGlyphIDs[],
|
||||
const SkPoint positions[],
|
||||
size_t n,
|
||||
int maxDimension,
|
||||
PreparationDetail detail,
|
||||
SkGlyphPos results[]) override;
|
||||
|
||||
void onAboutToExitScope() override {}
|
||||
|
||||
private:
|
||||
bool hasPendingGlyphs() const {
|
||||
return !fPendingGlyphImages.empty() || !fPendingGlyphPaths.empty();
|
||||
}
|
||||
void writeGlyphPath(const SkPackedGlyphID& glyphID, Serializer* serializer) const;
|
||||
|
||||
void ensureScalerContext();
|
||||
void resetScalerContext();
|
||||
|
||||
// The set of glyphs cached on the remote client.
|
||||
SkTHashSet<SkPackedGlyphID> fCachedGlyphImages;
|
||||
SkTHashSet<SkPackedGlyphID> fCachedGlyphPaths;
|
||||
|
||||
// The set of glyphs which has not yet been serialized and sent to the
|
||||
// remote client.
|
||||
std::vector<SkPackedGlyphID> fPendingGlyphImages;
|
||||
std::vector<SkPackedGlyphID> fPendingGlyphPaths;
|
||||
|
||||
const SkAutoDescriptor fDescriptor;
|
||||
|
||||
const SkDiscardableHandleId fDiscardableHandleId;
|
||||
|
||||
// Values saved from the initial context.
|
||||
const bool fIsSubpixel;
|
||||
const SkAxisAlignment fAxisAlignment;
|
||||
|
||||
// The context built using fDescriptor
|
||||
std::unique_ptr<SkScalerContext> fContext;
|
||||
|
||||
// These fields are set every time getOrCreateCache. This allows the code to maintain the
|
||||
// fContext as lazy as possible.
|
||||
const SkTypeface* fTypeface{nullptr};
|
||||
SkScalerContextEffects fEffects;
|
||||
|
||||
class GlyphMapHashTraits {
|
||||
public:
|
||||
static SkPackedGlyphID GetKey(const SkGlyph* glyph) {
|
||||
return glyph->getPackedID();
|
||||
}
|
||||
static uint32_t Hash(SkPackedGlyphID glyphId) {
|
||||
return glyphId.hash();
|
||||
}
|
||||
};
|
||||
|
||||
// FallbackTextHelper cases require glyph metrics when analyzing a glyph run, in which case
|
||||
// we cache them here.
|
||||
SkTHashTable<SkGlyph*, SkPackedGlyphID, GlyphMapHashTraits> fGlyphMap;
|
||||
|
||||
SkArenaAlloc fAlloc{256};
|
||||
};
|
||||
|
||||
class SkTextBlobCacheDiffCanvas::TrackLayerDevice : public SkNoPixelsDevice {
|
||||
public:
|
||||
TrackLayerDevice(const SkIRect& bounds, const SkSurfaceProps& props, SkStrikeServer* server,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
const SkTextBlobCacheDiffCanvas::Settings& settings);
|
||||
|
||||
SkBaseDevice* onCreateDevice(const CreateInfo& cinfo, const SkPaint*) override;
|
||||
|
||||
protected:
|
||||
void drawGlyphRunList(const SkGlyphRunList& glyphRunList) override;
|
||||
|
||||
private:
|
||||
SkStrikeServer* const fStrikeServer;
|
||||
const SkTextBlobCacheDiffCanvas::Settings fSettings;
|
||||
SkGlyphRunListPainter fPainter;
|
||||
};
|
||||
|
||||
#endif // SkRemoteGlyphCacheImpl_DEFINED
|
@ -11,7 +11,6 @@
|
||||
#include "include/private/SkMutex.h"
|
||||
#include "src/core/SkDraw.h"
|
||||
#include "src/core/SkRemoteGlyphCache.h"
|
||||
#include "src/core/SkRemoteGlyphCacheImpl.h"
|
||||
#include "src/core/SkStrike.h"
|
||||
#include "src/core/SkStrikeCache.h"
|
||||
#include "src/core/SkStrikeSpec.h"
|
||||
@ -988,7 +987,7 @@ DEF_TEST(SkRemoteGlyphCache_ReWriteGlyph, reporter) {
|
||||
auto* cacheState = server.getOrCreateCache(
|
||||
paint, font, SkSurfacePropsCopyOrDefault(nullptr),
|
||||
SkMatrix::I(), flags, &effects);
|
||||
cacheState->addGlyph(lostGlyphID, false);
|
||||
SkStrikeServer::AddGlyphForTesting(cacheState, lostGlyphID, false);
|
||||
|
||||
std::vector<uint8_t> serverStrikeData;
|
||||
server.writeStrikeData(&serverStrikeData);
|
||||
|
Loading…
Reference in New Issue
Block a user