OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
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 #ifndef SkDiscardableMemory_DEFINED | 8 #ifndef SkBasicDiscardableMemory_DEFINED |
9 #define SkDiscardableMemory_DEFINED | 9 #define SkBasicDiscardableMemory_DEFINED |
10 | 10 |
11 #include "SkTypes.h" | 11 #include "SkDiscardableMemory.h" |
12 | 12 |
13 /** | 13 /** |
14 * Interface for discardable memory. Implementation is provided by the | 14 * Always successful, never purges |
15 * embedder. | |
16 */ | 15 */ |
17 class SK_API SkDiscardableMemory { | 16 class SkBasicDiscardableMemory : public SkDiscardableMemory { |
reed1
2013/11/19 22:01:18
bikeshed: SkMallocDiscardableMemory?
scroggo
2013/11/19 22:19:27
It seems dishonest to call this SkBasicDiscardable
hal.canary
2013/11/20 00:07:10
Done.
| |
18 | |
19 public: | 17 public: |
20 /** | |
21 * Factory method that creates, initializes and locks an SkDiscardableMemor y | |
22 * object. If either of these steps fails, a NULL pointer will be returned. | |
23 */ | |
24 static SkDiscardableMemory* Create(size_t bytes); | |
25 | |
26 /** Must not be called while locked. | 18 /** Must not be called while locked. |
27 */ | 19 */ |
28 virtual ~SkDiscardableMemory() {} | 20 virtual ~SkBasicDiscardableMemory(); |
29 | 21 |
30 /** | 22 /** |
31 * Locks the memory, prevent it from being discarded. Once locked. you may | 23 * Locks the memory, prevent it from being discarded. Once locked. you may |
scroggo
2013/11/19 22:19:27
Comments don't apply.
hal.canary
2013/11/20 00:07:10
Done.
| |
32 * obtain a pointer to that memory using the data() method. | 24 * obtain a pointer to that memory using the data() method. |
reed1
2013/11/19 22:01:18
Not sure we should repeat the dox from the base-cl
hal.canary
2013/11/20 00:07:10
Done.
| |
33 * | 25 * |
34 * lock() may return false, indicating that the underlying memory was | 26 * lock() may return false, indicating that the underlying memory was |
35 * discarded and that the lock failed. | 27 * discarded and that the lock failed. |
36 * | 28 * |
37 * Nested calls to lock are not allowed. | 29 * Nested calls to lock are not allowed. |
38 */ | 30 */ |
39 virtual bool lock() = 0; | 31 virtual bool lock() SK_OVERRIDE; |
40 | 32 |
41 /** | 33 /** |
42 * Returns the current pointer for the discardable memory. This call is ONLY | 34 * Returns the current pointer for the discardable memory. This |
43 * valid when the discardable memory object is locked. | 35 * call is ONLY valid when the discardable memory object is |
36 * locked. | |
44 */ | 37 */ |
45 virtual void* data() = 0; | 38 virtual void* data() SK_OVERRIDE; |
46 | 39 |
47 /** | 40 /** |
48 * Unlock the memory so that it can be purged by the system. Must be called | 41 * Unlock the memory so that it can be purged by the system. Must |
49 * after every successful lock call. | 42 * be called after every successful lock call. |
50 */ | 43 */ |
51 virtual void unlock() = 0; | 44 virtual void unlock() SK_OVERRIDE; |
45 | |
46 static SkDiscardableMemory* Create(size_t bytes); | |
47 private: | |
48 bool fLocked; | |
49 void* fPointer; | |
50 SkBasicDiscardableMemory(void*); | |
52 }; | 51 }; |
53 | 52 |
54 #endif | 53 #endif // SkBasicDiscardableMemory_DEFINED |
OLD | NEW |