Changeset 141456 in webkit


Ignore:
Timestamp:
Jan 31, 2013 11:46:50 AM (11 years ago)
Author:
krit@webkit.org
Message:

[canvas] Implement currentPath to get and set the current path of the context
https://bugs.webkit.org/show_bug.cgi?id=108246

Patch by Dirk Schulze <krit@webkit.org> on 2013-01-31
Reviewed by Dean Jackson.

Source/WebCore:

Add currentPath attribute to CanvasRenderingContext2d interface. This allows
setting the current context path by an existing Path object as well as getting
the current context path as new Path object. The returned and the set Paths
are not live.

This feature is behind the CANVAS_PATH compiler flag which is disabled by
default for now.

Test: fast/canvas/canvas-currentPath.html

  • html/canvas/CanvasPathMethods.cpp: Rename transformIsInvertible to

isTransformInvertible for harmonizing naming schema.

(WebCore::CanvasPathMethods::moveTo): Ditto.
(WebCore::CanvasPathMethods::lineTo): Ditto.
(WebCore::CanvasPathMethods::quadraticCurveTo): Ditto.
(WebCore::CanvasPathMethods::bezierCurveTo): Ditto.
(WebCore::CanvasPathMethods::arcTo): Ditto.
(WebCore::CanvasPathMethods::arc): Ditto.
(WebCore::CanvasPathMethods::rect): Ditto.

  • html/canvas/CanvasPathMethods.h: Ditto.

(CanvasPathMethods):
(WebCore::CanvasPathMethods::isTransformInvertible):

  • html/canvas/CanvasRenderingContext2D.cpp:

(WebCore):
(WebCore::CanvasRenderingContext2D::currentPath): Getter for currentPath.
(WebCore::CanvasRenderingContext2D::setCurrentPath): Setter for currentPath.

  • html/canvas/CanvasRenderingContext2D.h:

(WebCore):
(CanvasRenderingContext2D):
(WebCore::CanvasRenderingContext2D::isTransformInvertible):

  • html/canvas/CanvasRenderingContext2D.idl: Add currentPath attribute.
  • html/canvas/DOMPath.h: Add new constructor and getter for Path object.

(WebCore::DOMPath::create): New static function for new ctor.
(DOMPath):
(WebCore::DOMPath::path): Getter for Path object.
(WebCore::DOMPath::DOMPath):

LayoutTests:

Added tests for canvas.currentPath in various combinations of the context state.

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

(testPointCollection):

  • platform/chromium/TestExpectations: Skip test until enabling CANVAS_PATH.
  • platform/efl/TestExpectations: Ditto.
  • platform/gtk/TestExpectations: Ditto.
  • platform/mac/TestExpectations: Ditto.
  • platform/qt/TestExpectations: Ditto.
