OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/app_list/fast_show_pickler.h" | 5 #include "chrome/browser/ui/app_list/fast_show_pickler.h" |
6 | 6 |
7 #include "third_party/skia/include/core/SkBitmap.h" | 7 #include "third_party/skia/include/core/SkBitmap.h" |
8 #include "ui/app_list/app_list_item_model.h" | 8 #include "ui/app_list/app_list_item_model.h" |
9 #include "ui/gfx/image/image_skia_rep.h" | 9 #include "ui/gfx/image/image_skia_rep.h" |
10 | 10 |
11 namespace { | 11 namespace { |
12 | 12 |
13 using app_list::AppListItemModel; | 13 using app_list::AppListItemModel; |
14 using app_list::AppListModel; | 14 using app_list::AppListModel; |
15 | 15 |
16 // These have the same meaning as SkBitmap::Config. Reproduced here to insure | 16 // These have the same meaning as SkBitmap::Config. Reproduced here to insure |
17 // against their value changing in Skia. If the order of these changes kVersion | 17 // against their value changing in Skia. If the order of these changes kVersion |
18 // should be incremented. | 18 // should be incremented. |
19 enum ImageFormat { | 19 enum ImageFormat { |
20 NONE, | 20 NONE, |
21 A1, | 21 // A1, // kA1_Config is DEPRECATED |
danakj
2013/11/21 00:18:12
Same here, this should be removed rather than left
| |
22 A8, | 22 A8, |
23 INDEX_8, | 23 INDEX_8, |
24 RGB_565, | 24 RGB_565, |
25 ARGB_4444, | 25 ARGB_4444, |
26 ARGB_8888, | 26 ARGB_8888, |
27 }; | 27 }; |
28 | 28 |
29 bool FormatToConfig(ImageFormat format, SkBitmap::Config* out) { | 29 bool FormatToConfig(ImageFormat format, SkBitmap::Config* out) { |
30 switch (format) { | 30 switch (format) { |
31 case NONE: | 31 case NONE: |
32 *out = SkBitmap::kNo_Config; | 32 *out = SkBitmap::kNo_Config; |
33 break; | 33 break; |
34 case A1: | |
35 *out = SkBitmap::kA1_Config; | |
36 break; | |
37 case A8: | 34 case A8: |
38 *out = SkBitmap::kA8_Config; | 35 *out = SkBitmap::kA8_Config; |
39 break; | 36 break; |
40 case INDEX_8: | 37 case INDEX_8: |
41 *out = SkBitmap::kIndex8_Config; | 38 *out = SkBitmap::kIndex8_Config; |
42 break; | 39 break; |
43 case RGB_565: | 40 case RGB_565: |
44 *out = SkBitmap::kRGB_565_Config; | 41 *out = SkBitmap::kRGB_565_Config; |
45 break; | 42 break; |
46 case ARGB_4444: | 43 case ARGB_4444: |
47 *out = SkBitmap::kARGB_4444_Config; | 44 *out = SkBitmap::kARGB_4444_Config; |
48 break; | 45 break; |
49 case ARGB_8888: | 46 case ARGB_8888: |
50 *out = SkBitmap::kARGB_8888_Config; | 47 *out = SkBitmap::kARGB_8888_Config; |
51 break; | 48 break; |
52 default: return false; | 49 default: return false; |
53 } | 50 } |
54 return true; | 51 return true; |
55 } | 52 } |
56 | 53 |
57 bool ConfigToFormat(SkBitmap::Config config, ImageFormat* out) { | 54 bool ConfigToFormat(SkBitmap::Config config, ImageFormat* out) { |
58 switch (config) { | 55 switch (config) { |
59 case SkBitmap::kNo_Config: | 56 case SkBitmap::kNo_Config: |
60 *out = NONE; | 57 *out = NONE; |
61 break; | 58 break; |
62 case SkBitmap::kA1_Config: | |
63 *out = A1; | |
64 break; | |
65 case SkBitmap::kA8_Config: | 59 case SkBitmap::kA8_Config: |
66 *out = A8; | 60 *out = A8; |
67 break; | 61 break; |
68 case SkBitmap::kIndex8_Config: | 62 case SkBitmap::kIndex8_Config: |
69 *out = INDEX_8; | 63 *out = INDEX_8; |
70 break; | 64 break; |
71 case SkBitmap::kRGB_565_Config: | 65 case SkBitmap::kRGB_565_Config: |
72 *out = RGB_565; | 66 *out = RGB_565; |
73 break; | 67 break; |
74 case SkBitmap::kARGB_4444_Config: | 68 case SkBitmap::kARGB_4444_Config: |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
191 | 185 |
192 void CopyOverItem(AppListItemModel* src_item, AppListItemModel* dest_item) { | 186 void CopyOverItem(AppListItemModel* src_item, AppListItemModel* dest_item) { |
193 dest_item->SetTitleAndFullName(src_item->title(), src_item->full_name()); | 187 dest_item->SetTitleAndFullName(src_item->title(), src_item->full_name()); |
194 dest_item->SetIcon(src_item->icon(), src_item->has_shadow()); | 188 dest_item->SetIcon(src_item->icon(), src_item->has_shadow()); |
195 } | 189 } |
196 | 190 |
197 } // namespace | 191 } // namespace |
198 | 192 |
199 // The version of the pickle format defined here. This needs to be incremented | 193 // The version of the pickle format defined here. This needs to be incremented |
200 // whenever this format is changed so new clients can invalidate old versions. | 194 // whenever this format is changed so new clients can invalidate old versions. |
201 const int FastShowPickler::kVersion = 1; | 195 const int FastShowPickler::kVersion = 2; |
202 | 196 |
203 scoped_ptr<Pickle> FastShowPickler::PickleAppListModelForFastShow( | 197 scoped_ptr<Pickle> FastShowPickler::PickleAppListModelForFastShow( |
204 AppListModel* model) { | 198 AppListModel* model) { |
205 scoped_ptr<Pickle> result(new Pickle); | 199 scoped_ptr<Pickle> result(new Pickle); |
206 if (!result->WriteInt(kVersion)) | 200 if (!result->WriteInt(kVersion)) |
207 return scoped_ptr<Pickle>(); | 201 return scoped_ptr<Pickle>(); |
208 if (!result->WriteBool(model->signed_in())) | 202 if (!result->WriteBool(model->signed_in())) |
209 return scoped_ptr<Pickle>(); | 203 return scoped_ptr<Pickle>(); |
210 if (!result->WriteInt((int) model->item_list()->item_count())) | 204 if (!result->WriteInt((int) model->item_list()->item_count())) |
211 return scoped_ptr<Pickle>(); | 205 return scoped_ptr<Pickle>(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
246 model->SetSignedIn(signed_in); | 240 model->SetSignedIn(signed_in); |
247 for (int i = 0; i < app_count; ++i) { | 241 for (int i = 0; i < app_count; ++i) { |
248 scoped_ptr<AppListItemModel> item(UnpickleAppListItemModel(&it).Pass()); | 242 scoped_ptr<AppListItemModel> item(UnpickleAppListItemModel(&it).Pass()); |
249 if (!item) | 243 if (!item) |
250 return scoped_ptr<AppListModel>(); | 244 return scoped_ptr<AppListModel>(); |
251 model->item_list()->AddItem(item.release()); | 245 model->item_list()->AddItem(item.release()); |
252 } | 246 } |
253 | 247 |
254 return model.Pass(); | 248 return model.Pass(); |
255 } | 249 } |
OLD | NEW |