diff options
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, |