Remove GraphicsContext::drawConvexPolygon() and GraphicsContext::clipConvexPolygon()
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 16 Jan 2016 18:12:41 +0000 (18:12 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 16 Jan 2016 18:12:41 +0000 (18:12 +0000)
https://bugs.webkit.org/show_bug.cgi?id=153174

Reviewed by Zalan Bujtas.

GraphicsContext::drawConvexPolygon() and GraphicsContext::clipConvexPolygon() were
poorly named (non-convex polygons are allowed), and just syntactic sugar over
clipPath() and drawPath().

Remove them, but add a convenience function to create a Path from a Vector of
points. For CG, we can use the more efficient CGPathAddLines().
Source/WebCore:

Add TextStream dumping for Path.

* platform/graphics/GraphicsContext.h:
* platform/graphics/Path.cpp:
(WebCore::Path::polygonPathFromPoints):
(WebCore::Path::dump):
(WebCore::operator<<):
* platform/graphics/Path.h:
* platform/graphics/cairo/GraphicsContextCairo.cpp:
(WebCore::GraphicsContext::setPlatformShouldAntialias):
(WebCore::addConvexPolygonToContext): Deleted.
(WebCore::GraphicsContext::drawConvexPolygon): Deleted.
(WebCore::GraphicsContext::clipConvexPolygon): Deleted.
* platform/graphics/cg/GraphicsContextCG.cpp:
(WebCore::addConvexPolygonToPath): Deleted.
(WebCore::GraphicsContext::drawConvexPolygon): Deleted.
(WebCore::GraphicsContext::clipConvexPolygon): Deleted.
* platform/graphics/cg/PathCG.cpp:
(WebCore::Path::polygonPathFromPoints):
(WebCore::Path::moveTo):
(WebCore::Path::addLineTo):
(WebCore::Path::addQuadCurveTo):
(WebCore::Path::addBezierCurveTo):
(WebCore::Path::addArcTo):
* platform/graphics/displaylists/DisplayListItems.cpp:
(WebCore::DisplayList::Item::sizeInBytes): Deleted.
(WebCore::DisplayList::ClipConvexPolygon::ClipConvexPolygon): Deleted.
(WebCore::DisplayList::ClipConvexPolygon::apply): Deleted.
(WebCore::DisplayList::operator<<): Deleted.
(WebCore::DisplayList::addConvexPolygonToPath): Deleted.
(WebCore::DisplayList::DrawConvexPolygon::DrawConvexPolygon): Deleted.
(WebCore::DisplayList::DrawConvexPolygon::localBounds): Deleted.
(WebCore::DisplayList::DrawConvexPolygon::apply): Deleted.
* platform/graphics/displaylists/DisplayListItems.h:
(WebCore::DisplayList::ClipConvexPolygon::create): Deleted.
(WebCore::DisplayList::ClipConvexPolygon::points): Deleted.
(WebCore::DisplayList::ClipConvexPolygon::antialias): Deleted.
(WebCore::DisplayList::DrawConvexPolygon::create): Deleted.
(WebCore::DisplayList::DrawConvexPolygon::points): Deleted.
(WebCore::DisplayList::DrawConvexPolygon::antialiased): Deleted.
* platform/graphics/displaylists/DisplayListRecorder.cpp:
(WebCore::DisplayList::Recorder::drawConvexPolygon): Deleted.
(WebCore::DisplayList::Recorder::clipConvexPolygon): Deleted.
* platform/graphics/displaylists/DisplayListRecorder.h:
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::clipBorderSidePolygon):
* rendering/RenderElement.cpp:
(WebCore::RenderElement::drawLineForBoxSide):
* rendering/RenderThemeIOS.mm:
(WebCore::RenderThemeIOS::paintMenuListButtonDecorations):
* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::paintMenuListButtonDecorations):

Source/WebKit/win:

* FullscreenVideoController.cpp:
(HUDSlider::draw):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195170 268f45cc-cd09-0410-ab3c-d52691b4dbfc

17 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/GraphicsContext.h
Source/WebCore/platform/graphics/Path.cpp
Source/WebCore/platform/graphics/Path.h
Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
Source/WebCore/platform/graphics/cg/PathCG.cpp
Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp
Source/WebCore/platform/graphics/displaylists/DisplayListItems.h
Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp
Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h
Source/WebCore/rendering/RenderBoxModelObject.cpp
Source/WebCore/rendering/RenderElement.cpp
Source/WebCore/rendering/RenderThemeIOS.mm
Source/WebCore/rendering/RenderThemeMac.mm
Source/WebKit/win/ChangeLog
Source/WebKit/win/FullscreenVideoController.cpp

index f275c63..8d29fb1 100644 (file)
@@ -1,3 +1,70 @@
+2016-01-15  Simon Fraser  <simon.fraser@apple.com>
+
+        Remove GraphicsContext::drawConvexPolygon() and GraphicsContext::clipConvexPolygon()
+        https://bugs.webkit.org/show_bug.cgi?id=153174
+
+        Reviewed by Zalan Bujtas.
+
+        GraphicsContext::drawConvexPolygon() and GraphicsContext::clipConvexPolygon() were
+        poorly named (non-convex polygons are allowed), and just syntactic sugar over
+        clipPath() and drawPath().
+        
+        Remove them, but add a convenience function to create a Path from a Vector of 
+        points. For CG, we can use the more efficient CGPathAddLines().
+        
+        Add TextStream dumping for Path.
+
+        * platform/graphics/GraphicsContext.h:
+        * platform/graphics/Path.cpp:
+        (WebCore::Path::polygonPathFromPoints):
+        (WebCore::Path::dump):
+        (WebCore::operator<<):
+        * platform/graphics/Path.h:
+        * platform/graphics/cairo/GraphicsContextCairo.cpp:
+        (WebCore::GraphicsContext::setPlatformShouldAntialias):
+        (WebCore::addConvexPolygonToContext): Deleted.
+        (WebCore::GraphicsContext::drawConvexPolygon): Deleted.
+        (WebCore::GraphicsContext::clipConvexPolygon): Deleted.
+        * platform/graphics/cg/GraphicsContextCG.cpp:
+        (WebCore::addConvexPolygonToPath): Deleted.
+        (WebCore::GraphicsContext::drawConvexPolygon): Deleted.
+        (WebCore::GraphicsContext::clipConvexPolygon): Deleted.
+        * platform/graphics/cg/PathCG.cpp:
+        (WebCore::Path::polygonPathFromPoints):
+        (WebCore::Path::moveTo):
+        (WebCore::Path::addLineTo):
+        (WebCore::Path::addQuadCurveTo):
+        (WebCore::Path::addBezierCurveTo):
+        (WebCore::Path::addArcTo):
+        * platform/graphics/displaylists/DisplayListItems.cpp:
+        (WebCore::DisplayList::Item::sizeInBytes): Deleted.
+        (WebCore::DisplayList::ClipConvexPolygon::ClipConvexPolygon): Deleted.
+        (WebCore::DisplayList::ClipConvexPolygon::apply): Deleted.
+        (WebCore::DisplayList::operator<<): Deleted.
+        (WebCore::DisplayList::addConvexPolygonToPath): Deleted.
+        (WebCore::DisplayList::DrawConvexPolygon::DrawConvexPolygon): Deleted.
+        (WebCore::DisplayList::DrawConvexPolygon::localBounds): Deleted.
+        (WebCore::DisplayList::DrawConvexPolygon::apply): Deleted.
+        * platform/graphics/displaylists/DisplayListItems.h:
+        (WebCore::DisplayList::ClipConvexPolygon::create): Deleted.
+        (WebCore::DisplayList::ClipConvexPolygon::points): Deleted.
+        (WebCore::DisplayList::ClipConvexPolygon::antialias): Deleted.
+        (WebCore::DisplayList::DrawConvexPolygon::create): Deleted.
+        (WebCore::DisplayList::DrawConvexPolygon::points): Deleted.
+        (WebCore::DisplayList::DrawConvexPolygon::antialiased): Deleted.
+        * platform/graphics/displaylists/DisplayListRecorder.cpp:
+        (WebCore::DisplayList::Recorder::drawConvexPolygon): Deleted.
+        (WebCore::DisplayList::Recorder::clipConvexPolygon): Deleted.
+        * platform/graphics/displaylists/DisplayListRecorder.h:
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::RenderBoxModelObject::clipBorderSidePolygon):
+        * rendering/RenderElement.cpp:
+        (WebCore::RenderElement::drawLineForBoxSide):
+        * rendering/RenderThemeIOS.mm:
+        (WebCore::RenderThemeIOS::paintMenuListButtonDecorations):
+        * rendering/RenderThemeMac.mm:
+        (WebCore::RenderThemeMac::paintMenuListButtonDecorations):
+
 2016-01-16  Jeremy Huddleston Sequoia  <jeremyhu@apple.com>
 
         Add Platform.cpp to ANGLESupport
