Home | History | Annotate | Download | only in core

Lines Matching refs:SkFlatData

151 // SkFlatData:       is a simple indexable container for the flattened data
156 // searchable set of SkFlatData objects of type T.
171 class SkFlatData;
193 * Used during creation and unflattening of SkFlatData objects. If the
201 * Used during creation of SkFlatData objects. If a typeface recorder is
208 * Used during unflattening of the SkFlatData objects in the
215 * Optional factory recorder used during creation of SkFlatData objects. Set
221 * Flags to use during creation of SkFlatData objects. Defaults to zero.
266 class SkFlatData {
268 // Flatten obj into an SkFlatData with this index. controller owns the SkFlatData*.
269 static SkFlatData* Create(SkFlatController* controller,
281 bool operator==(const SkFlatData& that) const {
313 static const SkFlatData& Identity(const SkFlatData& flat) { return flat; }
314 static uint32_t Hash(const SkFlatData& flat) { return flat.checksum(); }
315 static bool Equal(const SkFlatData& a, const SkFlatData& b) { return a == b; }
377 const SkFlatData* operator[](int index) {
392 * Similar to find. Allows the caller to specify an SkFlatData to replace in
393 * the case of an add. Also tells the caller whether a new SkFlatData was
396 * the entry in the dictionary, it returns the actual SkFlatData.
398 const SkFlatData* findAndReplace(const T& element,
399 const SkFlatData* toReplace,
405 SkFlatData* flat = this->findAndReturnMutableFlat(element);
415 const SkFlatData* found = fHash.find(*toReplace);
457 const SkFlatData* element = fIndexedData[index];
469 const SkFlatData* findAndReturnFlat(const T& element) {
478 // Layout: [ SkFlatData header, 20 bytes ] [ data ..., 4-byte aligned ]
481 return sizeof(SkFlatData) + flatDataSize;
484 // Allocate a new scratch SkFlatData. Must be sk_freed.
485 static SkFlatData* AllocScratch(size_t scratchSize) {
486 return (SkFlatData*) sk_malloc_throw(SizeWithPadding(scratchSize));
505 SkFlatData* findAndReturnMutableFlat(const T& element) {
507 const SkFlatData& scratch = this->resetScratch(element, fNextIndex);
509 SkFlatData* candidate = fHash.find(scratch);
512 SkFlatData* detached = this->detachScratch();
520 const SkFlatData& resetScratch(const T& element, int index) {
531 // It didn't all fit. Copy into a larger replacement SkFlatData.
533 SkFlatData* larger = AllocScratch(bytesWritten);
548 SkFlatData* detachScratch() {
549 // Allocate a new SkFlatData exactly big enough to hold our current scratch.
553 SkFlatData* detached = (SkFlatData*)fController->allocThrow(paddedSize);
555 // Copy scratch into the new SkFlatData.
562 void unflatten(T* dst, const SkFlatData* element) const {
569 // All SkFlatData* stored in fIndexedData and fHash are owned by the controller.
572 SkFlatData* fScratch; // Owned, must be freed with sk_free.
576 // We map between SkFlatData and a 1-based integer index.
579 // For index -> SkFlatData. fIndexedData[0] is always NULL.
580 SkTDArray<const SkFlatData*> fIndexedData;
582 // For SkFlatData -> cached SkFlatData, which has index().
583 SkTDynamicHash<SkFlatData, SkFlatData,
584 SkFlatData::Identity, SkFlatData::Hash, SkFlatData::Equal> fHash;