diff options
author | dcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-19 19:48:35 +0000 |
---|---|---|
committer | dcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-19 19:48:35 +0000 |
commit | fece3a7e17e0cd75ff3fa5a3ab88c41e94f7a923 (patch) | |
tree | 53808985c00baf5d4e4e7204ae7d5af2b6a96564 /webkit/tools | |
parent | 997aaec37d6e6197688b5a6d1541b7ace4c9f38b (diff) | |
download | chromium_src-fece3a7e17e0cd75ff3fa5a3ab88c41e94f7a923.zip chromium_src-fece3a7e17e0cd75ff3fa5a3ab88c41e94f7a923.tar.gz chromium_src-fece3a7e17e0cd75ff3fa5a3ab88c41e94f7a923.tar.bz2 |
Change Clipboard::ReadImage to return a bitmap.
This allows the PNG compression to be offloaded to another thread as
appropriate.
BUG=75237
TEST=Local testing.
Review URL: http://codereview.chromium.org/6835036
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@82142 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/tools')
-rw-r--r-- | webkit/tools/test_shell/DEPS | 1 | ||||
-rw-r--r-- | webkit/tools/test_shell/simple_clipboard_impl.cc | 23 |
2 files changed, 23 insertions, 1 deletions
diff --git a/webkit/tools/test_shell/DEPS b/webkit/tools/test_shell/DEPS index cdb5eeb..cce3c4b 100644 --- a/webkit/tools/test_shell/DEPS +++ b/webkit/tools/test_shell/DEPS @@ -1,5 +1,6 @@ include_rules = [ "+mac", "+app", + "+third_party/zlib", "+ui", ] diff --git a/webkit/tools/test_shell/simple_clipboard_impl.cc b/webkit/tools/test_shell/simple_clipboard_impl.cc index cd12ded..2bb35df 100644 --- a/webkit/tools/test_shell/simple_clipboard_impl.cc +++ b/webkit/tools/test_shell/simple_clipboard_impl.cc @@ -7,10 +7,14 @@ #include <string> #include "base/lazy_instance.h" +#include "base/stl_util-inl.h" #include "base/string16.h" #include "googleurl/src/gurl.h" #include "third_party/skia/include/core/SkBitmap.h" +#include "third_party/zlib/zlib.h" #include "ui/base/clipboard/clipboard.h" +#include "ui/gfx/codec/png_codec.h" +#include "ui/gfx/size.h" #include "webkit/glue/scoped_clipboard_writer_glue.h" // Clipboard glue @@ -60,7 +64,24 @@ void ClipboardReadHTML(ui::Clipboard::Buffer buffer, string16* markup, } void ClipboardReadImage(ui::Clipboard::Buffer buffer, std::string* data) { - ClipboardGetClipboard()->ReadImage(buffer, data); + SkBitmap bitmap = ClipboardGetClipboard()->ReadImage(buffer); + if (bitmap.isNull()) + return; + + std::vector<unsigned char> png_data; + SkAutoLockPixels lock(bitmap); + if (gfx::PNGCodec::EncodeWithCompressionLevel( + static_cast<const unsigned char*>(bitmap.getPixels()), + gfx::PNGCodec::FORMAT_BGRA, + gfx::Size(bitmap.width(), bitmap.height()), + bitmap.rowBytes(), + false, + std::vector<gfx::PNGCodec::Comment>(), + Z_BEST_SPEED, + &png_data)) { + data->assign(reinterpret_cast<char*>(vector_as_array(&png_data)), + png_data.size()); + } } bool ClipboardReadData(ui::Clipboard::Buffer buffer, const string16& type, |