Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(575)

Unified Diff: chrome/renderer/webplugin_delegate_proxy.cc

Issue 159128: linux: add windowless plugin plumbing (Closed)
Patch Set: address review comments Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/plugin/webplugin_proxy.cc ('k') | webkit/glue/plugins/plugin_host.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/webplugin_delegate_proxy.cc
diff --git a/chrome/renderer/webplugin_delegate_proxy.cc b/chrome/renderer/webplugin_delegate_proxy.cc
index 45a98bf5d756cb6fc5c6a43cfec276d63e21c9d6..524b9089faae611c9bec0bc70ee7c4da79b75da4 100644
--- a/chrome/renderer/webplugin_delegate_proxy.cc
+++ b/chrome/renderer/webplugin_delegate_proxy.cc
@@ -476,13 +476,8 @@ bool WebPluginDelegateProxy::CreateBitmap(
const size_t stride = skia::PlatformCanvas::StrideForWidth(width);
const size_t size = stride * height;
#if defined(OS_LINUX)
- static unsigned long max_size = 0;
- if (max_size == 0) {
- std::string contents;
- file_util::ReadFileToString(FilePath("/proc/sys/kernel/shmmax"), &contents);
- max_size = strtoul(contents.c_str(), NULL, 0);
- }
- if (size > max_size)
+ memory->reset(TransportDIB::Create(size, 0));
+ if (!memory->get())
return false;
#endif
#if defined(OS_MACOSX)
@@ -543,7 +538,19 @@ void WebPluginDelegateProxy::Paint(gfx::NativeDrawingContext context,
CGImageCreateWithImageInRect(background_image, offset_rect.ToCGRect()));
CGContextDrawImage(context, rect.ToCGRect(), sub_image);
#else
- NOTIMPLEMENTED();
+ cairo_t *cairo =
+ background_store_canvas_->getTopPlatformDevice().beginPlatformPaint();
+ cairo_save(cairo);
+ double surface_x = plugin_rect_.x();
+ double surface_y = plugin_rect_.y();
+ cairo_user_to_device(context, &surface_x, &surface_y);
+ cairo_set_source_surface(cairo, cairo_get_target(context),
+ -surface_x, -surface_y);
+ cairo_rectangle(cairo, offset_rect.x(), offset_rect.y(),
+ offset_rect.width(), offset_rect.height());
+ cairo_clip(cairo);
+ cairo_paint(cairo);
+ cairo_restore(cairo);
#endif
}
@@ -565,7 +572,15 @@ void WebPluginDelegateProxy::Paint(gfx::NativeDrawingContext context,
CGImageCreateWithImageInRect(backing_image, offset_rect.ToCGRect()));
CGContextDrawImage(context, rect.ToCGRect(), sub_image);
#else
- NOTIMPLEMENTED();
+ cairo_save(context);
+ cairo_t *cairo =
+ backing_store_canvas_->getTopPlatformDevice().beginPlatformPaint();
+ cairo_set_source_surface(context, cairo_get_target(cairo),
+ plugin_rect_.x(), plugin_rect_.y());
+ cairo_rectangle(context, rect.x(), rect.y(), rect.width(), rect.height());
+ cairo_paint(context);
+ cairo_clip(context);
+ cairo_restore(context);
#endif
if (invalidate_pending_) {
@@ -619,11 +634,11 @@ bool WebPluginDelegateProxy::BackgroundChanged(
if (memcmp(hdc_row_start, canvas_row_start, row_byte_size) != 0)
return true;
}
-
+ return false;
#else
NOTIMPLEMENTED();
+ return true;
#endif
- return false;
}
void WebPluginDelegateProxy::Print(gfx::NativeDrawingContext context) {
@@ -932,10 +947,14 @@ void WebPluginDelegateProxy::PaintSadPlugin(gfx::NativeDrawingContext context,
skia::PlatformDevice& device = canvas.getTopPlatformDevice();
device.drawToHDC(context, plugin_rect_.x(), plugin_rect_.y(), NULL);
#elif defined(OS_LINUX)
+ cairo_save(context);
cairo_t* cairo = canvas.getTopPlatformDevice().beginPlatformPaint();
- cairo_set_source_surface(cairo, cairo_get_target(context),
+ cairo_set_source_surface(context, cairo_get_target(cairo),
plugin_rect_.x(), plugin_rect_.y());
- cairo_paint(cairo);
+ cairo_rectangle(context, rect.x(), rect.y(), rect.width(), rect.height());
+ cairo_clip(context);
+ cairo_paint(context);
+ cairo_restore(context);
// We have no endPlatformPaint() on the Linux PlatformDevice.
// The cairo_t* is owned by the device.
#elif defined(OS_MACOSX)
@@ -967,8 +986,16 @@ void WebPluginDelegateProxy::CopyFromTransportToBacking(const gfx::Rect& rect) {
CGImageCreateWithImageInRect(image, rect.ToCGRect()));
CGContextDrawImage(backing, rect.ToCGRect(), sub_image);
#else
- // TODO(port): probably some new code in TransportDIB should go here.
- NOTIMPLEMENTED();
+ cairo_t *cairo =
+ backing_store_canvas_->getTopPlatformDevice().beginPlatformPaint();
+ cairo_save(cairo);
+ cairo_t *transport =
+ transport_store_canvas_->getTopPlatformDevice().beginPlatformPaint();
+ cairo_set_source_surface(cairo, cairo_get_target(transport), 0, 0);
+ cairo_rectangle(cairo, rect.x(), rect.y(), rect.width(), rect.height());
+ cairo_clip(cairo);
+ cairo_paint(cairo);
+ cairo_restore(cairo);
#endif
backing_store_painted_ = backing_store_painted_.Union(rect);
}
« no previous file with comments | « chrome/plugin/webplugin_proxy.cc ('k') | webkit/glue/plugins/plugin_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698