blob: c12623cade3b176107e5345202d8fd0c21325d99 [file] [log] [blame] [view]
andybons3322f762015-08-24 21:37:091# Bitmap Pipeline
2
3This pages details how bitmaps are moved from the renderer to the screen.
4
5The renderer can request two different operations from the browser:
6* PaintRect: a bitmap to be painted at a given location on the screen
7* Scroll: a horizontal or vertical scroll of the screen, and a bitmap to painted
8
9Across all three platforms, shared memory is used to transport the bitmap from
10the renderer to the browser. On Windows, a shared section is used. On Linux,
11it's SysV shared memory and on the Mac we use POSIX shared memory.
12
13Windows and Linux create shared memory in the renderer process. On Mac, since
14the renderer is sandboxed, it cannot create shared memory segments and uses a
15synchronous IPC to the browser to create them (ViewHostMsg\_AllocTransportDIB).
16These shared memory segments are called TranportDIBs (device independent
17bitmaps) in the code.
18
19Transport DIBs are allocated on demand by the render\_process and cached
20therein, in a two entry cache. The IPC messages to the browser contain a
21TransportDIB::Id which names a transport DIB. In the case of Mac, since the
22browser created them in the first place, it keeps a map of all allocated
23transport DIBs in the RenderProcessHost. The ids on the wire are then the inode
24numbers of the shared memory segments.
25
26On Windows, the Id is the HANDLE value from the renderer process. On Linux the
27id is the SysV key. Thus, on both Windows and Linux, the id is sufficient to map
28the transport DIB, while on Mac is is not. This is why, on Mac, the browser
29keeps handles to all the possible transport DIBs.
30
31Each RenderProcessHost keeps a small cache of recently used transport DIBs. This
32means that, when many paint operations are performed in succession, the same
33shared memory should be reused (as long as it's large enough). Also, this shared
34memory should remain mapped in both the renderer and browser process, reduci ng
35the amount of VM churn.
36
37The transport DIB caches in both the renderer and browser are flushed after some
38period of inactivity, currently five seconds.
39
40### Backing stores
41
42Backing stores are browser side copies of the current RenderView bitmap. The
43renderer sends paints to the browser to update small portions of the backing
44store but, for performance reasons, when we want to repaint the whole thing
45(i.e. because we switched tabs) we don't want to go to the renderer to redraw it
46all.
47
48On Windows and Mac, the backing store is kept in heap memory in the browser. On
49Windows, we use one advantage which is that we can use Win32 calls to scroll
50both the window and the backing store. This is faster than scrolling ourselves
51and redrawing everything to the window.
52
53On Mac, the backing store is a Skia bitmap and we do the scrolling ourselves.
54
55On Linux, the backing store is kept on the X server. It's a large X pixmap and
56we handle exposes by directing the X server to copy from this pixmap. This means
57that we can repaint the window without sending any bitmaps to the X server. It
58also means that we can perform optimised scrolling by directing the X server to
59scroll the window and pixmap for us.
60
61Having backing stores on the X server is a major win in the case of remote X.