| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * Copyright 2012 The Android Open Source Project | 2  * Copyright 2012 The Android Open Source Project | 
| 3  * | 3  * | 
| 4  * Use of this source code is governed by a BSD-style license that can be | 4  * Use of this source code is governed by a BSD-style license that can be | 
| 5  * found in the LICENSE file. | 5  * found in the LICENSE file. | 
| 6  */ | 6  */ | 
| 7 | 7 | 
| 8 #include "SkImageFilter.h" | 8 #include "SkImageFilter.h" | 
| 9 | 9 | 
| 10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" | 
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 427         SkBitmap fBitmap; | 427         SkBitmap fBitmap; | 
| 428         SkIPoint fOffset; | 428         SkIPoint fOffset; | 
| 429         static const Key& GetKey(const Value& v) { | 429         static const Key& GetKey(const Value& v) { | 
| 430             return v.fKey; | 430             return v.fKey; | 
| 431         } | 431         } | 
| 432         static uint32_t Hash(const Key& key) { | 432         static uint32_t Hash(const Key& key) { | 
| 433             return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(&key), 
     sizeof(Key)); | 433             return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(&key), 
     sizeof(Key)); | 
| 434         } | 434         } | 
| 435         SK_DECLARE_INTERNAL_LLIST_INTERFACE(Value); | 435         SK_DECLARE_INTERNAL_LLIST_INTERFACE(Value); | 
| 436     }; | 436     }; | 
| 437     virtual bool get(const Key& key, SkBitmap* result, SkIPoint* offset) const { | 437     virtual bool get(const Key& key, SkBitmap* result, SkIPoint* offset) const S
     K_OVERRIDE { | 
| 438         SkAutoMutexAcquire mutex(fMutex); | 438         SkAutoMutexAcquire mutex(fMutex); | 
| 439         if (Value* v = fLookup.find(key)) { | 439         if (Value* v = fLookup.find(key)) { | 
| 440             *result = v->fBitmap; | 440             *result = v->fBitmap; | 
| 441             *offset = v->fOffset; | 441             *offset = v->fOffset; | 
| 442             if (v != fLRU.head()) { | 442             if (v != fLRU.head()) { | 
| 443                 fLRU.remove(v); | 443                 fLRU.remove(v); | 
| 444                 fLRU.addToHead(v); | 444                 fLRU.addToHead(v); | 
| 445             } | 445             } | 
| 446             return true; | 446             return true; | 
| 447         } | 447         } | 
| 448         return false; | 448         return false; | 
| 449     } | 449     } | 
| 450     virtual void set(const Key& key, const SkBitmap& result, const SkIPoint& off
     set) { | 450     virtual void set(const Key& key, const SkBitmap& result, const SkIPoint& off
     set) SK_OVERRIDE { | 
| 451         SkAutoMutexAcquire mutex(fMutex); | 451         SkAutoMutexAcquire mutex(fMutex); | 
| 452         if (Value* v = fLookup.find(key)) { | 452         if (Value* v = fLookup.find(key)) { | 
| 453             removeInternal(v); | 453             removeInternal(v); | 
| 454         } | 454         } | 
| 455         Value* v = new Value(key, result, offset); | 455         Value* v = new Value(key, result, offset); | 
| 456         fLookup.add(v); | 456         fLookup.add(v); | 
| 457         fLRU.addToHead(v); | 457         fLRU.addToHead(v); | 
| 458         fCurrentBytes += result.getSize(); | 458         fCurrentBytes += result.getSize(); | 
| 459         while (fCurrentBytes > fMaxBytes) { | 459         while (fCurrentBytes > fMaxBytes) { | 
| 460             Value* tail = fLRU.tail(); | 460             Value* tail = fLRU.tail(); | 
| (...skipping 27 matching lines...) Expand all  Loading... | 
| 488 | 488 | 
| 489 SkImageFilter::Cache* SkImageFilter::Cache::Create(size_t maxBytes) { | 489 SkImageFilter::Cache* SkImageFilter::Cache::Create(size_t maxBytes) { | 
| 490     return SkNEW_ARGS(CacheImpl, (maxBytes)); | 490     return SkNEW_ARGS(CacheImpl, (maxBytes)); | 
| 491 } | 491 } | 
| 492 | 492 | 
| 493 SK_DECLARE_STATIC_LAZY_PTR(SkImageFilter::Cache, cache, CreateCache); | 493 SK_DECLARE_STATIC_LAZY_PTR(SkImageFilter::Cache, cache, CreateCache); | 
| 494 | 494 | 
| 495 SkImageFilter::Cache* SkImageFilter::Cache::Get() { | 495 SkImageFilter::Cache* SkImageFilter::Cache::Get() { | 
| 496     return cache.get(); | 496     return cache.get(); | 
| 497 } | 497 } | 
| OLD | NEW | 
|---|