OLD | NEW |
---|---|
(Empty) | |
1 # CSS Paint API | |
2 | |
3 This directory contains the implementation of the CSS Paint API. | |
4 | |
5 See [CSS Paint API](https://drafts.css-houdini.org/css-paint-api/) for the web e xposed APIs this | |
6 implements. | |
7 | |
8 ## Implementation | |
9 | |
10 ### [CSSPaintDefinition](CSSPaintDefinition.h) | |
11 | |
12 Represents a class registered by the author through `PaintWorkletGlobalScope#reg isterPaint`. | |
13 Specifically this class holds onto the javascript constructor and paint function s of the class via | |
14 persistent handles. This class keeps these functions alive so they don't get gar bage collected. | |
15 | |
16 The `CSSPaintDefinition` also holds onto an instance of the paint class va a per sistent handle. This | |
17 instance is lazily creating upon first use. If the constructor throws for some r eason the | |
chrishtr
2016/04/25 23:07:19
s/creating/created/
ikilpatrick
2016/04/26 16:57:41
Done.
| |
18 constructor is marked as invalid and will always produce invalid images. | |
chrishtr
2016/04/25 23:07:19
Is this per spec? I guess there are arguments both
ikilpatrick
2016/04/26 16:57:41
Going to bring this behaviour up at the next F2F.
| |
19 | |
20 The `PaintWorkletGlobalScope` has a map of paint `name` to `CSSPaintDefinition`. | |
21 | |
22 ### [CSSPaintImageGenerator][generator] and [CSSPaintImageGeneratorImpl][generat or-impl] | |
23 | |
24 `CSSPaintImageGenerator` represents the interface from which the `CSSPaintValue` can generate | |
25 `Image`s from. This is done via the `CSSPaintImageGenerator#paint` method. Each `CSSPaintValue` | |
chrishtr
2016/04/25 23:07:19
remove 'from'
ikilpatrick
2016/04/26 16:57:41
Done.
| |
26 owns a separate instance of `CSSPaintImageGenerator`. | |
27 | |
28 `CSSPaintImageGeneratorImpl` is the implementation which lives in `modules/csspa int`. (We have this | |
29 interface / implementation split as `core/` cannot depend on `modules/`). | |
30 | |
31 When created the generator will access paint worklet and lookup it's correspondi ng | |
chrishtr
2016/04/25 23:07:19
access its paint worklet
ikilpatrick
2016/04/26 16:57:41
Done.
| |
32 `CSSPaintDefinition` via `PaintWorkletGlobalScope#findDefinition`. | |
33 | |
34 If the paint worklet does not have a `CSSPaintDefinition` matching the paint `na me` the | |
35 `CSSPaintImageGeneratorImpl` is placed in a "pending" map. Once a paint class wi th `name` is | |
36 registered the generator is notified so it can invalidate an display the correct image. | |
37 | |
38 [generator]: ../../core/css/CSSPaintImageGenerator.h | |
39 [generator-impl]: CSSPaintImageGeneratorImpl.h | |
40 [paint-value]: ../../core/css/CSSPaintValue.h | |
41 | |
42 ### Generating a [PaintGeneratedImage](../../platform/graphics/PaintGeneratedIma ge.h) | |
43 | |
44 `PaintGeneratedImage` is a `Image` which just paints a single `SkPicture`. | |
45 | |
46 A `CSSPaintValue` can generate an image from the method `CSSPaintImageGenerator# paint`. This method | |
47 calls through to `CSSPaintDefinition#paint` which actually invokes the javascrip t paint method. | |
48 This method returns the `PaintGeneratedImage`. | |
49 | |
50 The `SkPicture` is produced from a `RecordingImageBufferSurface`. | |
51 | |
52 ## Testing | |
53 | |
54 Tests live [here](../../../LayoutTests/csspaint/). | |
55 | |
OLD | NEW |