Changeset 194816 in webkit


Ignore:
Timestamp:
Jan 8, 2016, 10:07:33 PM (10 years ago)
Author:
Simon Fraser
Message:

Add display-list drawing hooks to platform-specific GraphicsContext files
https://bugs.webkit.org/show_bug.cgi?id=152940

Reviewed by Zalan Bujtas.

Call into the display list recorder for top-level entrypoints implemented in platform-specific
files.

The convention is that if a function begins with "platform", it's not a top-level
entry point, and should only be called when there's a platform context (i.e. not
recording, and not paintingDisabled).

A few instances are stubbed out until we have a more complete display list implementation.

  • platform/graphics/GraphicsContext.cpp:

(WebCore::GraphicsContext::drawText):

  • platform/graphics/cairo/GraphicsContextCairo.cpp:

(WebCore::GraphicsContext::getCTM):
(WebCore::GraphicsContext::savePlatformState):
(WebCore::GraphicsContext::restorePlatformState):
(WebCore::GraphicsContext::drawRect):
(WebCore::GraphicsContext::drawNativeImage):
(WebCore::GraphicsContext::drawLine):
(WebCore::GraphicsContext::drawEllipse):
(WebCore::GraphicsContext::drawConvexPolygon):
(WebCore::GraphicsContext::clipConvexPolygon):
(WebCore::GraphicsContext::fillPath):
(WebCore::GraphicsContext::strokePath):
(WebCore::GraphicsContext::fillRect):
(WebCore::GraphicsContext::clip):
(WebCore::GraphicsContext::clipPath):
(WebCore::GraphicsContext::clipBounds):
(WebCore::GraphicsContext::drawLinesForText):
(WebCore::GraphicsContext::roundToDevicePixels):
(WebCore::GraphicsContext::translate):
(WebCore::GraphicsContext::setPlatformStrokeThickness):
(WebCore::GraphicsContext::setPlatformStrokeStyle):
(WebCore::GraphicsContext::concatCTM):
(WebCore::GraphicsContext::setCTM):
(WebCore::GraphicsContext::beginPlatformTransparencyLayer):
(WebCore::GraphicsContext::endPlatformTransparencyLayer):
(WebCore::GraphicsContext::clearRect):
(WebCore::GraphicsContext::strokeRect):
(WebCore::GraphicsContext::setLineCap):
(WebCore::GraphicsContext::setLineDash):
(WebCore::GraphicsContext::setLineJoin):
(WebCore::GraphicsContext::clipOut):
(WebCore::GraphicsContext::rotate):
(WebCore::GraphicsContext::scale):
(WebCore::GraphicsContext::platformFillRoundedRect):
(WebCore::GraphicsContext::fillRectWithRoundedHole):
(WebCore::GraphicsContext::drawPattern):
(WebCore::GraphicsContext::setPlatformShouldAntialias):
(WebCore::GraphicsContext::setPlatformImageInterpolationQuality):
(WebCore::GraphicsContext::isAcceleratedContext):

  • platform/graphics/cg/GraphicsContextCG.cpp:

