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

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

Issue 143073008: add installPixels (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « src/utils/debugger/SkDebugCanvas.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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 if (NULL == page) { 202 if (NULL == page) {
203 return false; 203 return false;
204 } 204 }
205 205
206 CGRect bounds = CGPDFPageGetBoxRect(page, kCGPDFMediaBox); 206 CGRect bounds = CGPDFPageGetBoxRect(page, kCGPDFMediaBox);
207 207
208 int w = (int)CGRectGetWidth(bounds); 208 int w = (int)CGRectGetWidth(bounds);
209 int h = (int)CGRectGetHeight(bounds); 209 int h = (int)CGRectGetHeight(bounds);
210 210
211 SkBitmap bitmap; 211 SkBitmap bitmap;
212 bitmap.setConfig(SkBitmap::kARGB_8888_Config, w, h); 212 if (!bitmap.allocPixels(SkImageInfo::MakeN32Premul(w, h))) {
213 bitmap.allocPixels(); 213 return false;
214 }
214 bitmap.eraseColor(SK_ColorWHITE); 215 bitmap.eraseColor(SK_ColorWHITE);
215 216
216 size_t bitsPerComponent; 217 size_t bitsPerComponent;
217 CGBitmapInfo info; 218 CGBitmapInfo info;
218 getBitmapInfo(bitmap, &bitsPerComponent, &info, NULL); 219 getBitmapInfo(bitmap, &bitsPerComponent, &info, NULL);
219 220
220 CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB(); 221 CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
221 CGContextRef ctx = CGBitmapContextCreate(bitmap.getPixels(), w, h, 222 CGContextRef ctx = CGBitmapContextCreate(bitmap.getPixels(), w, h,
222 bitsPerComponent, bitmap.rowBytes() , 223 bitsPerComponent, bitmap.rowBytes() ,
223 cs, info); 224 cs, info);
224 CGColorSpaceRelease(cs); 225 CGColorSpaceRelease(cs);
225 226
226 if (ctx) { 227 if (ctx) {
227 CGContextDrawPDFPage(ctx, page); 228 CGContextDrawPDFPage(ctx, page);
228 CGContextRelease(ctx); 229 CGContextRelease(ctx);
229 } 230 }
230 231
231 output->swap(bitmap); 232 output->swap(bitmap);
232 return true; 233 return true;
233 } 234 }
OLDNEW
« no previous file with comments | « src/utils/debugger/SkDebugCanvas.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698