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

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

Issue 147733004: Revert "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 SkColorType SkBitmapConfigToColorType(SkBitmap::Config config) { 40 bool SkBitmapConfigToColorType(SkBitmap::Config config, SkColorType* ctOut) {
41 static const SkColorType gCT[] = { 41 SkColorType ct;
42 kUnknown_SkColorType, // kNo_Config 42 switch (config) {
43 kAlpha_8_SkColorType, // kA8_Config 43 case SkBitmap::kA8_Config:
44 kIndex_8_SkColorType, // kIndex8_Config 44 ct = kAlpha_8_SkColorType;
45 kRGB_565_SkColorType, // kRGB_565_Config 45 break;
46 kARGB_4444_SkColorType, // kARGB_4444_Config 46 case SkBitmap::kIndex8_Config:
47 kPMColor_SkColorType, // kARGB_8888_Config 47 ct = kIndex_8_SkColorType;
48 }; 48 break;
49 SkASSERT((unsigned)config < SK_ARRAY_COUNT(gCT)); 49 case SkBitmap::kRGB_565_Config:
50 return gCT[config]; 50 ct = kRGB_565_SkColorType;
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;
51 } 66 }
52 67
68
53 SkImage* SkNewImageFromBitmap(const SkBitmap& bm, bool canSharePixelRef) { 69 SkImage* SkNewImageFromBitmap(const SkBitmap& bm, bool canSharePixelRef) {
54 SkImageInfo info; 70 SkImageInfo info;
55 if (!bm.asImageInfo(&info)) { 71 if (!bm.asImageInfo(&info)) {
56 return NULL; 72 return NULL;
57 } 73 }
58 74
59 SkImage* image = NULL; 75 SkImage* image = NULL;
60 if (canSharePixelRef || bm.isImmutable()) { 76 if (canSharePixelRef || bm.isImmutable()) {
61 image = SkNewImageFromPixelRef(info, bm.pixelRef(), bm.rowBytes()); 77 image = SkNewImageFromPixelRef(info, bm.pixelRef(), bm.rowBytes());
62 } else { 78 } else {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 canvas->save(); 134 canvas->save();
119 } 135 }
120 canvas->concat(matrix); 136 canvas->concat(matrix);
121 if (!paint || !needs_layer(*paint)) { 137 if (!paint || !needs_layer(*paint)) {
122 canvas->clipRect(tmpSrc); 138 canvas->clipRect(tmpSrc);
123 } 139 }
124 140
125 canvas->drawPicture(*picture); 141 canvas->drawPicture(*picture);
126 canvas->restoreToCount(saveCount); 142 canvas->restoreToCount(saveCount);
127 } 143 }
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