Canvas/GLES/Wayland: Use a textured gl surface to represent a 2D canvas. 56/12656/2
authorZhigang Gong <zhigang.gong@intel.com>
Wed, 16 Oct 2013 09:48:52 +0000 (17:48 +0800)
committerJoone Hur <joone.hur@intel.com>
Thu, 21 Nov 2013 05:43:45 +0000 (21:43 -0800)
commit953d9de5c22c7de73583f1ea1c0fe20429cdb648
treed25110d3153d5b00457514d92987eece3a708b4f
parent2222702f56e2c4b387efd82a9194b9d36c919248
Canvas/GLES/Wayland: Use a textured gl surface to represent a 2D canvas.

Actually, the 2D canvas is required to be shared between the WebProcess
and the UIProcess. On X platform, it's naturally implemented by the
global PIXMAP ID. On the other hand, it becomes different under Wayland.
It uses an EGL window buffer, which is indeed a double buffer. Each time
it  calls eglSwapBuffer, the UIProcess can get the correct buffer to be
used for the rest compositing.

However, it causes the following problem:
1. All canvases are created from EGL surfaces. The type of
those surfaces can't be treated as a source to render to other surface.
So it is very expensive (more than 10x slow) when we copy one canvas to
another.

2. Sometimes, for a static canvas, we only paint once in the WebProcess
, but may share it with the UIProcess several times.
Then, when we call eglSwapBuffers at the even time, we just pass the
wrong buffer to the UIProcess.

The ideal solution is to find another clean way to share buffers
on wayland platform rather than use this way. Before that, this
patch implemented a trade off solution to fix the above problem
partly, because it uses two cairo gl surface to represent one canvas:
the first is a pure gl surface for texture and the second is an EGL gl
surface. We do all canvas related painting on the first gl
surface thus we can avoid the first problem. And then, every time
we need to share the canvas to the UIProcess, we leverage cairo
to paint the first gl surface to the second EGL gl surface,
thus we always pass the correct content to the UIProcess. The side
effect is that we introduce one more copy and we use the required
gpu memory two times. The one more copy is not expensive, because
we do it on GPU side.

This solution could just solve the problem partly. As one big assumption
of this solution is that the WebProcess never use the rendering result
from the UIProcess.

After this patch, GUIMARK3 cache version and Penguin works fine.

Change-Id: Ie4b49e7190f241669332d296ab831a773df5ad1a
Signed-off-by: Zhigang Gong <zhigang.gong@intel.com>
Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp
Source/WebCore/platform/graphics/cairo/ImageBufferDataCairo.h