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

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

Issue 159653004: SkBitmap now really stores SkImageInfo -- config is just a ruse (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 10 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 | « src/image/SkImagePriv.h ('k') | src/images/SkDecodingImageGenerator.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"
(...skipping 19 matching lines...) Expand all
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 bool SkBitmapConfigToColorType(SkBitmap::Config config, SkColorType* ctOut) { 40 SkColorType SkBitmapConfigToColorType(SkBitmap::Config config) {
41 SkColorType ct; 41 static const SkColorType gCT[] = {
42 switch (config) { 42 kUnknown_SkColorType, // kNo_Config
43 case SkBitmap::kA8_Config: 43 kAlpha_8_SkColorType, // kA8_Config
44 ct = kAlpha_8_SkColorType; 44 kIndex_8_SkColorType, // kIndex8_Config
45 break; 45 kRGB_565_SkColorType, // kRGB_565_Config
46 case SkBitmap::kIndex8_Config: 46 kARGB_4444_SkColorType, // kARGB_4444_Config
47 ct = kIndex_8_SkColorType; 47 kPMColor_SkColorType, // kARGB_8888_Config
48 break; 48 };
49 case SkBitmap::kRGB_565_Config: 49 SkASSERT((unsigned)config < SK_ARRAY_COUNT(gCT));
50 ct = kRGB_565_SkColorType; 50 return gCT[config];
51 break;
52 case SkBitmap::kARGB_4444_Config:
53 ct = kARGB_4444_SkColorType;
54 break;
55 case SkBitmap::kARGB_8888_Config:
56 ct = kPMColor_SkColorType;
57 break;
58 case SkBitmap::kNo_Config:
59 default:
60 return false;
61 }
62 if (ctOut) {
63 *ctOut = ct;
64 }
65 return true;
66 } 51 }
67 52
68
69 SkImage* SkNewImageFromBitmap(const SkBitmap& bm, bool canSharePixelRef) { 53 SkImage* SkNewImageFromBitmap(const SkBitmap& bm, bool canSharePixelRef) {
70 SkImageInfo info; 54 SkImageInfo info;
71 if (!bm.asImageInfo(&info)) { 55 if (!bm.asImageInfo(&info)) {
72 return NULL; 56 return NULL;
73 } 57 }
74 58
75 SkImage* image = NULL; 59 SkImage* image = NULL;
76 if (canSharePixelRef || bm.isImmutable()) { 60 if (canSharePixelRef || bm.isImmutable()) {
77 image = SkNewImageFromPixelRef(info, bm.pixelRef(), bm.rowBytes()); 61 image = SkNewImageFromPixelRef(info, bm.pixelRef(), bm.rowBytes());
78 } else { 62 } else {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 canvas->save(); 118 canvas->save();
135 } 119 }
136 canvas->concat(matrix); 120 canvas->concat(matrix);
137 if (!paint || !needs_layer(*paint)) { 121 if (!paint || !needs_layer(*paint)) {
138 canvas->clipRect(tmpSrc); 122 canvas->clipRect(tmpSrc);
139 } 123 }
140 124
141 canvas->drawPicture(*picture); 125 canvas->drawPicture(*picture);
142 canvas->restoreToCount(saveCount); 126 canvas->restoreToCount(saveCount);
143 } 127 }
OLDNEW
« no previous file with comments | « src/image/SkImagePriv.h ('k') | src/images/SkDecodingImageGenerator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698