Changeset 64490 in webkit


Ignore:
Timestamp:
Aug 2, 2010 2:01:25 PM (14 years ago)
Author:
Martin Robinson
Message:

2010-08-02 Martin Robinson <mrobinson@igalia.com>

Reviewed by Xan Lopez.

[GTK] Style cleanup for CairoPath.h
https://bugs.webkit.org/show_bug.cgi?id=43133

Turn CairoPath into a class, as it has a constructor and destructor.
Change raw member access to use the new accessor.

No new tests as functionality has not changed.

  • platform/graphics/cairo/CairoPath.h: Cleanup and indentation fix. (WebCore::CairoPath::CairoPath): (WebCore::CairoPath::~CairoPath): (WebCore::CairoPath::context):
  • platform/graphics/cairo/GraphicsContextCairo.cpp: (WebCore::GraphicsContext::addPath): Convert raw member access to accessor access. (WebCore::GraphicsContext::clip): Ditto.
  • platform/graphics/cairo/PathCairo.cpp: (WebCore::Path::Path): Ditto. (WebCore::Path::operator=): Ditto. (WebCore::Path::clear): Ditto. (WebCore::Path::isEmpty): Ditto. (WebCore::Path::currentPoint): Ditto. (WebCore::Path::translate): Ditto. (WebCore::Path::moveTo): Ditto. (WebCore::Path::addLineTo): Ditto. (WebCore::Path::addRect): Ditto. (WebCore::Path::addQuadCurveTo): Ditto. (WebCore::Path::addBezierCurveTo): Ditto. (WebCore::Path::addArc): Ditto. (WebCore::Path::addArcTo): Ditto. (WebCore::Path::addEllipse): Ditto. (WebCore::Path::closeSubpath): Ditto. (WebCore::Path::boundingRect): Ditto. (WebCore::Path::strokeBoundingRect): Ditto. (WebCore::Path::contains): Ditto. (WebCore::Path::strokeContains): Ditto. (WebCore::Path::apply): Ditto. (WebCore::Path::transform): Ditto. (WebCore::Path::debugString): Ditto.
