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

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

Issue 1467533003: Eliminate SkFILE - it always is the same as FILE. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-11-20 (Friday) 14:01:26 EST Created 5 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
« no previous file with comments | « include/core/SkStream.h ('k') | src/core/SkStream.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 "SkOSFile.h" 9 #include "SkOSFile.h"
10 #include "SkOncePtr.h" 10 #include "SkOncePtr.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 SkData* SkData::NewWithProc(const void* ptr, size_t length, ReleaseProc proc, vo id* context) { 106 SkData* SkData::NewWithProc(const void* ptr, size_t length, ReleaseProc proc, vo id* context) {
107 return new SkData(ptr, length, proc, context); 107 return new SkData(ptr, length, proc, context);
108 } 108 }
109 109
110 // assumes fPtr was allocated with sk_fmmap 110 // assumes fPtr was allocated with sk_fmmap
111 static void sk_mmap_releaseproc(const void* addr, void* ctx) { 111 static void sk_mmap_releaseproc(const void* addr, void* ctx) {
112 size_t length = reinterpret_cast<size_t>(ctx); 112 size_t length = reinterpret_cast<size_t>(ctx);
113 sk_fmunmap(addr, length); 113 sk_fmunmap(addr, length);
114 } 114 }
115 115
116 SkData* SkData::NewFromFILE(SkFILE* f) { 116 SkData* SkData::NewFromFILE(FILE* f) {
117 size_t size; 117 size_t size;
118 void* addr = sk_fmmap(f, &size); 118 void* addr = sk_fmmap(f, &size);
119 if (nullptr == addr) { 119 if (nullptr == addr) {
120 return nullptr; 120 return nullptr;
121 } 121 }
122 122
123 return SkData::NewWithProc(addr, size, sk_mmap_releaseproc, reinterpret_cast <void*>(size)); 123 return SkData::NewWithProc(addr, size, sk_mmap_releaseproc, reinterpret_cast <void*>(size));
124 } 124 }
125 125
126 SkData* SkData::NewFromFileName(const char path[]) { 126 SkData* SkData::NewFromFileName(const char path[]) {
127 SkFILE* f = path ? sk_fopen(path, kRead_SkFILE_Flag) : nullptr; 127 FILE* f = path ? sk_fopen(path, kRead_SkFILE_Flag) : nullptr;
128 if (nullptr == f) { 128 if (nullptr == f) {
129 return nullptr; 129 return nullptr;
130 } 130 }
131 SkData* data = NewFromFILE(f); 131 SkData* data = NewFromFILE(f);
132 sk_fclose(f); 132 sk_fclose(f);
133 return data; 133 return data;
134 } 134 }
135 135
136 SkData* SkData::NewFromFD(int fd) { 136 SkData* SkData::NewFromFD(int fd) {
137 size_t size; 137 size_t size;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 /////////////////////////////////////////////////////////////////////////////// 185 ///////////////////////////////////////////////////////////////////////////////
186 186
187 SkData* SkData::NewFromStream(SkStream* stream, size_t size) { 187 SkData* SkData::NewFromStream(SkStream* stream, size_t size) {
188 SkAutoDataUnref data(SkData::NewUninitialized(size)); 188 SkAutoDataUnref data(SkData::NewUninitialized(size));
189 if (stream->read(data->writable_data(), size) != size) { 189 if (stream->read(data->writable_data(), size) != size) {
190 return nullptr; 190 return nullptr;
191 } 191 }
192 return data.detach(); 192 return data.detach();
193 } 193 }
194 194
OLDNEW
« no previous file with comments | « include/core/SkStream.h ('k') | src/core/SkStream.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698