Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 5th, 2012  |  syntax: None  |  size: 2.55 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. commit 1f2c0aadab8c573c4f0072cad09171f2dd7cffeb
  2. Author: Martin Robinson <mrobinson@igalia.com>
  3. Date:   Sat Jul 10 16:07:32 2010 -0700
  4.  
  5.     convex clip
  6.  
  7. diff --git a/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp b/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
  8. index 3226fe0..2f55f56 100644
  9. --- a/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
  10. +++ b/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
  11. @@ -66,6 +66,14 @@
  12.  
  13.  namespace WebCore {
  14.  
  15. +static void addConvexPolygonToContext(cairo_t* context, size_t numPoints, const FloatPoint* points)
  16. +{
  17. +    cairo_move_to(context, points[0].x(), points[0].y());
  18. +    for (size_t i = 1; i < numPoints; i++)
  19. +        cairo_line_to(context, points[i].x(), points[i].y());
  20. +    cairo_close_path(context);
  21. +}
  22. +
  23.  static inline void setColor(cairo_t* cr, const Color& col)
  24.  {
  25.      float red, green, blue, alpha;
  26. @@ -510,10 +518,7 @@ void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points
  27.      m_data->saveCairoPath();
  28.  
  29.      cairo_set_antialias(cr, shouldAntialias ? CAIRO_ANTIALIAS_DEFAULT : CAIRO_ANTIALIAS_NONE);
  30. -    cairo_move_to(cr, points[0].x(), points[0].y());
  31. -    for (size_t i = 1; i < npoints; i++)
  32. -        cairo_line_to(cr, points[i].x(), points[i].y());
  33. -    cairo_close_path(cr);
  34. +    addConvexPolygonToContext(cr, npoints, points);
  35.  
  36.      if (fillColor().alpha()) {
  37.          setColor(cr, fillColor());
  38. @@ -539,8 +544,21 @@ void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* poin
  39.  
  40.      if (numPoints <= 1)
  41.          return;
  42. -    
  43. -    // FIXME: IMPLEMENT!
  44. +
  45. +    cairo_t* cr = m_data->cr;
  46. +    m_data->saveCairoPath();
  47. +
  48. +    cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr);
  49. +    cairo_antialias_t savedAntialiasRule = cairo_get_antialias(cr);
  50. +    cairo_set_antialias(cr, CAIRO_ANTIALIAS_DEFAULT);
  51. +    cairo_set_fill_rule(cr, CAIRO_FILL_RULE_WINDING);
  52. +
  53. +    addConvexPolygonToContext(cr, numPoints, points);
  54. +    cairo_clip(cr);
  55. +
  56. +    cairo_set_antialias(cr, savedAntialiasRule);
  57. +    cairo_set_fill_rule(cr, savedFillRule);
  58. +    m_data->restoreCairoPath();
  59.  }
  60.  
  61.  void GraphicsContext::fillPath()
  62. diff --git a/WebCore/rendering/RenderObject.h b/WebCore/rendering/RenderObject.h
  63. index 33271df..f3bb7a1 100644
  64. --- a/WebCore/rendering/RenderObject.h
  65. +++ b/WebCore/rendering/RenderObject.h
  66. @@ -38,7 +38,7 @@
  67.  #include "TransformationMatrix.h"
  68.  #include <wtf/UnusedParam.h>
  69.  
  70. -#if PLATFORM(CG)
  71. +#if PLATFORM(CG) || PLATFORM(GTK)
  72.  #define HAVE_PATH_BASED_BORDER_RADIUS_DRAWING 1
  73.  #endif