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

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

Issue 93703004: Change SkDecodingImageGenerator API (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebased Created 6 years, 11 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.h » ('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 SkImageInfo& info) { 12 SkBitmap::Config SkColorTypeToBitmapConfig(SkColorType colorType) {
13 switch (info.fColorType) { 13 switch (colorType) {
14 case kAlpha_8_SkColorType: 14 case kAlpha_8_SkColorType:
15 return SkBitmap::kA8_Config; 15 return SkBitmap::kA8_Config;
16 16
17 case kARGB_4444_SkColorType: 17 case kARGB_4444_SkColorType:
18 return SkBitmap::kARGB_4444_Config; 18 return SkBitmap::kARGB_4444_Config;
19 19
20 case kRGB_565_SkColorType: 20 case kRGB_565_SkColorType:
21 return SkBitmap::kRGB_565_Config; 21 return SkBitmap::kRGB_565_Config;
22 22
23 case kPMColor_SkColorType: 23 case kPMColor_SkColorType:
24 return SkBitmap::kARGB_8888_Config; 24 return SkBitmap::kARGB_8888_Config;
25 25
26 case kIndex_8_SkColorType: 26 case kIndex_8_SkColorType:
27 return SkBitmap::kIndex8_Config; 27 return SkBitmap::kIndex8_Config;
28 28
29 default: 29 default:
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) {
37 return SkColorTypeToBitmapConfig(info.fColorType);
38 }
39
40 bool SkBitmapConfigToColorType(SkBitmap::Config config, SkColorType* ctOut) {
41 SkColorType ct;
42 switch (config) {
43 case SkBitmap::kA8_Config:
44 ct = kAlpha_8_SkColorType;
45 break;
46 case SkBitmap::kIndex8_Config:
47 ct = kIndex_8_SkColorType;
48 break;
49 case SkBitmap::kRGB_565_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;
66 }
67
68
36 SkImage* SkNewImageFromBitmap(const SkBitmap& bm, bool canSharePixelRef) { 69 SkImage* SkNewImageFromBitmap(const SkBitmap& bm, bool canSharePixelRef) {
37 SkImageInfo info; 70 SkImageInfo info;
38 if (!bm.asImageInfo(&info)) { 71 if (!bm.asImageInfo(&info)) {
39 return NULL; 72 return NULL;
40 } 73 }
41 74
42 SkImage* image = NULL; 75 SkImage* image = NULL;
43 if (canSharePixelRef || bm.isImmutable()) { 76 if (canSharePixelRef || bm.isImmutable()) {
44 image = SkNewImageFromPixelRef(info, bm.pixelRef(), bm.rowBytes()); 77 image = SkNewImageFromPixelRef(info, bm.pixelRef(), bm.rowBytes());
45 } else { 78 } else {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 canvas->save(); 134 canvas->save();
102 } 135 }
103 canvas->concat(matrix); 136 canvas->concat(matrix);
104 if (!paint || !needs_layer(*paint)) { 137 if (!paint || !needs_layer(*paint)) {
105 canvas->clipRect(tmpSrc); 138 canvas->clipRect(tmpSrc);
106 } 139 }
107 140
108 canvas->drawPicture(*picture); 141 canvas->drawPicture(*picture);
109 canvas->restoreToCount(saveCount); 142 canvas->restoreToCount(saveCount);
110 } 143 }
OLDNEW
« no previous file with comments | « src/image/SkImagePriv.h ('k') | src/images/SkDecodingImageGenerator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698