index e6377b8..4ffa7c6 100644 (file)
@@ -342,7 +342,6 @@ public:
 
     void drawEllipse(const FloatRect&);
     void drawRaisedEllipse(const FloatRect&, const Color& ellipseColor, const Color& shadowColor);
-    void drawConvexPolygon(size_t numPoints, const FloatPoint*, bool shouldAntialias = false);
 
     WEBCORE_EXPORT void fillPath(const Path&);
     void strokePath(const Path&);
@@ -388,7 +387,6 @@ public:
     void clipOut(const FloatRect&);
     void clipOutRoundedRect(const FloatRoundedRect&);
     void clipPath(const Path&, WindRule = RULE_EVENODD);
-    void clipConvexPolygon(size_t numPoints, const FloatPoint*, bool antialias = true);
     void clipToImageBuffer(ImageBuffer&, const FloatRect&);
     
     IntRect clipBounds() const;
index f088eff..01c623e 100644 (file)
@@ -34,6 +34,7 @@
 #include "FloatRoundedRect.h"
 #include "PathTraversalState.h"
 #include "RoundedRect.h"
+#include "TextStream.h"
 #include <math.h>
 #include <wtf/MathExtras.h>
 
@@ -162,10 +163,61 @@ void Path::addBeziersForRoundedRect(const FloatRect& rect, const FloatSize& topL
 }
 
 #if !USE(CG)
+Path Path::polygonPathFromPoints(const Vector<FloatPoint>& points)
+{
+    Path path;
+    if (points.size() < 2)
+        return path;
+
+    path.moveTo(points[0]);
+    for (size_t i = 1; i < points.size(); ++i)
+        path.addLineTo(points[i]);
+
+    path.closeSubpath();
+    return path;
+}
+
 FloatRect Path::fastBoundingRect() const
 {
     return boundingRect();
 }
 #endif
 
+#ifndef NDEBUG
+void Path::dump() const
+{
+    TextStream stream;
+    stream << *this;
+    WTFLogAlways("%s", stream.release().utf8().data());
+}
+#endif
+
+TextStream& operator<<(TextStream& stream, const Path& path)
+{
+    TextStream::GroupScope group(stream);
+    stream << "path " << &path;
+
+    path.apply([&stream](const PathElement& element) {
+        switch (element.type) {
+        case PathElementMoveToPoint: // The points member will contain 1 value.
+            stream << " move to " << element.points[0];
+            break;
+        case PathElementAddLineToPoint: // The points member will contain 1 value.
+            stream << " add line to " << element.points[0];
+            break;
+        case PathElementAddQuadCurveToPoint: // The points member will contain 2 values.
+            stream << " add quad curve to " << element.points[0] << " " << element.points[1];
+            break;
+        case PathElementAddCurveToPoint: // The points member will contain 3 values.
+            stream << " add curve to " << element.points[0] << " " << element.points[1] << " " << element.points[2];
+            break;
+        case PathElementCloseSubpath: // The points member will contain no values.
+            stream << " close subpath";
+            break;
+        }
+    });
+    
+    return stream;
+}
+
 }
index d37f900..83dcb14 100644 (file)
@@ -33,6 +33,7 @@
 #include <functional>
 #include <wtf/FastMalloc.h>
 #include <wtf/Forward.h>
+#include <wtf/Vector.h>
 
 #if USE(CG)
 
@@ -50,7 +51,7 @@ typedef WebCore::CairoPath PlatformPath;
 #elif USE(WINGDI)
 
 namespace WebCore {
-    class PlatformPath;
+class PlatformPath;
 }
 typedef WebCore::PlatformPath PlatformPath;
 
