Changeset 60911 in webkit


Ignore:
Timestamp:
Jun 9, 2010 2:02:47 PM (14 years ago)
Author:
jchaffraix@webkit.org
Message:

WebCore: Fix drawing zero-sized gradients on Canvas.
https://bugs.webkit.org/show_bug.cgi?id=40340

Patch by Enrico Ros <eros@codeaurora.org> on 2010-06-09
Reviewed by Ariya Hidayat.

HTML5 draft says that nothing must be painted if the gradient start
point equals the stop point.

This commit fixes the following canvas test:
http://philip.html5.org/tests/canvas/suite/tests/2d.gradient.interpolate.zerosize.html

  • html/canvas/CanvasRenderingContext2D.cpp:

(WebCore::CanvasRenderingContext2D::fillRect): skip zero-sized linear gradients

  • platform/graphics/Gradient.h:

(WebCore::Gradient::isRadial): made public
(WebCore::Gradient::isZeroSize): true if start == stop

LayoutTests: Fixed zero-sized gradients on canvas.
https://bugs.webkit.org/show_bug.cgi?id=40340

Patch by Enrico Ros <eros@codeaurora.org> on 2010-06-09
Reviewed by Ariya Hidayat.

  • platform/mac/Skipped: Unskip the test that is passing now.
  • platform/qt/Skipped: Unskip the test that is passing now.
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r60902 r60911  
     12010-06-09  Enrico Ros  <eros@codeaurora.org>
     2
     3        Reviewed by Ariya Hidayat.
     4
     5        Fixed zero-sized gradients on canvas.
     6        https://bugs.webkit.org/show_bug.cgi?id=40340
     7
     8        * platform/mac/Skipped: Unskip the test that is passing now.
     9        * platform/qt/Skipped: Unskip the test that is passing now.
     10
    1112010-06-09  Kenneth Russell  <kbr@google.com>
    212
  • trunk/LayoutTests/platform/mac/Skipped

    r60822 r60911  
    213213canvas/philip/tests/2d.fillStyle.parse.rgb-clamp-5.html
    214214canvas/philip/tests/2d.fillStyle.parse.system.html
    215 canvas/philip/tests/2d.gradient.interpolate.zerosize.html
    216215canvas/philip/tests/2d.gradient.radial.cone.front.html
    217216canvas/philip/tests/2d.gradient.radial.cone.top.html
  • trunk/LayoutTests/platform/qt/Skipped

    r60890 r60911  
    52865286canvas/philip/tests/2d.fillStyle.parse.system.html
    52875287canvas/philip/tests/2d.gradient.interpolate.colouralpha.html
    5288 canvas/philip/tests/2d.gradient.interpolate.zerosize.html
    52895288canvas/philip/tests/2d.gradient.radial.cone.behind.html
    52905289canvas/philip/tests/2d.gradient.radial.cone.beside.html
  • trunk/WebCore/ChangeLog

    r60909 r60911  
     12010-06-09  Enrico Ros  <eros@codeaurora.org>
     2
     3        Reviewed by Ariya Hidayat.
     4
     5        Fix drawing zero-sized gradients on Canvas.
     6        https://bugs.webkit.org/show_bug.cgi?id=40340
     7
     8        HTML5 draft says that nothing must be painted if the gradient start
     9        point equals the stop point.
     10
     11        This commit fixes the following canvas test:
     12        http://philip.html5.org/tests/canvas/suite/tests/2d.gradient.interpolate.zerosize.html
     13
     14        * html/canvas/CanvasRenderingContext2D.cpp:
     15        (WebCore::CanvasRenderingContext2D::fillRect): skip zero-sized linear gradients
     16        * platform/graphics/Gradient.h:
     17        (WebCore::Gradient::isRadial): made public
     18        (WebCore::Gradient::isZeroSize): true if start == stop
     19
    1202010-06-09  Leandro Pereira  <leandro@profusion.mobi>
    221
  • trunk/WebCore/html/canvas/CanvasRenderingContext2D.cpp

    r60731 r60911  
    754754        return;
    755755
     756    // from the HTML5 Canvas spec:
     757    // If x0 = x1 and y0 = y1, then the linear gradient must paint nothing
     758    Gradient* gradient = c->fillGradient();
     759    if (gradient && gradient->isZeroSize() && !gradient->isRadial())
     760        return;
     761
    756762    FloatRect rect(x, y, width, height);
    757763    willDraw(rect);
  • trunk/WebCore/platform/graphics/Gradient.h

    r58212 r60911  
    8989        void getColor(float value, float* r, float* g, float* b, float* a) const;
    9090
     91        bool isRadial() const { return m_radial; }
     92        bool isZeroSize() const { return m_p0.x() == m_p1.x() && m_p0.y() == m_p1.y(); }
     93
    9194#if OS(WINCE) && !PLATFORM(QT)
    9295        const FloatPoint& p0() const { return m_p0; }
     
    9497        float r0() const { return m_r0; }
    9598        float r1() const { return m_r1; }
    96         bool isRadial() const { return m_radial; }
    9799        const Vector<ColorStop>& getStops() const;
    98100#else
Note: See TracChangeset for help on using the changeset viewer.