OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef SKIA_EXT_SK_DISCARDABLE_MEMORY_CHROME_H_ | |
6 #define SKIA_EXT_SK_DISCARDABLE_MEMORY_CHROME_H_ | |
7 | |
8 #include "base/memory/discardable_memory.h" | |
9 #include "base/memory/singleton.h" | |
10 #include "third_party/skia/src/core/SkDiscardableMemory.h" | |
11 | |
12 namespace skia { | |
13 | |
14 // This class implements the SkDiscardableMemory interface using | |
15 // base::DiscardableMemory. | |
16 class SK_API SkDiscardableMemoryChrome : public SkDiscardableMemory { | |
nduca
2013/08/14 22:53:37
Also impl is a useful suffix when you're implement
ernstm
2013/08/15 20:30:12
Following the embedding pattern of SkThread, I kep
| |
17 public: | |
18 SkDiscardableMemoryChrome(); | |
scroggo
2013/08/15 14:15:25
It looks like someone could create an SkDiscardabl
ernstm
2013/08/15 20:30:12
I think it's safe to create and initialize SkDisca
| |
19 | |
20 // Initialize the SkDiscardableMemoryChrome object and lock the memory. | |
21 // Returns true on success. No memory is allocated if this call returns | |
22 // false. This call should only be called once. | |
23 bool InitializeAndLock(size_t bytes); | |
24 | |
25 // Implementation of SkDiscardableMemory interface. | |
26 bool lock(); | |
27 void* data(); | |
28 void unlock(); | |
29 | |
30 private: | |
31 scoped_ptr<base::DiscardableMemory> discardable_; | |
32 }; | |
33 | |
34 // This singleton class implements the SkDiscardableMemoryFactory interface | |
35 // for creation of SkDiscardableMemoryChrome objects. | |
36 class SK_API SkDiscardableMemoryFactoryChrome | |
37 : public SkDiscardableMemoryFactory { | |
38 public: | |
39 static SkDiscardableMemoryFactoryChrome* GetInstance() { | |
40 return Singleton<SkDiscardableMemoryFactoryChrome>::get(); | |
41 } | |
42 | |
43 // Implementation of SkDiscardableMemoryFactory interface. | |
44 SkDiscardableMemory* create(size_t bytes); | |
45 | |
46 private: | |
47 SkDiscardableMemoryFactoryChrome() {} | |
48 friend struct DefaultSingletonTraits<SkDiscardableMemoryFactoryChrome>; | |
49 }; | |
50 | |
51 } // namespace skia | |
52 | |
53 #endif // SKIA_EXT_SK_DISCARDABLE_MEMORY_CHROME_H_ | |
OLD | NEW |