(WebCore::GraphicsContext::savePlatformState):
(WebCore::GraphicsContext::restorePlatformState):
(WebCore::GraphicsContext::drawNativeImage):
(WebCore::GraphicsContext::drawPattern):
(WebCore::GraphicsContext::drawRect):
(WebCore::GraphicsContext::drawLine):
(WebCore::GraphicsContext::drawEllipse):
(WebCore::GraphicsContext::drawConvexPolygon):
(WebCore::GraphicsContext::clipConvexPolygon):
(WebCore::GraphicsContext::applyStrokePattern):
(WebCore::GraphicsContext::applyFillPattern):
(WebCore::GraphicsContext::drawPath):
(WebCore::GraphicsContext::fillPath):
(WebCore::GraphicsContext::strokePath):
(WebCore::GraphicsContext::fillRect):
(WebCore::GraphicsContext::platformFillRoundedRect):
(WebCore::GraphicsContext::fillRectWithRoundedHole):
(WebCore::GraphicsContext::clip):
(WebCore::GraphicsContext::clipOut):
(WebCore::GraphicsContext::clipPath):
(WebCore::GraphicsContext::clipBounds):
(WebCore::GraphicsContext::beginPlatformTransparencyLayer):
(WebCore::GraphicsContext::endPlatformTransparencyLayer):
(WebCore::GraphicsContext::setPlatformShadow):
(WebCore::GraphicsContext::setMiterLimit):
(WebCore::GraphicsContext::clearRect):
(WebCore::GraphicsContext::strokeRect):
(WebCore::GraphicsContext::setLineCap):
(WebCore::GraphicsContext::setLineDash):
(WebCore::GraphicsContext::setLineJoin):
(WebCore::GraphicsContext::scale):
(WebCore::GraphicsContext::rotate):
(WebCore::GraphicsContext::translate):
(WebCore::GraphicsContext::concatCTM):
(WebCore::GraphicsContext::setCTM):
(WebCore::GraphicsContext::getCTM):
(WebCore::GraphicsContext::roundToDevicePixels):
(WebCore::GraphicsContext::drawLinesForText):
(WebCore::GraphicsContext::setURLForRect):
(WebCore::GraphicsContext::setIsCALayerContext):
(WebCore::GraphicsContext::isCALayerContext):
(WebCore::GraphicsContext::setIsAcceleratedContext):
(WebCore::GraphicsContext::isAcceleratedContext):
(WebCore::GraphicsContext::setPlatformTextDrawingMode):
(WebCore::GraphicsContext::setPlatformStrokeColor):
(WebCore::GraphicsContext::setPlatformStrokeThickness):
(WebCore::GraphicsContext::setPlatformFillColor):
(WebCore::GraphicsContext::setPlatformShouldAntialias):
(WebCore::GraphicsContext::setPlatformShouldSmoothFonts):
(WebCore::GraphicsContext::setPlatformAlpha):
(WebCore::GraphicsContext::setPlatformCompositeOperation):
(WebCore::GraphicsContext::platformApplyDeviceScaleFactor):
(WebCore::GraphicsContext::platformFillEllipse):
(WebCore::GraphicsContext::platformStrokeEllipse):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r194814 r194816  
     12016-01-08  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Add display-list drawing hooks to platform-specific GraphicsContext files
     4        https://bugs.webkit.org/show_bug.cgi?id=152940
     5
     6        Reviewed by Zalan Bujtas.
     7
     8        Call into the display list recorder for top-level entrypoints implemented in platform-specific
     9        files.
     10       
     11        The convention is that if a function begins with "platform", it's not a top-level
     12        entry point, and should only be called when there's a platform context (i.e. not
     13        recording, and not paintingDisabled).
     14       
     15        A few instances are stubbed out until we have a more complete display list implementation.
     16
     17        * platform/graphics/GraphicsContext.cpp:
     18        (WebCore::GraphicsContext::drawText):
     19        * platform/graphics/cairo/GraphicsContextCairo.cpp:
     20        (WebCore::GraphicsContext::getCTM):
     21        (WebCore::GraphicsContext::savePlatformState):
     22        (WebCore::GraphicsContext::restorePlatformState):
     23        (WebCore::GraphicsContext::drawRect):
     24        (WebCore::GraphicsContext::drawNativeImage):
     25        (WebCore::GraphicsContext::drawLine):
     26        (WebCore::GraphicsContext::drawEllipse):
     27        (WebCore::GraphicsContext::drawConvexPolygon):
     28        (WebCore::GraphicsContext::clipConvexPolygon):
     29        (WebCore::GraphicsContext::fillPath):
     30        (WebCore::GraphicsContext::strokePath):
     31        (WebCore::GraphicsContext::fillRect):
     32        (WebCore::GraphicsContext::clip):
     33        (WebCore::GraphicsContext::clipPath):
     34        (WebCore::GraphicsContext::clipBounds):
     35        (WebCore::GraphicsContext::drawLinesForText):
     36        (WebCore::GraphicsContext::roundToDevicePixels):
     37        (WebCore::GraphicsContext::translate):
     38        (WebCore::GraphicsContext::setPlatformStrokeThickness):
     39        (WebCore::GraphicsContext::setPlatformStrokeStyle):
     40        (WebCore::GraphicsContext::concatCTM):
     41        (WebCore::GraphicsContext::setCTM):
     42        (WebCore::GraphicsContext::beginPlatformTransparencyLayer):
     43        (WebCore::GraphicsContext::endPlatformTransparencyLayer):
     44        (WebCore::GraphicsContext::clearRect):
     45        (WebCore::GraphicsContext::strokeRect):
     46        (WebCore::GraphicsContext::setLineCap):
     47        (WebCore::GraphicsContext::setLineDash):
     48        (WebCore::GraphicsContext::setLineJoin):
     49        (WebCore::GraphicsContext::clipOut):
     50        (WebCore::GraphicsContext::rotate):
     51        (WebCore::GraphicsContext::scale):
     52        (WebCore::GraphicsContext::platformFillRoundedRect):
     53        (WebCore::GraphicsContext::fillRectWithRoundedHole):
     54        (WebCore::GraphicsContext::drawPattern):
     55        (WebCore::GraphicsContext::setPlatformShouldAntialias):
     56        (WebCore::GraphicsContext::setPlatformImageInterpolationQuality):
     57        (WebCore::GraphicsContext::isAcceleratedContext):
     58        * platform/graphics/cg/GraphicsContextCG.cpp:
     59        (WebCore::GraphicsContext::savePlatformState):
     60        (WebCore::GraphicsContext::restorePlatformState):
     61        (WebCore::GraphicsContext::drawNativeImage):
     62        (WebCore::GraphicsContext::drawPattern):
     63        (WebCore::GraphicsContext::drawRect):
     64        (WebCore::GraphicsContext::drawLine):
     65        (WebCore::GraphicsContext::drawEllipse):
     66        (WebCore::GraphicsContext::drawConvexPolygon):
     67        (WebCore::GraphicsContext::clipConvexPolygon):
     68        (WebCore::GraphicsContext::applyStrokePattern):
     69        (WebCore::GraphicsContext::applyFillPattern):
     70        (WebCore::GraphicsContext::drawPath):
     71        (WebCore::GraphicsContext::fillPath):
     72        (WebCore::GraphicsContext::strokePath):
     73        (WebCore::GraphicsContext::fillRect):
     74        (WebCore::GraphicsContext::platformFillRoundedRect):
     75        (WebCore::GraphicsContext::fillRectWithRoundedHole):
     76        (WebCore::GraphicsContext::clip):
     77        (WebCore::GraphicsContext::clipOut):
     78        (WebCore::GraphicsContext::clipPath):
     79        (WebCore::GraphicsContext::clipBounds):
     80        (WebCore::GraphicsContext::beginPlatformTransparencyLayer):
     81        (WebCore::GraphicsContext::endPlatformTransparencyLayer):
     82        (WebCore::GraphicsContext::setPlatformShadow):
     83        (WebCore::GraphicsContext::setMiterLimit):
     84        (WebCore::GraphicsContext::clearRect):
     85        (WebCore::GraphicsContext::strokeRect):
     86        (WebCore::GraphicsContext::setLineCap):
     87        (WebCore::GraphicsContext::setLineDash):
     88        (WebCore::GraphicsContext::setLineJoin):
     89        (WebCore::GraphicsContext::scale):
     90        (WebCore::GraphicsContext::rotate):
     91        (WebCore::GraphicsContext::translate):
     92        (WebCore::GraphicsContext::concatCTM):
     93        (WebCore::GraphicsContext::setCTM):
     94        (WebCore::GraphicsContext::getCTM):
     95        (WebCore::GraphicsContext::roundToDevicePixels):
     96        (WebCore::GraphicsContext::drawLinesForText):
     97        (WebCore::GraphicsContext::setURLForRect):
     98        (WebCore::GraphicsContext::setIsCALayerContext):
     99        (WebCore::GraphicsContext::isCALayerContext):
     100        (WebCore::GraphicsContext::setIsAcceleratedContext):
     101        (WebCore::GraphicsContext::isAcceleratedContext):
     102        (WebCore::GraphicsContext::setPlatformTextDrawingMode):
     103        (WebCore::GraphicsContext::setPlatformStrokeColor):
     104        (WebCore::GraphicsContext::setPlatformStrokeThickness):
     105        (WebCore::GraphicsContext::setPlatformFillColor):
     106        (WebCore::GraphicsContext::setPlatformShouldAntialias):
     107        (WebCore::GraphicsContext::setPlatformShouldSmoothFonts):
     108        (WebCore::GraphicsContext::setPlatformAlpha):
     109        (WebCore::GraphicsContext::setPlatformCompositeOperation):
     110        (WebCore::GraphicsContext::platformApplyDeviceScaleFactor):
     111        (WebCore::GraphicsContext::platformFillEllipse):
     112        (WebCore::GraphicsContext::platformStrokeEllipse):
     113
    11142016-01-08  Simon Fraser  <simon.fraser@apple.com>
    2115
  • trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp

    r194814 r194816  
    683683        return 0;
    684684
     685    if (isRecording()) {
     686        // FIXME: Text drawing with display lists TBD.
     687        return 0;
     688    }
     689
    685690    return font.drawText(*this, run, point, from, to);
    686691}
  • trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp

    r194798 r194816  
    3838#include "AffineTransform.h"
    3939#include "CairoUtilities.h"
     40#include "DisplayListRecorder.h"
    4041#include "DrawErrorUnderline.h"
    4142#include "FloatConversion.h"
     
    202203        return AffineTransform();
    203204
     205    if (isRecording()) {
     206        WTFLogAlways("GraphicsContext::getCTM() is not yet compatible with recording contexts.");
     207        return AffineTransform();
     208    }
     209
    204210    cairo_t* cr = platformContext()->cr();
    205211    cairo_matrix_t m;
     
    215221void GraphicsContext::savePlatformState()
    216222{
     223    ASSERT(!isRecording());
    217224    platformContext()->save();
    218225    m_data->save();
     
    221228void GraphicsContext::restorePlatformState()
    222229{
     230    ASSERT(!isRecording());
    223231    platformContext()->restore();
    224232    m_data->restore();
     
    231239
    232240// Draws a filled rectangle with a stroked border.
    233 void GraphicsContext::drawRect(const FloatRect& rect, float)
    234 {
    235     if (paintingDisabled())
    236         return;
     241void GraphicsContext::drawRect(const FloatRect& rect, float borderThickness)
     242{
     243    if (paintingDisabled())
     244        return;
     245
     246    if (isRecording()) {
     247        m_displayListRecorder->drawRect(rect, borderThickness);
     248        return;
     249    }
    237250
    238251    ASSERT(!rect.isEmpty());
     
    248261        r.inflate(-.5f);
    249262        cairo_rectangle(cr, r.x(), r.y(), r.width(), r.height());
    250         cairo_set_line_width(cr, 1.0);
     263        cairo_set_line_width(cr, 1.0); // borderThickness?
    251264        cairo_stroke(cr);
    252265    }
     
    257270void GraphicsContext::drawNativeImage(PassNativeImagePtr imagePtr, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator op, BlendMode blendMode, ImageOrientation orientation)
    258271{
    259     UNUSED_PARAM(imageSize);
     272    if (paintingDisabled())
     273        return;
     274
     275    if (isRecording()) {
     276        m_displayListRecorder->drawNativeImage(imagePtr, imageSize, destRect, srcRect, op, blendMode, orientation);
     277        return;
     278    }
    260279
    261280    NativeImagePtr image = imagePtr;
     
    295314    if (strokeStyle() == NoStroke)
    296315        return;
     316
     317    if (isRecording()) {
     318        m_displayListRecorder->drawLine(point1, point2);
     319        return;
     320    }
    297321
    298322    const Color& strokeColor = this->strokeColor();
     
    385409        return;
    386410
     411    if (isRecording()) {
     412        m_displayListRecorder->drawEllipse(rect);
     413        return;
     414    }
     415
    387416    cairo_t* cr = platformContext()->cr();
    388417    cairo_save(cr);
     
    415444        return;
    416445
     446    if (isRecording()) {
     447        m_displayListRecorder->drawConvexPolygon(npoints, points, shouldAntialias);
     448        return;
     449    }
     450
    417451    cairo_t* cr = platformContext()->cr();
    418452
     
    445479        return;
    446480
     481    if (isRecording()) {
     482        m_displayListRecorder->clipConvexPolygon(numPoints, points, antialiased);
     483        return;
     484    }
     485
    447486    cairo_t* cr = platformContext()->cr();
    448487
     
    465504        return;
    466505
     506    if (isRecording()) {
     507        m_displayListRecorder->fillPath(path);
     508        return;
     509    }
     510
    467511    cairo_t* cr = platformContext()->cr();
    468512    setPathOnCairoContext(cr, path.platformPath()->context());
     
    475519        return;
    476520
     521    if (isRecording()) {
     522        m_displayListRecorder->strokePath(path);
     523        return;
     524    }
     525
    477526    cairo_t* cr = platformContext()->cr();
    478527    setPathOnCairoContext(cr, path.platformPath()->context());
     
    485534        return;
    486535
     536    if (isRecording()) {
     537        m_displayListRecorder->fillRect(rect);
     538        return;
     539    }
     540
    487541    cairo_t* cr = platformContext()->cr();
    488542    cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height());
     
    495549        return;
    496550
     551    if (isRecording()) {
     552        m_displayListRecorder->fillRect(rect, color);
     553        return;
     554    }
     555
    497556    if (hasShadow())
    498557        platformContext()->shadowBlur().drawRectShadow(*this, FloatRoundedRect(rect));
     
    505564    if (paintingDisabled())
    506565        return;
     566
     567    if (isRecording()) {
     568        m_displayListRecorder->clip(rect);
     569        return;
     570    }
    507571
    508572    cairo_t* cr = platformContext()->cr();
     
    528592        return;
    529593
     594    if (isRecording()) {
     595        m_displayListRecorder->clipPath(path, clipRule);
     596        return;
     597    }
     598
    530599    cairo_t* cr = platformContext()->cr();
    531600    if (!path.isNull())
     
    553622IntRect GraphicsContext::clipBounds() const
    554623{
     624    if (paintingDisabled())
     625        return IntRect();
     626
     627    if (isRecording()) {
     628        WTFLogAlways("Getting the clip bounds not yet supported with display lists");
     629        return IntRect(-2048, -2048, 4096, 4096); // FIXME: display lists.
     630    }
     631
    555632    double x1, x2, y1, y2;
    556633    cairo_clip_extents(platformContext()->cr(), &x1, &y1, &x2, &y2);
     
    664741        return;
    665742
     743    if (isRecording()) {
     744        m_displayListRecorder->drawLinesForText(point, widths, printing, doubleUnderlines, strokeThickness());
     745        return;
     746    }
     747
    666748    Color localStrokeColor(strokeColor());
    667749
     
    721803FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& frect, RoundingMode)
    722804{
     805    if (paintingDisabled())
     806        return frect;
     807
     808    if (!isRecording()) {
     809        WTFLogAlways("GraphicsContext::roundToDevicePixels() is not yet compatible with recording contexts.");
     810        return frect;
     811    }
     812
    723813    FloatRect result;
    724814    double x = frect.x();
     
    761851        return;
    762852
     853    if (isRecording()) {
     854        m_displayListRecorder->translate(x, y);
     855        return;
     856    }
     857
    763858    cairo_t* cr = platformContext()->cr();
    764859    cairo_translate(cr, x, y);
     
    783878        return;
    784879
     880    ASSERT(!isRecording());
     881
    785882    cairo_set_line_width(platformContext()->cr(), strokeThickness);
    786883}
     
    793890    if (paintingDisabled())
    794891        return;
     892
     893    ASSERT(!isRecording());
    795894
    796895    switch (strokeStyle) {
     
    823922        return;
    824923
     924    if (isRecording()) {
     925        m_displayListRecorder->concatCTM(transform);
     926        return;
     927    }
     928
    825929    cairo_t* cr = platformContext()->cr();
    826930    const cairo_matrix_t matrix = cairo_matrix_t(transform);
     
    833937    if (paintingDisabled())
    834938        return;
     939
     940    if (isRecording()) {
     941        WTFLogAlways("GraphicsContext::setCTM() is not compatible with recording contexts.");
     942        return;
     943    }
    835944
    836945    cairo_t* cr = platformContext()->cr();
     
    871980        return;
    872981
     982    ASSERT(!isRecording());
     983
    873984    cairo_t* cr = platformContext()->cr();
    874985    cairo_push_group(cr);
     
    880991    if (paintingDisabled())
    881992        return;
     993
     994    ASSERT(!isRecording());
    882995
    883996    cairo_t* cr = platformContext()->cr();
     
    8971010    if (paintingDisabled())
    8981011        return;
     1012
     1013    if (isRecording()) {
     1014        m_displayListRecorder->clearRect(rect);
     1015        return;
     1016    }
    8991017
    9001018    cairo_t* cr = platformContext()->cr();
     
    9121030        return;
    9131031
     1032    if (isRecording()) {
     1033        m_displayListRecorder->strokeRect(rect, width);
     1034        return;
     1035    }
     1036
    9141037    cairo_t* cr = platformContext()->cr();
    9151038    cairo_save(cr);
     
    9241047    if (paintingDisabled())
    9251048        return;
     1049
     1050    if (isRecording()) {
     1051        m_displayListRecorder->setLineCap(lineCap);
     1052        return;
     1053    }
    9261054
    9271055    cairo_line_cap_t cairoCap = CAIRO_LINE_CAP_BUTT;
     
    9511079void GraphicsContext::setLineDash(const DashArray& dashes, float dashOffset)
    9521080{
     1081    if (paintingDisabled())
     1082        return;
     1083
     1084    if (isRecording()) {
     1085        m_displayListRecorder->setLineDash(dashes, dashOffset);
     1086        return;
     1087    }
     1088
    9531089    if (isDashArrayAllZero(dashes))
    9541090        cairo_set_dash(platformContext()->cr(), 0, 0, 0);
     
    9611097    if (paintingDisabled())
    9621098        return;
     1099
     1100    if (isRecording()) {
     1101        m_displayListRecorder->setLineJoin(lineJoin);
     1102        return;
     1103    }
    9631104
    9641105    cairo_line_join_t cairoJoin = CAIRO_LINE_JOIN_MITER;
     
    10141155        return;
    10151156
     1157    if (isRecording()) {
     1158        m_displayListRecorder->clipOut(path);
     1159        return;
     1160    }
     1161
    10161162    cairo_t* cr = platformContext()->cr();
    10171163    double x1, y1, x2, y2;
     
    10311177        return;
    10321178
     1179    if (isRecording()) {
     1180        m_displayListRecorder->rotate(radians);
     1181        return;
     1182    }
     1183
    10331184    cairo_rotate(platformContext()->cr(), radians);
    10341185    m_data->rotate(radians);
     
    10401191        return;
    10411192
     1193    if (isRecording()) {
     1194        m_displayListRecorder->scale(size);
     1195        return;
     1196    }
     1197
    10421198    cairo_scale(platformContext()->cr(), size.width(), size.height());
    10431199    m_data->scale(size);
     
    10481204    if (paintingDisabled())
    10491205        return;
     1206
     1207    if (isRecording()) {
     1208        m_displayListRecorder->clipOut(r);
     1209        return;
     1210    }
    10501211
    10511212    cairo_t* cr = platformContext()->cr();
     
    10651226        return;
    10661227
     1228    ASSERT(!isRecording());
     1229
    10671230    if (hasShadow())
    10681231        platformContext()->shadowBlur().drawRectShadow(*this, rect);
     
    10831246        return;
    10841247
     1248    if (isRecording()) {
     1249        m_displayListRecorder->fillRectWithRoundedHole(rect, roundedHoleRect, color);
     1250        return;
     1251    }
     1252
    10851253    if (this->mustUseShadowBlur())
    10861254        platformContext()->shadowBlur().drawInsetShadow(*this, rect, roundedHoleRect);
     
    11001268}
    11011269
    1102 void GraphicsContext::drawPattern(Image& image, const FloatRect& tileRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize&, CompositeOperator op, const FloatRect& destRect, BlendMode)
    1103 {
     1270void GraphicsContext::drawPattern(Image& image, const FloatRect& tileRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, CompositeOperator op, const FloatRect& destRect, BlendMode blendMode)
     1271{
     1272    if (paintingDisabled())
     1273        return;
     1274
     1275    if (isRecording()) {
     1276        m_displayListRecorder->drawPattern(image, tileRect, patternTransform, phase, spacing, op, destRect, blendMode);
     1277        return;
     1278    }
     1279
    11041280    RefPtr<cairo_surface_t> surface = image.nativeImageForCurrentFrame();
    11051281    if (!surface) // If it's too early we won't have an image yet.
     
    11141290    if (paintingDisabled())
    11151291        return;
     1292
     1293    ASSERT(!isRecording());
    11161294
    11171295    // When true, use the default Cairo backend antialias mode (usually this
     
    11231301void GraphicsContext::setPlatformImageInterpolationQuality(InterpolationQuality quality)
    11241302{
     1303    ASSERT(!isRecording());
     1304
    11251305    platformContext()->setImageInterpolationQuality(quality);
    11261306}
     
    11281308bool GraphicsContext::isAcceleratedContext() const
    11291309{
     1310    if (isRecording())
     1311        return false;
     1312
    11301313    return cairo_surface_get_type(cairo_get_target(platformContext()->cr())) == CAIRO_SURFACE_TYPE_GL;
    11311314}
  • trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp

    r194798 r194816  
    3030#include "AffineTransform.h"
    3131#include "CoreGraphicsSPI.h"
     32#include "DisplayListRecorder.h"
    3233#include "FloatConversion.h"
    3334#include "GraphicsContextPlatformPrivateCG.h"
     
    142143{
    143144    ASSERT(!paintingDisabled());
     145    ASSERT(!isRecording());
     146
    144147    // Note: Do not use this function within this class implementation, since we want to avoid the extra
    145148    // save of the secondary context (in GraphicsContextPlatformPrivateCG.h).
     
    151154{
    152155    ASSERT(!paintingDisabled());
     156    ASSERT(!isRecording());
     157
    153158    // Note: Do not use this function within this class implementation, since we want to avoid the extra
    154159    // restore of the secondary context (in GraphicsContextPlatformPrivateCG.h).
     
    162167    if (paintingDisabled())
    163168        return;
     169
     170    if (isRecording()) {
     171        m_displayListRecorder->drawNativeImage(imagePtr, imageSize, destRect, srcRect, op, blendMode, orientation);
     172        return;
     173    }
    164174
    165175    RetainPtr<CGImageRef> image(imagePtr);
     
    279289    if (paintingDisabled() || !patternTransform.isInvertible())
    280290        return;
     291
     292    if (isRecording()) {
     293        m_displayListRecorder->drawPattern(image, tileRect, patternTransform, phase, spacing, op, destRect, blendMode);
     294        return;
     295    }
    281296
    282297    CGContextRef context = platformContext();
     
    380395        return;
    381396
     397    if (isRecording()) {
     398        m_displayListRecorder->drawRect(rect, borderThickness);
     399        return;
     400    }
     401
    382402    // FIXME: this function does not handle patterns and gradients like drawPath does, it probably should.
    383403    ASSERT(!rect.isEmpty());
     
    412432    if (strokeStyle() == NoStroke)
    413433        return;
     434
     435    if (isRecording()) {
     436        m_displayListRecorder->drawLine(point1, point2);
     437        return;
     438    }
    414439
    415440    float thickness = strokeThickness();
     
    498523        return;
    499524
     525    if (isRecording()) {
     526        m_displayListRecorder->drawEllipse(rect);
     527        return;
     528    }
     529
    500530    Path path;
    501531    path.addEllipse(rect);
     
    521551        return;
    522552
     553    if (isRecording()) {
     554        m_displayListRecorder->drawConvexPolygon(numberOfPoints, points, antialiased);
     555        return;
     556    }
     557
    523558    CGContextRef context = platformContext();
    524559
     
    542577        return;
    543578
     579    if (isRecording()) {
     580        m_displayListRecorder->clipConvexPolygon(numberOfPoints, points, antialias);
     581        return;
     582    }
     583
    544584    CGContextRef context = platformContext();
    545585
     
    560600        return;
    561601
     602    if (isRecording()) {
     603        m_displayListRecorder->applyStrokePattern();
     604        return;
     605    }
     606
    562607    CGContextRef cgContext = platformContext();
    563608    AffineTransform userToBaseCTM = AffineTransform(getUserToBaseCTM(cgContext));
     
    578623    if (paintingDisabled())
    579624        return;
     625
     626    if (isRecording()) {
     627        m_displayListRecorder->applyFillPattern();
     628        return;
     629    }
    580630
    581631    CGContextRef cgContext = platformContext();
     
    625675        return;
    626676
     677    if (isRecording()) {
     678        m_displayListRecorder->drawPath(path);
     679        return;
     680    }
     681
    627682    CGContextRef context = platformContext();
    628683    const GraphicsContextState& state = m_state;
     
    661716    if (paintingDisabled() || path.isEmpty())
    662717        return;
     718
     719    if (isRecording()) {
     720        m_displayListRecorder->fillPath(path);
     721        return;
     722    }
    663723
    664724    CGContextRef context = platformContext();
     
    715775    if (paintingDisabled() || path.isEmpty())
    716776        return;
     777
     778    if (isRecording()) {
     779        m_displayListRecorder->strokePath(path);
     780        return;
     781    }
    717782
    718783    CGContextRef context = platformContext();
     
    773838        return;
    774839
     840    if (isRecording()) {
     841        m_displayListRecorder->fillRect(rect);
     842        return;
     843    }
     844
    775845    CGContextRef context = platformContext();
    776846
     
    821891        return;
    822892
     893    if (isRecording()) {
     894        m_displayListRecorder->fillRect(rect, color);
     895        return;
     896    }
     897
    823898    CGContextRef context = platformContext();
    824899    Color oldFillColor = fillColor();
     
    850925    if (paintingDisabled())
    851926        return;
     927   
     928    ASSERT(!isRecording());
    852929
    853930    CGContextRef context = platformContext();
     
    892969        return;
    893970
     971    if (isRecording()) {
     972        m_displayListRecorder->fillRectWithRoundedHole(rect, roundedHoleRect, color);
     973        return;
     974    }
     975
    894976    CGContextRef context = platformContext();
    895977
     
    9331015        return;
    9341016
     1017    if (isRecording()) {
     1018        m_displayListRecorder->clip(rect);
     1019        return;
     1020    }
     1021
    9351022    CGContextClipToRect(platformContext(), rect);
    9361023    m_data->clip(rect);
     
    9411028    if (paintingDisabled())
    9421029        return;
     1030
     1031    if (isRecording()) {
     1032        m_displayListRecorder->clipOut(rect);
     1033        return;
     1034    }
    9431035
    9441036    // FIXME: Using CGRectInfinite is much faster than getting the clip bounding box. However, due
     
    9541046}
    9551047
     1048void GraphicsContext::clipOut(const Path& path)
     1049{
     1050    if (paintingDisabled())
     1051        return;
     1052
     1053    if (isRecording()) {
     1054        m_displayListRecorder->clipOut(path);
     1055        return;
     1056    }
     1057
     1058    CGContextBeginPath(platformContext());
     1059    CGContextAddRect(platformContext(), CGContextGetClipBoundingBox(platformContext()));
     1060    if (!path.isEmpty())
     1061        CGContextAddPath(platformContext(), path.platformPath());
     1062    CGContextEOClip(platformContext());
     1063}
     1064
    9561065void GraphicsContext::clipPath(const Path& path, WindRule clipRule)
    9571066{
    9581067    if (paintingDisabled())
    9591068        return;
     1069
     1070    if (isRecording()) {
     1071        m_displayListRecorder->clipPath(path, clipRule);
     1072        return;
     1073    }
    9601074
    9611075    CGContextRef context = platformContext();
     
    9801094        return IntRect();
    9811095
     1096    if (isRecording()) {
     1097        WTFLogAlways("Getting the clip bounds not yet supported with display lists");
     1098        return IntRect(-2048, -2048, 4096, 4096); // FIXME: display lists.
     1099    }
     1100
     1101
    9821102    return enclosingIntRect(CGContextGetClipBoundingBox(platformContext()));
    9831103}
     
    9871107    if (paintingDisabled())
    9881108        return;
     1109
     1110    ASSERT(!isRecording());
    9891111
    9901112    save();
     
    10001122    if (paintingDisabled())
    10011123        return;
     1124
     1125    ASSERT(!isRecording());
     1126
    10021127    CGContextRef context = platformContext();
    10031128    CGContextEndTransparencyLayer(context);
     
    10431168    if (paintingDisabled())
    10441169        return;
     1170
     1171    ASSERT(!isRecording());
    10451172   
    10461173    // FIXME: we could avoid the shadow setup cost when we know we'll render the shadow ourselves.
     
    10931220    if (paintingDisabled())
    10941221        return;
     1222
     1223    if (isRecording()) {
     1224        // Maybe this should be part of the state.
     1225        m_displayListRecorder->setMiterLimit(limit);
     1226        return;
     1227    }
     1228
    10951229    CGContextSetMiterLimit(platformContext(), limit);
    10961230}
     
    11001234    if (paintingDisabled())
    11011235        return;
     1236
     1237    if (isRecording()) {
     1238        m_displayListRecorder->clearRect(r);
     1239        return;
     1240    }
     1241
    11021242    CGContextClearRect(platformContext(), r);
    11031243}
     
    11071247    if (paintingDisabled())
    11081248        return;
     1249
     1250    if (isRecording()) {
     1251        m_displayListRecorder->strokeRect(rect, lineWidth);
     1252        return;
     1253    }
    11091254
    11101255    CGContextRef context = platformContext();
     
    11721317    if (paintingDisabled())
    11731318        return;
     1319
     1320    if (isRecording()) {
     1321        m_displayListRecorder->setLineCap(cap);
     1322        return;
     1323    }
     1324
    11741325    switch (cap) {
    11751326    case ButtCap:
     
    11901341        return;
    11911342
     1343    if (isRecording()) {
     1344        m_displayListRecorder->setLineDash(dashes, dashOffset);
     1345        return;
     1346    }
     1347
    11921348    if (dashOffset < 0) {
    11931349        float length = 0;
     
    12041360    if (paintingDisabled())
    12051361        return;
     1362
     1363    if (isRecording()) {
     1364        m_displayListRecorder->setLineJoin(join);
     1365        return;
     1366    }
     1367
    12061368    switch (join) {
    12071369    case MiterJoin:
     
    12221384}
    12231385
    1224 void GraphicsContext::clipOut(const Path& path)
    1225 {
    1226     if (paintingDisabled())
    1227         return;
    1228 
    1229     CGContextBeginPath(platformContext());
    1230     CGContextAddRect(platformContext(), CGContextGetClipBoundingBox(platformContext()));
    1231     if (!path.isEmpty())
    1232         CGContextAddPath(platformContext(), path.platformPath());
    1233     CGContextEOClip(platformContext());
    1234 }
    1235 
    12361386void GraphicsContext::scale(const FloatSize& size)
    12371387{
    12381388    if (paintingDisabled())
    12391389        return;
     1390
     1391    if (isRecording()) {
     1392        m_displayListRecorder->scale(size);
     1393        return;
     1394    }
     1395
    12401396    CGContextScaleCTM(platformContext(), size.width(), size.height());
    12411397    m_data->scale(size);
     
    12471403    if (paintingDisabled())
    12481404        return;
     1405
     1406    if (isRecording()) {
     1407        m_displayListRecorder->rotate(angle);
     1408        return;
     1409    }
     1410
    12491411    CGContextRotateCTM(platformContext(), angle);
    12501412    m_data->rotate(angle);
     
    12561418    if (paintingDisabled())
    12571419        return;
     1420
     1421    if (isRecording()) {
     1422        m_displayListRecorder->translate(x, y);
     1423        return;
     1424    }
     1425
    12581426    CGContextTranslateCTM(platformContext(), x, y);
    12591427    m_data->translate(x, y);
     
    12651433    if (paintingDisabled())
    12661434        return;
     1435
     1436    if (isRecording()) {
     1437        m_displayListRecorder->concatCTM(transform);
     1438        return;
     1439    }
     1440
    12671441    CGContextConcatCTM(platformContext(), transform);
    12681442    m_data->concatCTM(transform);
     
    12741448    if (paintingDisabled())
    12751449        return;
     1450
     1451    if (isRecording()) {
     1452        WTFLogAlways("GraphicsContext::setCTM() is not compatible with recording contexts.");
     1453        return;
     1454    }
     1455
    12761456    CGContextSetCTM(platformContext(), transform);
    12771457    m_data->setCTM(transform);
     
    12831463    if (paintingDisabled())
    12841464        return AffineTransform();
     1465
     1466    if (isRecording()) {
     1467        WTFLogAlways("GraphicsContext::getCTM() is not yet compatible with recording contexts.");
     1468        return AffineTransform();
     1469    }
    12851470
    12861471    // The CTM usually includes the deviceScaleFactor except in WebKit 1 when the
     
    12971482    if (paintingDisabled())
    12981483        return rect;
     1484
     1485    if (!isRecording()) {
     1486        WTFLogAlways("GraphicsContext::roundToDevicePixels() is not yet compatible with recording contexts.");
     1487        return rect;
     1488    }
    12991489
    13001490    // It is not enough just to round to pixels in device space. The rotation part of the
     
    13561546        return;
    13571547
     1548    if (isRecording()) {
     1549        m_displayListRecorder->drawLinesForText(point, widths, printing, doubleLines, strokeThickness());
     1550        return;
     1551    }
     1552
    13581553    Color localStrokeColor(strokeColor());
    13591554
     
    13871582    if (paintingDisabled())
    13881583        return;
     1584
     1585    if (isRecording()) {
     1586        WTFLogAlways("GraphicsContext::setURLForRect() is not yet compatible with recording contexts.");
     1587        return; // FIXME for display lists.
     1588    }
    13891589
    13901590    RetainPtr<CFURLRef> urlRef = link.createCFURL();
     
    14391639        return;
    14401640
     1641    // FIXME
     1642    if (isRecording())
     1643        return;
     1644
    14411645    if (isLayerContext)
    14421646        m_data->m_contextFlags |= IsLayerCGContext;
     
    14501654        return false;
    14511655
     1656    // FIXME
     1657    if (isRecording())
     1658        return false;
     1659
    14521660    return m_data->m_contextFlags & IsLayerCGContext;
    14531661}
     
    14561664{
    14571665    if (paintingDisabled())
     1666        return;
     1667
     1668    // FIXME
     1669    if (isRecording())
    14581670        return;
    14591671
     
    14691681        return false;
    14701682
     1683    // FIXME
     1684    if (isRecording())
     1685        return false;
     1686
    14711687    return m_data->m_contextFlags & IsAcceleratedCGContext;
    14721688}
     
    14761692    if (paintingDisabled())
    14771693        return;
     1694
     1695    ASSERT(!isRecording());
    14781696
    14791697    CGContextRef context = platformContext();
     
    14971715    if (paintingDisabled())
    14981716        return;
     1717
     1718    ASSERT(!isRecording());
     1719
    14991720    setCGStrokeColor(platformContext(), color);
    15001721}
     
    15041725    if (paintingDisabled())
    15051726        return;
     1727
     1728    ASSERT(!isRecording());
     1729
    15061730    CGContextSetLineWidth(platformContext(), std::max(thickness, 0.f));
    15071731}
     
    15111735    if (paintingDisabled())
    15121736        return;
     1737
     1738    ASSERT(!isRecording());
     1739
    15131740    setCGFillColor(platformContext(), color);
    15141741}
     
    15181745    if (paintingDisabled())
    15191746        return;
     1747
     1748    ASSERT(!isRecording());
     1749
    15201750    CGContextSetShouldAntialias(platformContext(), enable);
    15211751}
     
    15251755    if (paintingDisabled())
    15261756        return;
     1757
     1758    ASSERT(!isRecording());
     1759
    15271760    CGContextSetShouldSmoothFonts(platformContext(), enable);
    15281761}
     
    15321765    if (paintingDisabled())
    15331766        return;
     1767
     1768    ASSERT(!isRecording());
     1769
    15341770    CGContextSetAlpha(platformContext(), alpha);
    15351771}
     
    15391775    if (paintingDisabled())
    15401776        return;
     1777
     1778    ASSERT(!isRecording());
    15411779
    15421780    CGBlendMode target = kCGBlendModeNormal;
     
    16511889        return;
    16521890
     1891    ASSERT(!isRecording());
     1892
    16531893    // CoreGraphics expects the base CTM of a HiDPI context to have the scale factor applied to it.
    16541894    // Failing to change the base level CTM will cause certain CG features, such as focus rings,
     
    16621902        return;
    16631903
     1904    ASSERT(!isRecording());
     1905
    16641906    // CGContextFillEllipseInRect only supports solid colors.
    16651907    if (m_state.fillGradient || m_state.fillPattern) {
     
    16771919        return;
    16781920
     1921    ASSERT(!isRecording());
     1922
    16791923    // CGContextStrokeEllipseInRect only supports solid colors.
    16801924    if (m_state.strokeGradient || m_state.strokePattern) {
Note: See TracChangeset for help on using the changeset viewer.