@@ -142,13 +142,23 @@ interface PaintWorkletGlobalScope : WorkletGlobalScope {
142
142
};
143
143
</pre>
144
144
145
+ The {{PaintRenderingContext2DSettings}} contains the settings for the rendering context associated
146
+ with the paint canvas. The {{PaintRenderingContext2DSettings}} provides a supported subset
147
+ of canvas rendering context 2D settings. In the future, it may be extended to support color
148
+ management in paint canvas.
149
+ <pre class='idl'>
150
+ dictionary PaintRenderingContext2DSettings {
151
+ boolean alpha = true;
152
+ };
153
+ </pre>
154
+
145
155
<div class='note'>
146
156
Note: The shape of the class should be:
147
157
<pre class='lang-javascript'>
148
158
class MyPaint {
149
159
static get inputProperties() { return ['--foo'] ; }
150
160
static get inputArguments() { return ['<color>'] ; }
151
- static get alpha () { return true; }
161
+ static get contextOptions () { return {alpha: true} ; }
152
162
153
163
paint(ctx, size, styleMap) {
154
164
// Paint code goes here.
@@ -173,7 +183,7 @@ A <dfn>paint definition</dfn> is a <a>struct</a> which describes the information
173
183
- <dfn for="paint definition">input properties</dfn> which is a <a>list</a> of
174
184
<code> DOMStrings</code> .
175
185
176
- - A <dfn for="paint definition">context alpha flag </dfn> .
186
+ - A <dfn for="paint definition">PaintRenderingContext2DSettings object </dfn> .
177
187
178
188
A <dfn>document paint definition</dfn> is a <a>struct</a> which describes the information
179
189
needed by the <a>document</a> about the author defined <<image>> function (which can be referenced
@@ -185,7 +195,7 @@ by the paint function). It consists of:
185
195
- A <dfn for="document paint definition">input argument syntaxes</dfn> which is a <a>list</a> of
186
196
parsed [[css-properties-values-api-1#supported-syntax-strings]] .
187
197
188
- - A <dfn for="document paint definition">context alpha flag </dfn> .
198
+ - A <dfn for="document paint definition">PaintRenderingContext2DSettings object </dfn> .
189
199
190
200
Registering Custom Paint {#registering-custom-paint}
191
201
====================================================
@@ -248,15 +258,15 @@ called, the user agent <em>must</em> run the following steps:
248
258
249
259
2. <a for=list>Append</a> |parsedSyntax| to |inputArgumentSyntaxes|.
250
260
251
- 12. Let |alphaValue | be the result of <a>Get</a> (|paintCtor|, "alpha ").
261
+ 12. Let |contextOptionsValue | be the result of <a>Get</a> (|paintCtor|, "contextOptions ").
252
262
253
- 13. Let |alpha | be <code> true </code> if |alphaValue| is undefined, otherwise let it be the
254
- result of <a>converting</a> |alphaValue | to a <a>boolean</a> . If an exception is
255
- <a>thrown</a> , rethrow the exception and abort all these steps.
263
+ 13. Let |paintRenderingContext2DSettings | be the result of <a>converting</a>
264
+ |contextOptionsValue | to a {{PaintRenderingContext2DSettings}} .
265
+ If an exception is <a>thrown</a> , rethrow the exception and abort all these steps.
256
266
257
- Note: Setting <code> alpha</code> is <code> false</code> allows user agents to anti-alias text
258
- an addition to performing "visibility" optimizations, e.g. not painting an image behind
259
- the paint image as the paint image is opaque.
267
+ Note: Setting <code> paintRenderingContext2DSettings. alpha</code> is <code> false</code> allows user agents
268
+ to anti-alias text in addition to performing "visibility" optimizations, e.g. not
269
+ painting an image behind the paint image as the paint image is opaque.
260
270
261
271
14. If the result of <a>IsConstructor</a> (|paintCtor|) is false, <a>throw</a> a <a>TypeError</a>
262
272
and abort all these steps.
@@ -281,7 +291,7 @@ called, the user agent <em>must</em> run the following steps:
281
291
282
292
- <a for="paint definition">input properties</a> being |inputProperties|.
283
293
284
- - <a for="paint definition">context alpha flag </a> being |alpha |.
294
+ - <a for="paint definition">PaintRenderingContext2DSettings object </a> being |paintRenderingContext2DSettings |.
285
295
286
296
20. <a for=map>Set</a> |paintDefinitionMap|[|name|] to |definition|.
287
297
@@ -297,7 +307,7 @@ called, the user agent <em>must</em> run the following steps:
297
307
- <a for="document paint definition">input argument syntaxes</a> being
298
308
|inputArgumentSyntaxes|.
299
309
300
- - <a for="document paint definition">context alpha flag </a> being |alpha |.
310
+ - <a for="document paint definition">PaintRenderingContext2DSettings object </a> being |paintRenderingContext2DSettings |.
301
311
302
312
3. If |documentPaintDefinitionMap|[|name|] <a for=map>exists</a> , run the following steps:
303
313
@@ -309,13 +319,13 @@ called, the user agent <em>must</em> run the following steps:
309
319
3. If |existingDocumentDefinition| and |documentDefinition| are not equivalent, (that is
310
320
<a for="document paint definition">input properties</a> , <a for="document paint
311
321
definition">input argument syntaxes</a> , and <a for="document paint
312
- definition">context alpha flag </a> are different), then:
322
+ definition">PaintRenderingContext2DSettings object </a> are different), then:
313
323
314
324
<a for=map>Set</a> |documentPaintDefinitionMap|[|name|] to <code> "invalid"</code> .
315
325
316
326
Log an error to the debugging console stating that the same class was registered
317
327
with different <code> inputProperties</code> , <code> inputArguments</code> , or
318
- <code> alpha </code> .
328
+ <code> paintRenderingContext2DSettings </code> .
319
329
320
330
4. Otherwise, <a for=map>set</a> |documentPaintDefinitionMap|[|name|] to
321
331
|documentDefinition|.
@@ -409,10 +419,10 @@ is treated as opaque black.
409
419
410
420
<div algorithm>
411
421
When the user agent is to <dfn>create a PaintRenderingContext2D object</dfn> for a given |width|,
412
- |height|, and |alpha |, it <em> must</em> run the following steps:
422
+ |height|, and |paintRenderingContext2DSettings |, it <em> must</em> run the following steps:
413
423
1. Create a new {{PaintRenderingContext2D}} .
414
424
2. <a>Set bitmap dimensions</a> for the context's <a>output bitmap</a> to |width| and |height|.
415
- 3. Set the {{PaintRenderingContext2D}} 's <a>alpha</a> flag to |alpha|.
425
+ 3. Set the {{PaintRenderingContext2D}} 's <a>alpha</a> flag to |paintRenderingContext2DSettings. alpha|.
416
426
4. Return the new {{PaintRenderingContext2D}} .
417
427
418
428
Note: The initial state of the rendering context is set inside the <a>set bitmap dimensions</a>
@@ -609,7 +619,8 @@ When the user agent wants to <dfn>invoke a paint callback</dfn> given |name|, |i
609
619
8. Let |renderingContext| be the result of <a>create a PaintRenderingContext2D object</a> given:
610
620
- "width" - The width given by |concreteObjectSize|.
611
621
- "height" - The height given by |concreteObjectSize|.
612
- - "alpha" - The <a for="paint definition">context alpha flag</a> given by |definition|.
622
+ - "paintRenderingContext2DSettings" - The
623
+ <a for="paint definition">PaintRenderingContext2DSettings object</a> given by |definition|.
613
624
614
625
Note: The |renderingContext| is not be re-used between invocations of paint. Implicitly this
615
626
means that there is no stored data, or state on the |renderingContext| between
0 commit comments