@@ -72,6 +73,7 @@ namespace WebCore {
     class PathTraversalState;
     class RoundedRect;
     class StrokeStyleApplier;
+    class TextStream;
 
     enum PathElementType {
         PathElementMoveToPoint, // The points member will contain 1 value.
@@ -102,6 +104,8 @@ namespace WebCore {
 
         WEBCORE_EXPORT Path(const Path&);
         WEBCORE_EXPORT Path& operator=(const Path&);
+        
+        static Path polygonPathFromPoints(const Vector<FloatPoint>&);
 
         bool contains(const FloatPoint&, WindRule rule = RULE_NONZERO) const;
         bool strokeContains(StrokeStyleApplier*, const FloatPoint&) const;
@@ -164,10 +168,16 @@ namespace WebCore {
         void platformAddPathForRoundedRect(const FloatRect&, const FloatSize& topLeftRadius, const FloatSize& topRightRadius, const FloatSize& bottomLeftRadius, const FloatSize& bottomRightRadius);
 #endif
 
+#ifndef NDEBUG
+        void dump() const;
+#endif
+
     private:
         PlatformPathPtr m_path;
     };
 
+TextStream& operator<<(TextStream&, const Path&);
+
 }
 
 #endif
index c0744b0..b0036fd 100644 (file)
@@ -77,14 +77,6 @@ static inline void fillRectWithColor(cairo_t* cr, const FloatRect& rect, const C
     cairo_fill(cr);
 }
 
-static void addConvexPolygonToContext(cairo_t* context, size_t numPoints, const FloatPoint* points)
-{
-    cairo_move_to(context, points[0].x(), points[0].y());
-    for (size_t i = 1; i < numPoints; i++)
-        cairo_line_to(context, points[i].x(), points[i].y());
-    cairo_close_path(context);
-}
-
 enum PathDrawingStyle { 
     Fill = 1,
     Stroke = 2,
@@ -435,69 +427,6 @@ void GraphicsContext::drawEllipse(const FloatRect& rect)
         cairo_new_path(cr);
 }
 
-void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points, bool shouldAntialias)
-{
-    if (paintingDisabled())
-        return;
-
-    if (npoints <= 1)
-        return;
-
-    if (isRecording()) {
-        m_displayListRecorder->drawConvexPolygon(npoints, points, shouldAntialias);
-        return;
-    }
-
-    cairo_t* cr = platformContext()->cr();
-
-    cairo_save(cr);
-    cairo_set_antialias(cr, shouldAntialias ? CAIRO_ANTIALIAS_DEFAULT : CAIRO_ANTIALIAS_NONE);
-    addConvexPolygonToContext(cr, npoints, points);
-
-    if (fillColor().alpha()) {
-        setSourceRGBAFromColor(cr, fillColor());
-        cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD);
-        cairo_fill_preserve(cr);
-    }
-
-    if (strokeStyle() != NoStroke) {
-        setSourceRGBAFromColor(cr, strokeColor());
-        cairo_set_line_width(cr, strokeThickness());
-        cairo_stroke(cr);
-    } else
-        cairo_new_path(cr);
-
-    cairo_restore(cr);
-}
-
-void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* points, bool antialiased)
-{
-    if (paintingDisabled())
-        return;
-
-    if (numPoints <= 1)
-        return;
-
-    if (isRecording()) {
-        m_displayListRecorder->clipConvexPolygon(numPoints, points, antialiased);
-        return;
-    }
-
-    cairo_t* cr = platformContext()->cr();
-
-    cairo_new_path(cr);
-    cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr);
-    cairo_antialias_t savedAntialiasRule = cairo_get_antialias(cr);
-
-    cairo_set_antialias(cr, antialiased ? CAIRO_ANTIALIAS_DEFAULT : CAIRO_ANTIALIAS_NONE);
-    cairo_set_fill_rule(cr, CAIRO_FILL_RULE_WINDING);
-    addConvexPolygonToContext(cr, numPoints, points);
-    cairo_clip(cr);
-
-    cairo_set_antialias(cr, savedAntialiasRule);
-    cairo_set_fill_rule(cr, savedFillRule);
-}
-
 void GraphicsContext::fillPath(const Path& path)
 {
     if (paintingDisabled() || path.isEmpty())
@@ -1294,7 +1223,7 @@ void GraphicsContext::setPlatformShouldAntialias(bool enable)
 
     // When true, use the default Cairo backend antialias mode (usually this
     // enables standard 'grayscale' antialiasing); false to explicitly disable
-    // antialiasing. This is the same strategy as used in drawConvexPolygon().
+    // antialiasing.
     cairo_set_antialias(platformContext()->cr(), enable ? CAIRO_ANTIALIAS_DEFAULT : CAIRO_ANTIALIAS_NONE);
 }
 
index 1c6b94a..a449654 100644 (file)
@@ -532,68 +532,6 @@ void GraphicsContext::drawEllipse(const FloatRect& rect)
     drawPath(path);
 }
 
-static void addConvexPolygonToPath(Path& path, size_t numberOfPoints, const FloatPoint* points)
-{
-    ASSERT(numberOfPoints > 0);
-
-    path.moveTo(points[0]);
-    for (size_t i = 1; i < numberOfPoints; ++i)
-        path.addLineTo(points[i]);
-    path.closeSubpath();
-}
-
-void GraphicsContext::drawConvexPolygon(size_t numberOfPoints, const FloatPoint* points, bool antialiased)
-{
-    if (paintingDisabled())
-        return;
-
-    if (numberOfPoints <= 1)
-        return;
-
-    if (isRecording()) {
-        m_displayListRecorder->drawConvexPolygon(numberOfPoints, points, antialiased);
-        return;
-    }
-
-    CGContextRef context = platformContext();
-
-    if (antialiased != shouldAntialias())
-        CGContextSetShouldAntialias(context, antialiased);
-
-    Path path;
-    addConvexPolygonToPath(path, numberOfPoints, points);
-    drawPath(path);
-
-    if (antialiased != shouldAntialias())
-        CGContextSetShouldAntialias(context, shouldAntialias());
-}
-
-void GraphicsContext::clipConvexPolygon(size_t numberOfPoints, const FloatPoint* points, bool antialias)
-{
-    if (paintingDisabled())
-        return;
-
-    if (numberOfPoints <= 1)
-        return;
-
-    if (isRecording()) {
-        m_displayListRecorder->clipConvexPolygon(numberOfPoints, points, antialias);
-        return;
-    }
-
-    CGContextRef context = platformContext();
-
-    if (antialias != shouldAntialias())
-        CGContextSetShouldAntialias(context, antialias);
-
-    Path path;
-    addConvexPolygonToPath(path, numberOfPoints, points);
-    clipPath(path, RULE_NONZERO);
-
-    if (antialias != shouldAntialias())
-        CGContextSetShouldAntialias(context, shouldAntialias());
-}
-
 void GraphicsContext::applyStrokePattern()
 {
     if (paintingDisabled())
@@ -703,14 +641,6 @@ void GraphicsContext::drawPath(const Path& path)
         CGContextDrawPath(context, drawingMode);
 }
 
-static inline void fillPathWithFillRule(CGContextRef context, WindRule fillRule)
-{
-    if (fillRule == RULE_EVENODD)
-        CGContextEOFillPath(context);
-    else
-        CGContextFillPath(context);
-}
-
 void GraphicsContext::fillPath(const Path& path)
 {
     if (paintingDisabled() || path.isEmpty())
@@ -767,7 +697,11 @@ void GraphicsContext::fillPath(const Path& path)
 
     if (m_state.fillPattern)
         applyFillPattern();
-    fillPathWithFillRule(context, fillRule());
+
+    if (fillRule() == RULE_EVENODD)
+        CGContextEOFillPath(context);
+    else
+        CGContextFillPath(context);
 }
 
 void GraphicsContext::strokePath(const Path& path)
index 14bce93..707112d 100644 (file)
@@ -73,6 +73,22 @@ static inline CGContextRef scratchContext()
     return context;
 }
 
