Home | History | Annotate | Download | only in core

Lines Matching defs:Rec

25 static inline SkScaledImageCache::ID* rec_to_id(SkScaledImageCache::Rec* rec) {
26 return reinterpret_cast<SkScaledImageCache::ID*>(rec);
29 static inline SkScaledImageCache::Rec* id_to_rec(SkScaledImageCache::ID* id) {
30 return reinterpret_cast<SkScaledImageCache::Rec*>(id);
103 struct SkScaledImageCache::Rec {
104 Rec(const Key& key, const SkBitmap& bm) : fKey(key), fBitmap(bm) {
109 Rec(const Key& key, const SkMipMap* mip) : fKey(key) {
115 ~Rec() {
123 Rec* fNext;
124 Rec* fPrev;
139 const SkScaledImageCache::Key& key_from_rec(const SkScaledImageCache::Rec& rec) {
140 return rec.fKey;
147 bool eq_rec_key(const SkScaledImageCache::Rec& rec, const SkScaledImageCache::Key& key) {
148 return rec.fKey == key;
152 class SkScaledImageCache::Hash : public SkTDynamicHash<SkScaledImageCache::Rec,
164 static inline SkScaledImageCache::Rec* find_rec_in_list(
165 SkScaledImageCache::Rec* head, const Key & key) {
166 SkScaledImageCache::Rec* rec = head;
167 while ((rec != NULL) && (rec->fKey != key)) {
168 rec = rec->fNext;
170 return rec;
323 Rec* rec = fHead;
324 while (rec) {
325 Rec* next = rec->fNext;
326 SkDELETE(rec);
327 rec = next;
335 SkScaledImageCache::Rec* SkScaledImageCache::findAndLock(uint32_t genID,
346 SkScaledImageCache::Rec* SkScaledImageCache::findAndLock(const SkScaledImageCache::Key& key) {
351 Rec* rec = fHash->find(key);
353 Rec* rec = find_rec_in_list(fHead, key);
355 if (rec) {
356 this->moveToHead(rec); // for our LRU
357 rec->fLockCount += 1;
359 return rec;
382 Rec* rec = this->findAndLock(genID, SK_Scalar1, SK_Scalar1,
384 if (rec) {
385 SkASSERT(NULL == rec->fMip);
386 SkASSERT(rec->fBitmap.pixelRef());
387 *bitmap = rec->fBitmap;
389 return rec_to_id(rec);
400 Rec* rec = this->findAndLock(orig.getGenerationID(), scaleX,
402 if (rec) {
403 SkASSERT(NULL == rec->fMip);
404 SkASSERT(rec->fBitmap.pixelRef());
405 *scaled = rec->fBitmap;
407 return rec_to_id(rec);
412 Rec* rec = this->findAndLock(orig.getGenerationID(), 0, 0,
414 if (rec) {
415 SkASSERT(rec->fMip);
416 SkASSERT(NULL == rec->fBitmap.pixelRef());
417 *mip = rec->fMip;
419 return rec_to_id(rec);
427 SkScaledImageCache::ID* SkScaledImageCache::addAndLock(SkScaledImageCache::Rec* rec) {
428 SkASSERT(rec);
430 Rec* existing = this->findAndLock(rec->fKey);
435 this->addToHead(rec);
436 SkASSERT(1 == rec->fLockCount);
439 fHash->add(rec);
443 return rec_to_id(rec);
451 Rec* rec = SkNEW_ARGS(Rec, (key, bitmap));
452 return this->addAndLock(rec);
468 Rec* rec = SkNEW_ARGS(Rec, (key, scaled));
469 return this->addAndLock(rec);
479 Rec* rec = SkNEW_ARGS(Rec, (key, mip));
480 return this->addAndLock(rec);
489 Rec* rec = fHead;
490 while (rec != NULL) {
491 if (rec == id_to_rec(id)) {
495 rec = rec->fNext;
500 Rec* rec = id_to_rec(id);
501 SkASSERT(rec->fLockCount > 0);
502 rec->fLockCount -= 1;
506 if (0 == rec->fLockCount) {
526 Rec* rec = fTail;
527 while (rec) {
532 Rec* prev = rec->fPrev;
533 if (0 == rec->fLockCount) {
534 size_t used = rec->bytesUsed();
536 this->detach(rec);
538 fHash->remove(rec->fKey);
541 SkDELETE(rec);
546 rec = prev;
564 void SkScaledImageCache::detach(Rec* rec) {
565 Rec* prev = rec->fPrev;
566 Rec* next = rec->fNext;
569 SkASSERT(fHead == rec);
581 rec->fNext = rec->fPrev = NULL;
584 void SkScaledImageCache::moveToHead(Rec* rec) {
585 if (fHead == rec) {
594 this->detach(rec);
596 fHead->fPrev = rec;
597 rec->fNext = fHead;
598 fHead = rec;
603 void SkScaledImageCache::addToHead(Rec* rec) {
606 rec->fPrev = NULL;
607 rec->fNext = fHead;
609 fHead->fPrev = rec;
611 fHead = rec;
613 fTail = rec;
615 fBytesUsed += rec->bytesUsed();
645 const Rec* rec = fHead;
646 while (rec) {
648 used += rec->bytesUsed();
650 rec = rec->fNext;
654 rec = fTail;
655 while (rec) {
658 SkASSERT(used >= rec->bytesUsed());
659 used -= rec->bytesUsed();
660 rec = rec->fPrev;
671 const Rec* rec = fHead;
673 while (rec) {
674 locked += rec->fLockCount > 0;
675 rec = rec->fNext;