[webkit-reviews] review granted: [Bug 190697] Add new image type for CSS painting API : [Attachment 352710] Patch

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Oct 18 16:13:33 PDT 2018


Dean Jackson <dino at apple.com> has granted Justin Michaud
<justin_michaud at apple.com>'s request for review:
Bug 190697: Add new image type for CSS painting API
https://bugs.webkit.org/show_bug.cgi?id=190697

Attachment 352710: Patch

https://bugs.webkit.org/attachment.cgi?id=352710&action=review




--- Comment #3 from Dean Jackson <dino at apple.com> ---
Comment on attachment 352710
  --> https://bugs.webkit.org/attachment.cgi?id=352710
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=352710&action=review

> Source/WebCore/platform/graphics/CustomPaintImage.cpp:76
> +    auto canvas = OffscreenCanvas::create(*scriptExecutionContext,
destSize.width(), destSize.height());
> +    ExceptionOr<OffscreenRenderingContext> contextOrException =
canvas->getContext(*execState, OffscreenCanvas::RenderingContextType::Webgl, {
});
> +
> +    if (contextOrException.hasException())
> +	   return ImageDrawResult::DidNothing;
> +    auto context = contextOrException.releaseReturnValue();
> +
> +    context->clearColor(0, 0, 0, 1.0);
> +    context->clear(GL_COLOR_BUFFER_BIT);
> +
> +    auto result = m_paintCallback->handleEvent(*context);
> +    if (result.type() != CallbackResultType::Success)
> +	   return ImageDrawResult::DidNothing;
> +
> +    auto bitmap = canvas->transferToImageBitmap();
> +    if (!bitmap)
> +	   return ImageDrawResult::DidNothing;
> +
> +    destContext.drawImage(*bitmap->buffer()->copyImage(), FloatPoint());

This will work fine but will be too slow in practice, since
transferToImageBitmap is a GPU readback. However, it's a good place to start.

Ultimately I don't expect we'll want to support WebGL initially - only 2d
contexts. It's a bit scary to think that any element on a page could require a
WebGL canvas/context.


More information about the webkit-reviews mailing list