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

Side by Side Diff: skia/ext/sk_discardable_memory_chrome.h

Issue 23206002: skia: Added chrome implementation of SkDiscardableMemory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 4 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
« no previous file with comments | « content/renderer/render_thread_impl.cc ('k') | skia/ext/sk_discardable_memory_chrome.cc » ('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 // 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_
OLDNEW
« no previous file with comments | « content/renderer/render_thread_impl.cc ('k') | skia/ext/sk_discardable_memory_chrome.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698