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

Side by Side Diff: src/core/SkBasicDiscardableMemory.cpp

Issue 74793011: Add SkImageGenerator Interface (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: protected destructor Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 /*
2 * Copyright 2013 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "SkBasicDiscardableMemory.h"
9 #include "SkTypes.h"
10
11 SkDiscardableMemory* SkBasicDiscardableMemory::Create(size_t bytes) {
12 void* ptr = sk_malloc_throw(bytes);
13 if (NULL == ptr) {
14 return NULL;
15 }
16 return SkNEW_ARGS(SkBasicDiscardableMemory, (ptr));
17 }
18
19 SkBasicDiscardableMemory::SkBasicDiscardableMemory(void* ptr)
20 : fLocked(true)
21 , fPointer(ptr) {
22 SkASSERT(fPointer != NULL);
23 }
24
25 SkBasicDiscardableMemory::~SkBasicDiscardableMemory() {
26 SkASSERT(!fLocked);
27 sk_free(fPointer);
28 }
29
30 bool SkBasicDiscardableMemory::lock() {
31 SkASSERT(!fLocked);
32 return fLocked = true;
33 }
34
35 void* SkBasicDiscardableMemory::data() {
36 SkASSERT(fLocked);
37 return fPointer;
scroggo 2013/11/19 22:19:27 Should this return NULL if not locked?
hal.canary 2013/11/20 00:07:10 Should we allow the caller to make that mistake?
38 }
39
40 void SkBasicDiscardableMemory::unlock() {
41 SkASSERT(fLocked);
42 fLocked = false;
43 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698