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

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

Issue 68853003: add colortable enum to SkImage to ease interop between it and SkBitmap::Config (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « include/core/SkImage.h ('k') | no next file » | 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 SkBitmap::Config SkImageInfoToBitmapConfig(const SkImageInfo& info) { 12 SkBitmap::Config SkImageInfoToBitmapConfig(const SkImageInfo& info) {
13 switch (info.fColorType) { 13 switch (info.fColorType) {
14 case kAlpha_8_SkColorType: 14 case kAlpha_8_SkColorType:
15 return SkBitmap::kA8_Config; 15 return SkBitmap::kA8_Config;
16 16
17 case kRGB_565_SkColorType: 17 case kRGB_565_SkColorType:
18 return SkBitmap::kRGB_565_Config; 18 return SkBitmap::kRGB_565_Config;
19 19
20 case kPMColor_SkColorType: 20 case kPMColor_SkColorType:
21 return SkBitmap::kARGB_8888_Config; 21 return SkBitmap::kARGB_8888_Config;
22 22
23 case kIndex8_SkColorType:
24 return SkBitmap::kIndex8_Config;
25
23 default: 26 default:
24 // break for unsupported colortypes 27 // break for unsupported colortypes
25 break; 28 break;
26 } 29 }
27 return SkBitmap::kNo_Config; 30 return SkBitmap::kNo_Config;
28 } 31 }
29 32
30 int SkImageBytesPerPixel(SkColorType ct) { 33 int SkImageBytesPerPixel(SkColorType ct) {
31 static const uint8_t gColorTypeBytesPerPixel[] = { 34 static const uint8_t gColorTypeBytesPerPixel[] = {
32 1, // kAlpha_8_SkColorType 35 1, // kAlpha_8_SkColorType
33 2, // kRGB_565_SkColorType 36 2, // kRGB_565_SkColorType
34 4, // kRGBA_8888_SkColorType 37 4, // kRGBA_8888_SkColorType
35 4, // kBGRA_8888_SkColorType 38 4, // kBGRA_8888_SkColorType
36 4, // kPMColor_SkColorType 39 4, // kPMColor_SkColorType
40 1, // kIndex8_SkColorType
37 }; 41 };
38 42
39 SkASSERT((size_t)ct < SK_ARRAY_COUNT(gColorTypeBytesPerPixel)); 43 SkASSERT((size_t)ct < SK_ARRAY_COUNT(gColorTypeBytesPerPixel));
40 return gColorTypeBytesPerPixel[ct]; 44 return gColorTypeBytesPerPixel[ct];
41 } 45 }
42 46
43 bool SkBitmapToImageInfo(const SkBitmap& bm, SkImageInfo* info) { 47 bool SkBitmapToImageInfo(const SkBitmap& bm, SkImageInfo* info) {
44 switch (bm.config()) { 48 switch (bm.config()) {
45 case SkBitmap::kA8_Config: 49 case SkBitmap::kA8_Config:
46 info->fColorType = kAlpha_8_SkColorType; 50 info->fColorType = kAlpha_8_SkColorType;
47 break; 51 break;
48 52
53 case SkBitmap::kIndex8_Config:
54 info->fColorType = kIndex8_SkColorType;
55 break;
56
49 case SkBitmap::kRGB_565_Config: 57 case SkBitmap::kRGB_565_Config:
50 info->fColorType = kRGB_565_SkColorType; 58 info->fColorType = kRGB_565_SkColorType;
51 break; 59 break;
52 60
53 case SkBitmap::kARGB_8888_Config: 61 case SkBitmap::kARGB_8888_Config:
54 info->fColorType = kPMColor_SkColorType; 62 info->fColorType = kPMColor_SkColorType;
55 break; 63 break;
56 64
57 default: 65 default:
58 return false; 66 return false;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 canvas->save(); 141 canvas->save();
134 } 142 }
135 canvas->concat(matrix); 143 canvas->concat(matrix);
136 if (!paint || !needs_layer(*paint)) { 144 if (!paint || !needs_layer(*paint)) {
137 canvas->clipRect(tmpSrc); 145 canvas->clipRect(tmpSrc);
138 } 146 }
139 147
140 canvas->drawPicture(*picture); 148 canvas->drawPicture(*picture);
141 canvas->restoreToCount(saveCount); 149 canvas->restoreToCount(saveCount);
142 } 150 }
OLDNEW
« no previous file with comments | « include/core/SkImage.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698