diff options
author | kkania@chromium.org <kkania@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-06 03:48:48 +0000 |
---|---|---|
committer | kkania@chromium.org <kkania@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-06 03:48:48 +0000 |
commit | 6d853d9e57b7c5415a8042165e8668cb76a0f9b7 (patch) | |
tree | 95ddb2260d74765da6604c68a8c486adbc4be1bc /chrome/plugin | |
parent | 71743c1a6912e07cb6c9fbe342d23f8b4a9f31c1 (diff) | |
download | chromium_src-6d853d9e57b7c5415a8042165e8668cb76a0f9b7.zip chromium_src-6d853d9e57b7c5415a8042165e8668cb76a0f9b7.tar.gz chromium_src-6d853d9e57b7c5415a8042165e8668cb76a0f9b7.tar.bz2 |
On Windows, create a new TransportDIB::Handle struct which includes the file
mapping HANDLE and the source process ID. Duplicating the handle for the
remote process is done in TransportDIB::Map, instead of in various #ifdefs
scattered across the code. Also on windows, remove the struct for the
TransportDIB::Id which contained both the sequence number and the HANDLE
and replace it with just the sequence number.
Fix ThumbnailGenerator by mapping the TransportDIB on Windows and adding
a method to duplicate the file mapping handle before sending across the
channel.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/3305020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61608 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/plugin')
-rw-r--r-- | chrome/plugin/webplugin_proxy.cc | 108 | ||||
-rw-r--r-- | chrome/plugin/webplugin_proxy.h | 4 |
2 files changed, 38 insertions, 74 deletions
diff --git a/chrome/plugin/webplugin_proxy.cc b/chrome/plugin/webplugin_proxy.cc index 5ec1b43..4f3ecd3 100644 --- a/chrome/plugin/webplugin_proxy.cc +++ b/chrome/plugin/webplugin_proxy.cc @@ -218,7 +218,8 @@ NPObject* WebPluginProxy::GetPluginElement() { int npobject_route_id = channel_->GenerateRouteID(); bool success = false; - Send(new PluginHostMsg_GetPluginElement(route_id_, npobject_route_id, &success)); + Send(new PluginHostMsg_GetPluginElement(route_id_, npobject_route_id, + &success)); if (!success) return NULL; @@ -517,61 +518,31 @@ void WebPluginProxy::UpdateGeometry( #endif } -#if defined(OS_WIN) -void WebPluginProxy::SetWindowlessBuffer( - const TransportDIB::Handle& windowless_buffer, - const TransportDIB::Handle& background_buffer, - const gfx::Rect& window_rect) { - // Create a canvas that will reference the shared bits. We have to handle - // errors here since we're mapping a large amount of memory that may not fit - // in our address space, or go wrong in some other way. - windowless_canvas_.reset(new skia::PlatformCanvas); - if (!windowless_canvas_->initialize( - window_rect.width(), - window_rect.height(), - true, - win_util::GetSectionFromProcess(windowless_buffer, - channel_->renderer_handle(), false))) { - windowless_canvas_.reset(); - background_canvas_.reset(); - return; - } - - if (background_buffer) { - background_canvas_.reset(new skia::PlatformCanvas); - if (!background_canvas_->initialize( - window_rect.width(), - window_rect.height(), - true, - win_util::GetSectionFromProcess(background_buffer, - channel_->renderer_handle(), false))) { - windowless_canvas_.reset(); - background_canvas_.reset(); - return; - } - } -} - -#elif defined(OS_MACOSX) - void WebPluginProxy::SetWindowlessBuffer( const TransportDIB::Handle& windowless_buffer, const TransportDIB::Handle& background_buffer, const gfx::Rect& window_rect) { - // Convert the shared memory handle to a handle that works in our process, - // and then use that to create a CGContextRef. + // We have to handle errors here since we're mapping a large amount of memory + // that may not fit in our address space. Also, the renderer may have already + // destroyed the TransportDIB by the time we receive the handle, e.g. in case + // of multiple resizes. +#if defined(OS_MACOSX) windowless_dib_.reset(TransportDIB::Map(windowless_buffer)); background_dib_.reset(TransportDIB::Map(background_buffer)); - windowless_context_.reset(CGBitmapContextCreate( - windowless_dib_->memory(), - window_rect.width(), - window_rect.height(), - 8, 4 * window_rect.width(), - mac_util::GetSystemColorSpace(), - kCGImageAlphaPremultipliedFirst | - kCGBitmapByteOrder32Host)); - CGContextTranslateCTM(windowless_context_, 0, window_rect.height()); - CGContextScaleCTM(windowless_context_, 1, -1); + if (windowless_dib_.get()) { + windowless_context_.reset(CGBitmapContextCreate( + windowless_dib_->memory(), + window_rect.width(), + window_rect.height(), + 8, 4 * window_rect.width(), + mac_util::GetSystemColorSpace(), + kCGImageAlphaPremultipliedFirst | + kCGBitmapByteOrder32Host)); + CGContextTranslateCTM(windowless_context_, 0, window_rect.height()); + CGContextScaleCTM(windowless_context_, 1, -1); + } else { + windowless_context_.reset(); + } if (background_dib_.get()) { background_context_.reset(CGBitmapContextCreate( background_dib_->memory(), @@ -583,32 +554,28 @@ void WebPluginProxy::SetWindowlessBuffer( kCGBitmapByteOrder32Host)); CGContextTranslateCTM(background_context_, 0, window_rect.height()); CGContextScaleCTM(background_context_, 1, -1); + } else { + background_context_.reset(); } -} - -#elif defined(USE_X11) - -void WebPluginProxy::SetWindowlessBuffer( - const TransportDIB::Handle& windowless_buffer, - const TransportDIB::Handle& background_buffer, - const gfx::Rect& window_rect) { +#else int width = window_rect.width(); int height = window_rect.height(); - windowless_dib_.reset(TransportDIB::Map(windowless_buffer)); - if (windowless_dib_.get()) { - windowless_canvas_.reset(windowless_dib_->GetPlatformCanvas(width, height)); - } else { - // This can happen if the renderer has already destroyed the TransportDIB - // by the time we receive the handle, e.g. in case of multiple resizes. + windowless_dib_.reset(TransportDIB::CreateWithHandle(windowless_buffer)); + background_dib_.reset(TransportDIB::CreateWithHandle(background_buffer)); + windowless_canvas_.reset(windowless_dib_->GetPlatformCanvas(width, height)); + background_canvas_.reset(background_dib_->GetPlatformCanvas(width, height)); + if (!windowless_canvas_.get() || !background_canvas_.get()) { windowless_canvas_.reset(); - } - background_dib_.reset(TransportDIB::Map(background_buffer)); - if (background_dib_.get()) { - background_canvas_.reset(background_dib_->GetPlatformCanvas(width, height)); - } else { background_canvas_.reset(); + // Destroy the TransportDIB if the canvas was not created successfully. + // Otherwise we may have an unnecessary handle which is keeping the shared + // memory open. + windowless_dib_.reset(); + background_dib_.reset(); } +#endif +#if defined(USE_X11) // If SHM pixmaps support is available, create a SHM pixmap and // pass it to the delegate for windowless plugin painting. if (delegate_->IsWindowless() && use_shm_pixmap_ && windowless_dib_.get()) { @@ -628,9 +595,8 @@ void WebPluginProxy::SetWindowlessBuffer( delegate_->SetWindowlessShmPixmap(windowless_shm_pixmap_); } -} - #endif +} void WebPluginProxy::CancelDocumentLoad() { Send(new PluginHostMsg_CancelDocumentLoad(route_id_)); diff --git a/chrome/plugin/webplugin_proxy.h b/chrome/plugin/webplugin_proxy.h index 2134bf3..f25fc70 100644 --- a/chrome/plugin/webplugin_proxy.h +++ b/chrome/plugin/webplugin_proxy.h @@ -203,9 +203,9 @@ class WebPluginProxy : public webkit_glue::WebPlugin { // Variables used for desynchronized windowless plugin painting. See note in // webplugin_delegate_proxy.h for how this works. bool transparent_; -#if defined(OS_MACOSX) scoped_ptr<TransportDIB> windowless_dib_; scoped_ptr<TransportDIB> background_dib_; +#if defined(OS_MACOSX) scoped_cftyperef<CGContextRef> windowless_context_; scoped_cftyperef<CGContextRef> background_context_; scoped_ptr<WebPluginAcceleratedSurfaceProxy> accelerated_surface_; @@ -214,8 +214,6 @@ class WebPluginProxy : public webkit_glue::WebPlugin { scoped_ptr<skia::PlatformCanvas> background_canvas_; #if defined(USE_X11) - scoped_ptr<TransportDIB> windowless_dib_; - scoped_ptr<TransportDIB> background_dib_; // If we can use SHM pixmaps for windowless plugin painting or not. bool use_shm_pixmap_; // The SHM pixmap for windowless plugin painting. |