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

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

Issue 171723007: add new copyTo version to SkBitmap, which takes SkColorType (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: 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/SkBitmapHasher.cpp ('k') | tests/BitmapCopyTest.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 /* 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 bool upscaleTo32; 87 bool upscaleTo32;
88 if (!getBitmapInfo(bm, bitsPerComponent, info, &upscaleTo32)) { 88 if (!getBitmapInfo(bm, bitsPerComponent, info, &upscaleTo32)) {
89 return NULL; 89 return NULL;
90 } 90 }
91 91
92 SkBitmap* copy; 92 SkBitmap* copy;
93 if (upscaleTo32) { 93 if (upscaleTo32) {
94 copy = new SkBitmap; 94 copy = new SkBitmap;
95 // here we make a ceep copy of the pixels, since CG won't take our 95 // here we make a ceep copy of the pixels, since CG won't take our
96 // 565 directly 96 // 565 directly
97 bm.copyTo(copy, SkBitmap::kARGB_8888_Config); 97 bm.copyTo(copy, kPMColor_SkColorType);
98 } else { 98 } else {
99 copy = new SkBitmap(bm); 99 copy = new SkBitmap(bm);
100 } 100 }
101 return copy; 101 return copy;
102 } 102 }
103 103
104 CGImageRef SkCreateCGImageRefWithColorspace(const SkBitmap& bm, 104 CGImageRef SkCreateCGImageRefWithColorspace(const SkBitmap& bm,
105 CGColorSpaceRef colorSpace) { 105 CGColorSpaceRef colorSpace) {
106 size_t bitsPerComponent SK_INIT_TO_AVOID_WARNING; 106 size_t bitsPerComponent SK_INIT_TO_AVOID_WARNING;
107 CGBitmapInfo info SK_INIT_TO_AVOID_WARNING; 107 CGBitmapInfo info SK_INIT_TO_AVOID_WARNING;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 CGColorSpaceRelease(cs); 224 CGColorSpaceRelease(cs);
225 225
226 if (ctx) { 226 if (ctx) {
227 CGContextDrawPDFPage(ctx, page); 227 CGContextDrawPDFPage(ctx, page);
228 CGContextRelease(ctx); 228 CGContextRelease(ctx);
229 } 229 }
230 230
231 output->swap(bitmap); 231 output->swap(bitmap);
232 return true; 232 return true;
233 } 233 }
OLDNEW
« no previous file with comments | « src/utils/SkBitmapHasher.cpp ('k') | tests/BitmapCopyTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698