Changeset 166746 in webkit


Ignore:
Timestamp:
Apr 3, 2014 2:44:54 PM (10 years ago)
Author:
krit@webkit.org
Message:

[CG] Canvas lineDashOffset does not handle negative numbers correctly
https://bugs.webkit.org/show_bug.cgi?id=80560

Reviewed by Dean Jackson.

Source/WebCore:

CG ignores negative dash array offsets. Check if we have a negative offset, if yes
then calculate the length of the dash array and modulo the dash array offset with
the dash array length.

Test: fast/canvas/canvas-negative-lineDashOffset.html

  • platform/graphics/cg/GraphicsContextCG.cpp:

(WebCore::GraphicsContext::setLineDash):

LayoutTests:

Test correct rendering of negative offset for Canvas dash arrays.

  • fast/canvas/canvas-negative-lineDashOffset-expected.txt: Added.
  • fast/canvas/canvas-negative-lineDashOffset.html: Added.
  • fast/canvas/script-tests/canvas-negative-lineDashOffset.js: Added.

(dataToArray):
(getPixel):
(pixelShouldBe):

Location:
trunk
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r166736 r166746  
     12014-04-03  Dirk Schulze  <krit@webkit.org>
     2
     3        [CG] Canvas lineDashOffset does not handle negative numbers correctly
     4        https://bugs.webkit.org/show_bug.cgi?id=80560
     5
     6        Reviewed by Dean Jackson.
     7
     8        Test correct rendering of negative offset for Canvas dash arrays.
     9
     10        * fast/canvas/canvas-negative-lineDashOffset-expected.txt: Added.
     11        * fast/canvas/canvas-negative-lineDashOffset.html: Added.
     12        * fast/canvas/script-tests/canvas-negative-lineDashOffset.js: Added.
     13        (dataToArray):
     14        (getPixel):
     15        (pixelShouldBe):
     16
    1172014-04-03  David Hyatt  <hyatt@apple.com>
    218
  • trunk/Source/WebCore/ChangeLog

    r166745 r166746  
     12014-04-03  Dirk Schulze  <krit@webkit.org>
     2
     3        [CG] Canvas lineDashOffset does not handle negative numbers correctly
     4        https://bugs.webkit.org/show_bug.cgi?id=80560
     5
     6        Reviewed by Dean Jackson.
     7
     8        CG ignores negative dash array offsets. Check if we have a negative offset, if yes
     9        then calculate the length of the dash array and modulo the dash array offset with
     10        the dash array length.
     11
     12        Test: fast/canvas/canvas-negative-lineDashOffset.html
     13
     14        * platform/graphics/cg/GraphicsContextCG.cpp:
     15        (WebCore::GraphicsContext::setLineDash):
     16
    1172014-04-03  David Hyatt  <hyatt@apple.com>
    218
  • trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp

    r166100 r166746  
    11841184void GraphicsContext::setLineDash(const DashArray& dashes, float dashOffset)
    11851185{
     1186    if (dashOffset < 0) {
     1187        float length = 0;
     1188        for (size_t i = 0; i < dashes.size(); ++i)
     1189            length += static_cast<float>(dashes[i]);
     1190        if (length)
     1191            dashOffset = fmod(dashOffset, length) + length;
     1192    }
    11861193    CGContextSetLineDash(platformContext(), dashOffset, dashes.data(), dashes.size());
    11871194}
Note: See TracChangeset for help on using the changeset viewer.