[webkit-dev] Abstracting the canvas

Darin Adler darin at apple.com
Wed Jan 23 07:50:29 PST 2008


On Jan 23, 2008, at 3:25 AM, Alp Toker wrote:

> Oliver has proposed the first move in abstracting WebKit's canvas  
> implementation as part of his putImageData patch:
>
>  http://bugs.webkit.org/show_bug.cgi?id=16954
>
> The strategy involves splitting functions out into  
> CanvasRenderingContext2DCG, CanvasRenderingContext2DCairo, and  
> possibly moving other parts into the respective GraphicsContext  
> platform implementations.
>
> I know others have also considered abstracting the canvas but no  
> other approaches have yet been proposed, so I thought I'd give a  
> heads up on the list.
>
> If you're planning a different way to split canvas, now is a good  
> time to propose it -- silence is acceptance.

My proposal is to move everything into the platform/graphics  
implementation; there should be no platform specific code in the  
canvas class at all. There would be no separate functions per-platform  
in the canvas rendering context or canvas object. We'd create classes  
like Image and Pixmap that go along with GraphicsContext and abstract  
everything needed by canvas.

I was working on this a year or two ago, got about half way done, and  
then dropped it. This was back when canvas had only a CG  
implementation. Then others decided to port by adding more ifdefs  
instead, which I found disappointing.

I'd like to rework Oliver's patch to fit my preferred approach.

     -- Darin



More information about the webkit-dev mailing list