OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkImagePriv.h" | 8 #include "SkImagePriv.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkPicture.h" | 10 #include "SkPicture.h" |
11 | 11 |
| 12 #ifdef SK_SUPPORT_LEGACY_BITMAP_CONFIG |
12 SkBitmap::Config SkColorTypeToBitmapConfig(SkColorType colorType) { | 13 SkBitmap::Config SkColorTypeToBitmapConfig(SkColorType colorType) { |
13 switch (colorType) { | 14 switch (colorType) { |
14 case kAlpha_8_SkColorType: | 15 case kAlpha_8_SkColorType: |
15 return SkBitmap::kA8_Config; | 16 return SkBitmap::kA8_Config; |
16 | 17 |
17 case kARGB_4444_SkColorType: | 18 case kARGB_4444_SkColorType: |
18 return SkBitmap::kARGB_4444_Config; | 19 return SkBitmap::kARGB_4444_Config; |
19 | 20 |
20 case kRGB_565_SkColorType: | 21 case kRGB_565_SkColorType: |
21 return SkBitmap::kRGB_565_Config; | 22 return SkBitmap::kRGB_565_Config; |
(...skipping 16 matching lines...) Expand all Loading... |
38 kUnknown_SkColorType, // kNo_Config | 39 kUnknown_SkColorType, // kNo_Config |
39 kAlpha_8_SkColorType, // kA8_Config | 40 kAlpha_8_SkColorType, // kA8_Config |
40 kIndex_8_SkColorType, // kIndex8_Config | 41 kIndex_8_SkColorType, // kIndex8_Config |
41 kRGB_565_SkColorType, // kRGB_565_Config | 42 kRGB_565_SkColorType, // kRGB_565_Config |
42 kARGB_4444_SkColorType, // kARGB_4444_Config | 43 kARGB_4444_SkColorType, // kARGB_4444_Config |
43 kN32_SkColorType, // kARGB_8888_Config | 44 kN32_SkColorType, // kARGB_8888_Config |
44 }; | 45 }; |
45 SkASSERT((unsigned)config < SK_ARRAY_COUNT(gCT)); | 46 SkASSERT((unsigned)config < SK_ARRAY_COUNT(gCT)); |
46 return gCT[config]; | 47 return gCT[config]; |
47 } | 48 } |
| 49 #endif |
48 | 50 |
49 SkImage* SkNewImageFromBitmap(const SkBitmap& bm, bool canSharePixelRef) { | 51 SkImage* SkNewImageFromBitmap(const SkBitmap& bm, bool canSharePixelRef) { |
50 const SkImageInfo info = bm.info(); | 52 const SkImageInfo info = bm.info(); |
51 if (kUnknown_SkColorType == info.colorType()) { | 53 if (kUnknown_SkColorType == info.colorType()) { |
52 return NULL; | 54 return NULL; |
53 } | 55 } |
54 | 56 |
55 SkImage* image = NULL; | 57 SkImage* image = NULL; |
56 if (canSharePixelRef || bm.isImmutable()) { | 58 if (canSharePixelRef || bm.isImmutable()) { |
57 image = SkNewImageFromPixelRef(info, bm.pixelRef(), bm.rowBytes()); | 59 image = SkNewImageFromPixelRef(info, bm.pixelRef(), bm.rowBytes()); |
58 } else { | 60 } else { |
59 bm.lockPixels(); | 61 bm.lockPixels(); |
60 if (bm.getPixels()) { | 62 if (bm.getPixels()) { |
61 image = SkImage::NewRasterCopy(info, bm.getPixels(), bm.rowBytes()); | 63 image = SkImage::NewRasterCopy(info, bm.getPixels(), bm.rowBytes()); |
62 } | 64 } |
63 bm.unlockPixels(); | 65 bm.unlockPixels(); |
64 } | 66 } |
65 return image; | 67 return image; |
66 } | 68 } |
OLD | NEW |