+2007-12-23 Alp Toker <alp@atoker.com>
+
+ Reviewed by Holger Freyther.
+
+ http://bugs.webkit.org/show_bug.cgi?id=16577
+ Merge Cairo enhancements from Apollo project
+
+ This patch is based on initial merging work by Brent Fulgham. Adobe's
+ code has been modified in a few places to better suit the existing
+ coding style.
+
+ Implement more clipping and drawing functions.
+
+ Save and restore the fill rule manually when clipping.
+
+ Avoid image surface creation when the image buffer has height zero.
+
+ * platform/graphics/cairo/GraphicsContextCairo.cpp:
+ (WebCore::GraphicsContext::clip):
+ (WebCore::GraphicsContext::addInnerRoundedRectClip):
+ (WebCore::GraphicsContext::addPath):
+ (WebCore::GraphicsContext::clipOut):
+ (WebCore::GraphicsContext::clipOutEllipseInRect):
+ (WebCore::GraphicsContext::fillRoundedRect):
+ * platform/graphics/cairo/ImageSourceCairo.cpp:
+ (WebCore::ImageSource::createFrameAtIndex):
+
2007-12-23 Nikolas Zimmermann <zimmermann@kde.org>
Reviewed by Mark.
cairo_t* cr = m_data->cr;
cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height());
+ cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr);
+ cairo_set_fill_rule(cr, CAIRO_FILL_RULE_WINDING);
cairo_clip(cr);
+ cairo_set_fill_rule(cr, savedFillRule);
}
void GraphicsContext::drawFocusRing(const Color& color)
return;
clip(rect);
- Path path;
- path.addEllipse(rect);
-
- IntRect inner(rect);
- inner.inflate(-thickness);
- path.addEllipse(inner);
+ Path p;
+ FloatRect r(rect);
+ // Add outer ellipse
+ p.addEllipse(r);
+ // Add inner ellipse
+ r.inflate(-thickness);
+ p.addEllipse(r);
+ addPath(p);
cairo_t* cr = m_data->cr;
+ cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr);
cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD);
-
- clip(path);
+ cairo_clip(cr);
+ cairo_set_fill_rule(cr, savedFillRule);
}
+
void GraphicsContext::setShadow(IntSize const&, int, Color const&)
{
notImplemented();
return;
cairo_t* cr = m_data->cr;
- cairo_path_t *p = cairo_copy_path(path.platformPath()->m_cr);
+ cairo_path_t* p = cairo_copy_path(path.platformPath()->m_cr);
cairo_append_path(cr, p);
cairo_path_destroy(p);
}
return;
cairo_t* cr = m_data->cr;
- cairo_path_t *p = cairo_copy_path(path.platformPath()->m_cr);
+ cairo_path_t* p = cairo_copy_path(path.platformPath()->m_cr);
cairo_append_path(cr, p);
cairo_path_destroy(p);
+ cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr);
+ cairo_set_fill_rule(cr, CAIRO_FILL_RULE_WINDING);
cairo_clip(cr);
+ cairo_set_fill_rule(cr, savedFillRule);
}
-void GraphicsContext::clipOut(const Path&)
+void GraphicsContext::clipOut(const Path& path)
{
- notImplemented();
+ if (paintingDisabled())
+ return;
+
+ cairo_t* cr = m_data->cr;
+ double x1, y1, x2, y2;
+ cairo_clip_extents(cr, &x1, &y1, &x2, &y2);
+ cairo_rectangle(cr, x1, y1, x2 - x1, y2 - y1);
+ addPath(path);
+
+ cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr);
+ cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD);
+ cairo_clip(cr);
+ cairo_set_fill_rule(cr, savedFillRule);
}
void GraphicsContext::rotate(float radians)
cairo_scale(m_data->cr, size.width(), size.height());
}
-void GraphicsContext::clipOut(const IntRect&)
+void GraphicsContext::clipOut(const IntRect& r)
{
- notImplemented();
+ if (paintingDisabled())
+ return;
+
+ cairo_t* cr = m_data->cr;
+ double x1, y1, x2, y2;
+ cairo_clip_extents(cr, &x1, &y1, &x2, &y2);
+ cairo_rectangle(cr, x1, x2, x2 - x1, y2 - y1);
+ cairo_rectangle(cr, r.x(), r.y(), r.width(), r.height());
+ cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr);
+ cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD);
+ cairo_clip(cr);
+ cairo_set_fill_rule(cr, savedFillRule);
}
-void GraphicsContext::clipOutEllipseInRect(const IntRect&)
+void GraphicsContext::clipOutEllipseInRect(const IntRect& r)
{
- notImplemented();
+ if (paintingDisabled())
+ return;
+
+ Path p;
+ p.addEllipse(r);
+ clipOut(p);
}
-void GraphicsContext::fillRoundedRect(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color&)
+void GraphicsContext::fillRoundedRect(const IntRect& r, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color& color)
{
- notImplemented();
+ if (paintingDisabled())
+ return;
+
+ cairo_t* cr = m_data->cr;
+ cairo_save(cr);
+ beginPath();
+ addPath(Path::createRoundedRectangle(r, topLeft, topRight, bottomLeft, bottomRight));
+ setColor(cr, color);
+ cairo_fill(cr);
+ cairo_restore(cr);
}
#if PLATFORM(GTK)