Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 SkDiscardableMemory_DEFINED | |
| 9 #define SkDiscardableMemory_DEFINED | |
| 10 | |
| 11 #include "SkTypes.h" | |
| 12 | |
| 13 /** | |
| 14 * Interface for discardable memory. Implementation is provided by the | |
| 15 * embedder. | |
| 16 */ | |
| 17 class SkDiscardableMemory { | |
| 18 | |
| 19 public: | |
| 20 /** Must not be called while locked. | |
| 21 */ | |
| 22 virtual ~SkDiscardableMemory() {} | |
| 23 | |
| 24 /** | |
| 25 * Locks the memory, prevent it from being discarded. Once locked. you may | |
| 26 * obtain a pointer to that memory using the data() method. | |
| 27 * | |
| 28 * lock() may return false, indicating that the underlying memory was | |
| 29 * discarded and that the lock failed. | |
| 30 * | |
| 31 * Nested calls to lock are not allowed. | |
| 32 */ | |
| 33 virtual bool lock() = 0; | |
| 34 | |
| 35 /** | |
| 36 * Returns the current pointer for the discardable memory. This call is ONLY | |
| 37 * valid when the discardable memory object is locked. | |
| 38 */ | |
| 39 virtual void* data() = 0; | |
| 40 | |
| 41 /** | |
| 42 * Unlock the memory so that it can be purged by the system. Must be called | |
| 43 * after every successful lock call. | |
| 44 */ | |
| 45 virtual void unlock() = 0; | |
| 46 }; | |
| 47 | |
| 48 /** | |
| 49 * Factory function that creates, initializes and locks an SkDiscardableMemory | |
| 50 * object. If either of these steps fails, a NULL pointer will be returned. | |
| 51 */ | |
| 52 SK_API SkDiscardableMemory* sk_create_discardable_memory(size_t bytes); | |
|
reed1
2013/08/15 20:42:04
minor nit: Often in skia we will put this sort of
ernstm
2013/08/15 21:12:32
Done.
| |
| 53 | |
| 54 #endif | |
| OLD | NEW |