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 /content | |
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 'content')
-rw-r--r-- | content/browser/renderer_host/DEPS | 9 | ||||
-rw-r--r-- | content/browser/renderer_host/clipboard_message_filter.cc | 24 |
2 files changed, 28 insertions, 5 deletions
diff --git a/content/browser/renderer_host/DEPS b/content/browser/renderer_host/DEPS index 8e154f7..0a9e14a 100644 --- a/content/browser/renderer_host/DEPS +++ b/content/browser/renderer_host/DEPS @@ -1,4 +1,5 @@ -include_rules = [
- "+content/renderer", # For single-process mode.
- "+chrome/browser/extensions", # temporarily, for BrowserRenderProcessHost
-]
+include_rules = [ + "+content/renderer", # For single-process mode. + "+third_party/zlib", + "+chrome/browser/extensions", # temporarily, for BrowserRenderProcessHost +] diff --git a/content/browser/renderer_host/clipboard_message_filter.cc b/content/browser/renderer_host/clipboard_message_filter.cc index 7a68e08..1b09839 100644 --- a/content/browser/renderer_host/clipboard_message_filter.cc +++ b/content/browser/renderer_host/clipboard_message_filter.cc @@ -4,11 +4,16 @@ #include "content/browser/renderer_host/clipboard_message_filter.h" +#include "base/stl_util-inl.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/clipboard_dispatcher.h" #include "content/common/clipboard_messages.h" #include "googleurl/src/gurl.h" #include "ipc/ipc_message_macros.h" +#include "third_party/skia/include/core/SkBitmap.h" +#include "third_party/zlib/zlib.h" +#include "ui/gfx/codec/png_codec.h" +#include "ui/gfx/size.h" namespace { @@ -140,7 +145,24 @@ void ClipboardMessageFilter::OnReadHTML( void ClipboardMessageFilter::OnReadImage( ui::Clipboard::Buffer buffer, std::string* data) { - GetClipboard()->ReadImage(buffer, data); + SkBitmap bitmap = GetClipboard()->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()); + } } void ClipboardMessageFilter::OnReadAvailableTypes( |