Chromium Code Reviews| Index: third_party/WebKit/Source/modules/csspaint/README.md |
| diff --git a/third_party/WebKit/Source/modules/csspaint/README.md b/third_party/WebKit/Source/modules/csspaint/README.md |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d790c42bbed2199259c5c14e4ac3302b89c9bda7 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/modules/csspaint/README.md |
| @@ -0,0 +1,55 @@ |
| +# CSS Paint API |
| + |
| +This directory contains the implementation of the CSS Paint API. |
| + |
| +See [CSS Paint API](https://drafts.css-houdini.org/css-paint-api/) for the web exposed APIs this |
| +implements. |
| + |
| +## Implementation |
| + |
| +### [CSSPaintDefinition](CSSPaintDefinition.h) |
| + |
| +Represents a class registered by the author through `PaintWorkletGlobalScope#registerPaint`. |
| +Specifically this class holds onto the javascript constructor and paint functions of the class via |
| +persistent handles. This class keeps these functions alive so they don't get garbage collected. |
| + |
| +The `CSSPaintDefinition` also holds onto an instance of the paint class va a persistent handle. This |
| +instance is lazily creating upon first use. If the constructor throws for some reason the |
|
chrishtr
2016/04/25 23:07:19
s/creating/created/
ikilpatrick
2016/04/26 16:57:41
Done.
|
| +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.
|
| + |
| +The `PaintWorkletGlobalScope` has a map of paint `name` to `CSSPaintDefinition`. |
| + |
| +### [CSSPaintImageGenerator][generator] and [CSSPaintImageGeneratorImpl][generator-impl] |
| + |
| +`CSSPaintImageGenerator` represents the interface from which the `CSSPaintValue` can generate |
| +`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.
|
| +owns a separate instance of `CSSPaintImageGenerator`. |
| + |
| +`CSSPaintImageGeneratorImpl` is the implementation which lives in `modules/csspaint`. (We have this |
| +interface / implementation split as `core/` cannot depend on `modules/`). |
| + |
| +When created the generator will access paint worklet and lookup it's corresponding |
|
chrishtr
2016/04/25 23:07:19
access its paint worklet
ikilpatrick
2016/04/26 16:57:41
Done.
|
| +`CSSPaintDefinition` via `PaintWorkletGlobalScope#findDefinition`. |
| + |
| +If the paint worklet does not have a `CSSPaintDefinition` matching the paint `name` the |
| +`CSSPaintImageGeneratorImpl` is placed in a "pending" map. Once a paint class with `name` is |
| +registered the generator is notified so it can invalidate an display the correct image. |
| + |
| +[generator]: ../../core/css/CSSPaintImageGenerator.h |
| +[generator-impl]: CSSPaintImageGeneratorImpl.h |
| +[paint-value]: ../../core/css/CSSPaintValue.h |
| + |
| +### Generating a [PaintGeneratedImage](../../platform/graphics/PaintGeneratedImage.h) |
| + |
| +`PaintGeneratedImage` is a `Image` which just paints a single `SkPicture`. |
| + |
| +A `CSSPaintValue` can generate an image from the method `CSSPaintImageGenerator#paint`. This method |
| +calls through to `CSSPaintDefinition#paint` which actually invokes the javascript paint method. |
| +This method returns the `PaintGeneratedImage`. |
| + |
| +The `SkPicture` is produced from a `RecordingImageBufferSurface`. |
| + |
| +## Testing |
| + |
| +Tests live [here](../../../LayoutTests/csspaint/). |
| + |