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

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

Issue 24130009: promote SkImage::AlphaType to SkAlphaType (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « samplecode/SampleFatBits.cpp ('k') | src/image/SkImage_Raster.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 SkBitmap::Config SkImageInfoToBitmapConfig(const SkImage::Info& info, 12 SkBitmap::Config SkImageInfoToBitmapConfig(const SkImage::Info& info,
13 bool* isOpaque) { 13 bool* isOpaque) {
14 switch (info.fColorType) { 14 switch (info.fColorType) {
15 case SkImage::kAlpha_8_ColorType: 15 case SkImage::kAlpha_8_ColorType:
16 switch (info.fAlphaType) { 16 switch (info.fAlphaType) {
17 case SkImage::kIgnore_AlphaType: 17 case kIgnore_SkAlphaType:
18 // makes no sense 18 // makes no sense
19 return SkBitmap::kNo_Config; 19 return SkBitmap::kNo_Config;
20 20
21 case SkImage::kOpaque_AlphaType: 21 case kOpaque_SkAlphaType:
22 *isOpaque = true; 22 *isOpaque = true;
23 return SkBitmap::kA8_Config; 23 return SkBitmap::kA8_Config;
24 24
25 case SkImage::kPremul_AlphaType: 25 case kPremul_SkAlphaType:
26 case SkImage::kUnpremul_AlphaType: 26 case kUnpremul_SkAlphaType:
27 *isOpaque = false; 27 *isOpaque = false;
28 return SkBitmap::kA8_Config; 28 return SkBitmap::kA8_Config;
29 } 29 }
30 break; 30 break;
31 31
32 case SkImage::kRGB_565_ColorType: 32 case SkImage::kRGB_565_ColorType:
33 // we ignore fAlpahType, though some would not make sense 33 // we ignore fAlpahType, though some would not make sense
34 *isOpaque = true; 34 *isOpaque = true;
35 return SkBitmap::kRGB_565_Config; 35 return SkBitmap::kRGB_565_Config;
36 36
37 case SkImage::kRGBA_8888_ColorType:
38 case SkImage::kBGRA_8888_ColorType:
39 // not supported yet
40 return SkBitmap::kNo_Config;
41
42 case SkImage::kPMColor_ColorType: 37 case SkImage::kPMColor_ColorType:
43 switch (info.fAlphaType) { 38 switch (info.fAlphaType) {
44 case SkImage::kIgnore_AlphaType: 39 case kIgnore_SkAlphaType:
45 case SkImage::kUnpremul_AlphaType: 40 case kUnpremul_SkAlphaType:
46 // not supported yet 41 // not supported yet
47 return SkBitmap::kNo_Config; 42 return SkBitmap::kNo_Config;
48 case SkImage::kOpaque_AlphaType: 43 case kOpaque_SkAlphaType:
49 *isOpaque = true; 44 *isOpaque = true;
50 return SkBitmap::kARGB_8888_Config; 45 return SkBitmap::kARGB_8888_Config;
51 case SkImage::kPremul_AlphaType: 46 case kPremul_SkAlphaType:
52 *isOpaque = false; 47 *isOpaque = false;
53 return SkBitmap::kARGB_8888_Config; 48 return SkBitmap::kARGB_8888_Config;
54 } 49 }
55 break; 50 break;
51
52 default:
53 // break for unsupported colortypes
54 break;
56 } 55 }
57 SkDEBUGFAIL("how did we get here");
58 return SkBitmap::kNo_Config; 56 return SkBitmap::kNo_Config;
59 } 57 }
60 58
61 int SkImageBytesPerPixel(SkImage::ColorType ct) { 59 int SkImageBytesPerPixel(SkImage::ColorType ct) {
62 static const uint8_t gColorTypeBytesPerPixel[] = { 60 static const uint8_t gColorTypeBytesPerPixel[] = {
63 1, // kAlpha_8_ColorType 61 1, // kAlpha_8_ColorType
64 2, // kRGB_565_ColorType 62 2, // kRGB_565_ColorType
65 4, // kRGBA_8888_ColorType 63 4, // kRGBA_8888_ColorType
66 4, // kBGRA_8888_ColorType 64 4, // kBGRA_8888_ColorType
67 4, // kPMColor_ColorType 65 4, // kPMColor_ColorType
(...skipping 16 matching lines...) Expand all
84 case SkBitmap::kARGB_8888_Config: 82 case SkBitmap::kARGB_8888_Config:
85 info->fColorType = SkImage::kPMColor_ColorType; 83 info->fColorType = SkImage::kPMColor_ColorType;
86 break; 84 break;
87 85
88 default: 86 default:
89 return false; 87 return false;
90 } 88 }
91 89
92 info->fWidth = bm.width(); 90 info->fWidth = bm.width();
93 info->fHeight = bm.height(); 91 info->fHeight = bm.height();
94 info->fAlphaType = bm.isOpaque() ? SkImage::kOpaque_AlphaType : 92 info->fAlphaType = bm.isOpaque() ? kOpaque_SkAlphaType :
95 SkImage::kPremul_AlphaType; 93 kPremul_SkAlphaType;
96 return true; 94 return true;
97 } 95 }
98 96
99 SkImage* SkNewImageFromBitmap(const SkBitmap& bm, bool canSharePixelRef) { 97 SkImage* SkNewImageFromBitmap(const SkBitmap& bm, bool canSharePixelRef) {
100 SkImage::Info info; 98 SkImage::Info info;
101 if (!SkBitmapToImageInfo(bm, &info)) { 99 if (!SkBitmapToImageInfo(bm, &info)) {
102 return NULL; 100 return NULL;
103 } 101 }
104 102
105 SkImage* image = NULL; 103 SkImage* image = NULL;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 canvas->save(); 162 canvas->save();
165 } 163 }
166 canvas->concat(matrix); 164 canvas->concat(matrix);
167 if (!paint || !needs_layer(*paint)) { 165 if (!paint || !needs_layer(*paint)) {
168 canvas->clipRect(tmpSrc); 166 canvas->clipRect(tmpSrc);
169 } 167 }
170 168
171 canvas->drawPicture(*picture); 169 canvas->drawPicture(*picture);
172 canvas->restoreToCount(saveCount); 170 canvas->restoreToCount(saveCount);
173 } 171 }
OLDNEW
« no previous file with comments | « samplecode/SampleFatBits.cpp ('k') | src/image/SkImage_Raster.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698