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

Side by Side Diff: ui/base/clipboard/clipboard.cc

Issue 361643002: setConfig is deprecated, use setInfo or allocPixels instead (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: don't call allocPixels+rowbytes yet (skia bug) 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 | « ui/app_list/test/app_list_test_model.cc ('k') | ui/base/clipboard/clipboard_android.cc » ('j') | 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/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
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*>(&params[1].front()); 156 reinterpret_cast<const gfx::Size*>(&params[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
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
OLDNEW
« no previous file with comments | « ui/app_list/test/app_list_test_model.cc ('k') | ui/base/clipboard/clipboard_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698