OLD | NEW |
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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 public: | 167 public: |
168 SkAutoPDFRelease(CGPDFDocumentRef doc) : fDoc(doc) {} | 168 SkAutoPDFRelease(CGPDFDocumentRef doc) : fDoc(doc) {} |
169 ~SkAutoPDFRelease() { | 169 ~SkAutoPDFRelease() { |
170 if (fDoc) { | 170 if (fDoc) { |
171 CGPDFDocumentRelease(fDoc); | 171 CGPDFDocumentRelease(fDoc); |
172 } | 172 } |
173 } | 173 } |
174 private: | 174 private: |
175 CGPDFDocumentRef fDoc; | 175 CGPDFDocumentRef fDoc; |
176 }; | 176 }; |
| 177 #define SkAutoPDFRelease(...) SK_REQUIRE_LOCAL_VAR(SkAutoPDFRelease) |
177 | 178 |
178 static void CGDataProviderReleaseData_FromMalloc(void*, const void* data, | 179 static void CGDataProviderReleaseData_FromMalloc(void*, const void* data, |
179 size_t size) { | 180 size_t size) { |
180 sk_free((void*)data); | 181 sk_free((void*)data); |
181 } | 182 } |
182 | 183 |
183 bool SkPDFDocumentToBitmap(SkStream* stream, SkBitmap* output) { | 184 bool SkPDFDocumentToBitmap(SkStream* stream, SkBitmap* output) { |
184 size_t size = stream->getLength(); | 185 size_t size = stream->getLength(); |
185 void* ptr = sk_malloc_throw(size); | 186 void* ptr = sk_malloc_throw(size); |
186 stream->read(ptr, size); | 187 stream->read(ptr, size); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 CGColorSpaceRelease(cs); | 224 CGColorSpaceRelease(cs); |
224 | 225 |
225 if (ctx) { | 226 if (ctx) { |
226 CGContextDrawPDFPage(ctx, page); | 227 CGContextDrawPDFPage(ctx, page); |
227 CGContextRelease(ctx); | 228 CGContextRelease(ctx); |
228 } | 229 } |
229 | 230 |
230 output->swap(bitmap); | 231 output->swap(bitmap); |
231 return true; | 232 return true; |
232 } | 233 } |
OLD | NEW |