+Path Path::polygonPathFromPoints(const Vector<FloatPoint>& points)
+{
+    Path path;
+    if (points.size() < 2)
+        return path;
+
+    Vector<CGPoint, 32> cgPoints;
+    cgPoints.reserveInitialCapacity(points.size() - 1);
+    for (size_t i = 0; i < points.size(); ++i)
+        cgPoints.uncheckedAppend(points[i]);
+
+    CGPathAddLines(path.ensurePlatformPath(), nullptr, cgPoints.data(), cgPoints.size());
+    path.closeSubpath();
+    return path;
+}
+
 Path::Path()
     : m_path(nullptr)
 {
@@ -245,27 +261,27 @@ FloatRect Path::strokeBoundingRect(StrokeStyleApplier* applier) const
 
 void Path::moveTo(const FloatPoint& point)
 {
-    CGPathMoveToPoint(ensurePlatformPath(), 0, point.x(), point.y());
+    CGPathMoveToPoint(ensurePlatformPath(), nullptr, point.x(), point.y());
 }
 
 void Path::addLineTo(const FloatPoint& p)
 {
-    CGPathAddLineToPoint(ensurePlatformPath(), 0, p.x(), p.y());
+    CGPathAddLineToPoint(ensurePlatformPath(), nullptr, p.x(), p.y());
 }
 
 void Path::addQuadCurveTo(const FloatPoint& cp, const FloatPoint& p)
 {
-    CGPathAddQuadCurveToPoint(ensurePlatformPath(), 0, cp.x(), cp.y(), p.x(), p.y());
+    CGPathAddQuadCurveToPoint(ensurePlatformPath(), nullptr, cp.x(), cp.y(), p.x(), p.y());
 }
 
 void Path::addBezierCurveTo(const FloatPoint& cp1, const FloatPoint& cp2, const FloatPoint& p)
 {
-    CGPathAddCurveToPoint(ensurePlatformPath(), 0, cp1.x(), cp1.y(), cp2.x(), cp2.y(), p.x(), p.y());
+    CGPathAddCurveToPoint(ensurePlatformPath(), nullptr, cp1.x(), cp1.y(), cp2.x(), cp2.y(), p.x(), p.y());
 }
 
 void Path::addArcTo(const FloatPoint& p1, const FloatPoint& p2, float radius)
 {
-    CGPathAddArcToPoint(ensurePlatformPath(), 0, p1.x(), p1.y(), p2.x(), p2.y(), radius);
+    CGPathAddArcToPoint(ensurePlatformPath(), nullptr, p1.x(), p1.y(), p2.x(), p2.y(), radius);
 }
 
 void Path::platformAddPathForRoundedRect(const FloatRect& rect, const FloatSize& topLeftRadius, const FloatSize& topRightRadius, const FloatSize& bottomLeftRadius, const FloatSize& bottomRightRadius)
index 0cabe15..2e493ab 100644 (file)
@@ -79,8 +79,6 @@ size_t Item::sizeInBytes(const Item& item)
         return sizeof(downcast<ClipOutToPath>(item));
     case ItemType::ClipPath:
         return sizeof(downcast<ClipPath>(item));
-    case ItemType::ClipConvexPolygon:
-        return sizeof(downcast<ClipConvexPolygon>(item));
     case ItemType::DrawGlyphs:
         return sizeof(downcast<DrawGlyphs>(item));
     case ItemType::DrawImage:
@@ -105,8 +103,6 @@ size_t Item::sizeInBytes(const Item& item)
         return sizeof(downcast<DrawLineForDocumentMarker>(item));
     case ItemType::DrawEllipse:
         return sizeof(downcast<DrawEllipse>(item));
-    case ItemType::DrawConvexPolygon:
-        return sizeof(downcast<DrawConvexPolygon>(item));
     case ItemType::DrawPath:
         return sizeof(downcast<DrawPath>(item));
     case ItemType::DrawFocusRingPath:
@@ -348,26 +344,6 @@ static TextStream& operator<<(TextStream& ts, const ClipPath& item)
     return ts;
 }
 
-ClipConvexPolygon::ClipConvexPolygon(size_t numberOfPoints, const FloatPoint* points, bool antialiased)
-    : Item(ItemType::ClipConvexPolygon)
-    , m_antialias(antialiased)
-{
-    for (size_t i = 0; i < numberOfPoints; ++i)
-        m_points.append(points[i]);
-}
-
-void ClipConvexPolygon::apply(GraphicsContext& context) const
-{
-    context.clipConvexPolygon(m_points.size(), m_points.data(), m_antialias);
-}
-
-static TextStream& operator<<(TextStream& ts, const ClipConvexPolygon& item)
-{
-    ts.dumpProperty("points", item.points());
-    ts.dumpProperty("antialias", item.antialias());
-    return ts;
-}
-
 DrawGlyphs::DrawGlyphs(const Font& font, const GlyphBufferGlyph* glyphs, const GlyphBufferAdvance* advances, unsigned count, const FloatPoint& blockLocation, const FloatSize& localAnchor, FontSmoothingMode smoothingMode)
     : DrawingItem(ItemType::DrawGlyphs)
     , m_font(const_cast<Font&>(font))
@@ -682,47 +658,6 @@ static TextStream& operator<<(TextStream& ts, const DrawEllipse& item)
     return ts;
 }
 
