1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/src/effects/gradients/SkBitmapCache.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,49 @@ 1.4 + 1.5 +/* 1.6 + * Copyright 2010 Google Inc. 1.7 + * 1.8 + * Use of this source code is governed by a BSD-style license that can be 1.9 + * found in the LICENSE file. 1.10 + */ 1.11 + 1.12 + 1.13 +#ifndef SkBitmapCache_DEFINED 1.14 +#define SkBitmapCache_DEFINED 1.15 + 1.16 +#include "SkBitmap.h" 1.17 + 1.18 +class SkBitmapCache : SkNoncopyable { 1.19 +public: 1.20 + SkBitmapCache(int maxEntries); 1.21 + ~SkBitmapCache(); 1.22 + 1.23 + bool find(const void* buffer, size_t len, SkBitmap*) const; 1.24 + void add(const void* buffer, size_t len, const SkBitmap&); 1.25 + 1.26 +private: 1.27 + int fEntryCount; 1.28 + const int fMaxEntries; 1.29 + 1.30 + struct Entry; 1.31 + mutable Entry* fHead; 1.32 + mutable Entry* fTail; 1.33 + 1.34 + inline Entry* detach(Entry*) const; 1.35 + inline void attachToHead(Entry*) const; 1.36 + 1.37 +#ifdef SK_DEBUG 1.38 + void validate() const; 1.39 +#else 1.40 + void validate() const {} 1.41 +#endif 1.42 + 1.43 + class AutoValidate : SkNoncopyable { 1.44 + public: 1.45 + AutoValidate(const SkBitmapCache* bc) : fBC(bc) { bc->validate(); } 1.46 + ~AutoValidate() { fBC->validate(); } 1.47 + private: 1.48 + const SkBitmapCache* fBC; 1.49 + }; 1.50 +}; 1.51 + 1.52 +#endif