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

Side by Side 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, 3 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 | « skia/ext/SkDiscardableMemory_chrome.h ('k') | skia/skia_chrome.gypi » ('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 #include "SkDiscardableMemory_chrome.h"
6
7 SkDiscardableMemoryChrome::SkDiscardableMemoryChrome()
8 : discardable_(new base::DiscardableMemory()) {
9 }
10
11 SkDiscardableMemoryChrome::~SkDiscardableMemoryChrome() {
12 }
13
14 bool SkDiscardableMemoryChrome::lock() {
15 base::LockDiscardableMemoryStatus status = discardable_->Lock();
16 switch (status) {
17 case base::DISCARDABLE_MEMORY_SUCCESS:
18 return true;
19 case base::DISCARDABLE_MEMORY_PURGED:
20 discardable_->Unlock();
21 return false;
22 default:
23 discardable_.reset();
24 return false;
25 }
26 }
27
28 void* SkDiscardableMemoryChrome::data() {
29 return discardable_->Memory();
30 }
31
32 void SkDiscardableMemoryChrome::unlock() {
33 discardable_->Unlock();
34 }
35
36 bool SkDiscardableMemoryChrome::InitializeAndLock(size_t bytes) {
37 return discardable_->InitializeAndLock(bytes);
38 }
39
40 SkDiscardableMemory* SkDiscardableMemory::Create(size_t bytes) {
41 if (!base::DiscardableMemory::Supported()) {
42 return NULL;
43 }
44 scoped_ptr<SkDiscardableMemoryChrome> discardable(
45 new SkDiscardableMemoryChrome());
46 if (discardable->InitializeAndLock(bytes))
47 return discardable.release();
48 return NULL;
49 }
OLDNEW
« 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