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

Unified Diff: skia/ext/SkDiscardableMemory_chrome.cc

Issue 23206002: skia: Added chrome implementation of SkDiscardableMemory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed OVERRIDE keyword from destructor. 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 | « skia/ext/SkDiscardableMemory_chrome.h ('k') | skia/skia_chrome.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: skia/ext/SkDiscardableMemory_chrome.cc
diff --git a/skia/ext/SkDiscardableMemory_chrome.cc b/skia/ext/SkDiscardableMemory_chrome.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0f1ffacbe436afb4d4e40c8b28f5376fe1e6a41c
--- /dev/null
+++ b/skia/ext/SkDiscardableMemory_chrome.cc
@@ -0,0 +1,49 @@
+// 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.
+
+#include "SkDiscardableMemory_chrome.h"
+
+SkDiscardableMemoryChrome::SkDiscardableMemoryChrome()
+ : discardable_(new base::DiscardableMemory()) {
+}
+
+SkDiscardableMemoryChrome::~SkDiscardableMemoryChrome() {
+}
+
+bool SkDiscardableMemoryChrome::lock() {
+ base::LockDiscardableMemoryStatus status = discardable_->Lock();
+ switch (status) {
+ case base::DISCARDABLE_MEMORY_SUCCESS:
+ return true;
+ case base::DISCARDABLE_MEMORY_PURGED:
+ discardable_->Unlock();
+ return false;
+ default:
+ discardable_.reset();
+ return false;
+ }
+}
+
+void* SkDiscardableMemoryChrome::data() {
+ return discardable_->Memory();
+}
+
+void SkDiscardableMemoryChrome::unlock() {
+ discardable_->Unlock();
+}
+
+bool SkDiscardableMemoryChrome::InitializeAndLock(size_t bytes) {
+ return discardable_->InitializeAndLock(bytes);
+}
+
+SkDiscardableMemory* SkDiscardableMemory::Create(size_t bytes) {
+ if (!base::DiscardableMemory::Supported()) {
+ return NULL;
+ }
+ scoped_ptr<SkDiscardableMemoryChrome> discardable(
+ new SkDiscardableMemoryChrome());
+ if (discardable->InitializeAndLock(bytes))
+ return discardable.release();
+ return NULL;
+}
« no previous file with comments | « skia/ext/SkDiscardableMemory_chrome.h ('k') | skia/skia_chrome.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698