-// FIXME: Share this code.
-void addConvexPolygonToPath(Path& path, size_t numberOfPoints, const FloatPoint* points)
-{
-    ASSERT(numberOfPoints > 0);
-
-    path.moveTo(points[0]);
-    for (size_t i = 1; i < numberOfPoints; ++i)
-        path.addLineTo(points[i]);
-    path.closeSubpath();
-}
-
-DrawConvexPolygon::DrawConvexPolygon(size_t numberOfPoints, const FloatPoint* points, bool antialiased)
-    : DrawingItem(ItemType::DrawConvexPolygon)
-    , m_antialiased(antialiased)
-{
-    for (size_t i = 0; i < numberOfPoints; ++i)
-        m_points.append(points[i]);
-}
-
-Optional<FloatRect> DrawConvexPolygon::localBounds(const GraphicsContext&) const
-{
-    FloatRect result;
-    for (auto& point : m_points)
-        result.extend(point);
-    result.inflate(m_antialiased ? 1 : 0); // Account for antialiasing
-    return result;
-}
-
-void DrawConvexPolygon::apply(GraphicsContext& context) const
-{
-    context.drawConvexPolygon(m_points.size(), m_points.data(), m_antialiased);
-}
-
-static TextStream& operator<<(TextStream& ts, const DrawConvexPolygon& item)
-{
-    ts << static_cast<const DrawingItem&>(item);
-    ts.dumpProperty("points", item.points());
-    ts.dumpProperty("antialiased", item.antialiased());
-    return ts;
-}
-
 void DrawPath::apply(GraphicsContext& context) const
 {
 #if USE(CG)
@@ -1023,7 +958,6 @@ static TextStream& operator<<(TextStream& ts, const ItemType& type)
     case ItemType::ClipOut: ts << "clip-out"; break;
     case ItemType::ClipOutToPath: ts << "clip-out-to-path"; break;
     case ItemType::ClipPath: ts << "clip-path"; break;
-    case ItemType::ClipConvexPolygon: ts << "clip-convex-polygon"; break;
     case ItemType::DrawGlyphs: ts << "draw-glyphs"; break;
     case ItemType::DrawImage: ts << "draw-image"; break;
     case ItemType::DrawTiledImage: ts << "draw-tiled-image"; break;
@@ -1037,7 +971,6 @@ static TextStream& operator<<(TextStream& ts, const ItemType& type)
     case ItemType::DrawLinesForText: ts << "draw-lines-for-text"; break;
     case ItemType::DrawLineForDocumentMarker: ts << "draw-lines-for-document-marker"; break;
     case ItemType::DrawEllipse: ts << "draw-ellipse"; break;
-    case ItemType::DrawConvexPolygon: ts << "draw-convex-polgon"; break;
     case ItemType::DrawPath: ts << "draw-path"; break;
     case ItemType::DrawFocusRingPath: ts << "draw-focus-ring-path"; break;
     case ItemType::DrawFocusRingRects: ts << "draw-focus-ring-rects"; break;
@@ -1114,9 +1047,6 @@ TextStream& operator<<(TextStream& ts, const Item& item)
     case ItemType::ClipPath:
         ts << downcast<ClipPath>(item);
         break;
-    case ItemType::ClipConvexPolygon:
-        ts << downcast<ClipConvexPolygon>(item);
-        break;
     case ItemType::DrawGlyphs:
         ts << downcast<DrawGlyphs>(item);
         break;
@@ -1152,9 +1082,6 @@ TextStream& operator<<(TextStream& ts, const Item& item)
     case ItemType::DrawEllipse:
         ts << downcast<DrawEllipse>(item);
         break;
-    case ItemType::DrawConvexPolygon:
-        ts << downcast<DrawConvexPolygon>(item);
-        break;
     case ItemType::DrawPath:
         ts << downcast<DrawPath>(item);
         break;
index 07d2d5f..5065f38 100644 (file)
@@ -64,7 +64,6 @@ enum class ItemType {
     ClipOut,
     ClipOutToPath,
     ClipPath,
-    ClipConvexPolygon,
     DrawGlyphs,
     DrawImage,
     DrawTiledImage,
@@ -78,7 +77,6 @@ enum class ItemType {
     DrawLinesForText,
     DrawLineForDocumentMarker,
     DrawEllipse,
-    DrawConvexPolygon,
     DrawPath,
     DrawFocusRingPath,
     DrawFocusRingRects,
@@ -522,25 +520,6 @@ private:
     WindRule m_windRule;
 };
 
-class ClipConvexPolygon : public Item {
-public:
-    static Ref<ClipConvexPolygon> create(size_t numberOfPoints, const FloatPoint* points, bool antialiased)
-    {
-        return adoptRef(*new ClipConvexPolygon(numberOfPoints, points, antialiased));
-    }
-
-    const Vector<FloatPoint>& points() const { return m_points; }
-    bool antialias() const { return m_antialias; }
-
-private:
-    ClipConvexPolygon(size_t numberOfPoints, const FloatPoint*, bool antialiased);
-
-    virtual void apply(GraphicsContext&) const override;
-
-    Vector<FloatPoint> m_points;
-    bool m_antialias;
-};
-
 class DrawGlyphs : public DrawingItem {
 public:
     static Ref<DrawGlyphs> create(const Font& font, const GlyphBufferGlyph* glyphs, const GlyphBufferAdvance* advances, unsigned count, const FloatPoint& blockLocation, const FloatSize& localAnchor, FontSmoothingMode smoothingMode)
@@ -897,26 +876,6 @@ private:
     FloatRect m_rect;
 };
 
-class DrawConvexPolygon : public DrawingItem {
-public:
-    static Ref<DrawConvexPolygon> create(size_t numberOfPoints, const FloatPoint* points, bool antialiased)
-    {
-        return adoptRef(*new DrawConvexPolygon(numberOfPoints, points, antialiased));
-    }
-
-    const Vector<FloatPoint>& points() const { return m_points; }
-    bool antialiased() const { return m_antialiased; }
-
-private:
-    DrawConvexPolygon(size_t numberOfPoints, const FloatPoint*, bool antialiased);
-
-    virtual void apply(GraphicsContext&) const override;
-    virtual Optional<FloatRect> localBounds(const GraphicsContext&) const override;
-
-    Vector<FloatPoint> m_points;
-    bool m_antialiased;
-};
-
 class DrawPath : public DrawingItem {
 public:
     static Ref<DrawPath> create(const Path& path)
@@ -1355,9 +1314,6 @@ private:
     float m_scaleFactor;
 };
 
-// FIXME: this needs to move.
-void addConvexPolygonToPath(Path&, size_t numPoints, const FloatPoint*);
-
 TextStream& operator<<(TextStream&, const Item&);
 
 } // namespace DisplayList
@@ -1391,7 +1347,6 @@ SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(Clip)
 SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(ClipOut)
 SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(ClipOutToPath)
 SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(ClipPath)
-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(ClipConvexPolygon)
 SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawGlyphs)
 SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawImage)
 SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawTiledImage)
@@ -1405,7 +1360,6 @@ SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawLine)
 SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawLinesForText)
 SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawLineForDocumentMarker)
 SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawEllipse)
-SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawConvexPolygon)
 SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawPath)
 SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawFocusRingPath)
 SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawFocusRingRects)
index 789a846..366cff7 100644 (file)
@@ -237,12 +237,6 @@ void Recorder::drawEllipse(const FloatRect& rect)
     updateItemExtent(newItem);
 }
 
-void Recorder::drawConvexPolygon(size_t numberOfPoints, const FloatPoint* points, bool antialiased)
-{
-    DrawingItem& newItem = downcast<DrawingItem>(appendItem(DrawConvexPolygon::create(numberOfPoints, points, antialiased)));
-    updateItemExtent(newItem);
-}
-
 void Recorder::drawPath(const Path& path)
 {
     DrawingItem& newItem = downcast<DrawingItem>(appendItem(DrawPath::create(path)));
@@ -367,15 +361,6 @@ void Recorder::clipPath(const Path& path, WindRule windRule)
     appendItem(ClipPath::create(path, windRule));
 }
 
