Changeset 82962 in webkit


Ignore:
Timestamp:
Apr 5, 2011 11:40:21 AM (13 years ago)
Author:
Martin Robinson
Message:

2011-04-05 Martin Robinson <mrobinson@igalia.com>

Reviewed by Eric Seidel.

[Cairo] Better separate the concerns of GraphicsContextCairo
https://bugs.webkit.org/show_bug.cgi?id=55150

Add a PlatformContextCairo which right now stores the cairo_t* for a
GraphicsContextCairo. Later patches will move logic for tracking ContextShadow
and image masking layers into this PlatformContextCairo class.

No new tests. This patch is only a code cleanup.

  • GNUmakefile.am:
  • platform/graphics/GraphicsContext.h: The platform context is no longer a cairo_t, but our new class the PlatformContextCairo.
  • platform/graphics/cairo/ContextShadowCairo.cpp: Updated to reflect new class.j
  • platform/graphics/cairo/FontCairo.cpp: Ditto.
  • platform/graphics/cairo/GradientCairo.cpp: Ditto.
  • platform/graphics/cairo/GraphicsContextCairo.cpp: Mostly mechanical changes which now reference platformContext()->cr() to get the cairo_t.
  • platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h: Now hold the PlatformContextCairo instead of the cairo_t.
  • platform/graphics/cairo/ImageBufferCairo.cpp: Update to reflect new class.
  • platform/graphics/cairo/ImageCairo.cpp: Ditto.
  • platform/graphics/cairo/PathCairo.cpp: Ditto.
  • platform/graphics/cairo/PlatformContextCairo.cpp: Added.
  • platform/graphics/cairo/PlatformContextCairo.h: Added.
  • platform/graphics/gtk/FontGtk.cpp: Update to reflect new class.
  • platform/graphics/gtk/IconGtk.cpp: Ditto.
  • platform/graphics/win/GraphicsContextCairoWin.cpp: Now fill out m_data with a private section containing the platform context instead of just a cairo_t.
  • platform/gtk/RenderThemeGtk.cpp: Update to reflect new class.
  • platform/gtk/WidgetRenderingContext.cpp: Ditto. (WebCore::WidgetRenderingContext::~WidgetRenderingContext): Ditto.
  • plugins/gtk/PluginViewGtk.cpp: Ditto.

2011-04-05 Martin Robinson <mrobinson@igalia.com>

Reviewed by Eric Seidel.

[Cairo] Better separate the concerns of GraphicsContextCairo
https://bugs.webkit.org/show_bug.cgi?id=55150

Add a PlatformContextCairo which right now stores the cairo_t* for a
GraphicsContextCairo. Later patches will move logic for tracking ContextShadow
and image masking layers into this PlatformContextCairo class.

  • webkit/webkitwebframe.cpp: (draw_page_callback):
  • webkit/webkitwebview.cpp: (webkit_web_view_expose_event): (webkit_web_view_draw):

2011-04-05 Martin Robinson <mrobinson@igalia.com>

Reviewed by Eric Seidel.

[Cairo] Better separate the concerns of GraphicsContextCairo
https://bugs.webkit.org/show_bug.cgi?id=55150

  • WebFrame.cpp: (hdcFromContext): Modify this method to take PlatformContextCairo instead of a cairo_t. (WebFrame::spoolPage): Update to reflect new platform context. (WebFrame::spoolPages): Ditto.
  • WebFrame.h: Ditto.
