Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
SkStrikeServerImpl Class Referencefinal
Inheritance diagram for SkStrikeServerImpl:
sktext::StrikeForGPUCacheInterface

Public Member Functions

 SkStrikeServerImpl (SkStrikeServer::DiscardableHandleManager *discardableHandleManager)
 
void writeStrikeData (std::vector< uint8_t > *memory)
 
sk_sp< sktext::StrikeForGPUfindOrCreateScopedStrike (const SkStrikeSpec &strikeSpec) override
 
void setMaxEntriesInDescriptorMapForTesting (size_t count)
 
size_t remoteStrikeMapSizeForTesting () const
 
- Public Member Functions inherited from sktext::StrikeForGPUCacheInterface
virtual ~StrikeForGPUCacheInterface ()=default
 

Detailed Description

Definition at line 265 of file SkChromeRemoteGlyphCache.cpp.

Constructor & Destructor Documentation

◆ SkStrikeServerImpl()

SkStrikeServerImpl::SkStrikeServerImpl ( SkStrikeServer::DiscardableHandleManager discardableHandleManager)
explicit

Definition at line 308 of file SkChromeRemoteGlyphCache.cpp.

309 : fDiscardableHandleManager(dhm) {
310 SkASSERT(fDiscardableHandleManager);
311}
#define SkASSERT(cond)
Definition SkAssert.h:116

Member Function Documentation

◆ findOrCreateScopedStrike()

sk_sp< StrikeForGPU > SkStrikeServerImpl::findOrCreateScopedStrike ( const SkStrikeSpec strikeSpec)
overridevirtual

Implements sktext::StrikeForGPUCacheInterface.

Definition at line 366 of file SkChromeRemoteGlyphCache.cpp.

367 {
368 return this->getOrCreateCache(strikeSpec);
369}

◆ remoteStrikeMapSizeForTesting()

size_t SkStrikeServerImpl::remoteStrikeMapSizeForTesting ( ) const

Definition at line 316 of file SkChromeRemoteGlyphCache.cpp.

316 {
317 return fDescToRemoteStrike.size();
318}

◆ setMaxEntriesInDescriptorMapForTesting()

void SkStrikeServerImpl::setMaxEntriesInDescriptorMapForTesting ( size_t  count)

Definition at line 313 of file SkChromeRemoteGlyphCache.cpp.

313 {
314 fMaxEntriesInDescriptorMap = count;
315}
int count

◆ writeStrikeData()

void SkStrikeServerImpl::writeStrikeData ( std::vector< uint8_t > *  memory)

Definition at line 320 of file SkChromeRemoteGlyphCache.cpp.

320 {
321 // We can use the default SkSerialProcs because we do not currently need to encode any SkImages.
322 SkBinaryWriteBuffer buffer{nullptr, 0, {}};
323
324 // Gather statistics about what needs to be sent.
325 size_t strikesToSend = 0;
326 fRemoteStrikesToSend.foreach([&](RemoteStrike* strike) {
327 if (strike->hasPendingGlyphs()) {
328 strikesToSend++;
329 } else {
330 // This strike has nothing to send, so drop its scaler context to reduce memory.
331 strike->resetScalerContext();
332 }
333 });
334
335 // If there are no strikes or typefaces to send, then cleanup and return.
336 if (strikesToSend == 0 && fTypefacesToSend.empty()) {
337 fRemoteStrikesToSend.reset();
338 return;
339 }
340
341 // Send newly seen typefaces.
342 SkASSERT_RELEASE(SkTFitsIn<int>(fTypefacesToSend.size()));
343 buffer.writeInt(fTypefacesToSend.size());
344 for (const auto& typeface: fTypefacesToSend) {
345 SkTypefaceProxyPrototype proto{typeface};
346 proto.flatten(buffer);
347 }
348 fTypefacesToSend.clear();
349
350 buffer.writeInt(strikesToSend);
351 fRemoteStrikesToSend.foreach(
352 [&](RemoteStrike* strike) {
353 if (strike->hasPendingGlyphs()) {
354 strike->writePendingGlyphs(buffer);
355 strike->resetScalerContext();
356 }
357 }
358 );
359 fRemoteStrikesToSend.reset();
360
361 // Copy data into the vector.
362 auto data = buffer.snapshotAsData();
363 memory->assign(data->bytes(), data->bytes() + data->size());
364}
#define SkASSERT_RELEASE(cond)
Definition SkAssert.h:100
void flatten(SkWriteBuffer &buffer) const
void foreach(Fn &&fn) const
Definition SkTHash.h:590
static const uint8_t buffer[]
AutoTArray< uint8_t > data((int) size)

The documentation for this class was generated from the following file: