2007-07-05 Alp Toker <alp.toker@collabora.co.uk>
authorbdash <bdash@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Jul 2007 13:47:47 +0000 (13:47 +0000)
committerbdash <bdash@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Jul 2007 13:47:47 +0000 (13:47 +0000)
        Reviewed by Mark Rowe.

        http://bugs.webkit.org/show_bug.cgi?id=14445
        GraphicsContextCairo code style cleanup

        Follow the cr naming convention for cairo_t*.
        Remove trailing whitespace.
        Replace C casts with C++ casts.
        Avoid needless casts.

        * platform/graphics/cairo/GraphicsContextCairo.cpp:
        (WebCore::GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate):
        (WebCore::GraphicsContextPlatformPrivate::~GraphicsContextPlatformPrivate):
        (WebCore::GraphicsContext::GraphicsContext):
        (WebCore::GraphicsContext::platformContext):
        (WebCore::GraphicsContext::savePlatformState):
        (WebCore::GraphicsContext::restorePlatformState):
        (WebCore::GraphicsContext::drawRect):
        (WebCore::adjustLineToPixelBoundaries):
        (WebCore::GraphicsContext::drawLine):
        (WebCore::GraphicsContext::drawEllipse):
        (WebCore::GraphicsContext::strokeArc): Save/restore the graphics state.
        (WebCore::GraphicsContext::drawConvexPolygon):
        (WebCore::GraphicsContext::fillRect):
        (WebCore::GraphicsContext::clip):
        (WebCore::GraphicsContext::drawFocusRing):
        (WebCore::GraphicsContext::roundToDevicePixels):
        (WebCore::GraphicsContext::translate):
        (WebCore::GraphicsContext::origin):
        (WebCore::GraphicsContext::setPlatformStrokeThickness):
        (WebCore::GraphicsContext::setPlatformStrokeStyle):
        (WebCore::GraphicsContext::setPlatformFont):
        (WebCore::GraphicsContext::concatCTM):
        (WebCore::GraphicsContext::addInnerRoundedRectClip):
        (WebCore::GraphicsContext::beginTransparencyLayer):
        (WebCore::GraphicsContext::endTransparencyLayer):
        (WebCore::GraphicsContext::clearRect):
        (WebCore::GraphicsContext::setLineCap):
        (WebCore::GraphicsContext::setLineJoin):
        (WebCore::GraphicsContext::setMiterLimit):
        (WebCore::GraphicsContext::setCompositeOperation):
        (WebCore::GraphicsContext::beginPath):
        (WebCore::GraphicsContext::addPath):
        (WebCore::GraphicsContext::rotate):
        (WebCore::GraphicsContext::scale):
        * platform/graphics/cairo/ImageBufferCairo.cpp:
        (WebCore::ImageBuffer::ImageBuffer):
        * platform/graphics/cairo/ImageCairo.cpp: Avoid the confusing ctxt/context naming scheme.
        (WebCore::BitmapImage::draw):
        (WebCore::Image::drawPattern):

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

WebCore/ChangeLog
WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
WebCore/platform/graphics/cairo/ImageBufferCairo.cpp
WebCore/platform/graphics/cairo/ImageCairo.cpp

index 7f5abf42585965ed6d0f29b75bd76940aa8239e2..0d41243029528f9cded62360bcf40dd74f3110a0 100644 (file)
@@ -1,3 +1,56 @@
+2007-07-05  Alp Toker  <alp.toker@collabora.co.uk>
+
+        Reviewed by Mark Rowe.
+
+        http://bugs.webkit.org/show_bug.cgi?id=14445
+        GraphicsContextCairo code style cleanup
+
+        Follow the cr naming convention for cairo_t*.
+        Remove trailing whitespace.
+        Replace C casts with C++ casts.
+        Avoid needless casts.
+
+        * platform/graphics/cairo/GraphicsContextCairo.cpp:
+        (WebCore::GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate):
+        (WebCore::GraphicsContextPlatformPrivate::~GraphicsContextPlatformPrivate):
+        (WebCore::GraphicsContext::GraphicsContext):
+        (WebCore::GraphicsContext::platformContext):
+        (WebCore::GraphicsContext::savePlatformState):
+        (WebCore::GraphicsContext::restorePlatformState):
+        (WebCore::GraphicsContext::drawRect):
+        (WebCore::adjustLineToPixelBoundaries):
+        (WebCore::GraphicsContext::drawLine):
+        (WebCore::GraphicsContext::drawEllipse):
+        (WebCore::GraphicsContext::strokeArc): Save/restore the graphics state.
+        (WebCore::GraphicsContext::drawConvexPolygon):
+        (WebCore::GraphicsContext::fillRect):
+        (WebCore::GraphicsContext::clip):
+        (WebCore::GraphicsContext::drawFocusRing):
+        (WebCore::GraphicsContext::roundToDevicePixels):
+        (WebCore::GraphicsContext::translate):
+        (WebCore::GraphicsContext::origin):
+        (WebCore::GraphicsContext::setPlatformStrokeThickness):
+        (WebCore::GraphicsContext::setPlatformStrokeStyle):
+        (WebCore::GraphicsContext::setPlatformFont):
+        (WebCore::GraphicsContext::concatCTM):
+        (WebCore::GraphicsContext::addInnerRoundedRectClip):
+        (WebCore::GraphicsContext::beginTransparencyLayer):
+        (WebCore::GraphicsContext::endTransparencyLayer):
+        (WebCore::GraphicsContext::clearRect):
+        (WebCore::GraphicsContext::setLineCap):
+        (WebCore::GraphicsContext::setLineJoin):
+        (WebCore::GraphicsContext::setMiterLimit):
+        (WebCore::GraphicsContext::setCompositeOperation):
+        (WebCore::GraphicsContext::beginPath):
+        (WebCore::GraphicsContext::addPath):
+        (WebCore::GraphicsContext::rotate):
+        (WebCore::GraphicsContext::scale):
+        * platform/graphics/cairo/ImageBufferCairo.cpp:
+        (WebCore::ImageBuffer::ImageBuffer):
+        * platform/graphics/cairo/ImageCairo.cpp: Avoid the confusing ctxt/context naming scheme.
+        (WebCore::BitmapImage::draw):
+        (WebCore::Image::drawPattern):
+
 2007-07-05  Alp Toker  <alp.toker@collabora.co.uk>
 
         Reviewed by Mark Rowe.
index 0e0ec112f4d48d90aafb1f69b840cbe0d41252ef..be041c74989277b8f33639d006fe51c39ddacfb0 100644 (file)
@@ -57,7 +57,7 @@ public:
     GraphicsContextPlatformPrivate();
     ~GraphicsContextPlatformPrivate();
 
-    cairo_t* context;
+    cairo_t* cr;
     Vector<float> layers;
 };
 
@@ -78,13 +78,13 @@ static inline void fillRectSourceOver(cairo_t* cr, const FloatRect& rect, const
 }
 
 GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate()
-    :  context(0)
+    :  cr(0)
 {
 }
 
 GraphicsContextPlatformPrivate::~GraphicsContextPlatformPrivate()
 {
-    cairo_destroy(context);
+    cairo_destroy(cr);
 }
 
 #if PLATFORM(WIN)
@@ -93,15 +93,15 @@ GraphicsContext::GraphicsContext(HDC dc)
     , m_data(new GraphicsContextPlatformPrivate)
 {
     cairo_surface_t* surface = cairo_win32_surface_create(dc);
-    m_data->context = cairo_create(surface);
+    m_data->cr = cairo_create(surface);
 }
 #endif
 
-GraphicsContext::GraphicsContext(PlatformGraphicsContext* context)
+GraphicsContext::GraphicsContext(PlatformGraphicsContext* cr)
     : m_common(createGraphicsContextPrivate())
     , m_data(new GraphicsContextPlatformPrivate)
 {
-    m_data->context = cairo_reference(context);
+    m_data->cr = cairo_reference(cr);
 }
 
 GraphicsContext::~GraphicsContext()
@@ -112,17 +112,17 @@ GraphicsContext::~GraphicsContext()
 
 cairo_t* GraphicsContext::platformContext() const
 {
-    return m_data->context;
+    return m_data->cr;
 }
 
 void GraphicsContext::savePlatformState()
 {
-    cairo_save(m_data->context);
+    cairo_save(m_data->cr);
 }
 
 void GraphicsContext::restorePlatformState()
 {
-    cairo_restore(m_data->context);
+    cairo_restore(m_data->cr);
 }
 
 // Draws a filled rectangle with a stroked border.
