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

Side by Side Diff: ui/gfx/ipc/gfx_param_traits.cc

Issue 354483006: gfx: ipc: Remove deprecated calls from SkBitmap IPC traits (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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"
11 #include "ui/gfx/rect_f.h" 11 #include "ui/gfx/rect_f.h"
12 12
13 namespace { 13 namespace {
14 14
15 struct SkBitmap_Data { 15 struct SkBitmap_Data {
16 // The configuration for the bitmap (bits per pixel, etc). 16 // The color type for the bitmap (bits per pixel, etc).
17 SkBitmap::Config fConfig; 17 SkColorType fColorType;
18
19 // The alpha type for the bitmap (opaque, premul, unpremul).
20 SkAlphaType fAlphaType;
18 21
19 // The width of the bitmap in pixels. 22 // The width of the bitmap in pixels.
20 uint32 fWidth; 23 uint32 fWidth;
21 24
22 // The height of the bitmap in pixels. 25 // The height of the bitmap in pixels.
23 uint32 fHeight; 26 uint32 fHeight;
24 27
25 void InitSkBitmapDataForTransfer(const SkBitmap& bitmap) { 28 void InitSkBitmapDataForTransfer(const SkBitmap& bitmap) {
26 fConfig = bitmap.config(); 29 const SkImageInfo& info = bitmap.info();
27 fWidth = bitmap.width(); 30 fColorType = info.fColorType;
28 fHeight = bitmap.height(); 31 fAlphaType = info.fAlphaType;
32 fWidth = info.fWidth;
33 fHeight = info.fHeight;
29 } 34 }
30 35
31 // Returns whether |bitmap| successfully initialized. 36 // Returns whether |bitmap| successfully initialized.
32 bool InitSkBitmapFromData(SkBitmap* bitmap, const char* pixels, 37 bool InitSkBitmapFromData(SkBitmap* bitmap,
33 size_t total_pixels) const { 38 const char* pixels,
34 if (total_pixels) { 39 size_t pixels_size) const {
35 bitmap->setConfig(fConfig, fWidth, fHeight, 0); 40 if (!bitmap->allocPixels(
36 if (!bitmap->allocPixels()) 41 SkImageInfo::Make(fWidth, fHeight, fColorType, fAlphaType)))
37 return false; 42 return false;
38 if (total_pixels != bitmap->getSize()) 43 if (pixels_size != bitmap->getSize())
39 return false; 44 return false;
40 memcpy(bitmap->getPixels(), pixels, total_pixels); 45 memcpy(bitmap->getPixels(), pixels, pixels_size);
41 }
42 return true; 46 return true;
43 } 47 }
44 }; 48 };
45 49
46 } // namespace 50 } // namespace
47 51
48 namespace IPC { 52 namespace IPC {
49 53
50 void ParamTraits<gfx::Point>::Write(Message* m, const gfx::Point& p) { 54 void ParamTraits<gfx::Point>::Write(Message* m, const gfx::Point& p) {
51 m->WriteInt(p.x()); 55 m->WriteInt(p.x());
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 const SkBitmap_Data* bmp_data = 259 const SkBitmap_Data* bmp_data =
256 reinterpret_cast<const SkBitmap_Data*>(fixed_data); 260 reinterpret_cast<const SkBitmap_Data*>(fixed_data);
257 return bmp_data->InitSkBitmapFromData(r, variable_data, variable_data_size); 261 return bmp_data->InitSkBitmapFromData(r, variable_data, variable_data_size);
258 } 262 }
259 263
260 void ParamTraits<SkBitmap>::Log(const SkBitmap& p, std::string* l) { 264 void ParamTraits<SkBitmap>::Log(const SkBitmap& p, std::string* l) {
261 l->append("<SkBitmap>"); 265 l->append("<SkBitmap>");
262 } 266 }
263 267
264 } // namespace IPC 268 } // namespace IPC
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698