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

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

Issue 340533002: hide SkBitmap::Config entirely (behind a flag) (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 6 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
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
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 }
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