summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorpiman@google.com <piman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-22 00:46:22 +0000
committerpiman@google.com <piman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-22 00:46:22 +0000
commite82fafcd66be3f5c0cef28ee0c08ae4f9e0338b4 (patch)
treefa45c0c69e9e28524867e4c93d65d323dcf9c14a /chrome
parent4dc3cca352f08bfe126bb83c5a7030965538b7a0 (diff)
downloadchromium_src-e82fafcd66be3f5c0cef28ee0c08ae4f9e0338b4.zip
chromium_src-e82fafcd66be3f5c0cef28ee0c08ae4f9e0338b4.tar.gz
chromium_src-e82fafcd66be3f5c0cef28ee0c08ae4f9e0338b4.tar.bz2
linux: add windowless plugin plumbing
Review URL: http://codereview.chromium.org/159128 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21250 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/common/transport_dib_linux.cc2
-rw-r--r--chrome/plugin/webplugin_proxy.cc31
-rw-r--r--chrome/plugin/webplugin_proxy.h5
-rw-r--r--chrome/renderer/webplugin_delegate_proxy.cc57
4 files changed, 75 insertions, 20 deletions
diff --git a/chrome/common/transport_dib_linux.cc b/chrome/common/transport_dib_linux.cc
index 1037341..75b52d5 100644
--- a/chrome/common/transport_dib_linux.cc
+++ b/chrome/common/transport_dib_linux.cc
@@ -69,7 +69,7 @@ TransportDIB* TransportDIB::Map(Handle shmkey) {
if (shmctl(shmkey, IPC_STAT, &shmst) == -1)
return NULL;
- void* address = shmat(shmkey, NULL /* desired address */, SHM_RDONLY);
+ void* address = shmat(shmkey, NULL /* desired address */, 0 /* flags */);
if (address == kInvalidAddress)
return NULL;
diff --git a/chrome/plugin/webplugin_proxy.cc b/chrome/plugin/webplugin_proxy.cc
index 94f2b2f..1356c61 100644
--- a/chrome/plugin/webplugin_proxy.cc
+++ b/chrome/plugin/webplugin_proxy.cc
@@ -372,6 +372,9 @@ void WebPluginProxy::Paint(const gfx::Rect& rect) {
#elif defined(OS_MACOSX)
if (!windowless_context_.get())
return;
+#elif defined(OS_LINUX)
+ if (!windowless_canvas_.get())
+ return;
#endif
// Clear the damaged area so that if the plugin doesn't paint there we won't
@@ -415,8 +418,20 @@ void WebPluginProxy::Paint(const gfx::Rect& rect) {
delegate_->Paint(windowless_context_, rect);
CGContextRestoreGState(windowless_context_);
#else
- // TODO(port): windowless painting.
- NOTIMPLEMENTED();
+ cairo_t* cairo =
+ windowless_canvas_->getTopPlatformDevice().beginPlatformPaint();
+ cairo_save(cairo);
+ cairo_rectangle(cairo, rect.x(), rect.y(), rect.width(), rect.height());
+ cairo_clip(cairo);
+ if (background_canvas_.get()) {
+ cairo_t *background =
+ background_canvas_->getTopPlatformDevice().beginPlatformPaint();
+ cairo_set_source_surface(cairo, cairo_get_target(background), 0, 0);
+ cairo_paint(cairo);
+ }
+ cairo_translate(cairo, -delegate_->GetRect().x(), -delegate_->GetRect().y());
+ delegate_->Paint(cairo, offset_rect);
+ cairo_restore(cairo);
#endif
}
@@ -558,13 +573,21 @@ void WebPluginProxy::SetWindowlessBuffer(
}
#elif defined (OS_LINUX)
void WebPluginProxy::UpdateTransform() {
- NOTIMPLEMENTED();
}
void WebPluginProxy::SetWindowlessBuffer(
const TransportDIB::Handle& windowless_buffer,
const TransportDIB::Handle& background_buffer) {
- NOTIMPLEMENTED();
+ int width = delegate_->GetRect().width();
+ int height = delegate_->GetRect().height();
+ windowless_dib_.reset(TransportDIB::Map(windowless_buffer));
+ windowless_canvas_.reset(windowless_dib_->GetPlatformCanvas(width, height));
+ background_dib_.reset(TransportDIB::Map(background_buffer));
+ if (background_dib_.get()) {
+ background_canvas_.reset(background_dib_->GetPlatformCanvas(width, height));
+ } else {
+ background_canvas_.reset();
+ }
}
#endif
diff --git a/chrome/plugin/webplugin_proxy.h b/chrome/plugin/webplugin_proxy.h
index a55a3da2..b27e95b 100644
--- a/chrome/plugin/webplugin_proxy.h
+++ b/chrome/plugin/webplugin_proxy.h
@@ -182,6 +182,11 @@ class WebPluginProxy : public WebPlugin {
scoped_ptr<TransportDIB> background_dib_;
scoped_cftyperef<CGContextRef> windowless_context_;
scoped_cftyperef<CGContextRef> background_context_;
+#elif defined(OS_LINUX)
+ scoped_ptr<TransportDIB> windowless_dib_;
+ scoped_ptr<TransportDIB> background_dib_;
+ scoped_ptr<skia::PlatformCanvas> windowless_canvas_;
+ scoped_ptr<skia::PlatformCanvas> background_canvas_;
#endif
ScopedRunnableMethodFactory<WebPluginProxy> runnable_method_factory_;
diff --git a/chrome/renderer/webplugin_delegate_proxy.cc b/chrome/renderer/webplugin_delegate_proxy.cc
index 45a98bf..524b908 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);
}