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

Side by Side Diff: src/utils/mac/SkCreateCGImageRef.cpp

Issue 678763003: In SkPDFDocumentToBitmap, use SkCreateDataProviderFromStream (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 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 | « no previous file | 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
1 1
2 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
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 #include "SkCGUtils.h" 8 #include "SkCGUtils.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 ~SkAutoPDFRelease() { 181 ~SkAutoPDFRelease() {
182 if (fDoc) { 182 if (fDoc) {
183 CGPDFDocumentRelease(fDoc); 183 CGPDFDocumentRelease(fDoc);
184 } 184 }
185 } 185 }
186 private: 186 private:
187 CGPDFDocumentRef fDoc; 187 CGPDFDocumentRef fDoc;
188 }; 188 };
189 #define SkAutoPDFRelease(...) SK_REQUIRE_LOCAL_VAR(SkAutoPDFRelease) 189 #define SkAutoPDFRelease(...) SK_REQUIRE_LOCAL_VAR(SkAutoPDFRelease)
190 190
191 static void CGDataProviderReleaseData_FromMalloc(void*, const void* data,
192 size_t size) {
193 sk_free((void*)data);
194 }
195
196 bool SkPDFDocumentToBitmap(SkStream* stream, SkBitmap* output) { 191 bool SkPDFDocumentToBitmap(SkStream* stream, SkBitmap* output) {
197 size_t size = stream->getLength(); 192 CGDataProviderRef data = SkCreateDataProviderFromStream(stream);
198 void* ptr = sk_malloc_throw(size);
199 stream->read(ptr, size);
200 CGDataProviderRef data = CGDataProviderCreateWithData(NULL, ptr, size,
201 CGDataProviderReleaseData_FromMalloc);
202 if (NULL == data) { 193 if (NULL == data) {
203 return false; 194 return false;
204 } 195 }
205 196
206 CGPDFDocumentRef pdf = CGPDFDocumentCreateWithProvider(data); 197 CGPDFDocumentRef pdf = CGPDFDocumentCreateWithProvider(data);
207 CGDataProviderRelease(data); 198 CGDataProviderRelease(data);
208 if (NULL == pdf) { 199 if (NULL == pdf) {
209 return false; 200 return false;
210 } 201 }
211 SkAutoPDFRelease releaseMe(pdf); 202 SkAutoPDFRelease releaseMe(pdf);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 default: 297 default:
307 // we don't know if we're opaque or not, so compute it. 298 // we don't know if we're opaque or not, so compute it.
308 if (SkBitmap::ComputeIsOpaque(tmp)) { 299 if (SkBitmap::ComputeIsOpaque(tmp)) {
309 tmp.setAlphaType(kOpaque_SkAlphaType); 300 tmp.setAlphaType(kOpaque_SkAlphaType);
310 } 301 }
311 } 302 }
312 303
313 *dst = tmp; 304 *dst = tmp;
314 return true; 305 return true;
315 } 306 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698