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

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

Issue 12921003: reland 8200 w/ fix for android (use fullpath instead of path) (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « include/core/SkStream.h ('k') | src/core/SkMMapStream.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkData.h" 8 #include "SkData.h"
9 #include "SkFlattenableBuffers.h" 9 #include "SkFlattenableBuffers.h"
10 10
11 #if SK_MMAP_SUPPORT
12 #include <unistd.h>
13 #include <sys/mman.h>
14 #include <fcntl.h>
15 #include <errno.h>
16 #endif
17
11 SK_DEFINE_INST_COUNT(SkData) 18 SK_DEFINE_INST_COUNT(SkData)
12 19
13 SkData::SkData(const void* ptr, size_t size, ReleaseProc proc, void* context) { 20 SkData::SkData(const void* ptr, size_t size, ReleaseProc proc, void* context) {
14 fPtr = ptr; 21 fPtr = ptr;
15 fSize = size; 22 fSize = size;
16 fReleaseProc = proc; 23 fReleaseProc = proc;
17 fReleaseProcContext = context; 24 fReleaseProcContext = context;
18 } 25 }
19 26
20 SkData::~SkData() { 27 SkData::~SkData() {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 size_t size; 120 size_t size;
114 if (NULL == cstr) { 121 if (NULL == cstr) {
115 cstr = ""; 122 cstr = "";
116 size = 1; 123 size = 1;
117 } else { 124 } else {
118 size = strlen(cstr) + 1; 125 size = strlen(cstr) + 1;
119 } 126 }
120 return NewWithCopy(cstr, size); 127 return NewWithCopy(cstr, size);
121 } 128 }
122 129
130 #if SK_MMAP_SUPPORT
131 static void sk_munmap_releaseproc(const void* addr, size_t length, void*) {
132 munmap(const_cast<void*>(addr), length);
133 }
134
135 SkData* SkData::NewFromMMap(const void* addr, size_t length) {
136 return SkNEW_ARGS(SkData, (addr, length, sk_munmap_releaseproc, NULL));
137 }
138 #else
139 SkData* SkData::NewFromMMap(const void* addr, size_t length) {
140 return NULL;
141 }
142 #endif
143
123 /////////////////////////////////////////////////////////////////////////////// 144 ///////////////////////////////////////////////////////////////////////////////
124 145
125 void SkData::flatten(SkFlattenableWriteBuffer& buffer) const { 146 void SkData::flatten(SkFlattenableWriteBuffer& buffer) const {
126 buffer.writeByteArray(fPtr, fSize); 147 buffer.writeByteArray(fPtr, fSize);
127 } 148 }
128 149
129 SkData::SkData(SkFlattenableReadBuffer& buffer) { 150 SkData::SkData(SkFlattenableReadBuffer& buffer) {
130 fSize = buffer.getArrayCount(); 151 fSize = buffer.getArrayCount();
131 fReleaseProcContext = NULL; 152 fReleaseProcContext = NULL;
132 153
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 } 314 }
294 315
295 SkDataSet* SkDataSet::NewEmpty() { 316 SkDataSet* SkDataSet::NewEmpty() {
296 static SkDataSet* gEmptySet; 317 static SkDataSet* gEmptySet;
297 if (NULL == gEmptySet) { 318 if (NULL == gEmptySet) {
298 gEmptySet = SkNEW_ARGS(SkDataSet, (NULL, 0)); 319 gEmptySet = SkNEW_ARGS(SkDataSet, (NULL, 0));
299 } 320 }
300 gEmptySet->ref(); 321 gEmptySet->ref();
301 return gEmptySet; 322 return gEmptySet;
302 } 323 }
324
OLDNEW
« no previous file with comments | « include/core/SkStream.h ('k') | src/core/SkMMapStream.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698