Location:
trunk/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r64489 r64490  
     12010-08-02  Martin Robinson  <mrobinson@igalia.com>
     2
     3        Reviewed by Xan Lopez.
     4
     5        [GTK] Style cleanup for CairoPath.h
     6        https://bugs.webkit.org/show_bug.cgi?id=43133
     7
     8        Turn CairoPath into a class, as it has a constructor and destructor.
     9        Change raw member access to use the new accessor.
     10
     11        No new tests as functionality has not changed.
     12
     13        * platform/graphics/cairo/CairoPath.h: Cleanup and indentation fix.
     14        (WebCore::CairoPath::CairoPath):
     15        (WebCore::CairoPath::~CairoPath):
     16        (WebCore::CairoPath::context):
     17        * platform/graphics/cairo/GraphicsContextCairo.cpp:
     18        (WebCore::GraphicsContext::addPath): Convert raw member access to accessor access.
     19        (WebCore::GraphicsContext::clip): Ditto.
     20        * platform/graphics/cairo/PathCairo.cpp:
     21        (WebCore::Path::Path): Ditto.
     22        (WebCore::Path::operator=): Ditto.
     23        (WebCore::Path::clear): Ditto.
     24        (WebCore::Path::isEmpty): Ditto.
     25        (WebCore::Path::currentPoint): Ditto.
     26        (WebCore::Path::translate): Ditto.
     27        (WebCore::Path::moveTo): Ditto.
     28        (WebCore::Path::addLineTo): Ditto.
     29        (WebCore::Path::addRect): Ditto.
     30        (WebCore::Path::addQuadCurveTo): Ditto.
     31        (WebCore::Path::addBezierCurveTo): Ditto.
     32        (WebCore::Path::addArc): Ditto.
     33        (WebCore::Path::addArcTo): Ditto.
     34        (WebCore::Path::addEllipse): Ditto.
     35        (WebCore::Path::closeSubpath): Ditto.
     36        (WebCore::Path::boundingRect): Ditto.
     37        (WebCore::Path::strokeBoundingRect): Ditto.
     38        (WebCore::Path::contains): Ditto.
     39        (WebCore::Path::strokeContains): Ditto.
     40        (WebCore::Path::apply): Ditto.
     41        (WebCore::Path::transform): Ditto.
     42        (WebCore::Path::debugString): Ditto.
     43
    1442010-07-20  Ojan Vafai  <ojan@chromium.org>
    245
  • trunk/WebCore/platform/graphics/cairo/CairoPath.h

    r29663 r64490  
    11/*
    22    Copyright (C) 2007 Alp Toker <alp.toker@collabora.co.uk>
     3    Copyright (C) 2010 Igalia S.L.
    34
    45    This library is free software; you can redistribute it and/or
     
    2526namespace WebCore {
    2627
    27     // This is necessary since cairo_path_fixed_t isn't exposed in Cairo's public API.
    28     struct CairoPath {
    29         cairo_t* m_cr;
     28// This is necessary since cairo_path_fixed_t isn't exposed in Cairo's public API.
     29class CairoPath {
     30public:
     31    CairoPath()
     32    {
     33        static cairo_surface_t* pathSurface = cairo_image_surface_create(CAIRO_FORMAT_A8, 1, 1);
     34        m_cr = cairo_create(pathSurface);
     35    }
    3036
    31         CairoPath()
    32         {
    33             static cairo_surface_t* pathSurface = cairo_image_surface_create(CAIRO_FORMAT_A8, 1, 1);
    34             m_cr = cairo_create(pathSurface);
    35         }
     37    ~CairoPath()
     38    {
     39        cairo_destroy(m_cr);
     40    }
    3641
    37         ~CairoPath()
    38         {
    39             cairo_destroy(m_cr);
    40         }
    41     };
     42    cairo_t* context() { return m_cr; }
     43
     44private:
     45    cairo_t* m_cr;
     46};
    4247
    4348} // namespace WebCore
  • trunk/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp

    r64338 r64490  
    163163static void appendWebCorePathToCairoContext(cairo_t* context, const Path& path)
    164164{
    165     appendPathToCairoContext(context, path.platformPath()->m_cr);
     165    appendPathToCairoContext(context, path.platformPath()->context());
    166166}
    167167
     
    577577    cairo_t* cr = m_data->cr;
    578578
    579     setPathOnCairoContext(cr, m_data->m_pendingPath.m_cr);
     579    setPathOnCairoContext(cr, m_data->m_pendingPath.context());
    580580    fillCurrentCairoPath(this, m_common, cr);
    581581}
     
    587587
    588588    cairo_t* cr = m_data->cr;
    589     setPathOnCairoContext(cr, m_data->m_pendingPath.m_cr);
     589    setPathOnCairoContext(cr, m_data->m_pendingPath.context());
    590590    strokeCurrentCairoPath(this, m_common, cr);
    591591}
     
    598598    cairo_t* cr = m_data->cr;
    599599
    600     setPathOnCairoContext(cr, m_data->m_pendingPath.m_cr);
     600    setPathOnCairoContext(cr, m_data->m_pendingPath.context());
    601601
    602602    cairo_set_fill_rule(cr, fillRule() == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING);
     
    11301130        return;
    11311131
    1132     cairo_new_path(m_data->m_pendingPath.m_cr);
     1132    cairo_new_path(m_data->m_pendingPath.context());
    11331133}
    11341134
     
    11401140    cairo_matrix_t currentMatrix;
    11411141    cairo_get_matrix(m_data->cr, &currentMatrix);
    1142     cairo_set_matrix(m_data->m_pendingPath.m_cr, &currentMatrix);
    1143     appendWebCorePathToCairoContext(m_data->m_pendingPath.m_cr, path);
     1142    cairo_set_matrix(m_data->m_pendingPath.context(), &currentMatrix);
     1143    appendWebCorePathToCairoContext(m_data->m_pendingPath.context(), path);
    11441144}
    11451145
     
    11501150
    11511151    cairo_t* cr = m_data->cr;
    1152     cairo_path_t* p = cairo_copy_path(path.platformPath()->m_cr);
     1152    cairo_path_t* p = cairo_copy_path(path.platformPath()->context());
    11531153    cairo_append_path(cr, p);
    11541154    cairo_path_destroy(p);
  • trunk/WebCore/platform/graphics/cairo/PathCairo.cpp

    r63599 r64490  
    5252    : m_path(new CairoPath())
    5353{
    54     cairo_t* cr = platformPath()->m_cr;
    55     cairo_path_t* p = cairo_copy_path(other.platformPath()->m_cr);
     54    cairo_t* cr = platformPath()->context();
     55    cairo_path_t* p = cairo_copy_path(other.platformPath()->context());
    5656    cairo_append_path(cr, p);
    5757    cairo_path_destroy(p);
     
    6464
    6565    clear();
    66     cairo_t* cr = platformPath()->m_cr;
    67     cairo_path_t* p = cairo_copy_path(other.platformPath()->m_cr);
     66    cairo_t* cr = platformPath()->context();
     67    cairo_path_t* p = cairo_copy_path(other.platformPath()->context());
    6868    cairo_append_path(cr, p);
    6969    cairo_path_destroy(p);
     
    7373void Path::clear()
    7474{
    75     cairo_t* cr = platformPath()->m_cr;
     75    cairo_t* cr = platformPath()->context();
    7676    cairo_new_path(cr);
    7777}
     
    7979bool Path::isEmpty() const
    8080{
    81     return !cairo_has_current_point(platformPath()->m_cr);
     81    return !cairo_has_current_point(platformPath()->context());
    8282}
    8383
     
    9292    double x;
    9393    double y;
    94     cairo_get_current_point(platformPath()->m_cr, &x, &y);
     94    cairo_get_current_point(platformPath()->context(), &x, &y);
    9595    return FloatPoint(x, y);
    9696}
     
    9898void Path::translate(const FloatSize& p)
    9999{
    100     cairo_t* cr = platformPath()->m_cr;
     100    cairo_t* cr = platformPath()->context();
    101101    cairo_translate(cr, -p.width(), -p.height());
    102102}
     
    104104void Path::moveTo(const FloatPoint& p)
    105105{
    106     cairo_t* cr = platformPath()->m_cr;
     106    cairo_t* cr = platformPath()->context();
    107107    cairo_move_to(cr, p.x(), p.y());
    108108}
     
    110110void Path::addLineTo(const FloatPoint& p)
    111111{
    112     cairo_t* cr = platformPath()->m_cr;
     112    cairo_t* cr = platformPath()->context();
    113113    cairo_line_to(cr, p.x(), p.y());
    114114}
     
    116116void Path::addRect(const FloatRect& rect)
    117117{
    118     cairo_t* cr = platformPath()->m_cr;
     118    cairo_t* cr = platformPath()->context();
    119119    cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height());
    120120}
     
    125125void Path::addQuadCurveTo(const FloatPoint& controlPoint, const FloatPoint& point)
    126126{
    127     cairo_t* cr = platformPath()->m_cr;
     127    cairo_t* cr = platformPath()->context();
    128128    double x, y;
    129129    double x1 = controlPoint.x();
     
    140140void Path::addBezierCurveTo(const FloatPoint& controlPoint1, const FloatPoint& controlPoint2, const FloatPoint& controlPoint3)
    141141{
    142     cairo_t* cr = platformPath()->m_cr;
     142    cairo_t* cr = platformPath()->context();
    143143    cairo_curve_to(cr, controlPoint1.x(), controlPoint1.y(),
    144144                   controlPoint2.x(), controlPoint2.y(),
     
    153153        return;
    154154
    155     cairo_t* cr = platformPath()->m_cr;
     155    cairo_t* cr = platformPath()->context();
    156156    if (anticlockwise)
    157157        cairo_arc_negative(cr, p.x(), p.y(), r, sa, ea);
     
    165165        return;
    166166
    167     cairo_t* cr = platformPath()->m_cr;
     167    cairo_t* cr = platformPath()->context();
    168168
    169169    double x0, y0;
     
    238238void Path::addEllipse(const FloatRect& rect)
    239239{
    240     cairo_t* cr = platformPath()->m_cr;
     240    cairo_t* cr = platformPath()->context();
    241241    cairo_save(cr);
    242242    float yRadius = .5 * rect.height();
     
    250250void Path::closeSubpath()
    251251{
    252     cairo_t* cr = platformPath()->m_cr;
     252    cairo_t* cr = platformPath()->context();
    253253    cairo_close_path(cr);
    254254}
     
    256256FloatRect Path::boundingRect() const
    257257{
    258     cairo_t* cr = platformPath()->m_cr;
     258    cairo_t* cr = platformPath()->context();
    259259    double x0, x1, y0, y1;
    260260    cairo_path_extents(cr, &x0, &y0, &x1, &y1);
     
    264264FloatRect Path::strokeBoundingRect(StrokeStyleApplier* applier)
    265265{
    266     cairo_t* cr = platformPath()->m_cr;
     266    cairo_t* cr = platformPath()->context();
    267267    if (applier) {
    268268        GraphicsContext gc(cr);
     
    277277bool Path::contains(const FloatPoint& point, WindRule rule) const
    278278{
    279     cairo_t* cr = platformPath()->m_cr;
     279    cairo_t* cr = platformPath()->context();
    280280    cairo_fill_rule_t cur = cairo_get_fill_rule(cr);
    281281    cairo_set_fill_rule(cr, rule == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING);
     
    288288{
    289289    ASSERT(applier);
    290     cairo_t* cr = platformPath()->m_cr;
     290    cairo_t* cr = platformPath()->context();
    291291    GraphicsContext gc(cr);
    292292    applier->strokeStyle(&gc);
     
    297297void Path::apply(void* info, PathApplierFunction function) const
    298298{
    299     cairo_t* cr = platformPath()->m_cr;
     299    cairo_t* cr = platformPath()->context();
    300300    cairo_path_t* path = cairo_copy_path(cr);
    301301    cairo_path_data_t* data;
     
    335335void Path::transform(const AffineTransform& trans)
    336336{
    337     cairo_t* m_cr = platformPath()->m_cr;
     337    cairo_t* cr = platformPath()->context();
    338338    cairo_matrix_t c_matrix = cairo_matrix_t(trans);
    339339    cairo_matrix_invert(&c_matrix);
    340     cairo_transform(m_cr, &c_matrix);
     340    cairo_transform(cr, &c_matrix);
    341341}
    342342
     
    347347
    348348    String pathString;
    349     cairo_path_t* path = cairo_copy_path(platformPath()->m_cr);
     349    cairo_path_t* path = cairo_copy_path(platformPath()->context());
    350350    cairo_path_data_t* data;
    351351
Note: See TracChangeset for help on using the changeset viewer.