-
Notifications
You must be signed in to change notification settings - Fork 146
Replace alpha flag with a PaintRenderingContext2DSettings object #448
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
6c7ce5d
df0c249
f7796c4
66a64a6
2a24fd7
fe4d70d
e4ba80c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -138,13 +138,22 @@ interface PaintWorkletGlobalScope : WorkletGlobalScope { | |
| }; | ||
| </pre> | ||
|
|
||
| The {{ContextAttributes}} allows the settings for the rendering context associated | ||
| with the paint canvas. Right now, the {{ContextAttributes}} has a boolean flag | ||
| indicating if the paint canvas contains an alpha channel. | ||
| <pre class='idl'> | ||
| dictionary ContextAttributes { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PaintContextAttributes to match below. |
||
| boolean alpha = true; | ||
| }; | ||
| </pre> | ||
|
|
||
| <div class='note'> | ||
| Note: The shape of the class should be: | ||
| <pre class='lang-javascript'> | ||
| class MyPaint { | ||
| static get inputProperties() { return ['--foo']; } | ||
| static get inputArguments() { return ['<color>']; } | ||
| static get alpha() { return true; } | ||
| static get ContextAttributes() { return {alpha: true}; } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think should be lowerCamelCase, "contextAttributes" |
||
|
|
||
| paint(ctx, size, styleMap) { | ||
| // Paint code goes here. | ||
|
|
@@ -169,7 +178,7 @@ A <dfn>paint definition</dfn> is a <a>struct</a> which describes the information | |
| - <dfn for="paint definition">input properties</dfn> which is a <a>list</a> of | ||
| <code>DOMStrings</code>. | ||
|
|
||
| - A <dfn for="paint definition">context alpha flag</dfn>. | ||
| - A <dfn for="paint definition">ContextAttributes object</dfn>. | ||
|
|
||
| A <dfn>document paint definition</dfn> is a <a>struct</a> which describes the information | ||
| needed by the <a>document</a> about the author defined <<image>> function (which can be referenced | ||
|
|
@@ -181,7 +190,7 @@ by the paint function). It consists of: | |
| - A <dfn for="document paint definition">input argument syntaxes</dfn> which is a <a>list</a> of | ||
| parsed [[css-properties-values-api-1#supported-syntax-strings]]. | ||
|
|
||
| - A <dfn for="document paint definition">context alpha flag</dfn>. | ||
| - A <dfn for="document paint definition">ContextAttributes object</dfn>. | ||
|
|
||
| Registering Custom Paint {#registering-custom-paint} | ||
| ==================================================== | ||
|
|
@@ -244,15 +253,15 @@ called, the user agent <em>must</em> run the following steps: | |
|
|
||
| 2. <a for=list>Append</a> |parsedSyntax| to |inputArgumentSyntaxes|. | ||
|
|
||
| 12. Let |alphaValue| be the result of <a>Get</a>(|paintCtor|, "alpha"). | ||
| 12. Let |alphaValue| be the result of <a>Get</a>(|paintCtor|, "ContextAttributes.alpha"). | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be...
|
||
|
|
||
| 13. Let |alpha| be <code>true</code> if |alphaValue| is undefined, otherwise let it be the | ||
| result of <a>converting</a> |alphaValue| to a <a>boolean</a>. If an exception is | ||
| <a>thrown</a>, rethrow the exception and abort all these steps. | ||
|
|
||
| Note: Setting <code>alpha</code> is <code>false</code> allows user agents to anti-alias text | ||
| an addition to performing "visibility" optimizations, e.g. not painting an image behind | ||
| the paint image as the paint image is opaque. | ||
| Note: Setting <code>ContextAttributes.alpha</code> is <code>false</code> allows user agents | ||
| to anti-alias text in addition to performing "visibility" optimizations, e.g. not | ||
| painting an image behind the paint image as the paint image is opaque. | ||
|
|
||
| 14. If the result of <a>IsConstructor</a>(|paintCtor|) is false, <a>throw</a> a <a>TypeError</a> | ||
| and abort all these steps. | ||
|
|
@@ -277,7 +286,7 @@ called, the user agent <em>must</em> run the following steps: | |
|
|
||
| - <a for="paint definition">input properties</a> being |inputProperties|. | ||
|
|
||
| - <a for="paint definition">context alpha flag</a> being |alpha|. | ||
| - <a for="paint definition">ContextAttributes object</a> being {alpha: |alpha|}. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ... being |contextAttributes|. |
||
|
|
||
| 20. <a for=map>Set</a> |paintDefinitionMap|[|name|] to |definition|. | ||
|
|
||
|
|
@@ -293,7 +302,7 @@ called, the user agent <em>must</em> run the following steps: | |
| - <a for="document paint definition">input argument syntaxes</a> being | ||
| |inputArgumentSyntaxes|. | ||
|
|
||
| - <a for="document paint definition">context alpha flag</a> being |alpha|. | ||
| - <a for="document paint definition">ContextAttributes object</a> being {alpha: |alpha|}. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as above. |
||
|
|
||
| 3. If |documentPaintDefinitionMap|[|name|] <a for=map>exists</a>, run the following steps: | ||
|
|
||
|
|
@@ -305,13 +314,13 @@ called, the user agent <em>must</em> run the following steps: | |
| 3. If |existingDocumentDefinition| and |documentDefinition| are not equivalent, (that is | ||
| <a for="document paint definition">input properties</a>, <a for="document paint | ||
| definition">input argument syntaxes</a>, and <a for="document paint | ||
| definition">context alpha flag</a> are different), then: | ||
| definition">ContextAttributes object</a> are different), then: | ||
|
|
||
| <a for=map>Set</a> |documentPaintDefinitionMap|[|name|] to <code>"invalid"</code>. | ||
|
|
||
| Log an error to the debugging console stating that the same class was registered | ||
| with different <code>inputProperties</code>, <code>inputArguments</code>, or | ||
| <code>alpha</code>. | ||
| <code>ContextAttributes</code>. | ||
|
|
||
| 4. Otherwise, <a for=map>set</a> |documentPaintDefinitionMap|[|name|] to | ||
| |documentDefinition|. | ||
|
|
@@ -605,7 +614,7 @@ When the user agent wants to <dfn>invoke a paint callback</dfn> given |name|, |i | |
| 8. Let |renderingContext| be the result of <a>create a PaintRenderingContext2D object</a> given: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. has the "create a PaintRenderingContext2D object" algorithm been updated to receive a contextAttributes object?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch, I have updated that section. |
||
| - "width" - The width given by |concreteObjectSize|. | ||
| - "height" - The height given by |concreteObjectSize|. | ||
| - "alpha" - The <a for="paint definition">context alpha flag</a> given by |definition|. | ||
| - "context_attributes" - The <a for="paint definition">ContextAttributes object</a> given by |definition|. | ||
|
|
||
| Note: The |renderingContext| is not be re-used between invocations of paint. Implicitly this | ||
| means that there is no stored data, or state on the |renderingContext| between | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be nice to namespace this for the spec e.g. {{PaintContextAttributes}}, but doesn't really matter as not user visible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not very certain about this. I notice that there is a proposal for CanvasRenderingContext2DSettings in here: https://github.com/WICG/canvas-color-space/blob/master/CanvasColorSpaceProposal.md
Currently there is only one alpha, but the proposal make it including color space attributes. Maybe in the future we should make ContextAttributes inherit from it? Or maybe just directly using it for PaintRenderingContext2D?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@flackr thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes sense that we might eventually want to support settings like color space. However, in the event that we do this I think we might still only want to support a subset of CanvasRenderingContext2DSettings just like PaintRenderingContext2D implements a subset of CanvasRenderingContext2D. How about PaintRenderingContext2DSettings for consistency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'd support that. PaintRenderingContext2DSettings is a better name, because it is more clear that it is used for PaintRenderingContext2D.
Question: do we need to start a discussion somewhere and bring other people onboard, like CSS discussion group?