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

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

Issue 72603005: Guard against most unintentionally ephemeral SkAutoFoo instantiations. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: undo autoasciitolc Created 7 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 | Annotate | Revision Log
« no previous file with comments | « src/ports/SkFontHost_win.cpp ('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
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
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
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 }
OLDNEW
« no previous file with comments | « src/ports/SkFontHost_win.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698