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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: skia/ext/sk_discardable_memory_chrome.h
diff --git a/skia/ext/sk_discardable_memory_chrome.h b/skia/ext/sk_discardable_memory_chrome.h
new file mode 100644
index 0000000000000000000000000000000000000000..c213cf6666366a71209cea7c9b694a06373e7160
--- /dev/null
+++ b/skia/ext/sk_discardable_memory_chrome.h
@@ -0,0 +1,53 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SKIA_EXT_SK_DISCARDABLE_MEMORY_CHROME_H_
+#define SKIA_EXT_SK_DISCARDABLE_MEMORY_CHROME_H_
+
+#include "base/memory/discardable_memory.h"
+#include "base/memory/singleton.h"
+#include "third_party/skia/src/core/SkDiscardableMemory.h"
+
+namespace skia {
+
+// This class implements the SkDiscardableMemory interface using
+// base::DiscardableMemory.
+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
+public:
+ 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
+
+ // Initialize the SkDiscardableMemoryChrome object and lock the memory.
+ // Returns true on success. No memory is allocated if this call returns
+ // false. This call should only be called once.
+ bool InitializeAndLock(size_t bytes);
+
+ // Implementation of SkDiscardableMemory interface.
+ bool lock();
+ void* data();
+ void unlock();
+
+private:
+ scoped_ptr<base::DiscardableMemory> discardable_;
+};
+
+// This singleton class implements the SkDiscardableMemoryFactory interface
+// for creation of SkDiscardableMemoryChrome objects.
+class SK_API SkDiscardableMemoryFactoryChrome
+ : public SkDiscardableMemoryFactory {
+public:
+ static SkDiscardableMemoryFactoryChrome* GetInstance() {
+ return Singleton<SkDiscardableMemoryFactoryChrome>::get();
+ }
+
+ // Implementation of SkDiscardableMemoryFactory interface.
+ SkDiscardableMemory* create(size_t bytes);
+
+private:
+ SkDiscardableMemoryFactoryChrome() {}
+ friend struct DefaultSingletonTraits<SkDiscardableMemoryFactoryChrome>;
+};
+
+} // namespace skia
+
+#endif // SKIA_EXT_SK_DISCARDABLE_MEMORY_CHROME_H_
« 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