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

Side by Side Diff: include/gpu/GrCacheable.h

Issue 251013002: Split GrResource into GrCacheable/GrGpuObject (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase Created 6 years, 7 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 | « gyp/gpu.gypi ('k') | include/gpu/GrContext.h » ('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 2014 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 GrCacheable_DEFINED
9 #define GrCacheable_DEFINED
10
11 #include "SkRefCnt.h"
12
13 class GrResourceCacheEntry;
14
15 /**
16 * Base class for objects that can be kept in the GrResourceCache.
17 */
18 class GrCacheable : public SkRefCnt {
19 public:
20 SK_DECLARE_INST_COUNT(GrCacheable)
21
22 /**
23 * Retrieves the amount of GPU memory used by this resource in bytes. It is
24 * approximate since we aren't aware of additional padding or copies made
25 * by the driver.
26 *
27 * @return the amount of GPU memory used in bytes
28 */
29 virtual size_t gpuMemorySize() const = 0;
30
31 /**
32 * Checks whether the GPU memory allocated to this resource is still in effe ct.
33 * It can become invalid if its context is destroyed or lost, in which case it
34 * should no longer count against the GrResourceCache budget.
35 *
36 * @return true if this resource is still holding GPU memory
37 * false otherwise.
38 */
39 virtual bool isValidOnGpu() const = 0;
40
41 void setCacheEntry(GrResourceCacheEntry* cacheEntry) { fCacheEntry = cacheEn try; }
42 GrResourceCacheEntry* getCacheEntry() { return fCacheEntry; }
43
44 protected:
45 GrCacheable() : fCacheEntry(NULL) {}
46
47 bool isInCache() const { return NULL != fCacheEntry; }
48
49 private:
50 GrResourceCacheEntry* fCacheEntry; // NULL if not in cache
51
52 typedef SkRefCnt INHERITED;
53 };
54
55 #endif
OLDNEW
« no previous file with comments | « gyp/gpu.gypi ('k') | include/gpu/GrContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698