@@ -130,23 +130,23 @@ void GraphicsContext::drawRect(const IntRect& rect)
 {
     if (paintingDisabled())
         return;
-    
-    cairo_t* context = m_data->context;
-    cairo_save(context);
+
+    cairo_t* cr = m_data->cr;
+    cairo_save(cr);
 
     if (fillColor().alpha())
-        fillRectSourceOver(context, rect, fillColor());
+        fillRectSourceOver(cr, rect, fillColor());
 
     if (strokeStyle() != NoStroke) {
-        setColor(context, strokeColor());
+        setColor(cr, strokeColor());
         FloatRect r(rect);
         r.inflate(-.5f);
-        cairo_rectangle(context, r.x(), r.y(), r.width(), r.height());
-        cairo_set_line_width(context, 1.0);
-        cairo_stroke(context);
+        cairo_rectangle(cr, r.x(), r.y(), r.width(), r.height());
+        cairo_set_line_width(cr, 1.0);
+        cairo_stroke(cr);
     }
 
-    cairo_restore(context);
+    cairo_restore(cr);
 }
 
 // FIXME: Now that this is refactored, it should be shared by all contexts.
@@ -166,8 +166,8 @@ static void adjustLineToPixelBoundaries(FloatPoint& p1, FloatPoint& p2, float st
             p2.setX(p2.x() - strokeWidth);
         }
     }
-    
-    if (((int)strokeWidth)%2) {
+
+    if (static_cast<int>(strokeWidth) % 2) {
         if (p1.x() == p2.x()) {
             // We're a vertical line.  Adjust our x.
             p1.setX(p1.x() + 0.5);
@@ -191,8 +191,8 @@ void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2)
     if (style == NoStroke)
         return;
 
-    cairo_t* context = m_data->context;
-    cairo_save(context);
+    cairo_t* cr = m_data->cr;
+    cairo_save(cr);
 
     float width = strokeThickness();
     if (width < 1)
@@ -201,9 +201,9 @@ void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2)
     FloatPoint p1 = point1;
     FloatPoint p2 = point2;
     bool isVerticalLine = (p1.x() == p2.x());
-    
     adjustLineToPixelBoundaries(p1, p2, width, style);
-    cairo_set_line_width(context, width);
+    cairo_set_line_width(cr, width);
 
     int patWidth = 0;
     switch (style) {
@@ -211,32 +211,32 @@ void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2)
     case SolidStroke:
         break;
     case DottedStroke:
-        patWidth = (int)width;
+        patWidth = static_cast<int>(width);
         break;
     case DashedStroke:
-        patWidth = 3*(int)width;
+        patWidth = 3*static_cast<int>(width);
         break;
     }
 
-    setColor(context, strokeColor());
-    
-    cairo_set_antialias(context, CAIRO_ANTIALIAS_NONE);
-    
+    setColor(cr, strokeColor());
+
+    cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE);
+
     if (patWidth) {
         // Do a rect fill of our endpoints.  This ensures we always have the
         // appearance of being a border.  We then draw the actual dotted/dashed line.
         if (isVerticalLine) {
-            fillRectSourceOver(context, FloatRect(p1.x()-width/2, p1.y()-width, width, width), strokeColor());
-            fillRectSourceOver(context, FloatRect(p2.x()-width/2, p2.y(), width, width), strokeColor());
+            fillRectSourceOver(cr, FloatRect(p1.x() - width/2, p1.y() - width, width, width), strokeColor());
+            fillRectSourceOver(cr, FloatRect(p2.x() - width/2, p2.y(), width, width), strokeColor());
         } else {
-            fillRectSourceOver(context, FloatRect(p1.x()-width, p1.y()-width/2, width, width), strokeColor());
-            fillRectSourceOver(context, FloatRect(p2.x(), p2.y()-width/2, width, width), strokeColor());
+            fillRectSourceOver(cr, FloatRect(p1.x() - width, p1.y() - width/2, width, width), strokeColor());
+            fillRectSourceOver(cr, FloatRect(p2.x(), p2.y() - width/2, width, width), strokeColor());
         }
-        
+
         // Example: 80 pixels with a width of 30 pixels.
         // Remainder is 20.  The maximum pixels of line we could paint
         // will be 50 pixels.
-        int distance = (isVerticalLine ? (point2.y() - point1.y()) : (point2.x() - point1.x())) - 2*(int)width;
+        int distance = (isVerticalLine ? (point2.y() - point1.y()) : (point2.x() - point1.x())) - 2*static_cast<int>(width);
         int remainder = distance%patWidth;
         int coverage = distance-remainder;
         int numSegments = coverage/patWidth;
@@ -262,16 +262,16 @@ void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2)
                     patternOffset = (patWidth - remainder)/2;
             }
         }
-        
+
         double dash = patWidth;
-        cairo_set_dash(context, &dash, 1, patternOffset);
+        cairo_set_dash(cr, &dash, 1, patternOffset);
     }
 
-    cairo_move_to(context, p1.x(), p1.y());
-    cairo_line_to(context, p2.x(), p2.y());
+    cairo_move_to(cr, p1.x(), p1.y());
+    cairo_line_to(cr, p2.x(), p2.y());
 
-    cairo_stroke(context);
-    cairo_restore(context);
+    cairo_stroke(cr);
+    cairo_restore(cr);
 }
 
 // This method is only used to draw the little circles used in lists.
@@ -279,28 +279,28 @@ void GraphicsContext::drawEllipse(const IntRect& rect)
 {
     if (paintingDisabled())
         return;
-    
-    cairo_t* context = m_data->context;
-    cairo_save(context);
+
+    cairo_t* cr = m_data->cr;
+    cairo_save(cr);
     float yRadius = .5 * rect.height();
     float xRadius = .5 * rect.width();
-    cairo_translate(context, rect.x() + xRadius, rect.y() + yRadius);
-    cairo_scale(context, xRadius, yRadius);
-    cairo_arc(context, 0., 0., 1., 0., 2 * M_PI);
-    cairo_restore(context);
+    cairo_translate(cr, rect.x() + xRadius, rect.y() + yRadius);
+    cairo_scale(cr, xRadius, yRadius);
+    cairo_arc(cr, 0., 0., 1., 0., 2 * M_PI);
+    cairo_restore(cr);
 
     if (fillColor().alpha()) {
-        setColor(context, fillColor());
-        cairo_fill_preserve(context);
+        setColor(cr, fillColor());
+        cairo_fill_preserve(cr);
     }
 
     if (strokeStyle() != NoStroke) {
-        setColor(context, strokeColor());
-        cairo_set_line_width(context, strokeThickness());
-        cairo_stroke(context);
+        setColor(cr, strokeColor());
+        cairo_set_line_width(cr, strokeThickness());
+        cairo_stroke(cr);
     }
 
-    cairo_new_path(context);
+    cairo_new_path(cr);
 }
 
 // FIXME: This function needs to be adjusted to match the functionality on the Mac side.
@@ -308,26 +308,29 @@ void GraphicsContext::strokeArc(const IntRect& rect, int startAngle, int angleSp
 {
     if (paintingDisabled())
         return;
-    
+
+    if (strokeStyle() == NoStroke)
+        return;
+
     int x = rect.x();
     int y = rect.y();
-    float w = (float)rect.width();
+    float w = rect.width();
 #if 0 // FIXME: unused so far
-    float h = (float)rect.height();
+    float h = rect.height();
     float scaleFactor = h / w;
     float reverseScaleFactor = w / h;
 #endif
-    cairo_t* context = m_data->context;
-    if (strokeStyle() != NoStroke) {        
-        float r = w / 2;
-        float fa = startAngle;
-        float falen =  fa + angleSpan;
-        cairo_arc_negative(context, x + r, y + r, r, -fa * M_PI/180, -falen * M_PI/180);
-        
-        setColor(context, strokeColor());
-        cairo_set_line_width(context, strokeThickness());
-        cairo_stroke(context);
-    }
+    float r = w / 2;
+    float fa = startAngle;
+    float falen =  fa + angleSpan;
+
+    cairo_t* cr = m_data->cr;
+    cairo_save(cr);
+    cairo_arc_negative(cr, x + r, y + r, r, -fa * M_PI/180, -falen * M_PI/180);
+    setColor(cr, strokeColor());
+    cairo_set_line_width(cr, strokeThickness());
+    cairo_stroke(cr);
+    cairo_restore(cr);
 }
 
 void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points, bool shouldAntialias)
@@ -338,29 +341,29 @@ void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points
     if (npoints <= 1)
         return;
 
-    cairo_t* context = m_data->context;
+    cairo_t* cr = m_data->cr;
 
-    cairo_save(context);
-    cairo_set_antialias(context, shouldAntialias ? CAIRO_ANTIALIAS_DEFAULT : CAIRO_ANTIALIAS_NONE);
-    cairo_move_to(context, points[0].x(), points[0].y());
+    cairo_save(cr);
+    cairo_set_antialias(cr, shouldAntialias ? CAIRO_ANTIALIAS_DEFAULT : CAIRO_ANTIALIAS_NONE);
+    cairo_move_to(cr, points[0].x(), points[0].y());
     for (size_t i = 1; i < npoints; i++)
-        cairo_line_to(context, points[i].x(), points[i].y());
-    cairo_close_path(context);
+        cairo_line_to(cr, points[i].x(), points[i].y());
+    cairo_close_path(cr);
 
     if (fillColor().alpha()) {
-        setColor(context, fillColor());
-        cairo_set_fill_rule(context, CAIRO_FILL_RULE_EVEN_ODD);
-        cairo_fill_preserve(context);
+        setColor(cr, fillColor());
+        cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD);
+        cairo_fill_preserve(cr);
     }
 
     if (strokeStyle() != NoStroke) {
-        setColor(context, strokeColor());
-        cairo_set_line_width(context, strokeThickness());
-        cairo_stroke(context);
+        setColor(cr, strokeColor());
+        cairo_set_line_width(cr, strokeThickness());
+        cairo_stroke(cr);
     }
 
-    cairo_new_path(context);
-    cairo_restore(context);
+    cairo_new_path(cr);
+    cairo_restore(cr);
 }
 
 void GraphicsContext::fillRect(const IntRect& rect, const Color& color)
@@ -369,7 +372,7 @@ void GraphicsContext::fillRect(const IntRect& rect, const Color& color)
         return;
 
     if (color.alpha())
-        fillRectSourceOver(m_data->context, rect, color);
+        fillRectSourceOver(m_data->cr, rect, color);
 }
 
 void GraphicsContext::fillRect(const FloatRect& rect, const Color& color)
@@ -378,7 +381,7 @@ void GraphicsContext::fillRect(const FloatRect& rect, const Color& color)
         return;
 
     if (color.alpha())
-        fillRectSourceOver(m_data->context, rect, color);
+        fillRectSourceOver(m_data->cr, rect, color);
 }
 
 void GraphicsContext::clip(const IntRect& rect)
@@ -386,9 +389,9 @@ void GraphicsContext::clip(const IntRect& rect)
     if (paintingDisabled())
         return;
 
-    cairo_t* context = m_data->context;
-    cairo_rectangle(context, rect.x(), rect.y(), rect.width(), rect.height());
-    cairo_clip(context);
+    cairo_t* cr = m_data->cr;
+    cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height());
+    cairo_clip(cr);
 }
 
 void GraphicsContext::drawFocusRing(const Color& color)
@@ -398,7 +401,7 @@ void GraphicsContext::drawFocusRing(const Color& color)
 
     int radius = (focusRingWidth() - 1) / 2;
     int offset = radius + focusRingOffset();
-    
+
     const Vector<IntRect>& rects = focusRingRects();
     unsigned rectCount = rects.size();
     IntRect finalFocusRect;
@@ -407,13 +410,17 @@ void GraphicsContext::drawFocusRing(const Color& color)
         focusRect.inflate(offset);
         finalFocusRect.unite(focusRect);
     }
+
+    cairo_t* cr = m_data->cr;
+    cairo_save(cr);
     // FIXME: These rects should be rounded
-    cairo_rectangle(m_data->context, finalFocusRect.x(), finalFocusRect.y(), finalFocusRect.width(), finalFocusRect.height());
-    
+    cairo_rectangle(cr, finalFocusRect.x(), finalFocusRect.y(), finalFocusRect.width(), finalFocusRect.height());
+
     // Force the alpha to 50%.  This matches what the Mac does with outline rings.
     Color ringColor(color.red(), color.green(), color.blue(), 127);
-    setColor(m_data->context, ringColor);
-    cairo_stroke(m_data->context);
+    setColor(cr, ringColor);
+    cairo_stroke(cr);
+    cairo_restore(cr);
 }
 
 void GraphicsContext::setFocusRingClip(const IntRect&)
@@ -445,40 +452,41 @@ void GraphicsContext::drawLineForMisspellingOrBadGrammar(const IntPoint&, int wi
 FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& frect)
 {
     FloatRect result;
-    double x =frect.x();
+    double x = frect.x();
     double y = frect.y();
-    cairo_t* context = m_data->context;
-    cairo_user_to_device(context,&x,&y);
+    cairo_t* cr = m_data->cr;
+    cairo_user_to_device(cr, &x, &y);
     x = round(x);
     y = round(y);
-    cairo_device_to_user(context,&x,&y);
-    result.setX((float)x);
-    result.setY((float)y);
+    cairo_device_to_user(cr, &x, &y);
+    result.setX(static_cast<float>(x));
+    result.setY(static_cast<float>(y));
     x = frect.width();
     y = frect.height();
-    cairo_user_to_device_distance(context,&x,&y);
+    cairo_user_to_device_distance(cr, &x, &y);
     x = round(x);
     y = round(y);
-    cairo_device_to_user_distance(context,&x,&y);
-    result.setWidth((float)x);
-    result.setHeight((float)y);
-    return result; 
+    cairo_device_to_user_distance(cr, &x, &y);
+    result.setWidth(static_cast<float>(x));
+    result.setHeight(static_cast<float>(y));
+    return result;
 }
 
 void GraphicsContext::translate(float x, float y)
 {
     if (paintingDisabled())
         return;
-    cairo_t* context = m_data->context;
-    cairo_translate(context, x, y);
+
+    cairo_t* cr = m_data->cr;
+    cairo_translate(cr, x, y);
 }
 
 IntPoint GraphicsContext::origin()
 {
     cairo_matrix_t matrix;
-    cairo_t* context = m_data->context;
-    cairo_get_matrix(context, &matrix);
-    return IntPoint((int)matrix.x0, (int)matrix.y0);
+    cairo_t* cr = m_data->cr;
+    cairo_get_matrix(cr, &matrix);
+    return IntPoint(static_cast<int>(matrix.x0), static_cast<int>(matrix.y0));
 }
 
 void GraphicsContext::setPlatformFillColor(const Color& col)
@@ -497,7 +505,8 @@ void GraphicsContext::setPlatformStrokeThickness(float strokeThickness)
 {
     if (paintingDisabled())
         return;
-    cairo_set_line_width(m_data->context, strokeThickness);
+
+    cairo_set_line_width(m_data->cr, strokeThickness);
 }
 
 void GraphicsContext::setPlatformStrokeStyle(const StrokeStyle& strokeStyle)
@@ -511,16 +520,16 @@ void GraphicsContext::setPlatformStrokeStyle(const StrokeStyle& strokeStyle)
     switch (strokeStyle) {
     case NoStroke:
         // FIXME: is it the right way to emulate NoStroke?
-        cairo_set_line_width(m_data->context, 0);
+        cairo_set_line_width(m_data->cr, 0);
         break;
     case SolidStroke:
-        cairo_set_dash(m_data->context, 0, 0, 0);
+        cairo_set_dash(m_data->cr, 0, 0, 0);
         break;
     case DottedStroke:
-        cairo_set_dash(m_data->context, dotPattern, 2, 0);
+        cairo_set_dash(m_data->cr, dotPattern, 2, 0);
         break;
     case DashedStroke:
-        cairo_set_dash(m_data->context, dashPattern, 2, 0);
+        cairo_set_dash(m_data->cr, dashPattern, 2, 0);
         break;
     default:
         notImplemented();
@@ -537,7 +546,7 @@ void GraphicsContext::setPlatformFont(const Font& font)
     // FIXME: is it the right thing to do? Also, doesn't work on Win because
     // there FontData doesn't have ::setFont()
     const FontData *fontData = font.primaryFont();
-    fontData->setFont(m_data->context);
+    fontData->setFont(m_data->cr);
 #endif
 }
 
@@ -551,14 +560,14 @@ void GraphicsContext::concatCTM(const AffineTransform& transform)
     if (paintingDisabled())
         return;
 
-    cairo_t* cr = m_data->context;
+    cairo_t* cr = m_data->cr;
     const cairo_matrix_t* matrix = reinterpret_cast<const cairo_matrix_t*>(&transform);
     cairo_transform(cr, matrix);
 }
 
-void GraphicsContext::addInnerRoundedRectClip(const IntRect& rect, int thickness) 
-{ 
-    notImplemented(); 
+void GraphicsContext::addInnerRoundedRectClip(const IntRect& rect, int thickness)
+{
+    notImplemented();
 }
 
 void GraphicsContext::setShadow(IntSize const&, int, Color const&)
@@ -576,8 +585,8 @@ void GraphicsContext::beginTransparencyLayer(float opacity)
     if (paintingDisabled())
         return;
 
-    cairo_t* context = m_data->context;
-    cairo_push_group(context);
+    cairo_t* cr = m_data->cr;
+    cairo_push_group(cr);
     m_data->layers.append(opacity);
 }
 
@@ -586,10 +595,10 @@ void GraphicsContext::endTransparencyLayer()
     if (paintingDisabled())
         return;
 
-    cairo_t* context = m_data->context;
+    cairo_t* cr = m_data->cr;
 
-    cairo_pop_group_to_source(context);
-    cairo_paint_with_alpha(context, m_data->layers.last());
+    cairo_pop_group_to_source(cr);
+    cairo_paint_with_alpha(cr, m_data->layers.last());
     m_data->layers.removeLast();
 }
 
@@ -598,7 +607,7 @@ void GraphicsContext::clearRect(const FloatRect& rect)
     if (paintingDisabled())
         return;
 
-    cairo_t* cr = m_data->context;
+    cairo_t* cr = m_data->cr;
 
     cairo_save(cr);
     cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height());
@@ -629,7 +638,7 @@ void GraphicsContext::setLineCap(LineCap lineCap)
             cairoCap = CAIRO_LINE_CAP_SQUARE;
             break;
     }
-    cairo_set_line_cap(m_data->context, cairoCap);
+    cairo_set_line_cap(m_data->cr, cairoCap);
 }
 
 void GraphicsContext::setLineJoin(LineJoin lineJoin)
@@ -649,14 +658,15 @@ void GraphicsContext::setLineJoin(LineJoin lineJoin)
             cairoJoin = CAIRO_LINE_JOIN_BEVEL;
             break;
     }
-    cairo_set_line_join(m_data->context, cairoJoin);
+    cairo_set_line_join(m_data->cr, cairoJoin);
 }
 
 void GraphicsContext::setMiterLimit(float miter)
 {
     if (paintingDisabled())
         return;
-    cairo_set_miter_limit(m_data->context, miter);
+
+    cairo_set_miter_limit(m_data->cr, miter);
 }
 
 void GraphicsContext::setAlpha(float)
@@ -704,7 +714,8 @@ void GraphicsContext::setCompositeOperation(CompositeOperator op)
 {
     if (paintingDisabled())
         return;
-    cairo_set_operator(m_data->context, toCairoOperator(op));
+
+    cairo_set_operator(m_data->cr, toCairoOperator(op));
 }
 
 void GraphicsContext::beginPath()
@@ -712,7 +723,7 @@ void GraphicsContext::beginPath()
     if (paintingDisabled())
         return;
 
-    cairo_t* cr = m_data->context;
+    cairo_t* cr = m_data->cr;
     cairo_new_path(cr);
 }
 
@@ -721,7 +732,7 @@ void GraphicsContext::addPath(const Path& path)
     if (paintingDisabled())
         return;
 
-    cairo_t* cr = m_data->context;
+    cairo_t* cr = m_data->cr;
     cairo_path_t *p = cairo_copy_path(path.platformPath()->m_cr);
     cairo_append_path(cr, p);
     cairo_path_destroy(p);
@@ -731,7 +742,8 @@ void GraphicsContext::clip(const Path& path)
 {
     if (paintingDisabled())
         return;
-    cairo_t* cr = m_data->context;
+
+    cairo_t* cr = m_data->cr;
     cairo_path_t *p = cairo_copy_path(path.platformPath()->m_cr);
     cairo_append_path(cr, p);
     cairo_path_destroy(p);
@@ -747,14 +759,16 @@ void GraphicsContext::rotate(float radians)
 {
     if (paintingDisabled())
         return;
-    cairo_rotate(m_data->context, radians);
+
+    cairo_rotate(m_data->cr, radians);
 }
 
 void GraphicsContext::scale(const FloatSize& size)
 {
     if (paintingDisabled())
         return;
-    cairo_scale(m_data->context, size.width(), size.height());
+
+    cairo_scale(m_data->cr, size.width(), size.height());
 }
 
 void GraphicsContext::clipOut(const IntRect&)
index 597c6ca0fe0e68b84683e57b3739623f5e7001ba..a6f6fda301972718011e2d57038749f02b049a95 100644 (file)
@@ -48,13 +48,13 @@ auto_ptr<ImageBuffer> ImageBuffer::create(const IntSize& size, bool)
 ImageBuffer::ImageBuffer(_cairo_surface* surface)
     : m_surface(surface)
 {
-    cairo_t* context = cairo_create(m_surface);
-    m_context.set(new GraphicsContext(context));
+    cairo_t* cr = cairo_create(m_surface);
+    m_context.set(new GraphicsContext(cr));
 
     /*
      * The context is now owned by the GraphicsContext
      */
-    cairo_destroy(context);
+    cairo_destroy(cr);
 }
 
 ImageBuffer::~ImageBuffer()
index c2559f1862fcecce1c5675d1b2f85137d718d1ec..5b23f72a65532c1670de4447bd5f5c00fdc386b1 100644 (file)
@@ -53,28 +53,28 @@ void FrameData::clear()
 
 // Drawing Routines
 
-void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dst, const FloatRect& src, CompositeOperator op)
+void BitmapImage::draw(GraphicsContext* context, const FloatRect& dst, const FloatRect& src, CompositeOperator op)
 {
-    cairo_t* context = ctxt->platformContext();
+    cairo_t* cr = context->platformContext();
 
     if (!m_source.initialized())
         return;
-    
+
     cairo_surface_t* image = frameAtIndex(m_currentFrame);
     if (!image) // If it's too early we won't have an image yet.
         return;
 
-    IntSize selfSize = size();                       
+    IntSize selfSize = size();
     FloatRect srcRect(src);
     FloatRect dstRect(dst);
 
-    cairo_save(context);
+    cairo_save(cr);
 
     // Set the compositing operation.
     if (op == CompositeSourceOver && !frameHasAlphaAtIndex(m_currentFrame))
-        ctxt->setCompositeOperation(CompositeCopy);
+        context->setCompositeOperation(CompositeCopy);
     else
-        ctxt->setCompositeOperation(op);
+        context->setCompositeOperation(op);
 
     // If we're drawing a sub portion of the image or scaling then create
     // a pattern transformation on the image and draw the transformed pattern.
@@ -89,31 +89,30 @@ void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dst, const FloatR
 
     float scaleX = srcRect.width() / dstRect.width();
     float scaleY = srcRect.height() / dstRect.height();
-    cairo_matrix_t mat = { scaleX,  0, 0 , scaleY, srcRect.x(), srcRect.y() };
-    cairo_pattern_set_matrix(pattern, &mat);
+    cairo_matrix_t matrix = { scaleX,  0, 0 , scaleY, srcRect.x(), srcRect.y() };
+    cairo_pattern_set_matrix(pattern, &matrix);
 
     // Draw the image.
-    cairo_translate(context, dstRect.x(), dstRect.y());
-    cairo_set_source(context, pattern);
-    cairo_rectangle(context, 0, 0, dstRect.width(), dstRect.height());
-    cairo_fill(context);
+    cairo_translate(cr, dstRect.x(), dstRect.y());
+    cairo_set_source(cr, pattern);
+    cairo_rectangle(cr, 0, 0, dstRect.width(), dstRect.height());
+    cairo_fill(cr);
 
     cairo_pattern_destroy(pattern);
-    cairo_restore(context);
+    cairo_restore(cr);
 
     startAnimation();
-
 }
 
-void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const AffineTransform& patternTransform,
+void Image::drawPattern(GraphicsContext* context, const FloatRect& tileRect, const AffineTransform& patternTransform,
                         const FloatPoint& phase, CompositeOperator op, const FloatRect& destRect)
 {
     cairo_surface_t* image = nativeImageForCurrentFrame();
     if (!image) // If it's too early we won't have an image yet.
         return;
 
-    cairo_t* context = ctxt->platformContext();
-    ctxt->save();
+    cairo_t* cr = context->platformContext();
+    context->save();
 
     // TODO: Make use of tileRect.
 
@@ -130,13 +129,13 @@ void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const
     cairo_matrix_invert(&combined);
     cairo_pattern_set_matrix(pattern, &combined);
 
-    ctxt->setCompositeOperation(op);
-    cairo_set_source(context, pattern);
-    cairo_rectangle(context, destRect.x(), destRect.y(), destRect.width(), destRect.height());
-    cairo_fill(context);
+    context->setCompositeOperation(op);
+    cairo_set_source(cr, pattern);
+    cairo_rectangle(cr, destRect.x(), destRect.y(), destRect.width(), destRect.height());
+    cairo_fill(cr);
 
     cairo_pattern_destroy(pattern);
-    ctxt->restore();
+    context->restore();
 }
 
 void BitmapImage::checkForSolidColor()