@@ -114,6 +114,7 @@ interface PaintWorkletGlobalScope : WorkletGlobalScope {
114
114
<pre class='lang-javascript'>
115
115
class MyPaint {
116
116
static get inputProperties() { return ['--foo'] ; }
117
+ static get alpha() { return true; }
117
118
paint(ctx, size, styleMap) {
118
119
// Paint code goes here.
119
120
}
@@ -135,6 +136,8 @@ the <<paint()>> function. It consists of:
135
136
136
137
- A <dfn>paint constructor valid flag</dfn> .
137
138
139
+ - A <dfn>paint context alpha flag</dfn> .
140
+
138
141
Registering Custom Paint {#registering-custom-paint}
139
142
====================================================
140
143
@@ -177,20 +180,32 @@ called, the user agent <em>must</em> run the following steps:
177
180
can also contains currently invalid properties for the user agent. For example
178
181
<code> margin-bikeshed-property</code> .
179
182
180
- 5. If the result of <a>IsConstructor</a> (|paintCtor|) is false, <a>throw</a> a <a>TypeError</a>
183
+ 5. Let |alphaValue| be the result of <a>Get</a> (|paintCtor|, "alpha").
184
+
185
+ 6. If |alphaValue| is not undefined and the result of <a>Type</a> (|alpha|) is not Boolean,
186
+ <a>throw</a> a <a>TypeError</a> and abort all these steps.
187
+
188
+ 7. Let |alpha| be <code> true</code> if |alphaValue| is undefined, otherwise let it be the value
189
+ of |alphaValue|.
190
+
191
+ Note: Setting <code> alpha</code> is <code> false</code> allows user agents to anti-alias text
192
+ an addition to performing "visibility" optimizations, e.g. not painting an image behind
193
+ the paint image as the paint image is opaque.
194
+
195
+ 8. If the result of <a>IsConstructor</a> (|paintCtor|) is false, <a>throw</a> a <a>TypeError</a>
181
196
and abort all these steps.
182
197
183
- 6 . Let |prototype| be the result of <a>Get</a> (|paintCtor|, "prototype").
198
+ 9 . Let |prototype| be the result of <a>Get</a> (|paintCtor|, "prototype").
184
199
185
- 7 . If the result of <a>Type</a> (|prototype|) is not Object, <a>throw</a> a <a>TypeError</a> and
200
+ 10 . If the result of <a>Type</a> (|prototype|) is not Object, <a>throw</a> a <a>TypeError</a> and
186
201
abort all these steps.
187
202
188
- 8 . Let |paint| be the result of <a>Get</a> (|prototype|, "paint").
203
+ 11 . Let |paint| be the result of <a>Get</a> (|prototype|, "paint").
189
204
190
- 9 . If the result of <a>IsCallable</a> (|paint|) is false, <a>throw</a> a <a>TypeError</a> and
205
+ 12 . If the result of <a>IsCallable</a> (|paint|) is false, <a>throw</a> a <a>TypeError</a> and
191
206
abort all these steps.
192
207
193
- 10 . Let |definition| be a new <a>paint image definition</a> with:
208
+ 13 . Let |definition| be a new <a>paint image definition</a> with:
194
209
195
210
- <a>paint image name</a> being |name|
196
211
@@ -199,11 +214,13 @@ called, the user agent <em>must</em> run the following steps:
199
214
- <a>paint function</a> being |paint|
200
215
201
216
- <a>paint constructor valid flag</a> being true
217
+
218
+ - <a>paint context alpha flag</a> being |alpha|.
202
219
203
- 11 . Add the key-value pair (|name| - |inputProperties|) to the <a>paint name to input properties
220
+ 14 . Add the key-value pair (|name| - |inputProperties|) to the <a>paint name to input properties
204
221
map</a> of the associated <a>document</a> .
205
222
206
- 12 . Add the key-value pair (|name| - |definition|) to the <a>paint name to paint image
223
+ 15 . Add the key-value pair (|name| - |definition|) to the <a>paint name to paint image
207
224
definition map</a> of the associated <a>document</a> .
208
225
209
226
@@ -269,19 +286,17 @@ that the user agent will use internally or during rendering. For example, if the
269
286
zoomed the user agent may internally use bitmaps which correspond to the number of device pixels in
270
287
the coordinate space, so that the resulting rendering is of high quality.
271
288
272
- The {{PaintRenderingContext2D}} object should have its <a>alpha</a> flag set to true. That is the
273
- rendering context is initially fully transparent.
274
-
275
289
Additionally the user agent may record the sequence of drawing operations which have been applied to
276
290
the <a>output bitmap</a> such that the user agent can subsequently draw onto a device bitmap at the
277
291
correct resolution. This also allows user agents to re-use the same output of the <a>output
278
292
bitmap</a> repeatably while the visual viewport is being zoomed for example.
279
293
280
294
When the user agent is to <dfn>create a PaintRenderingContext2D object</dfn> for a given |width|,
281
- |height| it <em> must</em> run the following steps:
295
+ |height| and |alpha| it <em> must</em> run the following steps:
282
296
1. Create a new {{PaintRenderingContext2D}} .
283
297
2. <a>Set bitmap dimensions</a> for the context's <a>output bitmap</a> to |width| and |height|.
284
- 3. Return the new {{PaintRenderingContext2D}} .
298
+ 3. Set the {{PaintRenderingContext2D}} 's <a>alpha</a> flag to |alpha|.
299
+ 4. Return the new {{PaintRenderingContext2D}} .
285
300
286
301
Note: The initial state of the rendering context is set inside the <a>set bitmap dimensions</a>
287
302
algorithm, as it invokes <a>reset the rendering context to its default state</a> and clears the
@@ -387,6 +402,7 @@ following steps:
387
402
9. Let |renderingContext| be the result of <a>create a PaintRenderingContext2D object</a> given:
388
403
- "width" - The width given by |concreteObjectSize|.
389
404
- "height" - The height given by |concreteObjectSize|.
405
+ - "alpha" - The <a>paint context alpha flag</a> given by |definition|.
390
406
391
407
Note: The |renderingContext| must not be re-used between invocations of paint. Implicitly
392
408
this means that there is no stored data, or state on the |renderingContext| between
0 commit comments