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

Side by Side Diff: src/utils/ios/SkStream_NSData.mm

Issue 1197963003: Remove old iOS porting files. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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
« no previous file with comments | « src/utils/ios/SkOSFile_iOS.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2010 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 "SkStream_NSData.h"
9
10 NSData* NSData_dataWithStream(SkStream* stream) {
11 size_t length = stream->getLength();
12 void* src = malloc(length);
13 size_t bytes = stream->read(src, length);
14 SkASSERT(bytes == length);
15 return [NSData dataWithBytesNoCopy:src length:length freeWhenDone:YES];
16 }
17
18 NSData* NSData_dataFromResource(const char cname[], const char csuffix[]) {
19 NSBundle* bundle = [NSBundle mainBundle];
20 NSString* name = [NSString stringWithUTF8String:cname];
21 NSString* suffix = [NSString stringWithUTF8String:csuffix];
22 NSString* path = [bundle pathForResource:name ofType:suffix];
23 return [NSData dataWithContentsOfMappedFile:path];
24 }
25
26 ///////////////////////////////////////////////////////////////////////////////
27
28 SkStream_NSData::SkStream_NSData(NSData* data) {
29 fNSData = data;
30 [fNSData retain];
31
32 this->setMemory([fNSData bytes], [fNSData length], false);
33 }
34
35 SkStream_NSData::~SkStream_NSData() {
36 [fNSData release];
37 }
38
39 SkStream_NSData* SkStream_NSData::CreateFromResource(const char name[],
40 const char suffix[]) {
41 NSData* data = NSData_dataFromResource(name, suffix);
42 return SkNEW_ARGS(SkStream_NSData, (data));
43 }
44
OLDNEW
« no previous file with comments | « src/utils/ios/SkOSFile_iOS.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698