Location:
trunk/Source
Files:
28 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r82956 r82962  
     12011-04-05  Martin Robinson  <mrobinson@igalia.com>
     2
     3        Reviewed by Eric Seidel.
     4
     5        [Cairo] Better separate the concerns of GraphicsContextCairo
     6        https://bugs.webkit.org/show_bug.cgi?id=55150
     7
     8        Add a PlatformContextCairo which right now stores the cairo_t* for a
     9        GraphicsContextCairo. Later patches will move logic for tracking ContextShadow
     10        and image masking layers into this PlatformContextCairo class.
     11
     12        No new tests. This patch is only a code cleanup.
     13
     14        * GNUmakefile.am:
     15        * platform/graphics/GraphicsContext.h: The platform context is no longer a
     16        cairo_t, but our new class the PlatformContextCairo.
     17        * platform/graphics/cairo/ContextShadowCairo.cpp: Updated to reflect new class.j
     18        * platform/graphics/cairo/FontCairo.cpp: Ditto.
     19        * platform/graphics/cairo/GradientCairo.cpp: Ditto.
     20        * platform/graphics/cairo/GraphicsContextCairo.cpp: Mostly mechanical
     21        changes which now reference platformContext()->cr() to get the cairo_t.
     22        * platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h: Now hold the
     23        PlatformContextCairo instead of the cairo_t.
     24        * platform/graphics/cairo/ImageBufferCairo.cpp: Update to reflect new class.
     25        * platform/graphics/cairo/ImageCairo.cpp: Ditto.
     26        * platform/graphics/cairo/PathCairo.cpp: Ditto.
     27        * platform/graphics/cairo/PlatformContextCairo.cpp: Added.
     28        * platform/graphics/cairo/PlatformContextCairo.h: Added.
     29        * platform/graphics/gtk/FontGtk.cpp: Update to reflect new class.
     30        * platform/graphics/gtk/IconGtk.cpp: Ditto.
     31        * platform/graphics/win/GraphicsContextCairoWin.cpp: Now fill out
     32        m_data with a private section containing the platform context instead of
     33        just a cairo_t.
     34        * platform/gtk/RenderThemeGtk.cpp: Update to reflect new class.
     35        * platform/gtk/WidgetRenderingContext.cpp: Ditto.
     36        (WebCore::WidgetRenderingContext::~WidgetRenderingContext): Ditto.
     37        * plugins/gtk/PluginViewGtk.cpp: Ditto.
     38
    1392011-04-05  David Dorwin  <ddorwin@chromium.org>
    240
  • trunk/Source/WebCore/GNUmakefile.am

    r82899 r82962  
    37753775        Source/WebCore/platform/graphics/cairo/PathCairo.cpp \
    37763776        Source/WebCore/platform/graphics/cairo/PatternCairo.cpp \
     3777        Source/WebCore/platform/graphics/cairo/PlatformContextCairo.cpp \
     3778        Source/WebCore/platform/graphics/cairo/PlatformContextCairo.h \
    37773779        Source/WebCore/platform/graphics/cairo/RefPtrCairo.cpp \
    37783780        Source/WebCore/platform/graphics/cairo/RefPtrCairo.h \
  • trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj

    r82899 r82962  
    2862928629                                        </File>
    2863028630                                        <File
     28631                                                RelativePath="..\platform\graphics\cairo\PlatformContextCairo.cpp"
     28632                                                >
     28633                                                <FileConfiguration
     28634                                                        Name="Debug|Win32"
     28635                                                        ExcludedFromBuild="true"
     28636                                                        >
     28637                                                        <Tool
     28638                                                                Name="VCCLCompilerTool"
     28639                                                        />
     28640                                                </FileConfiguration>
     28641                                                <FileConfiguration
     28642                                                        Name="Release|Win32"
     28643                                                        ExcludedFromBuild="true"
     28644                                                        >
     28645                                                        <Tool
     28646                                                                Name="VCCLCompilerTool"
     28647                                                        />
     28648                                                </FileConfiguration>
     28649                                                <FileConfiguration
     28650                                                        Name="Debug_All|Win32"
     28651                                                        ExcludedFromBuild="true"
     28652                                                        >
     28653                                                        <Tool
     28654                                                                Name="VCCLCompilerTool"
     28655                                                        />
     28656                                                </FileConfiguration>
     28657                                                <FileConfiguration
     28658                                                        Name="Production|Win32"
     28659                                                        ExcludedFromBuild="true"
     28660                                                        >
     28661                                                        <Tool
     28662                                                                Name="VCCLCompilerTool"
     28663                                                        />
     28664                                                </FileConfiguration>
     28665                                        </File>
     28666                                        <File
    2863128667                                                RelativePath="..\platform\graphics\cairo\RefPtrCairo.cpp"
    2863228668                                                >
  • trunk/Source/WebCore/platform/efl/RenderThemeEfl.cpp

    r82561 r82962  
    3535#include "PaintInfo.h"
    3636#include "Page.h"
     37#include "PlatformContextCairo.h"
    3738#include "RenderBox.h"
    3839#include "RenderObject.h"
     
    284285    applyEdjeStateFromForm(entry->o, controlStatesForRenderer(object));
    285286
    286     cairo = info.context->platformContext();
     287    cairo = info.context->platformContext()->cr();
    287288    ASSERT(cairo);
    288289
  • trunk/Source/WebCore/platform/graphics/GraphicsContext.h

    r82640 r82962  
    4343namespace WebCore {
    4444class ContextShadow;
     45class PlatformContextCairo;
    4546}
    46 typedef struct _cairo PlatformGraphicsContext;
     47typedef WebCore::PlatformContextCairo PlatformGraphicsContext;
    4748#elif PLATFORM(OPENVG)
    4849namespace WebCore {
     
    491492
    492493#if PLATFORM(CAIRO)
     494        GraphicsContext(cairo_t*);
    493495        void pushImageMask(cairo_surface_t*, const FloatRect&);
    494496#endif
  • trunk/Source/WebCore/platform/graphics/cairo/ContextShadowCairo.cpp

    r82553 r82962  
    3535#include "OwnPtrCairo.h"
    3636#include "Path.h"
     37#include "PlatformContextCairo.h"
    3738#include "Timer.h"
    3839#include <cairo.h>
     
    8990
    9091    double x1, x2, y1, y2;
    91     cairo_clip_extents(context->platformContext(), &x1, &y1, &x2, &y2);
     92    cairo_clip_extents(context->platformContext()->cr(), &x1, &y1, &x2, &y2);
    9293    IntRect layerRect = calculateLayerBoundingRect(context, layerArea, IntRect(x1, y1, x2 - x1, y2 - y1));
    9394
     
    121122    }
    122123
    123     cairo_t* cr = context->platformContext();
     124    cairo_t* cr = context->platformContext()->cr();
    124125    cairo_save(cr);
    125126    setSourceRGBAFromColor(cr, m_color);
     
    199200        max(bottomLeftRadius.height(), bottomRightRadius.height());
    200201
    201     cairo_t* cr = context->platformContext();
     202    cairo_t* cr = context->platformContext()->cr();
    202203
    203204    // drawShadowedRect still does not work with rotations.
  • trunk/Source/WebCore/platform/graphics/cairo/FontCairo.cpp

    r82553 r82962  
    3737#include "Gradient.h"
    3838#include "GraphicsContext.h"
     39#include "PlatformContextCairo.h"
    3940#include "ImageBuffer.h"
    4041#include "Pattern.h"
     
    6566}
    6667
    67 static void drawGlyphsShadow(GraphicsContext* graphicsContext, cairo_t* context, const FloatPoint& point, const SimpleFontData* font, GlyphBufferGlyph* glyphs, int numGlyphs)
     68static void drawGlyphsShadow(GraphicsContext* graphicsContext, const FloatPoint& point, const SimpleFontData* font, GlyphBufferGlyph* glyphs, int numGlyphs)
    6869{
    6970    ContextShadow* shadow = graphicsContext->contextShadow();
     
    7576    if (!shadow->mustUseContextShadow(graphicsContext)) {
    7677        // Optimize non-blurry shadows, by just drawing text without the ContextShadow.
     78        cairo_t* context = graphicsContext->platformContext()->cr();
    7779        cairo_save(context);
    7880        cairo_translate(context, shadow->m_offset.width(), shadow->m_offset.height());
     
    107109    }
    108110
    109     cairo_t* cr = context->platformContext();
    110     drawGlyphsShadow(context, cr, point, font, glyphs, numGlyphs);
     111    PlatformContextCairo* platformContext = context->platformContext();
     112    drawGlyphsShadow(context, point, font, glyphs, numGlyphs);
    111113
     114    cairo_t* cr = platformContext->cr();
    112115    cairo_save(cr);
    113116    prepareContextForGlyphDrawing(cr, font, point);
  • trunk/Source/WebCore/platform/graphics/cairo/GradientCairo.cpp

    r82553 r82962  
    3030#include "CSSParser.h"
    3131#include "GraphicsContext.h"
     32#include "PlatformContextCairo.h"
    3233#include <cairo.h>
    3334
     
    8889void Gradient::fill(GraphicsContext* context, const FloatRect& rect)
    8990{
    90     cairo_t* cr = context->platformContext();
     91    cairo_t* cr = context->platformContext()->cr();
    9192
    9293    context->save();
  • trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp

    r82553 r82962  
    4848#include "Path.h"
    4949#include "Pattern.h"
     50#include "PlatformContextCairo.h"
    5051#include "RefPtrCairo.h"
    5152#include "SimpleFontData.h"
     
    149150
    150151    // Calculate the extents of the rendered solid paths.
    151     cairo_t* cairoContext = context->platformContext();
     152    cairo_t* cairoContext = context->platformContext()->cr();
    152153    OwnPtr<cairo_path_t> path(cairo_copy_path(cairoContext));
    153154
     
    200201}
    201202
    202 void GraphicsContext::platformInit(PlatformGraphicsContext* cr)
    203 {
    204     m_data = new GraphicsContextPlatformPrivate;
    205     m_data->cr = cairo_reference(cr);
    206     m_data->syncContext(cr);
    207     setPaintingDisabled(!cr);
     203GraphicsContext::GraphicsContext(cairo_t* cr)
     204    : m_updatingControlTints(false)
     205{
     206    m_data = new GraphicsContextPlatformPrivateToplevel(new PlatformContextCairo(cr));
     207}
     208
     209void GraphicsContext::platformInit(PlatformContextCairo* platformContext)
     210{
     211    m_data = new GraphicsContextPlatformPrivate(platformContext);
     212    if (platformContext)
     213        m_data->syncContext(platformContext->cr());
     214    else
     215        setPaintingDisabled(true);
    208216}
    209217
     
    215223AffineTransform GraphicsContext::getCTM() const
    216224{
    217     cairo_t* cr = platformContext();
     225    cairo_t* cr = platformContext()->cr();
    218226    cairo_matrix_t m;
    219227    cairo_get_matrix(cr, &m);
     
    221229}
    222230
    223 cairo_t* GraphicsContext::platformContext() const
    224 {
    225     return m_data->cr;
     231PlatformContextCairo* GraphicsContext::platformContext() const
     232{
     233    return m_data->platformContext;
    226234}
    227235
    228236void GraphicsContext::savePlatformState()
    229237{
    230     cairo_save(m_data->cr);
     238    cairo_save(platformContext()->cr());
    231239    m_data->save();
    232240    m_data->shadowStack.append(m_data->shadow);
     
    236244void GraphicsContext::restorePlatformState()
    237245{
    238     cairo_t* cr = m_data->cr;
     246    cairo_t* cr = platformContext()->cr();
     247
    239248    const ImageMaskInformation& maskInformation = m_data->maskImageStack.last();
    240249    if (maskInformation.isValid()) {
     
    252261    }
    253262
    254     cairo_restore(m_data->cr);
     263    cairo_restore(cr);
    255264    m_data->restore();
    256265}
     
    262271        return;
    263272
    264     cairo_t* cr = m_data->cr;
     273    cairo_t* cr = platformContext()->cr();
    265274    cairo_save(cr);
    266275
     
    290299        return;
    291300
    292     cairo_t* cr = m_data->cr;
     301    cairo_t* cr = platformContext()->cr();
    293302    cairo_save(cr);
    294303
     
    377386        return;
    378387
    379     cairo_t* cr = m_data->cr;
     388    cairo_t* cr = platformContext()->cr();
    380389    cairo_save(cr);
    381390    float yRadius = .5 * rect.height();
     
    416425    float falen =  fa + angleSpan;
    417426
    418     cairo_t* cr = m_data->cr;
     427    cairo_t* cr = platformContext()->cr();
    419428    cairo_save(cr);
    420429
     
    493502        return;
    494503
    495     cairo_t* cr = m_data->cr;
     504    cairo_t* cr = platformContext()->cr();
    496505
    497506    cairo_save(cr);
     
    523532        return;
    524533
    525     cairo_t* cr = m_data->cr;
     534    cairo_t* cr = platformContext()->cr();
    526535
    527536    cairo_new_path(cr);
     
    543552        return;
    544553
    545     cairo_t* cr = m_data->cr;
     554    cairo_t* cr = platformContext()->cr();
    546555    setPathOnCairoContext(cr, path.platformPath()->context());
    547556    fillCurrentCairoPath(this, cr);
     
    553562        return;
    554563
    555     cairo_t* cr = m_data->cr;
     564    cairo_t* cr = platformContext()->cr();
    556565    setPathOnCairoContext(cr, path.platformPath()->context());
    557566    strokeCurrentCairoPath(this, cr);
     
    563572        return;
    564573
    565     cairo_t* cr = m_data->cr;
     574    cairo_t* cr = platformContext()->cr();
    566575    cairo_save(cr);
    567576    cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height());
     
    579588
    580589    if (color.alpha())
    581         fillRectSourceOver(m_data->cr, rect, color);
     590        fillRectSourceOver(platformContext()->cr(), rect, color);
    582591}
    583592
     
    587596        return;
    588597
    589     cairo_t* cr = m_data->cr;
     598    cairo_t* cr = platformContext()->cr();
    590599    cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height());
    591600    cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr);
     
    601610        return;
    602611
    603     cairo_t* cr = m_data->cr;
     612    cairo_t* cr = platformContext()->cr();
    604613    setPathOnCairoContext(cr, path.platformPath()->context());
    605614    cairo_set_fill_rule(cr, clipRule == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING);
     
    639648    adjustFocusRingLineWidth(width);
    640649
    641     cairo_t* cr = m_data->cr;
     650    cairo_t* cr = platformContext()->cr();
    642651    cairo_save(cr);
    643652    appendWebCorePathToCairoContext(cr, path);
     
    656665    unsigned rectCount = rects.size();
    657666
    658     cairo_t* cr = m_data->cr;
     667    cairo_t* cr = platformContext()->cr();
    659668    cairo_save(cr);
    660669    cairo_push_group(cr);
     
    733742        return;
    734743
    735     cairo_t* cr = m_data->cr;
     744    cairo_t* cr = platformContext()->cr();
    736745    cairo_save(cr);
    737746
     
    763772    double x = frect.x();
    764773    double y = frect.y();
    765     cairo_t* cr = m_data->cr;
     774    cairo_t* cr = platformContext()->cr();
    766775    cairo_user_to_device(cr, &x, &y);
    767776    x = round(x);
     
    800809        return;
    801810
    802     cairo_t* cr = m_data->cr;
     811    cairo_t* cr = platformContext()->cr();
    803812    cairo_translate(cr, x, y);
    804813    m_data->translate(x, y);
     
    822831        return;
    823832
    824     cairo_set_line_width(m_data->cr, strokeThickness);
     833    cairo_set_line_width(platformContext()->cr(), strokeThickness);
    825834}
    826835
     
    836845    case NoStroke:
    837846        // FIXME: is it the right way to emulate NoStroke?
    838         cairo_set_line_width(m_data->cr, 0);
     847        cairo_set_line_width(platformContext()->cr(), 0);
    839848        break;
    840849    case SolidStroke:
    841         cairo_set_dash(m_data->cr, 0, 0, 0);
     850        cairo_set_dash(platformContext()->cr(), 0, 0, 0);
    842851        break;
    843852    case DottedStroke:
    844         cairo_set_dash(m_data->cr, dotPattern, 2, 0);
     853        cairo_set_dash(platformContext()->cr(), dotPattern, 2, 0);
    845854        break;
    846855    case DashedStroke:
    847         cairo_set_dash(m_data->cr, dashPattern, 2, 0);
     856        cairo_set_dash(platformContext()->cr(), dashPattern, 2, 0);
    848857        break;
    849858    }
     
    860869        return;
    861870
    862     cairo_t* cr = m_data->cr;
     871    cairo_t* cr = platformContext()->cr();
    863872    const cairo_matrix_t matrix = cairo_matrix_t(transform);
    864873    cairo_transform(cr, &matrix);
     
    871880        return;
    872881
    873     cairo_t* cr = m_data->cr;
     882    cairo_t* cr = platformContext()->cr();
    874883    const cairo_matrix_t matrix = cairo_matrix_t(transform);
    875884    cairo_set_matrix(cr, &matrix);
     
    882891        return;
    883892
    884     cairo_t* cr = m_data->cr;
     893    cairo_t* cr = platformContext()->cr();
    885894    clip(rect);
    886895
     
    929938        return;
    930939
    931     cairo_t* cr = m_data->cr;
     940    cairo_t* cr = platformContext()->cr();
    932941    cairo_push_group(cr);
    933942    m_data->layers.append(opacity);
     
    940949        return;
    941950
    942     cairo_t* cr = m_data->cr;
     951    cairo_t* cr = platformContext()->cr();
    943952
    944953    cairo_pop_group_to_source(cr);
     
    953962        return;
    954963
    955     cairo_t* cr = m_data->cr;
     964    cairo_t* cr = platformContext()->cr();
    956965
    957966    cairo_save(cr);
     
    967976        return;
    968977
    969     cairo_t* cr = m_data->cr;
     978    cairo_t* cr = platformContext()->cr();
    970979    cairo_save(cr);
    971980    cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height());
     
    9921001        break;
    9931002    }
    994     cairo_set_line_cap(m_data->cr, cairoCap);
     1003    cairo_set_line_cap(platformContext()->cr(), cairoCap);
    9951004}
    9961005
    9971006void GraphicsContext::setLineDash(const DashArray& dashes, float dashOffset)
    9981007{
    999     cairo_set_dash(m_data->cr, dashes.data(), dashes.size(), dashOffset);
     1008    cairo_set_dash(platformContext()->cr(), dashes.data(), dashes.size(), dashOffset);
    10001009}
    10011010
     
    10171026        break;
    10181027    }
    1019     cairo_set_line_join(m_data->cr, cairoJoin);
     1028    cairo_set_line_join(platformContext()->cr(), cairoJoin);
    10201029}
    10211030
     
    10251034        return;
    10261035
    1027     cairo_set_miter_limit(m_data->cr, miter);
     1036    cairo_set_miter_limit(platformContext()->cr(), miter);
    10281037}
    10291038
     
    10431052        return;
    10441053
    1045     cairo_set_operator(m_data->cr, toCairoOperator(op));
     1054    cairo_set_operator(platformContext()->cr(), toCairoOperator(op));
    10461055}
    10471056
     
    10511060        return;
    10521061
    1053     cairo_t* cr = m_data->cr;
     1062    cairo_t* cr = platformContext()->cr();
    10541063    OwnPtr<cairo_path_t> p(cairo_copy_path(path.platformPath()->context()));
    10551064    cairo_append_path(cr, p.get());
     
    10711080        return;
    10721081
    1073     cairo_t* cr = m_data->cr;
     1082    cairo_t* cr = platformContext()->cr();
    10741083    double x1, y1, x2, y2;
    10751084    cairo_clip_extents(cr, &x1, &y1, &x2, &y2);
     
    10881097        return;
    10891098
    1090     cairo_rotate(m_data->cr, radians);
     1099    cairo_rotate(platformContext()->cr(), radians);
    10911100    m_data->rotate(radians);
    10921101}
     
    10971106        return;
    10981107
    1099     cairo_scale(m_data->cr, size.width(), size.height());
     1108    cairo_scale(platformContext()->cr(), size.width(), size.height());
    11001109    m_data->scale(size);
    11011110}
     
    11061115        return;
    11071116
    1108     cairo_t* cr = m_data->cr;
     1117    cairo_t* cr = platformContext()->cr();
    11091118    double x1, y1, x2, y2;
    11101119    cairo_clip_extents(cr, &x1, &y1, &x2, &y2);
     
    11331142        m_data->shadow.drawRectShadow(this, r, topLeft, topRight, bottomLeft, bottomRight);
    11341143
    1135     cairo_t* cr = m_data->cr;
     1144    cairo_t* cr = platformContext()->cr();
    11361145    cairo_save(cr);
    11371146    Path path;
     
    11711180    // enables standard 'grayscale' antialiasing); false to explicitly disable
    11721181    // antialiasing. This is the same strategy as used in drawConvexPolygon().
    1173     cairo_set_antialias(m_data->cr, enable ? CAIRO_ANTIALIAS_DEFAULT : CAIRO_ANTIALIAS_NONE);
     1182    cairo_set_antialias(platformContext()->cr(), enable ? CAIRO_ANTIALIAS_DEFAULT : CAIRO_ANTIALIAS_NONE);
    11741183}
    11751184
     
    11971206    // is now, but they are isolated in another group. To make this work, we're
    11981207    // going to blit the current surface contents onto the new group once we push it.
    1199     cairo_t* cr = m_data->cr;
     1208    cairo_t* cr = platformContext()->cr();
    12001209    cairo_surface_t* currentTarget = cairo_get_target(cr);
    12011210    cairo_surface_flush(currentTarget);
  • trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h

    r82553 r82962  
    3232
    3333#include "ContextShadow.h"
     34#include "PlatformContextCairo.h"
    3435#include "RefPtrCairo.h"
    3536#include <cairo.h>
     
    6869class GraphicsContextPlatformPrivate {
    6970public:
    70     GraphicsContextPlatformPrivate()
    71         : cr(0)
     71    GraphicsContextPlatformPrivate(PlatformContextCairo* newPlatformContext)
     72        : platformContext(newPlatformContext)
    7273#if PLATFORM(GTK)
    7374        , expose(0)
     
    8182    }
    8283
    83     ~GraphicsContextPlatformPrivate()
     84    virtual ~GraphicsContextPlatformPrivate()
    8485    {
    85         cairo_destroy(cr);
    8686    }
    8787
     
    100100    void beginTransparencyLayer() { m_transparencyCount++; }
    101101    void endTransparencyLayer() { m_transparencyCount--; }
    102     void syncContext(PlatformGraphicsContext* cr);
     102    void syncContext(cairo_t* cr);
    103103#else
    104104    // On everything else, we do nothing.
     
    115115    void beginTransparencyLayer() {}
    116116    void endTransparencyLayer() {}
    117     void syncContext(PlatformGraphicsContext* cr) {}
     117    void syncContext(cairo_t* cr) {}
    118118#endif
    119119
    120     cairo_t* cr;
     120    PlatformContextCairo* platformContext;
    121121    Vector<float> layers;
    122 
    123122    ContextShadow shadow;
    124123    Vector<ContextShadow> shadowStack;
     
    134133};
    135134
     135// This is a specialized private section for the Cairo GraphicsContext, which knows how
     136// to clean up the heap allocated PlatformContextCairo that we must use for the top-level
     137// GraphicsContext.
     138class GraphicsContextPlatformPrivateToplevel : public GraphicsContextPlatformPrivate {
     139public:
     140    GraphicsContextPlatformPrivateToplevel(PlatformContextCairo* platformContext)
     141        : GraphicsContextPlatformPrivate(platformContext)
     142    {
     143    }
     144
     145    virtual ~GraphicsContextPlatformPrivateToplevel()
     146    {
     147        delete platformContext;
     148    }
     149};
     150
     151
    136152} // namespace WebCore
    137153
  • trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp

    r82553 r82962  
    3838#include "NotImplemented.h"
    3939#include "Pattern.h"
     40#include "PlatformContextCairo.h"
    4041#include "PlatformString.h"
     42#include "RefPtrCairo.h"
    4143#include <cairo.h>
    4244#include <wtf/Vector.h>
     
    6769ImageBufferData::ImageBufferData(const IntSize& size)
    6870    : m_surface(0)
     71    , m_platformContext(0)
    6972{
    7073}
     
    8184        return;  // create will notice we didn't set m_initialized and fail.
    8285
    83     cairo_t* cr = cairo_create(m_data.m_surface);
    84     m_context.set(new GraphicsContext(cr));
    85     cairo_destroy(cr);  // The context is now owned by the GraphicsContext.
     86    RefPtr<cairo_t> cr = adoptRef(cairo_create(m_data.m_surface));
     87    m_data.m_platformContext.setCr(cr.get());
     88    m_context.set(new GraphicsContext(&m_data.m_platformContext));
    8689    success = true;
    8790}
     
    302305String ImageBuffer::toDataURL(const String& mimeType, const double*) const
    303306{
    304     cairo_surface_t* image = cairo_get_target(context()->platformContext());
     307    cairo_surface_t* image = cairo_get_target(context()->platformContext()->cr());
    305308    if (!image)
    306309        return "data:,";
  • trunk/Source/WebCore/platform/graphics/cairo/ImageBufferData.h

    r82553 r82962  
    2727#define ImageBufferData_h
    2828
    29 #include "cairo.h"
     29#include "PlatformContextCairo.h"
     30
     31typedef struct _cairo_surface cairo_surface_t;
    3032
    3133namespace WebCore {
     
    3840
    3941    cairo_surface_t* m_surface;
     42    PlatformContextCairo m_platformContext;
    4043};
    4144
  • trunk/Source/WebCore/platform/graphics/cairo/ImageCairo.cpp

    r82553 r82962  
    3737#include "FloatRect.h"
    3838#include "GraphicsContext.h"
     39#include "PlatformContextCairo.h"
    3940#include "ImageBuffer.h"
    4041#include "ImageObserver.h"
     
    115116    IntSize selfSize = size();
    116117
    117     cairo_t* cr = context->platformContext();
     118    cairo_t* cr = context->platformContext()->cr();
    118119    context->save();
    119120
     
    170171        return;
    171172
    172     cairo_t* cr = context->platformContext();
    173 
     173    cairo_t* cr = context->platformContext()->cr();
    174174    drawPatternToCairoContext(cr, image, size(), tileRect, patternTransform, phase, toCairoOperator(op), destRect);
    175175
  • trunk/Source/WebCore/platform/graphics/cairo/PlatformContextCairo.cpp

    r82961 r82962  
    11/*
    2  * Copyright (C) 2008 Google Inc. All rights reserved.
     2 * Copyright (C) 2011 Igalia S.L.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2121 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    2222 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    2424 */
    2525
    26 #ifndef ImageBufferData_h
    27 #define ImageBufferData_h
     26#include "config.h"
     27#include "PlatformContextCairo.h"
    2828
    29 #include "cairo.h"
     29#include <cairo.h>
    3030
    3131namespace WebCore {
    3232
    33 class IntSize;
     33PlatformContextCairo::PlatformContextCairo(cairo_t* cr)
     34    : m_cr(cr)
     35{
     36}
    3437
    35 class ImageBufferData {
    36 public:
    37     ImageBufferData(const IntSize&);
    38 
    39     cairo_surface_t* m_surface;
    40 };
    41 
    42 }  // namespace WebCore
    43 
    44 #endif  // ImageBufferData_h
     38} // namespace WebCore
  • trunk/Source/WebCore/platform/graphics/cairo/PlatformContextCairo.h

    r82961 r82962  
    11/*
    2  * Copyright (C) 2008 Google Inc. All rights reserved.
     2 * Copyright (C) 2011 Igalia S.L.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2121 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    2222 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    2424 */
    2525
    26 #ifndef ImageBufferData_h
    27 #define ImageBufferData_h
     26#ifndef PlatformContextCairo_h
     27#define PlatformContextCairo_h
    2828
    29 #include "cairo.h"
     29#include "ContextShadow.h"
     30#include "RefPtrCairo.h"
    3031
    3132namespace WebCore {
    3233
    33 class IntSize;
     34// Much like PlatformContextSkia in the Skia port, this class holds information that
     35// would normally be private to GraphicsContext, except that we want to allow access
     36// to it in Font and Image code. This allows us to separate the concerns of Cairo-specific
     37// code from the platform-independent GraphicsContext.
    3438
    35 class ImageBufferData {
     39class PlatformContextCairo {
     40    WTF_MAKE_NONCOPYABLE(PlatformContextCairo);
    3641public:
    37     ImageBufferData(const IntSize&);
     42    PlatformContextCairo(cairo_t*);
     43    cairo_t* cr() { return m_cr.get(); }
     44    void setCr(cairo_t* cr) { m_cr = cr; }
    3845
    39     cairo_surface_t* m_surface;
     46private:
     47    RefPtr<cairo_t> m_cr;
    4048};
    4149
    42 }  // namespace WebCore
     50} // namespace WebCore
    4351
    44 #endif  // ImageBufferData_h
     52#endif // PlatformContextCairo_h
  • trunk/Source/WebCore/platform/graphics/gtk/FontGtk.cpp

    r82772 r82962  
    3939#include "GraphicsContext.h"
    4040#include "NotImplemented.h"
     41#include "PlatformContextCairo.h"
    4142#include "SimpleFontData.h"
    4243#include "TextRun.h"
     
    218219}
    219220
    220 static void drawGlyphsShadow(GraphicsContext* graphicsContext, cairo_t* context, const FloatPoint& point, PangoLayoutLine* layoutLine, PangoRegionType renderRegion)
     221static void drawGlyphsShadow(GraphicsContext* graphicsContext, const FloatPoint& point, PangoLayoutLine* layoutLine, PangoRegionType renderRegion)
    221222{
    222223    ContextShadow* shadow = graphicsContext->contextShadow();
     
    230231    // Optimize non-blurry shadows, by just drawing text without the ContextShadow.
    231232    if (!shadow->mustUseContextShadow(graphicsContext)) {
     233        cairo_t* context = graphicsContext->platformContext()->cr();
    232234        cairo_save(context);
    233235        cairo_translate(context, totalOffset.x(), totalOffset.y());
     
    253255        // drawn. Since ContextShadow expects a consistent transform, we have to undo the
    254256        // translation before calling endShadowLayer as well.
     257        cairo_t* context = graphicsContext->platformContext()->cr();
    255258        cairo_save(context);
    256259        cairo_translate(context, totalOffset.x(), totalOffset.y());
     
    273276#endif
    274277
    275     cairo_t* cr = context->platformContext();
     278    cairo_t* cr = context->platformContext()->cr();
    276279    PangoLayout* layout = pango_cairo_create_layout(cr);
    277280    setPangoAttributes(this, run, layout);
     
    292295    partialRegion = gdk_pango_layout_line_get_clip_region(layoutLine, 0, 0, ranges, 1);
    293296
    294     drawGlyphsShadow(context, cr, point, layoutLine, partialRegion);
     297    drawGlyphsShadow(context, point, layoutLine, partialRegion);
    295298
    296299    cairo_save(cr);
  • trunk/Source/WebCore/platform/graphics/gtk/IconGtk.cpp

    r82553 r82962  
    3434#include "MIMETypeRegistry.h"
    3535#include "PassRefPtr.h"
     36#include "PlatformContextCairo.h"
     37#include <gtk/gtk.h>
    3638#include <wtf/text/CString.h>
    37 
    38 #include <gtk/gtk.h>
    3939
    4040namespace WebCore {
     
    118118
    119119    // TODO: Scale/clip the image if necessary.
    120     cairo_t* cr = context->platformContext();
     120    cairo_t* cr = context->platformContext()->cr();
    121121    cairo_save(cr);
    122122    gdk_cairo_set_source_pixbuf(cr, m_icon, rect.x(), rect.y());
  • trunk/Source/WebCore/platform/graphics/win/GraphicsContextCairoWin.cpp

    r82640 r82962  
    7373void GraphicsContext::platformInit(HDC dc, bool hasAlpha)
    7474{
    75     m_data = new GraphicsContextPlatformPrivate;
     75    cairo_t* cr = 0;
     76    if (dc)
     77        cr = createCairoContextWithHDC(dc, hasAlpha);
     78    else
     79        setPaintingDisabled(true);
    7680
    77     if (dc) {
    78         m_data->cr = createCairoContextWithHDC(dc, hasAlpha);
    79         m_data->m_hdc = dc;
    80     } else {
    81         setPaintingDisabled(true);
    82         m_data->cr = 0;
    83         m_data->m_hdc = 0;
    84     }
    85 
    86     if (m_data->cr) {
     81    m_data = new GraphicsContextPlatformPrivateToplevel(new PlatformContextCairo(cr));
     82    m_data->m_hdc = dc;
     83    if (platformContext()->cr()) {
    8784        // Make sure the context starts in sync with our state.
    8885        setPlatformFillColor(fillColor(), fillColorSpace());
     
    9794}
    9895
    99 static void drawBitmapToContext(GraphicsContextPlatformPrivate* context, const DIBPixelData& pixelData, const IntSize& translate)
     96static void drawBitmapToContext(GraphicsContextPlatformPrivate* context, cairo_t* cr, const DIBPixelData& pixelData, const IntSize& translate)
    10097{
    10198    // Need to make a cairo_surface_t out of the bitmap's pixel buffer and then draw
     
    109106    // Flip the target surface so that when we set the srcImage as
    110107    // the surface it will draw right-side-up.
    111     cairo_save(context->cr);
    112     cairo_translate(context->cr, static_cast<double>(translate.width()), static_cast<double>(translate.height()));
    113     cairo_scale(context->cr, 1, -1);
    114     cairo_set_source_surface(context->cr, surface, 0, 0);
     108    cairo_save(cr);
     109    cairo_translate(cr, static_cast<double>(translate.width()), static_cast<double>(translate.height()));
     110    cairo_scale(cr, 1, -1);
     111    cairo_set_source_surface(cr, surface, 0, 0);
    115112
    116113    if (context->layers.size())
    117         cairo_paint_with_alpha(context->cr, context->layers.last());
     114        cairo_paint_with_alpha(cr, context->layers.last());
    118115    else
    119         cairo_paint(context->cr);
     116        cairo_paint(cr);
    120117     
    121118    // Delete all our junk.
    122119    cairo_surface_destroy(surface);
    123     cairo_restore(context->cr);
     120    cairo_restore(cr);
    124121}
    125122
     
    147144        setRGBABitmapAlpha(bytes, pixelData.size().height() * pixelData.bytesPerRow(), 255);
    148145
    149     drawBitmapToContext(m_data, pixelData, IntSize(dstRect.x(), dstRect.height() + dstRect.y()));
     146    drawBitmapToContext(m_data, platformContext()->cr(), pixelData, IntSize(dstRect.x(), dstRect.height() + dstRect.y()));
    150147
    151148    ::DeleteDC(hdc);
     
    154151void GraphicsContext::drawWindowsBitmap(WindowsBitmap* bitmap, const IntPoint& point)
    155152{
    156     drawBitmapToContext(m_data, bitmap->windowsDIB(), IntSize(point.x(), bitmap->size().height() + point.y()));
     153    drawBitmapToContext(m_data, platformContext()->cr(), bitmap->windowsDIB(), IntSize(point.x(), bitmap->size().height() + point.y()));
    157154}
    158155
    159 void GraphicsContextPlatformPrivate::syncContext(PlatformGraphicsContext* cr)
     156void GraphicsContextPlatformPrivate::syncContext(cairo_t* cr)
    160157{
    161158    if (!cr)
  • trunk/Source/WebCore/platform/gtk/RenderThemeGtk.cpp

    r82553 r82962  
    3535#include "MediaControlElements.h"
    3636#include "PaintInfo.h"
     37#include "PlatformContextCairo.h"
    3738#include "RenderBox.h"
    3839#include "RenderObject.h"
     
    235236    }
    236237
    237     cairo_t* cr = context->platformContext();
     238    cairo_t* cr = context->platformContext()->cr();
    238239    cairo_save(cr);
    239240    gdk_cairo_set_source_pixbuf(cr, icon, iconRect.x(), iconRect.y());
  • trunk/Source/WebCore/platform/gtk/WidgetRenderingContext.cpp

    r82553 r82962  
    3434#include "GraphicsContext.h"
    3535#include "GtkVersioning.h"
     36#include "PlatformContextCairo.h"
    3637#include "RefPtrCairo.h"
    3738#include "RenderThemeGtk.h"
     
    129130
    130131    // FIXME: It's unclear if it is necessary to preserve the current source here.
    131     cairo_t* cairoContext = m_graphicsContext->platformContext();
     132    cairo_t* cairoContext = m_graphicsContext->platformContext()->cr();
    132133    RefPtr<cairo_pattern_t> previousSource(cairo_get_source(cairoContext));
    133134
  • trunk/Source/WebCore/platform/win/DragImageCairoWin.cpp

    r82553 r82962  
    3030#include "CachedImage.h"
    3131#include "GraphicsContext.h"
     32#include "GraphicsContextPlatformPrivateCairo.h"
    3233#include "Image.h"
    3334#include "RetainPtr.h"
    34 
    3535#include <cairo-win32.h>
    36 #include "GraphicsContextPlatformPrivateCairo.h"
    37 
    3836#include <windows.h>
    39 
    40 extern "C" {
    41 typedef struct _cairo* CairoContextRef;
    42 }
    4337
    4438namespace WebCore {
    4539
    46 void deallocContext(CairoContextRef target)
     40void deallocContext(PlatformContextCairo* target)
    4741{
    48     cairo_destroy(target);
     42    delete target;
    4943}
    5044
    51 HBITMAP allocImage(HDC dc, IntSize size, CairoContextRef* targetRef)
     45HBITMAP allocImage(HDC dc, IntSize size, PlatformContextCairo** targetRef)
    5246{
    5347    BitmapInfo bmpInfo = BitmapInfo::create(size);
     
    7367    }
    7468
    75     *targetRef = cairo_create (bitmapContext);
    76     cairo_surface_destroy (bitmapContext);
     69    cairo_t* cr = cairo_create(bitmapContext);
     70    cairo_surface_destroy(bitmapContext);
    7771
    7872    // At this point, we have a Cairo surface that points to a Windows DIB.  The DIB interprets
     
    8478    cairo_matrix_t matrix;
    8579    cairo_matrix_init(&matrix, 1.0, 0.0, 0.0, -1.0, 0.0, size.height());
    86     cairo_set_matrix(*targetRef, &matrix);
     80    cairo_set_matrix(cr, &matrix);
     81
     82    *targetRef = new PlatformGraphicsContext(cr);
     83    cairo_destroy(cr);
    8784
    8885    return hbmp;
     
    122119        goto exit;
    123120
    124     CairoContextRef targetContext;
     121    PlatformContextCairo* targetContext;
    125122    hbmp = allocImage(dstDC, dstSize, &targetContext);
    126123    if (!hbmp)
     
    132129    // so that when we set the srcImage as the surface it will draw
    133130    // right-side-up.
    134     cairo_translate(targetContext, 0, dstSize.height());
    135     cairo_scale(targetContext, scale.width(), -scale.height());
    136     cairo_set_source_surface (targetContext, srcImage, 0.0, 0.0);
     131    cairo_t* cr = targetContext->cr();
     132    cairo_translate(cr, 0, dstSize.height());
     133    cairo_scale(cr, scale.width(), -scale.height());
     134    cairo_set_source_surface(cr, srcImage, 0.0, 0.0);
    137135
    138136    // Now we can paint and get the correct result
    139     cairo_paint(targetContext);
     137    cairo_paint(cr);
    140138
    141     cairo_surface_destroy (srcImage);
    142     cairo_destroy(targetContext);
     139    cairo_surface_destroy(srcImage);
     140    deallocContext(targetContext);
    143141    ::DeleteObject(image);
    144142    image = 0;
     
    161159        goto exit;
    162160
    163     CairoContextRef drawContext = 0;
     161    PlatformContextCairo* drawContext = 0;
    164162    hbmp = allocImage(workingDC, img->size(), &drawContext);
    165163    if (!hbmp)
     
    171169    }
    172170
    173     cairo_set_source_rgb (drawContext, 1.0, 0.0, 1.0);
    174     cairo_fill_preserve (drawContext);
     171    cairo_t* cr = drawContext->cr();
     172    cairo_set_source_rgb(cr, 1.0, 0.0, 1.0);
     173    cairo_fill_preserve(cr);
    175174
    176175    cairo_surface_t* srcImage = img->nativeImageForCurrentFrame();
    177176
    178177    // Draw the image.
    179     cairo_set_source_surface(drawContext, srcImage, 0.0, 0.0);
    180     cairo_paint(drawContext);
     178    cairo_set_source_surface(cr, srcImage, 0.0, 0.0);
     179    cairo_paint(cr);
    181180
    182     cairo_destroy (drawContext);
     181    deallocContext(drawContext);
    183182
    184183exit:
  • trunk/Source/WebCore/plugins/gtk/PluginViewGtk.cpp

    r82833 r82962  
    4949#include "MouseEvent.h"
    5050#include "Page.h"
     51#include "PlatformContextCairo.h"
    5152#include "PlatformKeyboardEvent.h"
    5253#include "PlatformMouseEvent.h"
     
    218219
    219220            // This Would not work without double buffering, but we always use it.
    220             cairo_set_source_surface(cr.get(), cairo_get_group_target(context->platformContext()),
     221            cairo_set_source_surface(cr.get(), cairo_get_group_target(context->platformContext()->cr()),
    221222                                     -m_windowRect.x(), -m_windowRect.y());
    222223            cairo_set_operator(cr.get(), CAIRO_OPERATOR_SOURCE);
     
    245246        XSync(m_pluginDisplay, false); // sync changes by plugin
    246247
    247     cairo_t* cr = context->platformContext();
     248    cairo_t* cr = context->platformContext()->cr();
    248249    cairo_save(cr);
    249250
  • trunk/Source/WebCore/plugins/win/PluginViewWin.cpp

    r82553 r82962  
    8484
    8585#if PLATFORM(CAIRO)
     86#include "PlatformContextCairo.h"
    8687#include <cairo-win32.h>
    8788#endif
     
    573574    // plugin region will be overwritten with any clear regions specified in the
    574575    // cairo-controlled portions of the rendering.
    575     PlatformGraphicsContext* ctx = context->platformContext();
    576     cairo_show_page(ctx);
     576    cairo_show_page(context->platformContext()->cr());
    577577#endif
    578578
  • trunk/Source/WebKit/gtk/ChangeLog

    r82952 r82962  
     12011-04-05  Martin Robinson  <mrobinson@igalia.com>
     2
     3        Reviewed by Eric Seidel.
     4
     5        [Cairo] Better separate the concerns of GraphicsContextCairo
     6        https://bugs.webkit.org/show_bug.cgi?id=55150
     7
     8        Add a PlatformContextCairo which right now stores the cairo_t* for a
     9        GraphicsContextCairo. Later patches will move logic for tracking ContextShadow
     10        and image masking layers into this PlatformContextCairo class.
     11
     12        * webkit/webkitwebframe.cpp:
     13        (draw_page_callback):
     14        * webkit/webkitwebview.cpp:
     15        (webkit_web_view_expose_event):
     16        (webkit_web_view_draw):
     17
    1182011-04-04  MORITA Hajime  <morrita@google.com>
    219
  • trunk/Source/WebKit/gtk/webkit/webkitwebframe.cpp

    r82553 r82962  
    4545#include "JSDOMWindow.h"
    4646#include "JSElement.h"
     47#include "PlatformContextCairo.h"
    4748#include "PrintContext.h"
    4849#include "RenderListItem.h"
     
    766767}
    767768
    768 static void draw_page_callback(GtkPrintOperation* op, GtkPrintContext* context, gint page_nr, gpointer user_data)
    769 {
    770     PrintContext* printContext = reinterpret_cast<PrintContext*>(user_data);
    771 
    772     if (page_nr >= static_cast<gint>(printContext->pageCount()))
     769static void draw_page_callback(GtkPrintOperation*, GtkPrintContext* gtkPrintContext, gint pageNumber, PrintContext* corePrintContext)
     770{
     771    if (pageNumber >= static_cast<gint>(corePrintContext->pageCount()))
    773772        return;
    774773
    775     cairo_t* cr = gtk_print_context_get_cairo_context(context);
    776     GraphicsContext ctx(cr);
    777     float width = gtk_print_context_get_width(context);
    778     printContext->spoolPage(ctx, page_nr, width);
     774    cairo_t* cr = gtk_print_context_get_cairo_context(gtkPrintContext);
     775    float pageWidth = gtk_print_context_get_width(gtkPrintContext);
     776
     777    PlatformContextCairo platformContext(cr);
     778    GraphicsContext graphicsContext(&platformContext);
     779    corePrintContext->spoolPage(graphicsContext, pageNumber, pageWidth);
    779780}
    780781
  • trunk/Source/WebKit/gtk/webkit/webkitwebview.cpp

    r82878 r82962  
    670670
    671671        RefPtr<cairo_t> cr = adoptRef(gdk_cairo_create(event->window));
    672         GraphicsContext ctx(cr.get());
    673         ctx.setGdkExposeEvent(event);
     672        GraphicsContext gc(cr.get());
     673        gc.setGdkExposeEvent(event);
    674674
    675675        int rectCount;
     
    680680            paintRects.append(IntRect(rects.get()[i]));
    681681
    682         paintWebView(frame, priv->transparent, ctx, static_cast<IntRect>(event->area), paintRects);
     682        paintWebView(frame, priv->transparent, gc, static_cast<IntRect>(event->area), paintRects);
    683683    }
    684684
     
    697697    Frame* frame = core(webView)->mainFrame();
    698698    if (frame->contentRenderer() && frame->view()) {
    699         GraphicsContext ctx(cr);
     699        GraphicsContext gc(cr);
    700700        IntRect rect = clipRect;
    701701        cairo_rectangle_list_t* rectList = cairo_copy_clip_rectangle_list(cr);
     
    708708                rects.append(enclosingIntRect(FloatRect(rectList->rectangles[i])));
    709709        }
    710         paintWebView(frame, priv->transparent, ctx, rect, rects);
     710        paintWebView(frame, priv->transparent, gc, rect, rects);
    711711
    712712        cairo_rectangle_list_destroy(rectList);
  • trunk/Source/WebKit/win/ChangeLog

    r82952 r82962  
     12011-04-05  Martin Robinson  <mrobinson@igalia.com>
     2
     3        Reviewed by Eric Seidel.
     4
     5        [Cairo] Better separate the concerns of GraphicsContextCairo
     6        https://bugs.webkit.org/show_bug.cgi?id=55150
     7
     8        * WebFrame.cpp:
     9        (hdcFromContext): Modify this method to take PlatformContextCairo
     10        instead of a cairo_t.
     11        (WebFrame::spoolPage): Update to reflect new platform context.
     12        (WebFrame::spoolPages): Ditto.
     13        * WebFrame.h: Ditto.
     14
    1152011-04-04  MORITA Hajime  <morrita@google.com>
    216
  • trunk/Source/WebKit/win/WebFrame.cpp

    r82553 r82962  
    108108#include <CoreGraphics/CoreGraphics.h>
    109109#elif PLATFORM(CAIRO)
     110#include "PlatformContextCairo.h"
    110111#include <cairo-win32.h>
    111112#endif
     
    21872188static HDC hdcFromContext(PlatformGraphicsContext* pctx)
    21882189{
    2189     cairo_surface_t* surface = cairo_get_target(pctx);
    2190     return cairo_win32_surface_get_dc(surface);
     2190    return cairo_win32_surface_get_dc(cairo_get_target(pctx->cr()));
    21912191}
    21922192
     
    22432243    GetWorldTransform(hdc, &original);
    22442244   
     2245    cairo_t* cr = pctx->cr();
    22452246    bool preview = (hdc != printDC);
    22462247    if (preview) {
     
    22492250        // drawing completes so that we can scale our GDI-based header/footer calls. This is a
    22502251        // workaround for a bug in Cairo (see https://bugs.freedesktop.org/show_bug.cgi?id=28161)
    2251         scaled = buildXFORMFromCairo(hdc, pctx);
     2252        scaled = buildXFORMFromCairo(hdc, cr);
    22522253    }
    22532254
     
    22592260    // We cannot scale the display HDC because the print surface also scales fonts,
    22602261    // resulting in invalid printing (and print preview)
    2261     cairo_scale(pctx, scale, scale);
    2262     cairo_translate(pctx, cairoMarginRect.x(), cairoMarginRect.y() + headerHeight);
     2262    cairo_scale(cr, scale, scale);
     2263    cairo_translate(cr, cairoMarginRect.x(), cairoMarginRect.y() + headerHeight);
    22632264
    22642265    // Modify Cairo (only) to account for page position.
    2265     cairo_translate(pctx, -pageRect.x(), -pageRect.y());
     2266    cairo_translate(cr, -pageRect.x(), -pageRect.y());
    22662267    coreFrame->view()->paintContents(spoolCtx, pageRect);
    2267     cairo_translate(pctx, pageRect.x(), pageRect.y());
     2268    cairo_translate(cr, pageRect.x(), pageRect.y());
    22682269   
    22692270    if (preview) {
     
    22862287    SetWorldTransform(hdc, &original);
    22872288
    2288     cairo_show_page(pctx);
    2289     ASSERT(!cairo_status(pctx));
     2289    cairo_show_page(cr);
     2290    ASSERT(!cairo_status(cr));
    22902291    spoolCtx->restore();
    22912292}
     
    23392340        printSurface = cairo_win32_printing_surface_create(targetDC); // metafile
    23402341   
    2341     PlatformGraphicsContext* pctx = (PlatformGraphicsContext*)cairo_create(printSurface);
    2342     if (!pctx) {
     2342    cairo_t* cr = cairo_create(printSurface);
     2343    if (!cr) {
    23432344        cairo_surface_destroy(printSurface);   
    23442345        return E_FAIL;
    23452346    }
    2346    
     2347
     2348    PlatformContextCairo platformContext(cr);
     2349    PlatformGraphicsContext* pctx = &platformContext;
     2350    cairo_destroy(cr);
     2351
    23472352    if (ctx) {
    23482353        // If this is a preview, the Windows HDC was sent with scaling information.
    23492354        // Retrieve it and reset it so that it draws properly.  This is a workaround
    23502355        // for a bug in Cairo (see https://bugs.freedesktop.org/show_bug.cgi?id=28161)
    2351         setCairoTransformToPreviewHDC(pctx, targetDC);
     2356        setCairoTransformToPreviewHDC(cr, targetDC);
    23522357    }
    23532358   
     
    23932398
    23942399#if PLATFORM(CAIRO)
    2395     cairo_destroy(pctx);
    23962400    cairo_surface_finish(printSurface);
    23972401    ASSERT(!cairo_surface_status(printSurface));
  • trunk/Source/WebKit/win/WebFrame.h

    r82553 r82962  
    6363typedef struct CGContext PlatformGraphicsContext;
    6464#elif PLATFORM(CAIRO)
    65 typedef struct _cairo PlatformGraphicsContext;
     65namespace WebCore {
     66class PlatformContextCairo;
     67}
     68typedef class WebCore::PlatformContextCairo PlatformGraphicsContext;
    6669#endif
    6770
  • trunk/Source/WebKit2/Shared/WebGraphicsContext.cpp

    r82553 r82962  
    2727#include "WebGraphicsContext.h"
    2828
     29#if PLATFORM(GTK)
     30#include <WebCore/PlatformContextCairo.h>
     31#endif
     32
    2933using namespace WebCore;
    3034
     
    3539    : m_platformContext(graphicsContext->platformContext())
    3640#elif PLATFORM(GTK)
    37     : m_platformContext(graphicsContext->platformContext())
     41    : m_platformContext(graphicsContext->platformContext()->cr())
    3842#endif
    3943{
Note: See TracChangeset for help on using the changeset viewer.