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

Side by Side Diff: ui/gfx/ipc/gfx_param_traits.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ui/gfx/ipc/gfx_param_traits.h" 5 #include "ui/gfx/ipc/gfx_param_traits.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "third_party/skia/include/core/SkBitmap.h" 9 #include "third_party/skia/include/core/SkBitmap.h"
10 #include "ui/gfx/rect.h" 10 #include "ui/gfx/rect.h"
(...skipping 19 matching lines...) Expand all
30 fColorType = info.fColorType; 30 fColorType = info.fColorType;
31 fAlphaType = info.fAlphaType; 31 fAlphaType = info.fAlphaType;
32 fWidth = info.fWidth; 32 fWidth = info.fWidth;
33 fHeight = info.fHeight; 33 fHeight = info.fHeight;
34 } 34 }
35 35
36 // Returns whether |bitmap| successfully initialized. 36 // Returns whether |bitmap| successfully initialized.
37 bool InitSkBitmapFromData(SkBitmap* bitmap, 37 bool InitSkBitmapFromData(SkBitmap* bitmap,
38 const char* pixels, 38 const char* pixels,
39 size_t pixels_size) const { 39 size_t pixels_size) const {
40 if (!bitmap->allocPixels( 40 if (!bitmap->tryAllocPixels(
41 SkImageInfo::Make(fWidth, fHeight, fColorType, fAlphaType))) 41 SkImageInfo::Make(fWidth, fHeight, fColorType, fAlphaType)))
42 return false; 42 return false;
43 if (pixels_size != bitmap->getSize()) 43 if (pixels_size != bitmap->getSize())
44 return false; 44 return false;
45 memcpy(bitmap->getPixels(), pixels, pixels_size); 45 memcpy(bitmap->getPixels(), pixels, pixels_size);
46 return true; 46 return true;
47 } 47 }
48 }; 48 };
49 49
50 } // namespace 50 } // namespace
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 const SkBitmap_Data* bmp_data = 259 const SkBitmap_Data* bmp_data =
260 reinterpret_cast<const SkBitmap_Data*>(fixed_data); 260 reinterpret_cast<const SkBitmap_Data*>(fixed_data);
261 return bmp_data->InitSkBitmapFromData(r, variable_data, variable_data_size); 261 return bmp_data->InitSkBitmapFromData(r, variable_data, variable_data_size);
262 } 262 }
263 263
264 void ParamTraits<SkBitmap>::Log(const SkBitmap& p, std::string* l) { 264 void ParamTraits<SkBitmap>::Log(const SkBitmap& p, std::string* l) {
265 l->append("<SkBitmap>"); 265 l->append("<SkBitmap>");
266 } 266 }
267 267
268 } // namespace IPC 268 } // namespace IPC
OLDNEW
« cc/resources/bitmap_content_layer_updater.cc ('K') | « skia/ext/skia_utils_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698