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

Side by Side Diff: chrome/browser/ui/app_list/fast_show_pickler.cc

Issue 545513002: tryAllocPixels returns bool, allocPixels requires success (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
OLDNEW
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.h" 8 #include "ui/app_list/app_list_item.h"
9 #include "ui/gfx/image/image_skia_rep.h" 9 #include "ui/gfx/image/image_skia_rep.h"
10 10
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 125
126 int size = 0; 126 int size = 0;
127 if (!it->ReadInt(&size)) 127 if (!it->ReadInt(&size))
128 return false; 128 return false;
129 129
130 const char* pixels = NULL; 130 const char* pixels = NULL;
131 if (!it->ReadBytes(&pixels, size)) 131 if (!it->ReadBytes(&pixels, size))
132 return false; 132 return false;
133 133
134 SkBitmap bitmap; 134 SkBitmap bitmap;
135 if (!bitmap.allocPixels(SkImageInfo::Make( 135 if (!bitmap.tryAllocPixels(SkImageInfo::Make(
136 width, height, color_type, kPremul_SkAlphaType))) 136 width, height, color_type, kPremul_SkAlphaType)))
137 return false; 137 return false;
138 138
139 memcpy(bitmap.getPixels(), pixels, bitmap.getSize()); 139 memcpy(bitmap.getPixels(), pixels, bitmap.getSize());
140 result.AddRepresentation(gfx::ImageSkiaRep(bitmap, scale)); 140 result.AddRepresentation(gfx::ImageSkiaRep(bitmap, scale));
141 } 141 }
142 142
143 *out = result; 143 *out = result;
144 return true; 144 return true;
145 } 145 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 for (int i = 0; i < app_count; ++i) { 236 for (int i = 0; i < app_count; ++i) {
237 scoped_ptr<AppListItem> item(UnpickleAppListItem(&it).Pass()); 237 scoped_ptr<AppListItem> item(UnpickleAppListItem(&it).Pass());
238 if (!item) 238 if (!item)
239 return scoped_ptr<AppListModel>(); 239 return scoped_ptr<AppListModel>();
240 std::string folder_id = item->folder_id(); 240 std::string folder_id = item->folder_id();
241 model->AddItemToFolder(item.Pass(), folder_id); 241 model->AddItemToFolder(item.Pass(), folder_id);
242 } 242 }
243 243
244 return model.Pass(); 244 return model.Pass();
245 } 245 }
OLDNEW
« no previous file with comments | « chrome/browser/themes/browser_theme_pack.cc ('k') | chrome/browser/ui/cocoa/table_row_nsimage_cache_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698