diff options
author | kkania@chromium.org <kkania@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-20 18:00:36 +0000 |
---|---|---|
committer | kkania@chromium.org <kkania@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-20 18:00:36 +0000 |
commit | ae849ea693102dd66d5f01d9ad6799e0bde070d0 (patch) | |
tree | 2fdafb8dd84f96c9e61a6b5831860e4ba8406aba /chrome/renderer | |
parent | d62b5fc77d374524bed3752950f268851b8585c6 (diff) | |
download | chromium_src-ae849ea693102dd66d5f01d9ad6799e0bde070d0.zip chromium_src-ae849ea693102dd66d5f01d9ad6799e0bde070d0.tar.gz chromium_src-ae849ea693102dd66d5f01d9ad6799e0bde070d0.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.
Also, add a ScopedHandle and fix some handle leaks.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/3834003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63232 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r-- | chrome/renderer/media/ipc_video_renderer.cc | 1 | ||||
-rw-r--r-- | chrome/renderer/nacl_desc_wrapper_chrome.cc | 2 | ||||
-rw-r--r-- | chrome/renderer/render_widget.cc | 31 | ||||
-rw-r--r-- | chrome/renderer/webplugin_delegate_proxy.cc | 3 |
4 files changed, 20 insertions, 17 deletions
diff --git a/chrome/renderer/media/ipc_video_renderer.cc b/chrome/renderer/media/ipc_video_renderer.cc index d9a194d..15d05e6 100644 --- a/chrome/renderer/media/ipc_video_renderer.cc +++ b/chrome/renderer/media/ipc_video_renderer.cc @@ -160,6 +160,7 @@ void IPCVideoRenderer::DoUpdateVideo() { Send(new ViewHostMsg_UpdateVideo(routing_id_, transport_dib_->id(), + transport_dib_->handle(), video_rect_)); } diff --git a/chrome/renderer/nacl_desc_wrapper_chrome.cc b/chrome/renderer/nacl_desc_wrapper_chrome.cc index a4efc70..45a5a36 100644 --- a/chrome/renderer/nacl_desc_wrapper_chrome.cc +++ b/chrome/renderer/nacl_desc_wrapper_chrome.cc @@ -33,7 +33,7 @@ DescWrapper* DescWrapperFactory::ImportPepper2DSharedMemory(intptr_t shm_int) { return ImportShmHandle(dib->handle().fd, dib->size()); #elif defined(OS_WIN) // TransportDIBs use MapViewOfFile shared memory on Windows. - return ImportShmHandle(dib->handle(), dib->size()); + return ImportShmHandle(dib->handle().section(), dib->size()); #else # error "What platform?" #endif diff --git a/chrome/renderer/render_widget.cc b/chrome/renderer/render_widget.cc index 8880a03..2e7d975 100644 --- a/chrome/renderer/render_widget.cc +++ b/chrome/renderer/render_widget.cc @@ -508,6 +508,7 @@ void RenderWidget::DoDeferredUpdate() { // A plugin may be able to do an optimized paint. First check this, in which // case we can skip all of the bitmap generation and regular paint code. TransportDIB::Id dib_id = TransportDIB::Id(); + TransportDIB::Handle dib_handle = TransportDIB::DefaultHandleValue(); TransportDIB* dib = NULL; std::vector<gfx::Rect> copy_rects; gfx::Rect optimized_copy_rect, optimized_copy_location; @@ -518,6 +519,7 @@ void RenderWidget::DoDeferredUpdate() { bounds = optimized_copy_location; copy_rects.push_back(optimized_copy_rect); dib_id = dib->id(); + dib_handle = dib->handle(); } else if (!is_gpu_rendering_active_) { // Compute a buffer for painting and cache it. scoped_ptr<skia::PlatformCanvas> canvas( @@ -553,6 +555,7 @@ void RenderWidget::DoDeferredUpdate() { PaintRect(copy_rects[i], bounds.origin(), canvas.get()); dib_id = current_paint_buf_->id(); + dib_handle = current_paint_buf_->handle(); } else { // Accelerated compositing path // Begin painting. bool finish = next_paint_is_resize_ack(); @@ -561,7 +564,8 @@ void RenderWidget::DoDeferredUpdate() { // sending an ack to browser process that the paint is complete... ViewHostMsg_UpdateRect_Params params; - params.bitmap = dib_id; + params.dib_id = dib_id; + params.dib_handle = dib_handle; params.bitmap_rect = bounds; params.dx = update.scroll_delta.x(); params.dy = update.scroll_delta.y(); @@ -819,7 +823,8 @@ void RenderWidget::OnMsgPaintAtSize(const TransportDIB::Handle& dib_handle, int tag, const gfx::Size& page_size, const gfx::Size& desired_size) { - if (!webwidget_ || dib_handle == TransportDIB::DefaultHandleValue()) + TransportDIB::ScopedHandle scoped_dib_handle(dib_handle); + if (!webwidget_ || !TransportDIB::is_valid(dib_handle)) return; if (page_size.IsEmpty() || desired_size.IsEmpty()) { @@ -831,13 +836,17 @@ void RenderWidget::OnMsgPaintAtSize(const TransportDIB::Handle& dib_handle, // Map the given DIB ID into this process, and unmap it at the end // of this function. - scoped_ptr<TransportDIB> paint_at_size_buffer(TransportDIB::Map(dib_handle)); - - DCHECK(paint_at_size_buffer.get()); - if (!paint_at_size_buffer.get()) + scoped_ptr<TransportDIB> paint_at_size_buffer( + TransportDIB::CreateWithHandle(scoped_dib_handle.release())); + gfx::Size canvas_size = page_size; + scoped_ptr<skia::PlatformCanvas> canvas( + paint_at_size_buffer->GetPlatformCanvas(canvas_size.width(), + canvas_size.height())); + if (!canvas.get()) { + NOTREACHED(); return; + } - gfx::Size canvas_size = page_size; float x_scale = static_cast<float>(desired_size.width()) / static_cast<float>(canvas_size.width()); float y_scale = static_cast<float>(desired_size.height()) / @@ -848,14 +857,6 @@ void RenderWidget::OnMsgPaintAtSize(const TransportDIB::Handle& dib_handle, canvas_size.set_height(static_cast<int>(canvas_size.height() * y_scale)); gfx::Rect bounds(canvas_size); - scoped_ptr<skia::PlatformCanvas> canvas( - paint_at_size_buffer->GetPlatformCanvas(canvas_size.width(), - canvas_size.height())); - if (!canvas.get()) { - NOTREACHED(); - return; - } - // Reset bounds to what we actually received, but they should be the // same. DCHECK_EQ(bounds.width(), canvas->getDevice()->width()); diff --git a/chrome/renderer/webplugin_delegate_proxy.cc b/chrome/renderer/webplugin_delegate_proxy.cc index a2553f2..7b3938e 100644 --- a/chrome/renderer/webplugin_delegate_proxy.cc +++ b/chrome/renderer/webplugin_delegate_proxy.cc @@ -1506,9 +1506,10 @@ void WebPluginDelegateProxy::OnAcceleratedSurfaceSetTransportDIB( int32 width, int32 height, TransportDIB::Handle transport_dib) { + TransportDIB::ScopedHandle scoped_dib_handle(transport_dib); if (render_view_) render_view_->AcceleratedSurfaceSetTransportDIB(window, width, height, - transport_dib); + scoped_dib_handle.release()); } void WebPluginDelegateProxy::OnAcceleratedSurfaceAllocTransportDIB( |