summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authordcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-20 01:54:04 +0000
committerdcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-20 01:54:04 +0000
commitd2a2a409f713ce9f28b8d40b3ed2ef9140057a38 (patch)
tree4e0f6cf3097fd7dd09e726fac7bd791409fd493b /ui
parent7cb5029c99a5b3164e7b190538c245e0617b4fd9 (diff)
downloadchromium_src-d2a2a409f713ce9f28b8d40b3ed2ef9140057a38.zip
chromium_src-d2a2a409f713ce9f28b8d40b3ed2ef9140057a38.tar.gz
chromium_src-d2a2a409f713ce9f28b8d40b3ed2ef9140057a38.tar.bz2
Implement Clipboard::ReadImage on Linux.
I split the IPC up into two parts on Linux--one that reads the image on the UI thread, and a second part that encodes the image on the file thread before replying. I've also switched it to send the data over shared memory instead of passing a (potentially) huge blob of data over IPC. BUG=75237 TEST=Local testing. Review URL: http://codereview.chromium.org/6871001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@82212 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/base/clipboard/clipboard_linux.cc19
1 files changed, 16 insertions, 3 deletions
diff --git a/ui/base/clipboard/clipboard_linux.cc b/ui/base/clipboard/clipboard_linux.cc
index 3cbe7d8..883dcf5 100644
--- a/ui/base/clipboard/clipboard_linux.cc
+++ b/ui/base/clipboard/clipboard_linux.cc
@@ -15,6 +15,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/utf_string_conversions.h"
#include "third_party/skia/include/core/SkBitmap.h"
+#include "ui/gfx/canvas_skia.h"
#include "ui/gfx/gtk_util.h"
#include "ui/gfx/size.h"
@@ -304,6 +305,8 @@ void Clipboard::ReadAvailableTypes(Clipboard::Buffer buffer,
types->push_back(UTF8ToUTF16(kMimeTypeText));
if (IsFormatAvailable(GetHtmlFormatType(), buffer))
types->push_back(UTF8ToUTF16(kMimeTypeHTML));
+ if (IsFormatAvailable(GetBitmapFormatType(), buffer))
+ types->push_back(UTF8ToUTF16(kMimeTypePNG));
*contains_filenames = false;
}
@@ -377,9 +380,19 @@ void Clipboard::ReadHTML(Clipboard::Buffer buffer, string16* markup,
}
SkBitmap Clipboard::ReadImage(Buffer buffer) const {
- // TODO(dcheng): implement this.
- NOTIMPLEMENTED();
- return SkBitmap();
+ ScopedGObject<GdkPixbuf>::Type pixbuf(
+ gtk_clipboard_wait_for_image(clipboard_));
+ if (!pixbuf.get())
+ return SkBitmap();
+
+ gfx::CanvasSkia canvas(gdk_pixbuf_get_width(pixbuf.get()),
+ gdk_pixbuf_get_height(pixbuf.get()),
+ false);
+ cairo_t* context = canvas.beginPlatformPaint();
+ gdk_cairo_set_source_pixbuf(context, pixbuf.get(), 0.0, 0.0);
+ cairo_paint(context);
+ canvas.endPlatformPaint();
+ return canvas.ExtractBitmap();
}
void Clipboard::ReadBookmark(string16* title, std::string* url) const {