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 "base/android/jni_string.h" | 7 #include "base/android/jni_string.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 SkBitmap Clipboard::ReadImage(ClipboardType type) const { | 299 SkBitmap Clipboard::ReadImage(ClipboardType type) const { |
300 DCHECK(CalledOnValidThread()); | 300 DCHECK(CalledOnValidThread()); |
301 DCHECK_EQ(type, CLIPBOARD_TYPE_COPY_PASTE); | 301 DCHECK_EQ(type, CLIPBOARD_TYPE_COPY_PASTE); |
302 std::string input = g_map.Get().Get(kBitmapFormat); | 302 std::string input = g_map.Get().Get(kBitmapFormat); |
303 | 303 |
304 SkBitmap bmp; | 304 SkBitmap bmp; |
305 if (!input.empty()) { | 305 if (!input.empty()) { |
306 DCHECK_LE(sizeof(gfx::Size), input.size()); | 306 DCHECK_LE(sizeof(gfx::Size), input.size()); |
307 const gfx::Size* size = reinterpret_cast<const gfx::Size*>(input.data()); | 307 const gfx::Size* size = reinterpret_cast<const gfx::Size*>(input.data()); |
308 | 308 |
309 bmp.setConfig(SkBitmap::kARGB_8888_Config, size->width(), size->height()); | 309 bmp.allocN32Pixels(size->width(), size->height()); |
310 bmp.allocPixels(); | |
311 | 310 |
312 DCHECK_EQ(sizeof(gfx::Size) + bmp.getSize(), input.size()); | 311 DCHECK_EQ(sizeof(gfx::Size) + bmp.getSize(), input.size()); |
313 | 312 |
314 memcpy(bmp.getPixels(), input.data() + sizeof(gfx::Size), bmp.getSize()); | 313 memcpy(bmp.getPixels(), input.data() + sizeof(gfx::Size), bmp.getSize()); |
315 } | 314 } |
316 return bmp; | 315 return bmp; |
317 } | 316 } |
318 | 317 |
319 void Clipboard::ReadCustomData(ClipboardType clipboard_type, | 318 void Clipboard::ReadCustomData(ClipboardType clipboard_type, |
320 const base::string16& type, | 319 const base::string16& type, |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 const char* data_data, size_t data_len) { | 433 const char* data_data, size_t data_len) { |
435 g_map.Get().Set(format.data(), std::string(data_data, data_len)); | 434 g_map.Get().Set(format.data(), std::string(data_data, data_len)); |
436 } | 435 } |
437 | 436 |
438 // See clipboard_android_initialization.h for more information. | 437 // See clipboard_android_initialization.h for more information. |
439 bool RegisterClipboardAndroid(JNIEnv* env) { | 438 bool RegisterClipboardAndroid(JNIEnv* env) { |
440 return RegisterNativesImpl(env); | 439 return RegisterNativesImpl(env); |
441 } | 440 } |
442 | 441 |
443 } // namespace ui | 442 } // namespace ui |
OLD | NEW |