Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: include/ports/SkAshmemImageCache.h

Issue 12433020: Improvements/additions to SkImageCache/SkLazyPixelRef. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Respond to comments. Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « include/lazy/SkPurgeableImageCache.h ('k') | src/lazy/SkBitmapFactory.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2013 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef SkAshmemImageCache_DEFINED
9 #define SkAshmemImageCache_DEFINED
10
11 #include "SkImageCache.h"
12 #include "SkTDArray.h"
13 #include "SkTypes.h"
14
15 class SkAshmemImageCache : public SkImageCache {
16
17 public:
18 /**
19 * Get a pointer to the single global instance of SkAshmemImageCache.
20 */
21 static SkAshmemImageCache* GetAshmemImageCache();
22
23 virtual void* allocAndPinCache(size_t bytes, intptr_t* ID) SK_OVERRIDE;
24 virtual void* pinCache(intptr_t ID) SK_OVERRIDE;
25 virtual void releaseCache(intptr_t ID) SK_OVERRIDE;
26 virtual void throwAwayCache(intptr_t ID) SK_OVERRIDE;
27
28 #ifdef SK_DEBUG
29 SkImageCache::CacheStatus getCacheStatus(intptr_t ID) const SK_OVERRIDE;
30
31 virtual ~SkAshmemImageCache();
32 #endif
33
34 private:
35 struct AshmemRec {
36 int fFD;
37 void* fAddr;
38 size_t fSize;
39 #ifdef SK_DEBUG
40 bool fPinned;
41
42 static int Compare(const AshmemRec*, const AshmemRec*);
43 #endif
44 };
45
46 /**
47 * Constructor is private. The correct way to get this cache is through
48 * GetAshmemImageCache, so that all callers can get the single global.
49 */
50 SkAshmemImageCache();
51
52 #ifdef SK_DEBUG
53 // Stores a list of AshmemRecs to track deletion.
54 SkTDArray<AshmemRec*> fRecs;
55
56 /**
57 * Debug only function to add an AshmemRec to the list.
58 */
59 void appendRec(AshmemRec*);
60
61 /**
62 * Return the index of AshmemRec.
63 */
64 int findRec(const AshmemRec*) const;
65 #endif
66
67 /**
68 * Deletes AshmemRec. In debug, also removes from the list.
69 */
70 void removeRec(AshmemRec*);
71 };
72 #endif // SkAshmemImageCache_DEFINED
OLDNEW
« no previous file with comments | « include/lazy/SkPurgeableImageCache.h ('k') | src/lazy/SkBitmapFactory.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698