| 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 16 matching lines...) Expand all Loading... |
| 27 #if 0 | 27 #if 0 |
| 28 // doesn't see quite right. Are they thinking 1555? | 28 // doesn't see quite right. Are they thinking 1555? |
| 29 *bitsPerComponent = 5; | 29 *bitsPerComponent = 5; |
| 30 *info = kCGBitmapByteOrder16Little | kCGImageAlphaNone; | 30 *info = kCGBitmapByteOrder16Little | kCGImageAlphaNone; |
| 31 break; | 31 break; |
| 32 #endif | 32 #endif |
| 33 if (upscaleTo32) { | 33 if (upscaleTo32) { |
| 34 *upscaleTo32 = true; | 34 *upscaleTo32 = true; |
| 35 } | 35 } |
| 36 // fall through | 36 // fall through |
| 37 case kPMColor_SkColorType: | 37 case kN32_SkColorType: |
| 38 *bitsPerComponent = 8; | 38 *bitsPerComponent = 8; |
| 39 #if SK_PMCOLOR_BYTE_ORDER(R,G,B,A) | 39 #if SK_PMCOLOR_BYTE_ORDER(R,G,B,A) |
| 40 *info = kCGBitmapByteOrder32Big; | 40 *info = kCGBitmapByteOrder32Big; |
| 41 if (bm.isOpaque()) { | 41 if (bm.isOpaque()) { |
| 42 *info |= kCGImageAlphaNoneSkipLast; | 42 *info |= kCGImageAlphaNoneSkipLast; |
| 43 } else { | 43 } else { |
| 44 *info |= kCGImageAlphaPremultipliedLast; | 44 *info |= kCGImageAlphaPremultipliedLast; |
| 45 } | 45 } |
| 46 #elif SK_PMCOLOR_BYTE_ORDER(B,G,R,A) | 46 #elif SK_PMCOLOR_BYTE_ORDER(B,G,R,A) |
| 47 // Matches the CGBitmapInfo that Apple recommends for best | 47 // Matches the CGBitmapInfo that Apple recommends for best |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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, kPMColor_SkColorType); | 97 bm.copyTo(copy, kN32_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 Loading... |
| 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 } |
| OLD | NEW |