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

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

Issue 15675025: One allocation for an SkData which makes a copy. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Clean Created 7 years, 6 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
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkStream.h" 10 #include "SkStream.h"
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 } 299 }
300 return fData->data(); 300 return fData->data();
301 } 301 }
302 302
303 /////////////////////////////////////////////////////////////////////////////// 303 ///////////////////////////////////////////////////////////////////////////////
304 304
305 static SkData* newFromParams(const void* src, size_t size, bool copyData) { 305 static SkData* newFromParams(const void* src, size_t size, bool copyData) {
306 if (copyData) { 306 if (copyData) {
307 return SkData::NewWithCopy(src, size); 307 return SkData::NewWithCopy(src, size);
308 } else { 308 } else {
309 return SkData::NewWithProc(src, size, NULL, NULL); 309 return SkData::NewUnowned(src, size);
310 } 310 }
311 } 311 }
312 312
313 SkMemoryStream::SkMemoryStream() { 313 SkMemoryStream::SkMemoryStream() {
314 fData = SkData::NewEmpty(); 314 fData = SkData::NewEmpty();
315 fOffset = 0; 315 fOffset = 0;
316 } 316 }
317 317
318 SkMemoryStream::SkMemoryStream(size_t size) { 318 SkMemoryStream::SkMemoryStream(size_t size) {
319 fData = SkData::NewFromMalloc(sk_malloc_throw(size), size); 319 fData = SkData::NewFromMalloc(sk_malloc_throw(size), size);
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 705
706 // If we get here, then our attempt at using mmap failed, so try normal 706 // If we get here, then our attempt at using mmap failed, so try normal
707 // file access. 707 // file access.
708 SkFILEStream* stream = SkNEW_ARGS(SkFILEStream, (path)); 708 SkFILEStream* stream = SkNEW_ARGS(SkFILEStream, (path));
709 if (!stream->isValid()) { 709 if (!stream->isValid()) {
710 stream->unref(); 710 stream->unref();
711 stream = NULL; 711 stream = NULL;
712 } 712 }
713 return stream; 713 return stream;
714 } 714 }
OLDNEW
« include/core/SkWeakRefCnt.h ('K') | « src/core/SkData.cpp ('k') | src/pdf/SkPDFFont.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698