Changeset 238839 in webkit


Ignore:
Timestamp:
Dec 3, 2018 8:03:13 PM (5 years ago)
Author:
Justin Michaud
Message:

CSS Painting API should scale display list when drawing
https://bugs.webkit.org/show_bug.cgi?id=192217

Reviewed by Simon Fraser.

Source/WebCore:

When we replay the display list, fix the scaling. The separate buffer is needed to make sure that globalCompositeOperation functions correctly.

  • html/CustomPaintCanvas.cpp:

(WebCore::CustomPaintCanvas::replayDisplayList const):

  • html/CustomPaintCanvas.h:
  • platform/graphics/CustomPaintImage.cpp:

(WebCore::CustomPaintImage::doCustomPaint):

LayoutTests:

  • fast/css-custom-paint/properties-expected.html:
  • fast/css-custom-paint/registerPaintBindings-expected.html:
  • fast/css-custom-paint/simple-hidpi-expected.html: Added.
  • fast/css-custom-paint/simple-hidpi.html: Added.
  • fast/css-custom-paint/worklet-expected.html:
Location:
trunk
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r238838 r238839  
     12018-12-03  Justin Michaud  <justin_michaud@apple.com>
     2
     3        CSS Painting API should scale display list when drawing
     4        https://bugs.webkit.org/show_bug.cgi?id=192217
     5
     6        Reviewed by Simon Fraser.
     7
     8        * fast/css-custom-paint/properties-expected.html:
     9        * fast/css-custom-paint/registerPaintBindings-expected.html:
     10        * fast/css-custom-paint/simple-hidpi-expected.html: Added.
     11        * fast/css-custom-paint/simple-hidpi.html: Added.
     12        * fast/css-custom-paint/worklet-expected.html:
     13
    1142018-12-03  Myles C. Maxfield  <mmaxfield@apple.com>
    215
  • trunk/LayoutTests/fast/css-custom-paint/properties-expected.html

    r237981 r238839  
    77</style>
    88
    9 <canvas id="paint" width="150px" height="150px" ></canvas>
    10 <canvas id="paint2" width="150px" height="150px" ></canvas>
     9<canvas id="paint" style="width: 150px; height: 150px;" ></canvas>
     10<canvas id="paint2" style="width: 150px; height: 150px;" ></canvas>
    1111
    1212<script id="code">
    1313for (canvasID of ['paint', 'paint2']) {
    14   var canvas = document.getElementById(canvasID);
    15   var ctx = canvas.getContext('2d');
     14  const canvas = document.getElementById(canvasID);
     15  canvas.width = 150 * window.devicePixelRatio;
     16  canvas.height = 150 * window.devicePixelRatio;
     17
     18  const ctx = canvas.getContext('2d');
     19  ctx.scale(window.devicePixelRatio, window.devicePixelRatio);
    1620
    1721  for (var i = 0; i < 6; i++){
  • trunk/LayoutTests/fast/css-custom-paint/registerPaintBindings-expected.html

    r237766 r238839  
    11<!DOCTYPE html><!-- webkit-test-runner [ experimental:CSSPaintingAPIEnabled=true ] -->
    22
    3 <canvas id="paint" width="150px" height="150px" ></canvas>
     3<canvas id="paint" style="width: 150px; height: 150px;" ></canvas>
    44
    55<script id="code">
    6 var canvas = document.getElementById('paint');
    7 var ctx = canvas.getContext('2d');
     6const canvas = document.getElementById('paint');
     7canvas.width = 150 * window.devicePixelRatio;
     8canvas.height = 150 * window.devicePixelRatio;
     9
     10const ctx = canvas.getContext('2d');
     11ctx.scale(window.devicePixelRatio, window.devicePixelRatio);
    812
    913for (var i = 0; i < 6; i++){
  • trunk/LayoutTests/fast/css-custom-paint/worklet-expected.html

    r237766 r238839  
    11<!DOCTYPE html><!-- webkit-test-runner [ experimental:CSSPaintingAPIEnabled=true ] -->
    22
    3 <canvas id="paint" width="150px" height="150px" ></canvas>
     3<canvas id="paint" style="width: 150px; height: 150px;" ></canvas>
    44
    55<script id="code">
    6 var canvas = document.getElementById('paint');
    7 var ctx = canvas.getContext('2d');
     6const canvas = document.getElementById('paint');
     7canvas.width = 150 * window.devicePixelRatio;
     8canvas.height = 150 * window.devicePixelRatio;
     9
     10const ctx = canvas.getContext('2d');
     11ctx.scale(window.devicePixelRatio, window.devicePixelRatio);
    812
    913for (var i = 0; i < 6; i++){
  • trunk/Source/WebCore/ChangeLog

    r238838 r238839  
     12018-12-03  Justin Michaud  <justin_michaud@apple.com>
     2
     3        CSS Painting API should scale display list when drawing
     4        https://bugs.webkit.org/show_bug.cgi?id=192217
     5
     6        Reviewed by Simon Fraser.
     7
     8        When we replay the display list, fix the scaling. The separate buffer is needed to make sure that globalCompositeOperation functions correctly.
     9
     10        * html/CustomPaintCanvas.cpp:
     11        (WebCore::CustomPaintCanvas::replayDisplayList const):
     12        * html/CustomPaintCanvas.h:
     13        * platform/graphics/CustomPaintImage.cpp:
     14        (WebCore::CustomPaintImage::doCustomPaint):
     15
    1162018-12-03  Myles C. Maxfield  <mmaxfield@apple.com>
    217
  • trunk/Source/WebCore/html/CustomPaintCanvas.cpp

    r237409 r238839  
    9494}
    9595
     96void CustomPaintCanvas::replayDisplayList(GraphicsContext* ctx) const
     97{
     98    ASSERT(!m_destinationGraphicsContext);
     99    if (!width() || !height())
     100        return;
     101
     102    // FIXME: Using an intermediate buffer is not needed if there are no composite operations.
     103    auto clipBounds = ctx->clipBounds();
     104
     105    auto image = ImageBuffer::createCompatibleBuffer(clipBounds.size(), *ctx);
     106    if (!image)
     107        return;
     108
     109    m_destinationGraphicsContext = &image->context();
     110    m_destinationGraphicsContext->translate(-clipBounds.location());
     111    if (m_context)
     112        m_context->paintRenderingResultsToCanvas();
     113    m_destinationGraphicsContext = nullptr;
     114
     115    ctx->drawImageBuffer(*image, clipBounds);
     116}
     117
    96118Image* CustomPaintCanvas::copiedImage() const
    97119{
  • trunk/Source/WebCore/html/CustomPaintCanvas.h

    r237344 r238839  
    7171    AffineTransform baseTransform() const final { ASSERT(m_destinationGraphicsContext && m_copiedBuffer); return m_copiedBuffer->baseTransform(); }
    7272    Image* copiedImage() const final;
     73    void replayDisplayList(GraphicsContext*) const;
    7374
    7475    using RefCounted::ref;
  • trunk/Source/WebCore/platform/graphics/CustomPaintImage.cpp

    r238686 r238839  
    130130        return ImageDrawResult::DidNothing;
    131131
    132     auto image = canvas->copiedImage();
    133     if (!image)
    134         return ImageDrawResult::DidNothing;
    135 
    136     destContext.drawImage(*image, FloatPoint());
     132    canvas->replayDisplayList(&destContext);
    137133
    138134    return ImageDrawResult::DidDraw;
Note: See TracChangeset for help on using the changeset viewer.