[webkit-qt] GraphicsContext and Canvas

noam.rosenthal at nokia.com noam.rosenthal at nokia.com
Wed Feb 3 22:56:50 PST 2010

Hi Ariya
First of all, awesome that you're looking into this! I was praying for this moment :)
Second - our canvas implementation is not just slow, it's also inaccurate. See https://bugs.webkit.org/show_bug.cgi?id=32405.

About that internal buffer - how would that work with HW acceleration and memory consumption, also considering  that GraphicsLayer has an additional intermediate buffer in the form of graphics-view cache?


From: webkit-qt-bounces at lists.webkit.org [webkit-qt-bounces at lists.webkit.org] On Behalf Of ext Ariya Hidayat [ariya.hidayat at gmail.com]
Sent: Wednesday, February 03, 2010 10:43 PM
To: webkit-qt at lists.webkit.org
Subject: [webkit-qt] GraphicsContext and Canvas

Hello good people,

Currently Canvas is not performing very well, see
https://bugs.webkit.org/show_bug.cgi?id=32530 for the details of one
of the problems. I have a patch for that (attached in the bug, please
review!) by introducing BufferedImage, but that is just a stop-gap
measure. This is because ImageBuffer still gets created and destroyed
for every single frame, which causes us to recreate the pixmap for the
canvas all the time.

My proposal would be as follows. We change Graphics Context so that it
has an internal buffer (of ImageBuffer instance). For a graphics
context that operates on a canvas, we just use its ImageBuffer for the
painting, with some reference counting so everytime we clear the
(Buffered)Image instance we don't need to throw the pixmap again and

Bonus: we can get rid of our ImageBufferData.

Also, this opens further optimization for pixel manipulation (which I
have planned to do since ages, but then I am a lazy guy :). Currently
getting or setting a pixel from our canvas converts the pixmap to an
image and later back again to the pixmap (expensive on non-raster
graphics systems). If we can keep both the pixmap and image ourselves,
we might do some heuristic caching and optimization. For example,
usually pixel manipulations are not interleaved with vector/path
fill/stroke etc. This allows us to keep either the pixmap format or
the image format as long as we need it and avoid constant conversion
between them.

I'l try to give it a shot in the next few weeks. Ideas and feedbacks
are warmly welcomed.

Thank you!


Ariya Hidayat
webkit-qt mailing list
webkit-qt at lists.webkit.org

More information about the webkit-qt mailing list