| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/common/common_param_traits.h" | 5 #include "chrome/common/common_param_traits.h" |
| 6 | 6 |
| 7 #include "base/gfx/rect.h" | 7 #include "base/gfx/rect.h" |
| 8 #include "googleurl/src/gurl.h" | 8 #include "googleurl/src/gurl.h" |
| 9 #ifndef EXCLUDE_SKIA_DEPENDENCIES | 9 #ifndef EXCLUDE_SKIA_DEPENDENCIES |
| 10 #include "third_party/skia/include/core/SkBitmap.h" | 10 #include "third_party/skia/include/core/SkBitmap.h" |
| 11 #endif | 11 #endif |
| 12 #include "webkit/glue/dom_operations.h" | 12 #include "webkit/glue/dom_operations.h" |
| 13 | 13 |
| 14 namespace IPC { | 14 namespace IPC { |
| 15 | 15 |
| 16 #ifndef EXCLUDE_SKIA_DEPENDENCIES | 16 #ifndef EXCLUDE_SKIA_DEPENDENCIES |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 struct SkBitmap_Data { | 20 struct SkBitmap_Data { |
| 21 // The configuration for the bitmap (bits per pixel, etc). | 21 // The configuration for the bitmap (bits per pixel, etc). |
| 22 SkBitmap::Config fConfig; | 22 SkBitmap::Config fConfig; |
| 23 | 23 |
| 24 // The width of the bitmap in pixels. | 24 // The width of the bitmap in pixels. |
| 25 uint32 fWidth; | 25 uint32 fWidth; |
| 26 | 26 |
| 27 // The height of the bitmap in pixels. | 27 // The height of the bitmap in pixels. |
| 28 uint32 fHeight; | 28 uint32 fHeight; |
| 29 | 29 |
| 30 // The number of bytes between subsequent rows of the bitmap. | |
| 31 uint32 fRowBytes; | |
| 32 | |
| 33 void InitSkBitmapDataForTransfer(const SkBitmap& bitmap) { | 30 void InitSkBitmapDataForTransfer(const SkBitmap& bitmap) { |
| 34 fConfig = bitmap.config(); | 31 fConfig = bitmap.config(); |
| 35 fWidth = bitmap.width(); | 32 fWidth = bitmap.width(); |
| 36 fHeight = bitmap.height(); | 33 fHeight = bitmap.height(); |
| 37 fRowBytes = bitmap.rowBytes(); | |
| 38 } | 34 } |
| 39 | 35 |
| 40 // Returns whether |bitmap| successfully initialized. | 36 // Returns whether |bitmap| successfully initialized. |
| 41 bool InitSkBitmapFromData(SkBitmap* bitmap, const char* pixels, | 37 bool InitSkBitmapFromData(SkBitmap* bitmap, const char* pixels, |
| 42 size_t total_pixels) const { | 38 size_t total_pixels) const { |
| 43 if (total_pixels) { | 39 if (total_pixels) { |
| 44 bitmap->setConfig(fConfig, fWidth, fHeight, fRowBytes); | 40 bitmap->setConfig(fConfig, fWidth, fHeight, 0); |
| 45 if (!bitmap->allocPixels()) | 41 if (!bitmap->allocPixels()) |
| 46 return false; | 42 return false; |
| 47 if (total_pixels > bitmap->getSize()) | 43 if (total_pixels != bitmap->getSize()) |
| 48 return false; | 44 return false; |
| 49 memcpy(bitmap->getPixels(), pixels, total_pixels); | 45 memcpy(bitmap->getPixels(), pixels, total_pixels); |
| 50 } | 46 } |
| 51 return true; | 47 return true; |
| 52 } | 48 } |
| 53 }; | 49 }; |
| 54 | 50 |
| 55 } // namespace | 51 } // namespace |
| 56 | 52 |
| 57 | 53 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 bool ParamTraits<webkit_glue::WebApplicationInfo>::Read( | 194 bool ParamTraits<webkit_glue::WebApplicationInfo>::Read( |
| 199 const Message* m, void** iter, webkit_glue::WebApplicationInfo* r) { | 195 const Message* m, void** iter, webkit_glue::WebApplicationInfo* r) { |
| 200 size_t icon_count; | 196 size_t icon_count; |
| 201 bool result = | 197 bool result = |
| 202 ReadParam(m, iter, &r->title) && | 198 ReadParam(m, iter, &r->title) && |
| 203 ReadParam(m, iter, &r->description) && | 199 ReadParam(m, iter, &r->description) && |
| 204 ReadParam(m, iter, &r->app_url) && | 200 ReadParam(m, iter, &r->app_url) && |
| 205 ReadParam(m, iter, &icon_count); | 201 ReadParam(m, iter, &icon_count); |
| 206 if (!result) | 202 if (!result) |
| 207 return false; | 203 return false; |
| 208 for (size_t i = 0; i < icon_count && result; ++i) { | 204 for (size_t i = 0; i < icon_count; ++i) { |
| 209 param_type::IconInfo icon_info; | 205 param_type::IconInfo icon_info; |
| 210 result = | 206 result = |
| 211 ReadParam(m, iter, &icon_info.url) && | 207 ReadParam(m, iter, &icon_info.url) && |
| 212 ReadParam(m, iter, &icon_info.width) && | 208 ReadParam(m, iter, &icon_info.width) && |
| 213 ReadParam(m, iter, &icon_info.height); | 209 ReadParam(m, iter, &icon_info.height); |
| 210 if (!result) |
| 211 return false; |
| 214 r->icons.push_back(icon_info); | 212 r->icons.push_back(icon_info); |
| 215 } | 213 } |
| 216 return result; | 214 return true; |
| 217 } | 215 } |
| 218 | 216 |
| 219 void ParamTraits<webkit_glue::WebApplicationInfo>::Log( | 217 void ParamTraits<webkit_glue::WebApplicationInfo>::Log( |
| 220 const webkit_glue::WebApplicationInfo& p, std::wstring* l) { | 218 const webkit_glue::WebApplicationInfo& p, std::wstring* l) { |
| 221 l->append(L"<WebApplicationInfo>"); | 219 l->append(L"<WebApplicationInfo>"); |
| 222 } | 220 } |
| 223 | 221 |
| 224 } // namespace IPC | 222 } // namespace IPC |
| 225 | 223 |
| OLD | NEW |