| OLD | NEW |
| 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/base/clipboard/clipboard.h" | 5 #include "ui/base/clipboard/clipboard.h" |
| 6 | 6 |
| 7 #include <iterator> | 7 #include <iterator> |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 if (params[0].size() != sizeof(SharedMemory*) || | 149 if (params[0].size() != sizeof(SharedMemory*) || |
| 150 params[1].size() != sizeof(gfx::Size)) { | 150 params[1].size() != sizeof(gfx::Size)) { |
| 151 return; | 151 return; |
| 152 } | 152 } |
| 153 | 153 |
| 154 SkBitmap bitmap; | 154 SkBitmap bitmap; |
| 155 const gfx::Size* unvalidated_size = | 155 const gfx::Size* unvalidated_size = |
| 156 reinterpret_cast<const gfx::Size*>(¶ms[1].front()); | 156 reinterpret_cast<const gfx::Size*>(¶ms[1].front()); |
| 157 // Let Skia do some sanity checking for us (no negative widths/heights, no | 157 // Let Skia do some sanity checking for us (no negative widths/heights, no |
| 158 // overflows while calculating bytes per row, etc). | 158 // overflows while calculating bytes per row, etc). |
| 159 if (!bitmap.setConfig(SkBitmap::kARGB_8888_Config, | 159 if (!bitmap.setInfo(SkImageInfo::MakeN32Premul( |
| 160 unvalidated_size->width(), | 160 unvalidated_size->width(), unvalidated_size->height()))) { |
| 161 unvalidated_size->height())) { | |
| 162 return; | 161 return; |
| 163 } | 162 } |
| 164 // Make sure the size is representable as a signed 32-bit int, so | 163 // Make sure the size is representable as a signed 32-bit int, so |
| 165 // SkBitmap::getSize() won't be truncated. | 164 // SkBitmap::getSize() won't be truncated. |
| 166 if (!sk_64_isS32(bitmap.computeSize64())) | 165 if (!sk_64_isS32(bitmap.computeSize64())) |
| 167 return; | 166 return; |
| 168 | 167 |
| 169 // It's OK to cast away constness here since we map the handle as | 168 // It's OK to cast away constness here since we map the handle as |
| 170 // read-only. | 169 // read-only. |
| 171 const char* raw_bitmap_data_const = | 170 const char* raw_bitmap_data_const = |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 iter->second[0].clear(); | 224 iter->second[0].clear(); |
| 226 for (size_t i = 0; i < sizeof(SharedMemory*); ++i) | 225 for (size_t i = 0; i < sizeof(SharedMemory*); ++i) |
| 227 iter->second[0].push_back(reinterpret_cast<char*>(&bitmap)[i]); | 226 iter->second[0].push_back(reinterpret_cast<char*>(&bitmap)[i]); |
| 228 has_shared_bitmap = true; | 227 has_shared_bitmap = true; |
| 229 } | 228 } |
| 230 } | 229 } |
| 231 return true; | 230 return true; |
| 232 } | 231 } |
| 233 | 232 |
| 234 } // namespace ui | 233 } // namespace ui |
| OLD | NEW |