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

Side by Side Diff: src/image/SkImagePriv.cpp

Issue 483593002: eliminate code related to SkBitmap::Config (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 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
« no previous file with comments | « src/gpu/SkGr.cpp ('k') | src/images/SkImageDecoder.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 * 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
13 SkBitmap::Config SkColorTypeToBitmapConfig(SkColorType colorType) {
14 switch (colorType) {
15 case kAlpha_8_SkColorType:
16 return SkBitmap::kA8_Config;
17
18 case kARGB_4444_SkColorType:
19 return SkBitmap::kARGB_4444_Config;
20
21 case kRGB_565_SkColorType:
22 return SkBitmap::kRGB_565_Config;
23
24 case kN32_SkColorType:
25 return SkBitmap::kARGB_8888_Config;
26
27 case kIndex_8_SkColorType:
28 return SkBitmap::kIndex8_Config;
29
30 default:
31 // break for unsupported colortypes
32 break;
33 }
34 return SkBitmap::kNo_Config;
35 }
36
37 SkColorType SkBitmapConfigToColorType(SkBitmap::Config config) {
38 static const SkColorType gCT[] = {
39 kUnknown_SkColorType, // kNo_Config
40 kAlpha_8_SkColorType, // kA8_Config
41 kIndex_8_SkColorType, // kIndex8_Config
42 kRGB_565_SkColorType, // kRGB_565_Config
43 kARGB_4444_SkColorType, // kARGB_4444_Config
44 kN32_SkColorType, // kARGB_8888_Config
45 };
46 SkASSERT((unsigned)config < SK_ARRAY_COUNT(gCT));
47 return gCT[config];
48 }
49 #endif
50
51 SkImage* SkNewImageFromBitmap(const SkBitmap& bm, bool canSharePixelRef) { 12 SkImage* SkNewImageFromBitmap(const SkBitmap& bm, bool canSharePixelRef) {
52 const SkImageInfo info = bm.info(); 13 const SkImageInfo info = bm.info();
53 if (kUnknown_SkColorType == info.colorType()) { 14 if (kUnknown_SkColorType == info.colorType()) {
54 return NULL; 15 return NULL;
55 } 16 }
56 17
57 SkImage* image = NULL; 18 SkImage* image = NULL;
58 if (canSharePixelRef || bm.isImmutable()) { 19 if (canSharePixelRef || bm.isImmutable()) {
59 image = SkNewImageFromPixelRef(info, bm.pixelRef(), bm.rowBytes()); 20 image = SkNewImageFromPixelRef(info, bm.pixelRef(), bm.rowBytes());
60 } else { 21 } else {
61 bm.lockPixels(); 22 bm.lockPixels();
62 if (bm.getPixels()) { 23 if (bm.getPixels()) {
63 image = SkImage::NewRasterCopy(info, bm.getPixels(), bm.rowBytes()); 24 image = SkImage::NewRasterCopy(info, bm.getPixels(), bm.rowBytes());
64 } 25 }
65 bm.unlockPixels(); 26 bm.unlockPixels();
66 } 27 }
67 return image; 28 return image;
68 } 29 }
OLDNEW
« no previous file with comments | « src/gpu/SkGr.cpp ('k') | src/images/SkImageDecoder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698