Location:
trunk
Files:
3 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r141449 r141456  
     12013-01-31  Dirk Schulze  <krit@webkit.org>
     2
     3        [canvas] Implement currentPath to get and set the current path of the context
     4        https://bugs.webkit.org/show_bug.cgi?id=108246
     5
     6        Reviewed by Dean Jackson.
     7
     8        Added tests for canvas.currentPath in various combinations of the context state.
     9
     10        * fast/canvas/canvas-currentPath-expected.txt: Added.
     11        * fast/canvas/canvas-currentPath.html: Added.
     12        * fast/canvas/script-tests/canvas-currentPath.js: Added.
     13        (testPointCollection):
     14        * platform/chromium/TestExpectations: Skip test until enabling CANVAS_PATH.
     15        * platform/efl/TestExpectations: Ditto.
     16        * platform/gtk/TestExpectations: Ditto.
     17        * platform/mac/TestExpectations: Ditto.
     18        * platform/qt/TestExpectations: Ditto.
     19
    1202013-01-31  Tony Chang  <tony@chromium.org>
    221
  • trunk/LayoutTests/platform/chromium/TestExpectations

    r141449 r141456  
    42544254webkit.org/b/107508 platform/chromium/fast/forms/calendar-picker/calendar-picker-appearance-step.html [ ImageOnlyFailure Pass ]
    42554255webkit.org/b/107508 platform/chromium/fast/forms/calendar-picker/calendar-picker-appearance.html [ ImageOnlyFailure Pass ]
    4256                    
     4256
     4257# Rebaseline after currentPath
     4258webkit.org/b/108246 fast/canvas/canvas-currentPath.html [ Failure ]
     4259webkit.org/b/108246 platform/chromium/virtual/gpu/fast/canvas/canvas-currentPath.html [ Failure ]
     4260
    42574261# Broken by Skia flag changes in r139445
    42584262crbug.com/169550 [ Debug ] fast/lists/big-list-marker.html [ Crash ]
  • trunk/LayoutTests/platform/efl/TestExpectations

    r141439 r141456  
    18111811inspector/editor/text-editor-ctrl-movements.html
    18121812
     1813# Remove from list after enabling CANVAS_PATH
     1814webkit.org/b/108508 fast/canvas/canvas-currentPath.html [ Failure ]
     1815
    18131816# Test fails on JSC platforms due to GC timing problems
    18141817webkit.org/b/106957 svg/dom/SVGViewSpec-invalid-ref-crash.html [ Failure ]
  • trunk/LayoutTests/platform/gtk/TestExpectations

    r141434 r141456  
    13701370webkit.org/b/103740 editing/selection/caret-alignment-for-vertical-text.html [ Failure ]
    13711371
     1372# Remove from list after enabling CANVAS_PATH
     1373webkit.org/b/108508 fast/canvas/canvas-currentPath.html [ Failure ]
     1374
    13721375# volume is reset when mediaelement.src is modified
    13731376webkit.org/b/103893 media/video-volume.html [ Failure ]
  • trunk/LayoutTests/platform/mac/TestExpectations

    r141418 r141456  
    140140http/tests/security/cross-origin-worker-indexeddb-allowed.html
    141141http/tests/security/cross-origin-worker-indexeddb.html
     142
     143# Remove from list after enabling CANVAS_PATH
     144fast/canvas/canvas-currentPath.html
    142145
    143146# This port doesn't support DeviceMotion or DeviceOrientation.
  • trunk/LayoutTests/platform/qt/TestExpectations

    r141423 r141456  
    9090# ENABLE_GAMEPAD not enabled.
    9191gamepad/
     92
     93# Remove from list after enabling CANVAS_PATH
     94fast/canvas/canvas-currentPath.html
    9295
    9396# ENABLE(INPUT_SPEECH) is disabled.
  • trunk/LayoutTests/platform/win/TestExpectations

    r141418 r141456  
    4444# Custom filters not yet supported on Windows
    4545css3/filters/custom
     46
     47# Remove from list after enabling CANVAS_PATH
     48fast/canvas/canvas-currentPath.html
    4649
    4750# Needs rebaseline after bug 97217 is fixed
  • trunk/Source/WebCore/ChangeLog

    r141450 r141456  
     12013-01-31  Dirk Schulze  <krit@webkit.org>
     2
     3        [canvas] Implement currentPath to get and set the current path of the context
     4        https://bugs.webkit.org/show_bug.cgi?id=108246
     5
     6        Reviewed by Dean Jackson.
     7
     8        Add currentPath attribute to CanvasRenderingContext2d interface. This allows
     9        setting the current context path by an existing Path object as well as getting
     10        the current context path as new Path object. The returned and the set Paths
     11        are not live.
     12
     13        This feature is behind the CANVAS_PATH compiler flag which is disabled by
     14        default for now.
     15
     16        Test: fast/canvas/canvas-currentPath.html
     17
     18        * html/canvas/CanvasPathMethods.cpp: Rename transformIsInvertible to
     19            isTransformInvertible for harmonizing naming schema.
     20        (WebCore::CanvasPathMethods::moveTo): Ditto.
     21        (WebCore::CanvasPathMethods::lineTo): Ditto.
     22        (WebCore::CanvasPathMethods::quadraticCurveTo): Ditto.
     23        (WebCore::CanvasPathMethods::bezierCurveTo): Ditto.
     24        (WebCore::CanvasPathMethods::arcTo): Ditto.
     25        (WebCore::CanvasPathMethods::arc): Ditto.
     26        (WebCore::CanvasPathMethods::rect): Ditto.
     27        * html/canvas/CanvasPathMethods.h: Ditto.
     28        (CanvasPathMethods):
     29        (WebCore::CanvasPathMethods::isTransformInvertible):
     30        * html/canvas/CanvasRenderingContext2D.cpp:
     31        (WebCore):
     32        (WebCore::CanvasRenderingContext2D::currentPath): Getter for currentPath.
     33        (WebCore::CanvasRenderingContext2D::setCurrentPath): Setter for currentPath.
     34        * html/canvas/CanvasRenderingContext2D.h:
     35        (WebCore):
     36        (CanvasRenderingContext2D):
     37        (WebCore::CanvasRenderingContext2D::isTransformInvertible):
     38        * html/canvas/CanvasRenderingContext2D.idl: Add currentPath attribute.
     39        * html/canvas/DOMPath.h: Add new constructor and getter for Path object.
     40        (WebCore::DOMPath::create): New static function for new ctor.
     41        (DOMPath):
     42        (WebCore::DOMPath::path): Getter for Path object.
     43        (WebCore::DOMPath::DOMPath):
     44
    1452013-01-31  Alexandre Elias  <aelias@chromium.org>
    246
  • trunk/Source/WebCore/html/canvas/CanvasPathMethods.cpp

    r140604 r141456  
    5656    if (!isfinite(x) || !isfinite(y))
    5757        return;
    58     if (!transformIsInvertible())
     58    if (!isTransformInvertible())
    5959        return;
    6060    m_path.moveTo(FloatPoint(x, y));
     
    6565    if (!isfinite(x) || !isfinite(y))
    6666        return;
    67     if (!transformIsInvertible())
     67    if (!isTransformInvertible())
    6868        return;
    6969
     
    7979    if (!isfinite(cpx) || !isfinite(cpy) || !isfinite(x) || !isfinite(y))
    8080        return;
    81     if (!transformIsInvertible())
     81    if (!isTransformInvertible())
    8282        return;
    8383    if (!m_path.hasCurrentPoint())
     
    9393    if (!isfinite(cp1x) || !isfinite(cp1y) || !isfinite(cp2x) || !isfinite(cp2y) || !isfinite(x) || !isfinite(y))
    9494        return;
    95     if (!transformIsInvertible())
     95    if (!isTransformInvertible())
    9696        return;
    9797    if (!m_path.hasCurrentPoint())
     
    114114    }
    115115
    116     if (!transformIsInvertible())
     116    if (!isTransformInvertible())
    117117        return;
    118118
     
    145145    }
    146146
    147     if (!transformIsInvertible())
     147    if (!isTransformInvertible())
    148148        return;
    149149
     
    163163void CanvasPathMethods::rect(float x, float y, float width, float height)
    164164{
    165     if (!transformIsInvertible())
     165    if (!isTransformInvertible())
    166166        return;
    167167
  • trunk/Source/WebCore/html/canvas/CanvasPathMethods.h

    r140604 r141456  
    5252    void arc(float x, float y, float r, float sa, float ea, bool anticlockwise, ExceptionCode&);
    5353    void rect(float x, float y, float width, float height);
    54    
    55     virtual bool transformIsInvertible() { return true; }
     54
     55    virtual bool isTransformInvertible() const { return true; }
    5656
    5757protected:
  • trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp

    r141141 r141456  
    4343#include "CanvasStyle.h"
    4444#include "Console.h"
     45#include "DOMPath.h"
    4546#include "ExceptionCode.h"
    4647#include "FloatConversion.h"
     
    859860}
    860861
     862#if ENABLE(CANVAS_PATH)
     863PassRefPtr<DOMPath> CanvasRenderingContext2D::currentPath()
     864{
     865    return DOMPath::create(m_path);
     866}
     867
     868void CanvasRenderingContext2D::setCurrentPath(DOMPath* path)
     869{
     870    m_path = path->path();
     871}
     872#endif
     873
    861874static bool validateRectForCanvas(float& x, float& y, float& width, float& height)
    862875{
  • trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h

    r141141 r141456  
    5050class CanvasPattern;
    5151class CanvasStyle;
     52#if ENABLE(CANVAS_PATH)
     53class DOMPath;
     54#endif
    5255class FloatRect;
    5356class GraphicsContext;
     
    138141    void beginPath();
    139142
     143#if ENABLE(CANVAS_PATH)
     144    PassRefPtr<DOMPath> currentPath();
     145    void setCurrentPath(DOMPath*);
     146#endif
    140147    void fill(const String& winding = "nonzero");
    141148    void stroke();
     
    325332    virtual bool isAccelerated() const OVERRIDE;
    326333
    327     virtual bool transformIsInvertible() { return state().m_invertibleCTM; }
     334    virtual bool isTransformInvertible() const { return state().m_invertibleCTM; }
    328335
    329336#if ENABLE(ACCELERATED_2D_CANVAS) && USE(ACCELERATED_COMPOSITING)
  • trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl

    r141141 r141456  
    9797    void beginPath();
    9898
     99#if defined(ENABLE_CANVAS_PATH) && ENABLE_CANVAS_PATH
     100    attribute DOMPath currentPath;
     101#endif
     102
    99103    // FIXME: These methods should be shared with CanvasRenderingContext2D in the CanvasPathMethods interface.
    100104    void closePath();
  • trunk/Source/WebCore/html/canvas/DOMPath.h

    r140604 r141456  
    4040public:
    4141    static PassRefPtr<DOMPath> create() { return adoptRef(new DOMPath); }
     42    static PassRefPtr<DOMPath> create(const Path& path) { return adoptRef(new DOMPath(path)); }
     43
     44    const Path& path() const { return m_path; }
     45
    4246    virtual ~DOMPath() { }
    4347private:
    4448    DOMPath() : CanvasPathMethods() { }
     49    DOMPath(const Path& path)
     50        : CanvasPathMethods()
     51    {
     52        m_path = path;
     53    }
    4554};
    4655}
Note: See TracChangeset for help on using the changeset viewer.