diff options
-rw-r--r-- | chrome/common/transport_dib_linux.cc | 2 | ||||
-rw-r--r-- | chrome/plugin/webplugin_proxy.cc | 31 | ||||
-rw-r--r-- | chrome/plugin/webplugin_proxy.h | 5 | ||||
-rw-r--r-- | chrome/renderer/webplugin_delegate_proxy.cc | 57 | ||||
-rw-r--r-- | webkit/glue/plugins/plugin_host.cc | 2 | ||||
-rw-r--r-- | webkit/glue/plugins/webplugin_delegate_impl_gtk.cc | 16 |
6 files changed, 85 insertions, 28 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); } diff --git a/webkit/glue/plugins/plugin_host.cc b/webkit/glue/plugins/plugin_host.cc index 40b2e1e..90ffd51 100644 --- a/webkit/glue/plugins/plugin_host.cc +++ b/webkit/glue/plugins/plugin_host.cc @@ -610,8 +610,6 @@ void NPN_InvalidateRect(NPP id, NPRect *invalidRect) { ::InvalidateRect(plugin->window_handle(), &rect, FALSE); return; } -#elif defined(OS_LINUX) - NOTIMPLEMENTED(); #endif gfx::Rect rect(invalidRect->left, invalidRect->top, diff --git a/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc b/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc index 5afa911..265551a 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc +++ b/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc @@ -374,7 +374,8 @@ void WebPluginDelegateImpl::EnsurePixmapAtLeastSize(int width, int height) { // |sys_visual| is owned by gdk; we shouldn't free it. GdkVisual* sys_visual = gdk_visual_get_system(); pixmap_ = gdk_pixmap_new(NULL, // use width/height/depth params - width, height, sys_visual->depth); + std::max(1, width), std::max(1, height), + sys_visual->depth); GdkColormap* colormap = gdk_colormap_new(gdk_visual_get_system(), FALSE); gdk_drawable_set_colormap(GDK_DRAWABLE(pixmap_), colormap); @@ -383,17 +384,15 @@ void WebPluginDelegateImpl::EnsurePixmapAtLeastSize(int width, int height) { #ifdef DEBUG_RECTANGLES namespace { -// Draw a rectangle on a Cairo surface. +// Draw a rectangle on a Cairo context. // Useful for debugging various rectangles involved in drawing plugins. -void DrawDebugRectangle(cairo_surface_t* surface, +void DrawDebugRectangle(cairo_t* cairo, const gfx::Rect& rect, float r, float g, float b) { - cairo_t* cairo = cairo_create(surface); cairo_set_source_rgba(cairo, r, g, b, 0.5); cairo_rectangle(cairo, rect.x(), rect.y(), rect.width(), rect.height()); cairo_stroke(cairo); - cairo_destroy(cairo); } } // namespace @@ -526,8 +525,11 @@ void WebPluginDelegateImpl::WindowlessPaint(cairo_t* context, // Copy the current image into the pixmap, so the plugin can draw over // this background. cairo_t* cairo = gdk_cairo_create(pixmap_); + double surface_x = -offset_x; + double surface_y = -offset_y; + cairo_user_to_device(context, &surface_x, &surface_y); cairo_set_source_surface(cairo, cairo_get_target(context), - offset_x, offset_y); + -surface_x, -surface_y); cairo_rectangle(cairo, draw_rect.x() + offset_x, draw_rect.y() + offset_y, draw_rect.width(), draw_rect.height()); cairo_clip(cairo); @@ -551,6 +553,7 @@ void WebPluginDelegateImpl::WindowlessPaint(cairo_t* context, NPError err = instance()->NPP_HandleEvent(&np_event); DCHECK_EQ(err, NPERR_NO_ERROR); + cairo_save(context); // Now copy the rendered image pixmap back into the drawing buffer. gdk_cairo_set_source_pixmap(context, pixmap_, -offset_x, -offset_y); cairo_rectangle(context, draw_rect.x(), draw_rect.y(), @@ -565,6 +568,7 @@ void WebPluginDelegateImpl::WindowlessPaint(cairo_t* context, // Drawing rect = red. DrawDebugRectangle(context, draw_rect, 1, 0, 0); #endif + cairo_restore(context); } void WebPluginDelegateImpl::WindowlessSetWindow(bool force_set_window) { |