Open Bug 631640 Opened 13 years ago Updated 2 years ago

add support for context options to 2D canvas context

Categories

(Core :: Graphics: Canvas2D, defect)

defect

Tracking

()

People

(Reporter: vlad, Unassigned)

References

Details

We added the notion of context options for WebGL, but we can use them for 2D as well.  We have moz-opaque as an attribute, but we can also define it as a getContext option, e.g. { alpha: false }, just like WebGL.

An additional one to consider would be something like optimizeForPixelManipulation, which would optimize for getImageData/putImageData by creating an image surface instead of a d2d surface on windows.
Depends on: 982480
This has happened. The second argument to getContext is declared in WebIDL as "any", but when the first argument is "2d", the second argument is treated by C++ as a "dictionary ContextAttributes2D".

Currently, the dictionary has willReadFrequently (added in bug 884226) and alpha (added in bug 982480).

The first argument is logically an enum; I don't know why it's declared as a string. The second argument is logically a "ContextAttributes2D or WebGLContextAttributes", but maybe it has to be "any" for implementation reasons.
What Jesse mentions has happened indeed.

What about implementing context.getContextAttributes() to retrieve the context's attributes here?

interface Canvas2DRenderingContext {
    ...
    Canvas2DContextAttributes? getContextAttributes();
}

http://wiki.whatwg.org/wiki/CanvasOpaque
Inspired by WebGL: https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.2

Implemented and enabled in Chrome 32: https://code.google.com/p/chromium/issues/detail?id=234297
WebKit bug: https://bugs.webkit.org/show_bug.cgi?id=112628
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.