-void Recorder::clipConvexPolygon(size_t numPoints, const FloatPoint* points, bool antialias)
-{
-    Path polygonPath;
-    addConvexPolygonToPath(polygonPath, numPoints, points);
-    currentState().clipBounds.intersect(polygonPath.fastBoundingRect());
-
-    appendItem(ClipConvexPolygon::create(numPoints, points, antialias));
-}
-
 void Recorder::applyDeviceScaleFactor(float deviceScaleFactor)
 {
     // FIXME: this changes the baseCTM, which will invalidate all of our cached extents.
index 2f36a3f..52e39ac 100644 (file)
@@ -95,7 +95,6 @@ public:
     void drawLinesForText(const FloatPoint&, const DashArray& widths, bool printing, bool doubleLines, float strokeThickness);
     void drawLineForDocumentMarker(const FloatPoint&, float width, GraphicsContext::DocumentMarkerLineStyle);
     void drawEllipse(const FloatRect&);
-    void drawConvexPolygon(size_t numberOfPoints, const FloatPoint*, bool antialiased);
     void drawPath(const Path&);
 
     void drawFocusRing(const Path&, int width, int offset, const Color&);
@@ -116,7 +115,6 @@ public:
     void clipOut(const FloatRect&);
     void clipOut(const Path&);
     void clipPath(const Path&, WindRule);
-    void clipConvexPolygon(size_t numPoints, const FloatPoint*, bool antialias);
     
     void applyDeviceScaleFactor(float);
 
index 0afbdf8..7c1d0a7 100644 (file)
@@ -1905,8 +1905,6 @@ static void findInnerVertex(const FloatPoint& outerCorner, const FloatPoint& inn
 void RenderBoxModelObject::clipBorderSidePolygon(GraphicsContext& graphicsContext, const RoundedRect& outerBorder, const RoundedRect& innerBorder,
                                                  BoxSide side, bool firstEdgeMatches, bool secondEdgeMatches)
 {
-    FloatPoint quad[4];
-
     float deviceScaleFactor = document().deviceScaleFactor();
     const FloatRect& outerRect = snapRectToDevicePixels(outerBorder.rect(), deviceScaleFactor);
     const FloatRect& innerRect = snapRectToDevicePixels(innerBorder.rect(), deviceScaleFactor);
@@ -1927,12 +1925,14 @@ void RenderBoxModelObject::clipBorderSidePolygon(GraphicsContext& graphicsContex
     //       3  /              \  3   
     //         0----------------3
     //
+    Vector<FloatPoint> quad;
+    quad.reserveInitialCapacity(4);
     switch (side) {
     case BSTop:
-        quad[0] = outerRect.minXMinYCorner();
-        quad[1] = innerRect.minXMinYCorner();
-        quad[2] = innerRect.maxXMinYCorner();
-        quad[3] = outerRect.maxXMinYCorner();
+        quad.uncheckedAppend(outerRect.minXMinYCorner());
+        quad.uncheckedAppend(innerRect.minXMinYCorner());
+        quad.uncheckedAppend(innerRect.maxXMinYCorner());
+        quad.uncheckedAppend(outerRect.maxXMinYCorner());
 
         if (!innerBorder.radii().topLeft().isZero())
             findInnerVertex(outerRect.minXMinYCorner(), innerRect.minXMinYCorner(), centerPoint, quad[1]);
@@ -1942,10 +1942,10 @@ void RenderBoxModelObject::clipBorderSidePolygon(GraphicsContext& graphicsContex
         break;
 
     case BSLeft:
-        quad[0] = outerRect.minXMinYCorner();
-        quad[1] = innerRect.minXMinYCorner();
-        quad[2] = innerRect.minXMaxYCorner();
-        quad[3] = outerRect.minXMaxYCorner();
+        quad.uncheckedAppend(outerRect.minXMinYCorner());
+        quad.uncheckedAppend(innerRect.minXMinYCorner());
+        quad.uncheckedAppend(innerRect.minXMaxYCorner());
+        quad.uncheckedAppend(outerRect.minXMaxYCorner());
 
         if (!innerBorder.radii().topLeft().isZero())
             findInnerVertex(outerRect.minXMinYCorner(), innerRect.minXMinYCorner(), centerPoint, quad[1]);
@@ -1955,10 +1955,10 @@ void RenderBoxModelObject::clipBorderSidePolygon(GraphicsContext& graphicsContex
         break;
 
     case BSBottom:
-        quad[0] = outerRect.minXMaxYCorner();
-        quad[1] = innerRect.minXMaxYCorner();
-        quad[2] = innerRect.maxXMaxYCorner();
-        quad[3] = outerRect.maxXMaxYCorner();
+        quad.uncheckedAppend(outerRect.minXMaxYCorner());
+        quad.uncheckedAppend(innerRect.minXMaxYCorner());
+        quad.uncheckedAppend(innerRect.maxXMaxYCorner());
+        quad.uncheckedAppend(outerRect.maxXMaxYCorner());
 
         if (!innerBorder.radii().bottomLeft().isZero())
             findInnerVertex(outerRect.minXMaxYCorner(), innerRect.minXMaxYCorner(), centerPoint, quad[1]);
@@ -1968,10 +1968,10 @@ void RenderBoxModelObject::clipBorderSidePolygon(GraphicsContext& graphicsContex
         break;
 
     case BSRight:
-        quad[0] = outerRect.maxXMinYCorner();
-        quad[1] = innerRect.maxXMinYCorner();
-        quad[2] = innerRect.maxXMaxYCorner();
-        quad[3] = outerRect.maxXMaxYCorner();
+        quad.uncheckedAppend(outerRect.maxXMinYCorner());
+        quad.uncheckedAppend(innerRect.maxXMinYCorner());
+        quad.uncheckedAppend(innerRect.maxXMaxYCorner());
+        quad.uncheckedAppend(outerRect.maxXMaxYCorner());
 
         if (!innerBorder.radii().topRight().isZero())
             findInnerVertex(outerRect.maxXMinYCorner(), innerRect.maxXMinYCorner(), centerPoint, quad[1]);
@@ -1984,25 +1984,35 @@ void RenderBoxModelObject::clipBorderSidePolygon(GraphicsContext& graphicsContex
     // If the border matches both of its adjacent sides, don't anti-alias the clip, and
     // if neither side matches, anti-alias the clip.
     if (firstEdgeMatches == secondEdgeMatches) {
-        graphicsContext.clipConvexPolygon(4, quad, !firstEdgeMatches);
+        bool wasAntialiased = graphicsContext.shouldAntialias();
+        graphicsContext.setShouldAntialias(!firstEdgeMatches);
+        graphicsContext.clipPath(Path::polygonPathFromPoints(quad), RULE_NONZERO);
+        graphicsContext.setShouldAntialias(wasAntialiased);
         return;
     }
 
     // Square off the end which shouldn't be affected by antialiasing, and clip.
-    FloatPoint firstQuad[4];
-    firstQuad[0] = quad[0];
-    firstQuad[1] = quad[1];
-    firstQuad[2] = side == BSTop || side == BSBottom ? FloatPoint(quad[3].x(), quad[2].y()) : FloatPoint(quad[2].x(), quad[3].y());
-    firstQuad[3] = quad[3];
-    graphicsContext.clipConvexPolygon(4, firstQuad, !firstEdgeMatches);
-
-    FloatPoint secondQuad[4];
-    secondQuad[0] = quad[0];
-    secondQuad[1] = side == BSTop || side == BSBottom ? FloatPoint(quad[0].x(), quad[1].y()) : FloatPoint(quad[1].x(), quad[0].y());
-    secondQuad[2] = quad[2];
-    secondQuad[3] = quad[3];
+    Vector<FloatPoint> firstQuad = {
+        quad[0],
+        quad[1],
+        side == BSTop || side == BSBottom ? FloatPoint(quad[3].x(), quad[2].y()) : FloatPoint(quad[2].x(), quad[3].y()),
+        quad[3]
+    };
+    bool wasAntialiased = graphicsContext.shouldAntialias();
+    graphicsContext.setShouldAntialias(!firstEdgeMatches);
+    graphicsContext.clipPath(Path::polygonPathFromPoints(firstQuad), RULE_NONZERO);
+
+    Vector<FloatPoint> secondQuad = {
+        quad[0],
+        side == BSTop || side == BSBottom ? FloatPoint(quad[0].x(), quad[1].y()) : FloatPoint(quad[1].x(), quad[0].y()),
+        quad[2],
+        quad[3]
+    };
     // Antialiasing affects the second side.
-    graphicsContext.clipConvexPolygon(4, secondQuad, !secondEdgeMatches);
+    graphicsContext.setShouldAntialias(!secondEdgeMatches);
+    graphicsContext.clipPath(Path::polygonPathFromPoints(secondQuad), RULE_NONZERO);
+
+    graphicsContext.setShouldAntialias(wasAntialiased);
 }
 
 static LayoutRect calculateSideRectIncludingInner(const RoundedRect& outerBorder, const BorderEdge edges[], BoxSide side)
index a2cc71e..63d38c8 100644 (file)
@@ -2037,8 +2037,6 @@ void RenderElement::drawLineForBoxSide(GraphicsContext& graphicsContext, const F
         ASSERT(x2 >= x1);
         ASSERT(y2 >= y1);
         if (!adjacentWidth1 && !adjacentWidth2) {
-            // Turn off antialiasing to match the behavior of drawConvexPolygon();
-            // this matters for rects in transformed contexts.
             graphicsContext.setStrokeStyle(NoStroke);
             graphicsContext.setFillColor(color);
             bool wasAntialiased = graphicsContext.shouldAntialias();
@@ -2055,37 +2053,42 @@ void RenderElement::drawLineForBoxSide(GraphicsContext& graphicsContext, const F
         x2 = roundToDevicePixel(x2, deviceScaleFactor);
         y2 = roundToDevicePixel(y2, deviceScaleFactor);
 
-        FloatPoint quad[4];
+        Vector<FloatPoint> quad;
+        quad.reserveInitialCapacity(4);
         switch (side) {
         case BSTop:
-            quad[0] = FloatPoint(x1 + std::max<float>(-adjacentWidth1, 0), y1);
-            quad[1] = FloatPoint(x1 + std::max<float>(adjacentWidth1, 0), y2);
-            quad[2] = FloatPoint(x2 - std::max<float>(adjacentWidth2, 0), y2);
-            quad[3] = FloatPoint(x2 - std::max<float>(-adjacentWidth2, 0), y1);
+            quad.uncheckedAppend({ x1 + std::max<float>(-adjacentWidth1, 0), y1 });
+            quad.uncheckedAppend({ x1 + std::max<float>( adjacentWidth1, 0), y2 });
+            quad.uncheckedAppend({ x2 - std::max<float>( adjacentWidth2, 0), y2 });
+            quad.uncheckedAppend({ x2 - std::max<float>(-adjacentWidth2, 0), y1 });
             break;
         case BSBottom:
-            quad[0] = FloatPoint(x1 + std::max<float>(adjacentWidth1, 0), y1);
-            quad[1] = FloatPoint(x1 + std::max<float>(-adjacentWidth1, 0), y2);
-            quad[2] = FloatPoint(x2 - std::max<float>(-adjacentWidth2, 0), y2);
-            quad[3] = FloatPoint(x2 - std::max<float>(adjacentWidth2, 0), y1);
+            quad.uncheckedAppend({ x1 + std::max<float>( adjacentWidth1, 0), y1 });
+            quad.uncheckedAppend({ x1 + std::max<float>(-adjacentWidth1, 0), y2 });
+            quad.uncheckedAppend({ x2 - std::max<float>(-adjacentWidth2, 0), y2 });
+            quad.uncheckedAppend({ x2 - std::max<float>( adjacentWidth2, 0), y1 });
             break;
         case BSLeft:
-            quad[0] = FloatPoint(x1, y1 + std::max<float>(-adjacentWidth1, 0));
-            quad[1] = FloatPoint(x1, y2 - std::max<float>(-adjacentWidth2, 0));
-            quad[2] = FloatPoint(x2, y2 - std::max<float>(adjacentWidth2, 0));
-            quad[3] = FloatPoint(x2, y1 + std::max<float>(adjacentWidth1, 0));
+            quad.uncheckedAppend({ x1, y1 + std::max<float>(-adjacentWidth1, 0) });
+            quad.uncheckedAppend({ x1, y2 - std::max<float>(-adjacentWidth2, 0) });
+            quad.uncheckedAppend({ x2, y2 - std::max<float>( adjacentWidth2, 0) });
+            quad.uncheckedAppend({ x2, y1 + std::max<float>( adjacentWidth1, 0) });
             break;
         case BSRight:
-            quad[0] = FloatPoint(x1, y1 + std::max<float>(adjacentWidth1, 0));
-            quad[1] = FloatPoint(x1, y2 - std::max<float>(adjacentWidth2, 0));
-            quad[2] = FloatPoint(x2, y2 - std::max<float>(-adjacentWidth2, 0));
-            quad[3] = FloatPoint(x2, y1 + std::max<float>(-adjacentWidth1, 0));
+            quad.uncheckedAppend({ x1, y1 + std::max<float>( adjacentWidth1, 0) });
+            quad.uncheckedAppend({ x1, y2 - std::max<float>( adjacentWidth2, 0) });
+            quad.uncheckedAppend({ x2, y2 - std::max<float>(-adjacentWidth2, 0) });
+            quad.uncheckedAppend({ x2, y1 + std::max<float>(-adjacentWidth1, 0) });
             break;
         }
 
         graphicsContext.setStrokeStyle(NoStroke);
         graphicsContext.setFillColor(color);
-        graphicsContext.drawConvexPolygon(4, quad, antialias);
+        bool wasAntialiased = graphicsContext.shouldAntialias();
+        graphicsContext.setShouldAntialias(antialias);
+        graphicsContext.fillPath(Path::polygonPathFromPoints(quad));
+        graphicsContext.setShouldAntialias(wasAntialiased);
+
         graphicsContext.setStrokeStyle(oldStrokeStyle);
         break;
     }
index ff09b14..9f2df51 100644 (file)
@@ -683,25 +683,26 @@ bool RenderThemeIOS::paintMenuListButtonDecorations(const RenderBox& box, const
         float centerX = floorf(buttonClip.x() + buttonClip.width() / 2.0) - 0.5;
         float centerY = floorf(buttonClip.y() + buttonClip.height() * 3.0 / 8.0);
 
-        FloatPoint arrow[3];
-        FloatPoint shadow[3];
-
-        arrow[0] = FloatPoint(centerX - MenuListArrowWidth / 2.0, centerY);
-        arrow[1] = FloatPoint(centerX + MenuListArrowWidth / 2.0, centerY);
-        arrow[2] = FloatPoint(centerX, centerY + MenuListArrowHeight);
+        Vector<FloatPoint> arrow = {
+            { centerX - MenuListArrowWidth / 2, centerY },
+            { centerX + MenuListArrowWidth / 2, centerY },
+            { centerX, centerY + MenuListArrowHeight }
+        };
 
-        shadow[0] = FloatPoint(arrow[0].x(), arrow[0].y() + 1.0f);
-        shadow[1] = FloatPoint(arrow[1].x(), arrow[1].y() + 1.0f);
-        shadow[2] = FloatPoint(arrow[2].x(), arrow[2].y() + 1.0f);
+        Vector<FloatPoint> shadow = {
+            { arrow[0].x(), arrow[0].y() + 1 },
+            { arrow[1].x(), arrow[1].y() + 1 },
+            { arrow[2].x(), arrow[2].y() + 1 }
+        };
 
         float opacity = isReadOnlyControl(box) ? 0.2 : 0.5;
         paintInfo.context().setStrokeColor(Color(0.0f, 0.0f, 0.0f, opacity));
         paintInfo.context().setFillColor(Color(0.0f, 0.0f, 0.0f, opacity));
-        paintInfo.context().drawConvexPolygon(3, shadow, true);
+        paintInfo.context().drawPath(Path::polygonPathFromPoints(shadow));
 
         paintInfo.context().setStrokeColor(Color::white);
         paintInfo.context().setFillColor(Color::white);
-        paintInfo.context().drawConvexPolygon(3, arrow, true);
+        paintInfo.context().drawPath(Path::polygonPathFromPoints(arrow));
     }
 
     return false;
index ad10f27..ac40049 100644 (file)
@@ -1278,21 +1278,21 @@ bool RenderThemeMac::paintMenuListButtonDecorations(const RenderBox& renderer, c
     paintInfo.context().setFillColor(renderer.style().visitedDependentColor(CSSPropertyColor));
     paintInfo.context().setStrokeStyle(NoStroke);
 
-    FloatPoint arrow1[3];
-    arrow1[0] = FloatPoint(leftEdge, centerY - spaceBetweenArrows / 2.0f);
-    arrow1[1] = FloatPoint(leftEdge + arrowWidth, centerY - spaceBetweenArrows / 2.0f);
-    arrow1[2] = FloatPoint(leftEdge + arrowWidth / 2.0f, centerY - spaceBetweenArrows / 2.0f - arrowHeight);
-
     // Draw the top arrow
-    paintInfo.context().drawConvexPolygon(3, arrow1, true);
-
-    FloatPoint arrow2[3];
-    arrow2[0] = FloatPoint(leftEdge, centerY + spaceBetweenArrows / 2.0f);
-    arrow2[1] = FloatPoint(leftEdge + arrowWidth, centerY + spaceBetweenArrows / 2.0f);
-    arrow2[2] = FloatPoint(leftEdge + arrowWidth / 2.0f, centerY + spaceBetweenArrows / 2.0f + arrowHeight);
+    Vector<FloatPoint> arrow1 = {
+        { leftEdge, centerY - spaceBetweenArrows / 2.0f },
+        { leftEdge + arrowWidth, centerY - spaceBetweenArrows / 2.0f },
+        { leftEdge + arrowWidth / 2.0f, centerY - spaceBetweenArrows / 2.0f - arrowHeight }
+    };
+    paintInfo.context().fillPath(Path::polygonPathFromPoints(arrow1));
 
     // Draw the bottom arrow
-    paintInfo.context().drawConvexPolygon(3, arrow2, true);
+    Vector<FloatPoint> arrow2 = {
+        { leftEdge, centerY + spaceBetweenArrows / 2.0f },
+        { leftEdge + arrowWidth, centerY + spaceBetweenArrows / 2.0f },
+        { leftEdge + arrowWidth / 2.0f, centerY + spaceBetweenArrows / 2.0f + arrowHeight }
+    };
+    paintInfo.context().fillPath(Path::polygonPathFromPoints(arrow2));
 
     Color leftSeparatorColor(0, 0, 0, 40);
     Color rightSeparatorColor(255, 255, 255, 40);
index c089558..d4f7d53 100644 (file)
@@ -1,3 +1,20 @@
+2016-01-15  Simon Fraser  <simon.fraser@apple.com>
+
+        Remove GraphicsContext::drawConvexPolygon() and GraphicsContext::clipConvexPolygon()
+        https://bugs.webkit.org/show_bug.cgi?id=153174
+
+        Reviewed by Zalan Bujtas.
+
+        GraphicsContext::drawConvexPolygon() and GraphicsContext::clipConvexPolygon() were
+        poorly named (non-convex polygons are allowed), and just syntactic sugar over
+        clipPath() and drawPath().
+        
+        Remove them, but add a convenience function to create a Path from a Vector of 
+        points. For CG, we can use the more efficient CGPathAddLines().
+
+        * FullscreenVideoController.cpp:
+        (HUDSlider::draw):
+
 2016-01-05  Per Arne Vollan  <peavo@outlook.com>
 
         [WinCairo] Download should use header values from provided request object.
index 1cd9754..808396a 100644 (file)
@@ -146,17 +146,15 @@ void HUDSlider::draw(GraphicsContext& context)
     }
 
     // Draw a diamond
-    FloatPoint points[4];
     float half = static_cast<float>(m_buttonSize) / 2;
-    points[0].setX(m_rect.location().x() + m_buttonPosition + half);
-    points[0].setY(m_rect.location().y());
-    points[1].setX(m_rect.location().x() + m_buttonPosition + m_buttonSize);
-    points[1].setY(m_rect.location().y() + half);
-    points[2].setX(m_rect.location().x() + m_buttonPosition + half);
-    points[2].setY(m_rect.location().y() + m_buttonSize);
-    points[3].setX(m_rect.location().x() + m_buttonPosition);
-    points[3].setY(m_rect.location().y() + half);
-    context.drawConvexPolygon(4, points, true);
+
+    Vector<FloatPoint> points = {
+        FloatPoint(m_rect.location().x() + m_buttonPosition + half, m_rect.location().y()),
+        FloatPoint(m_rect.location().x() + m_buttonPosition + m_buttonSize, m_rect.location().y() + half),
+        FloatPoint(m_rect.location().x() + m_buttonPosition + half, m_rect.location().y() + m_buttonSize),
+        FloatPoint(m_rect.location().x() + m_buttonPosition, m_rect.location().y() + half)
+    };
+    context.drawPath(Path::polygonPathFromPoints(points));
 }
 
 void HUDSlider::drag(const IntPoint& point, bool start)