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 SkBitmap::Config SkColorTypeToBitmapConfig(SkColorType colorType) { | 12 SkBitmap::Config SkColorTypeToBitmapConfig(SkColorType colorType) { |
13 switch (colorType) { | 13 switch (colorType) { |
14 case kAlpha_8_SkColorType: | 14 case kAlpha_8_SkColorType: |
15 return SkBitmap::kA8_Config; | 15 return SkBitmap::kA8_Config; |
16 | 16 |
17 case kARGB_4444_SkColorType: | 17 case kARGB_4444_SkColorType: |
18 return SkBitmap::kARGB_4444_Config; | 18 return SkBitmap::kARGB_4444_Config; |
19 | 19 |
20 case kRGB_565_SkColorType: | 20 case kRGB_565_SkColorType: |
21 return SkBitmap::kRGB_565_Config; | 21 return SkBitmap::kRGB_565_Config; |
22 | 22 |
23 case kPMColor_SkColorType: | 23 case kN32_SkColorType: |
24 return SkBitmap::kARGB_8888_Config; | 24 return SkBitmap::kARGB_8888_Config; |
25 | 25 |
26 case kIndex_8_SkColorType: | 26 case kIndex_8_SkColorType: |
27 return SkBitmap::kIndex8_Config; | 27 return SkBitmap::kIndex8_Config; |
28 | 28 |
29 default: | 29 default: |
30 // break for unsupported colortypes | 30 // break for unsupported colortypes |
31 break; | 31 break; |
32 } | 32 } |
33 return SkBitmap::kNo_Config; | 33 return SkBitmap::kNo_Config; |
34 } | 34 } |
35 | 35 |
36 SkBitmap::Config SkImageInfoToBitmapConfig(const SkImageInfo& info) { | 36 SkBitmap::Config SkImageInfoToBitmapConfig(const SkImageInfo& info) { |
37 return SkColorTypeToBitmapConfig(info.fColorType); | 37 return SkColorTypeToBitmapConfig(info.fColorType); |
38 } | 38 } |
39 | 39 |
40 SkColorType SkBitmapConfigToColorType(SkBitmap::Config config) { | 40 SkColorType SkBitmapConfigToColorType(SkBitmap::Config config) { |
41 static const SkColorType gCT[] = { | 41 static const SkColorType gCT[] = { |
42 kUnknown_SkColorType, // kNo_Config | 42 kUnknown_SkColorType, // kNo_Config |
43 kAlpha_8_SkColorType, // kA8_Config | 43 kAlpha_8_SkColorType, // kA8_Config |
44 kIndex_8_SkColorType, // kIndex8_Config | 44 kIndex_8_SkColorType, // kIndex8_Config |
45 kRGB_565_SkColorType, // kRGB_565_Config | 45 kRGB_565_SkColorType, // kRGB_565_Config |
46 kARGB_4444_SkColorType, // kARGB_4444_Config | 46 kARGB_4444_SkColorType, // kARGB_4444_Config |
47 kPMColor_SkColorType, // kARGB_8888_Config | 47 kN32_SkColorType, // kARGB_8888_Config |
48 }; | 48 }; |
49 SkASSERT((unsigned)config < SK_ARRAY_COUNT(gCT)); | 49 SkASSERT((unsigned)config < SK_ARRAY_COUNT(gCT)); |
50 return gCT[config]; | 50 return gCT[config]; |
51 } | 51 } |
52 | 52 |
53 SkImage* SkNewImageFromBitmap(const SkBitmap& bm, bool canSharePixelRef) { | 53 SkImage* SkNewImageFromBitmap(const SkBitmap& bm, bool canSharePixelRef) { |
54 SkImageInfo info; | 54 SkImageInfo info; |
55 if (!bm.asImageInfo(&info)) { | 55 if (!bm.asImageInfo(&info)) { |
56 return NULL; | 56 return NULL; |
57 } | 57 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 canvas->save(); | 118 canvas->save(); |
119 } | 119 } |
120 canvas->concat(matrix); | 120 canvas->concat(matrix); |
121 if (!paint || !needs_layer(*paint)) { | 121 if (!paint || !needs_layer(*paint)) { |
122 canvas->clipRect(tmpSrc); | 122 canvas->clipRect(tmpSrc); |
123 } | 123 } |
124 | 124 |
125 canvas->drawPicture(*picture); | 125 canvas->drawPicture(*picture); |
126 canvas->restoreToCount(saveCount); | 126 canvas->restoreToCount(saveCount); |
127 } | 127 } |
OLD | NEW |