From e68e62fa169c45bd779bfe890aa4fcdaa24d267d Mon Sep 17 00:00:00 2001 From: "agl@chromium.org" Date: Fri, 20 Feb 2009 02:00:04 +0000 Subject: Bitmap transport This patch reworks bitmap transport on all platforms. Linux and Mac are switched from serialising bitmaps over the IPC channel to using shared memory. All platforms gain a shared memory mapping cache on the host side. The concept of a TransportDIB (device independent bitmap) is added to encapsulate most of the platform specifics. On Linux, we use SysV shared memory. This is because X shared pixmaps, which predate POSIX SHM, can only use SysV. By using SysV between renderer and browser, we open up the possibility to map the shared memory directly from the renderer to the X server. On Mac, we use POSIX shared memory. However, since this needs filesystem access and the Mac renderer is sandboxed from the filesystem, we add two new messages from renderer -> browser: The first, AllocTransportDIB, synchronously creates a transport DIB in the browser and passes a handle back to the renderer. The second, FreeTransportDIB, asynchronously, notifies the browser that it may close its handle to the shared memory region. On Mac, the shared memory regions are identified by their inode numbers on the wire. This means that the browser must keep handles open to all the allocated shared memory regions (since an inode number is insufficient to map the region). The alternative design is that the renderer passes the file descriptor with each paint operation. Since passing file descriptors is special case in the code, I felt that it would be best to minimise their use. Creating and freeing transport DIBs are relatively rare operations relative to paints and scrolls. On Windows, most of the code remains the same, except that Windows now uses the mapping cache added in this patch. This allows the browser to maintain a shared memory mapping for a transport DIB over several paints. Previously it mapped and unmapped for every operation, causing lots of TLB and VM churn. Review URL: http://codereview.chromium.org/21485 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10071 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/renderer/render_widget.h | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'chrome/renderer/render_widget.h') diff --git a/chrome/renderer/render_widget.h b/chrome/renderer/render_widget.h index 4153ce0..b0c4b11 100644 --- a/chrome/renderer/render_widget.h +++ b/chrome/renderer/render_widget.h @@ -14,6 +14,7 @@ #include "base/ref_counted.h" #include "base/shared_memory.h" #include "chrome/common/ipc_channel.h" +#include "chrome/renderer/render_process.h" #include "skia/ext/platform_canvas.h" #include "webkit/glue/webwidget_delegate.h" @@ -86,10 +87,6 @@ class RenderWidget : public IPC::Channel::Listener, // Close the underlying WebWidget. void Close(); - // Get the size of the paint buffer for the given rectangle, rounding up to - // the allocation granularity of the system. - static size_t GetPaintBufSize(const gfx::Rect& rect); - protected: // Friend RefCounted so that the dtor can be non-public. Using this class // without ref-counting is an error. @@ -192,10 +189,10 @@ class RenderWidget : public IPC::Channel::Listener, // The size of the RenderWidget. gfx::Size size_; - // Shared memory handles that are currently in use to transfer an image to - // the browser. - base::SharedMemory* current_paint_buf_; - base::SharedMemory* current_scroll_buf_; + // Transport DIBs that are currently in use to transfer an image to the + // browser. + TransportDIB* current_paint_buf_; + TransportDIB* current_scroll_buf_; // The smallest bounding rectangle that needs to be re-painted. This is non- // empty if a paint event is pending. -- cgit v1.1