Add display-list drawing hooks to platform-specific GraphicsContext files
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 9 Jan 2016 06:07:33 +0000 (06:07 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 9 Jan 2016 06:07:33 +0000 (06:07 +0000)
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):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/GraphicsContext.cpp
Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp

index 11eecbc..f6bbf0e 100644 (file)
@@ -1,5 +1,118 @@
 2016-01-08  Simon Fraser  <simon.fraser@apple.com>
 
+        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):
+
+2016-01-08  Simon Fraser  <simon.fraser@apple.com>
+
         Add DisplayList hooks into GraphicsContext
         https://bugs.webkit.org/show_bug.cgi?id=152932
 
index 529d6ef..11e0c33 100644 (file)
@@ -682,6 +682,11 @@ float GraphicsContext::drawText(const FontCascade& font, const TextRun& run, con
     if (paintingDisabled())
         return 0;
 
+    if (isRecording()) {
+        // FIXME: Text drawing with display lists TBD.
+        return 0;
+    }
+
     return font.drawText(*this, run, point, from, to);
 }
 
index 29eec3f..034dad1 100644 (file)
@@ -37,6 +37,7 @@
 
 #include "AffineTransform.h"
 #include "CairoUtilities.h"
+#include "DisplayListRecorder.h"
 #include "DrawErrorUnderline.h"
 #include "FloatConversion.h"
 #include "FloatRect.h"
@@ -201,6 +202,11 @@ AffineTransform GraphicsContext::getCTM(IncludeDeviceScale) const
     if (paintingDisabled())
         return AffineTransform();
 
+    if (isRecording()) {
+        WTFLogAlways("GraphicsContext::getCTM() is not yet compatible with recording contexts.");
+        return AffineTransform();
+    }
+
     cairo_t* cr = platformContext()->cr();
     cairo_matrix_t m;
     cairo_get_matrix(cr, &m);
@@ -214,12 +220,14 @@ PlatformContextCairo* GraphicsContext::platformContext() const
 
 void GraphicsContext::savePlatformState()
 {
+    ASSERT(!isRecording());
     platformContext()->save();
     m_data->save();
 }
 
 void GraphicsContext::restorePlatformState()
 {
+    ASSERT(!isRecording());
     platformContext()->restore();
     m_data->restore();
 
@@ -230,11 +238,16 @@ void GraphicsContext::restorePlatformState()
 }
 
 // Draws a filled rectangle with a stroked border.
-void GraphicsContext::drawRect(const FloatRect& rect, float)
+void GraphicsContext::drawRect(const FloatRect& rect, float borderThickness)
 {
     if (paintingDisabled())
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->drawRect(rect, borderThickness);
+        return;
+    }
+
     ASSERT(!rect.isEmpty());
 
     cairo_t* cr = platformContext()->cr();
@@ -247,7 +260,7 @@ void GraphicsContext::drawRect(const FloatRect& rect, float)
         FloatRect r(rect);
         r.inflate(-.5f);
         cairo_rectangle(cr, r.x(), r.y(), r.width(), r.height());
-        cairo_set_line_width(cr, 1.0);
+        cairo_set_line_width(cr, 1.0); // borderThickness?
         cairo_stroke(cr);
     }
 
@@ -256,7 +269,13 @@ void GraphicsContext::drawRect(const FloatRect& rect, float)
 
 void GraphicsContext::drawNativeImage(PassNativeImagePtr imagePtr, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator op, BlendMode blendMode, ImageOrientation orientation)
 {
-    UNUSED_PARAM(imageSize);
+    if (paintingDisabled())
+        return;
+
+    if (isRecording()) {
+        m_displayListRecorder->drawNativeImage(imagePtr, imageSize, destRect, srcRect, op, blendMode, orientation);
+        return;
+    }
 
     NativeImagePtr image = imagePtr;
 
@@ -295,6 +314,11 @@ void GraphicsContext::drawLine(const FloatPoint& point1, const FloatPoint& point
     if (strokeStyle() == NoStroke)
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->drawLine(point1, point2);
+        return;
+    }
+
     const Color& strokeColor = this->strokeColor();
     float thickness = strokeThickness();
     bool isVerticalLine = (point1.x() + thickness == point2.x());
@@ -384,6 +408,11 @@ void GraphicsContext::drawEllipse(const FloatRect& rect)
     if (paintingDisabled())
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->drawEllipse(rect);
+        return;
+    }
+
     cairo_t* cr = platformContext()->cr();
     cairo_save(cr);
     float yRadius = .5 * rect.height();
@@ -414,6 +443,11 @@ void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points
     if (npoints <= 1)
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->drawConvexPolygon(npoints, points, shouldAntialias);
+        return;
+    }
+
     cairo_t* cr = platformContext()->cr();
 
     cairo_save(cr);
@@ -444,6 +478,11 @@ void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* poin
     if (numPoints <= 1)
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->clipConvexPolygon(numPoints, points, antialiased);
+        return;
+    }
+
     cairo_t* cr = platformContext()->cr();
 
     cairo_new_path(cr);
@@ -464,6 +503,11 @@ void GraphicsContext::fillPath(const Path& path)
     if (paintingDisabled() || path.isEmpty())
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->fillPath(path);
+        return;
+    }
+
     cairo_t* cr = platformContext()->cr();
     setPathOnCairoContext(cr, path.platformPath()->context());
     shadowAndFillCurrentCairoPath(*this);
@@ -474,6 +518,11 @@ void GraphicsContext::strokePath(const Path& path)
     if (paintingDisabled() || path.isEmpty())
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->strokePath(path);
+        return;
+    }
+
     cairo_t* cr = platformContext()->cr();
     setPathOnCairoContext(cr, path.platformPath()->context());
     shadowAndStrokeCurrentCairoPath(*this);
@@ -484,6 +533,11 @@ void GraphicsContext::fillRect(const FloatRect& rect)
     if (paintingDisabled())
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->fillRect(rect);
+        return;
+    }
+
     cairo_t* cr = platformContext()->cr();
     cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height());
     shadowAndFillCurrentCairoPath(*this);
@@ -494,6 +548,11 @@ void GraphicsContext::fillRect(const FloatRect& rect, const Color& color)
     if (paintingDisabled())
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->fillRect(rect, color);
+        return;
+    }
+
     if (hasShadow())
         platformContext()->shadowBlur().drawRectShadow(*this, FloatRoundedRect(rect));
 
@@ -505,6 +564,11 @@ void GraphicsContext::clip(const FloatRect& rect)
     if (paintingDisabled())
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->clip(rect);
+        return;
+    }
+
     cairo_t* cr = platformContext()->cr();
     cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height());
     cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr);
@@ -527,6 +591,11 @@ void GraphicsContext::clipPath(const Path& path, WindRule clipRule)
     if (paintingDisabled())
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->clipPath(path, clipRule);
+        return;
+    }
+
     cairo_t* cr = platformContext()->cr();
     if (!path.isNull())
         setPathOnCairoContext(cr, path.platformPath()->context());
@@ -552,6 +621,14 @@ void GraphicsContext::clipToImageBuffer(ImageBuffer& buffer, const FloatRect& de
 
 IntRect GraphicsContext::clipBounds() const
 {
+    if (paintingDisabled())
+        return IntRect();
+
+    if (isRecording()) {
+        WTFLogAlways("Getting the clip bounds not yet supported with display lists");
+        return IntRect(-2048, -2048, 4096, 4096); // FIXME: display lists.
+    }
+
     double x1, x2, y1, y2;
     cairo_clip_extents(platformContext()->cr(), &x1, &y1, &x2, &y2);
     return enclosingIntRect(FloatRect(x1, y1, x2 - x1, y2 - y1));
@@ -663,6 +740,11 @@ void GraphicsContext::drawLinesForText(const FloatPoint& point, const DashArray&
     if (widths.size() <= 0)
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->drawLinesForText(point, widths, printing, doubleUnderlines, strokeThickness());
+        return;
+    }
+
     Color localStrokeColor(strokeColor());
 
     FloatRect bounds = computeLineBoundsAndAntialiasingModeForText(point, widths.last(), printing, localStrokeColor);
@@ -720,6 +802,14 @@ void GraphicsContext::drawLineForDocumentMarker(const FloatPoint& origin, float
 
 FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& frect, RoundingMode)
 {
+    if (paintingDisabled())
+        return frect;
+
+    if (!isRecording()) {
+        WTFLogAlways("GraphicsContext::roundToDevicePixels() is not yet compatible with recording contexts.");
+        return frect;
+    }
+
     FloatRect result;
     double x = frect.x();
     double y = frect.y();
@@ -760,6 +850,11 @@ void GraphicsContext::translate(float x, float y)
     if (paintingDisabled())
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->translate(x, y);
+        return;
+    }
+
     cairo_t* cr = platformContext()->cr();
     cairo_translate(cr, x, y);
     m_data->translate(x, y);
@@ -782,6 +877,8 @@ void GraphicsContext::setPlatformStrokeThickness(float strokeThickness)
     if (paintingDisabled())
         return;
 
+    ASSERT(!isRecording());
+
     cairo_set_line_width(platformContext()->cr(), strokeThickness);
 }
 
@@ -793,6 +890,8 @@ void GraphicsContext::setPlatformStrokeStyle(StrokeStyle strokeStyle)
     if (paintingDisabled())
         return;
 
+    ASSERT(!isRecording());
+
     switch (strokeStyle) {
     case NoStroke:
         // FIXME: is it the right way to emulate NoStroke?
@@ -822,6 +921,11 @@ void GraphicsContext::concatCTM(const AffineTransform& transform)
     if (paintingDisabled())
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->concatCTM(transform);
+        return;
+    }
+
     cairo_t* cr = platformContext()->cr();
     const cairo_matrix_t matrix = cairo_matrix_t(transform);
     cairo_transform(cr, &matrix);
@@ -833,6 +937,11 @@ void GraphicsContext::setCTM(const AffineTransform& transform)
     if (paintingDisabled())
         return;
 
+    if (isRecording()) {
+        WTFLogAlways("GraphicsContext::setCTM() is not compatible with recording contexts.");
+        return;
+    }
+
     cairo_t* cr = platformContext()->cr();
     const cairo_matrix_t matrix = cairo_matrix_t(transform);
     cairo_set_matrix(cr, &matrix);
@@ -870,6 +979,8 @@ void GraphicsContext::beginPlatformTransparencyLayer(float opacity)
     if (paintingDisabled())
         return;
 
+    ASSERT(!isRecording());
+
     cairo_t* cr = platformContext()->cr();
     cairo_push_group(cr);
     m_data->layers.append(opacity);
@@ -880,6 +991,8 @@ void GraphicsContext::endPlatformTransparencyLayer()
     if (paintingDisabled())
         return;
 
+    ASSERT(!isRecording());
+
     cairo_t* cr = platformContext()->cr();
 
     cairo_pop_group_to_source(cr);
@@ -897,6 +1010,11 @@ void GraphicsContext::clearRect(const FloatRect& rect)
     if (paintingDisabled())
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->clearRect(rect);
+        return;
+    }
+
     cairo_t* cr = platformContext()->cr();
 
     cairo_save(cr);
@@ -911,6 +1029,11 @@ void GraphicsContext::strokeRect(const FloatRect& rect, float width)
     if (paintingDisabled())
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->strokeRect(rect, width);
+        return;
+    }
+
     cairo_t* cr = platformContext()->cr();
     cairo_save(cr);
     cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height());
@@ -924,6 +1047,11 @@ void GraphicsContext::setLineCap(LineCap lineCap)
     if (paintingDisabled())
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->setLineCap(lineCap);
+        return;
+    }
+
     cairo_line_cap_t cairoCap = CAIRO_LINE_CAP_BUTT;
     switch (lineCap) {
     case ButtCap:
@@ -950,6 +1078,14 @@ static inline bool isDashArrayAllZero(const DashArray& dashes)
 
 void GraphicsContext::setLineDash(const DashArray& dashes, float dashOffset)
 {
+    if (paintingDisabled())
+        return;
+
+    if (isRecording()) {
+        m_displayListRecorder->setLineDash(dashes, dashOffset);
+        return;
+    }
+
     if (isDashArrayAllZero(dashes))
         cairo_set_dash(platformContext()->cr(), 0, 0, 0);
     else
@@ -961,6 +1097,11 @@ void GraphicsContext::setLineJoin(LineJoin lineJoin)
     if (paintingDisabled())
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->setLineJoin(lineJoin);
+        return;
+    }
+
     cairo_line_join_t cairoJoin = CAIRO_LINE_JOIN_MITER;
     switch (lineJoin) {
     case MiterJoin:
@@ -1013,6 +1154,11 @@ void GraphicsContext::clipOut(const Path& path)
     if (paintingDisabled())
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->clipOut(path);
+        return;
+    }
+
     cairo_t* cr = platformContext()->cr();
     double x1, y1, x2, y2;
     cairo_clip_extents(cr, &x1, &y1, &x2, &y2);
@@ -1030,6 +1176,11 @@ void GraphicsContext::rotate(float radians)
     if (paintingDisabled())
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->rotate(radians);
+        return;
+    }
+
     cairo_rotate(platformContext()->cr(), radians);
     m_data->rotate(radians);
 }
@@ -1039,6 +1190,11 @@ void GraphicsContext::scale(const FloatSize& size)
     if (paintingDisabled())
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->scale(size);
+        return;
+    }
+
     cairo_scale(platformContext()->cr(), size.width(), size.height());
     m_data->scale(size);
 }
@@ -1048,6 +1204,11 @@ void GraphicsContext::clipOut(const FloatRect& r)
     if (paintingDisabled())
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->clipOut(r);
+        return;
+    }
+
     cairo_t* cr = platformContext()->cr();
     double x1, y1, x2, y2;
     cairo_clip_extents(cr, &x1, &y1, &x2, &y2);
@@ -1064,6 +1225,8 @@ void GraphicsContext::platformFillRoundedRect(const FloatRoundedRect& rect, cons
     if (paintingDisabled())
         return;
 
+    ASSERT(!isRecording());
+
     if (hasShadow())
         platformContext()->shadowBlur().drawRectShadow(*this, rect);
 
@@ -1082,6 +1245,11 @@ void GraphicsContext::fillRectWithRoundedHole(const FloatRect& rect, const Float
     if (paintingDisabled() || !color.isValid())
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->fillRectWithRoundedHole(rect, roundedHoleRect, color);
+        return;
+    }
+
     if (this->mustUseShadowBlur())
         platformContext()->shadowBlur().drawInsetShadow(*this, rect, roundedHoleRect);
 
@@ -1099,8 +1267,16 @@ void GraphicsContext::fillRectWithRoundedHole(const FloatRect& rect, const Float
     cairo_restore(cr);
 }
 
-void GraphicsContext::drawPattern(Image& image, const FloatRect& tileRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize&, CompositeOperator op, const FloatRect& destRect, BlendMode)
+void GraphicsContext::drawPattern(Image& image, const FloatRect& tileRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, CompositeOperator op, const FloatRect& destRect, BlendMode blendMode)
 {
+    if (paintingDisabled())
+        return;
+
+    if (isRecording()) {
+        m_displayListRecorder->drawPattern(image, tileRect, patternTransform, phase, spacing, op, destRect, blendMode);
+        return;
+    }
+
     RefPtr<cairo_surface_t> surface = image.nativeImageForCurrentFrame();
     if (!surface) // If it's too early we won't have an image yet.
         return;
@@ -1114,6 +1290,8 @@ void GraphicsContext::setPlatformShouldAntialias(bool enable)
     if (paintingDisabled())
         return;
 
+    ASSERT(!isRecording());
+
     // When true, use the default Cairo backend antialias mode (usually this
     // enables standard 'grayscale' antialiasing); false to explicitly disable
     // antialiasing. This is the same strategy as used in drawConvexPolygon().
@@ -1122,11 +1300,16 @@ void GraphicsContext::setPlatformShouldAntialias(bool enable)
 
 void GraphicsContext::setPlatformImageInterpolationQuality(InterpolationQuality quality)
 {
+    ASSERT(!isRecording());
+
     platformContext()->setImageInterpolationQuality(quality);
 }
 
 bool GraphicsContext::isAcceleratedContext() const
 {
+    if (isRecording())
+        return false;
+
     return cairo_surface_get_type(cairo_get_target(platformContext()->cr())) == CAIRO_SURFACE_TYPE_GL;
 }
 
index c45dc19..7149f42 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "AffineTransform.h"
 #include "CoreGraphicsSPI.h"
+#include "DisplayListRecorder.h"
 #include "FloatConversion.h"
 #include "GraphicsContextPlatformPrivateCG.h"
 #include "ImageBuffer.h"
@@ -141,6 +142,8 @@ CGContextRef GraphicsContext::platformContext() const
 void GraphicsContext::savePlatformState()
 {
     ASSERT(!paintingDisabled());
+    ASSERT(!isRecording());
+
     // Note: Do not use this function within this class implementation, since we want to avoid the extra
     // save of the secondary context (in GraphicsContextPlatformPrivateCG.h).
     CGContextSaveGState(platformContext());
@@ -150,6 +153,8 @@ void GraphicsContext::savePlatformState()
 void GraphicsContext::restorePlatformState()
 {
     ASSERT(!paintingDisabled());
+    ASSERT(!isRecording());
+
     // Note: Do not use this function within this class implementation, since we want to avoid the extra
     // restore of the secondary context (in GraphicsContextPlatformPrivateCG.h).
     CGContextRestoreGState(platformContext());
@@ -162,6 +167,11 @@ void GraphicsContext::drawNativeImage(PassNativeImagePtr imagePtr, const FloatSi
     if (paintingDisabled())
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->drawNativeImage(imagePtr, imageSize, destRect, srcRect, op, blendMode, orientation);
+        return;
+    }
+
     RetainPtr<CGImageRef> image(imagePtr);
 
     float currHeight = orientation.usesWidthAsHeight() ? CGImageGetWidth(image.get()) : CGImageGetHeight(image.get());
@@ -279,6 +289,11 @@ void GraphicsContext::drawPattern(Image& image, const FloatRect& tileRect, const
     if (paintingDisabled() || !patternTransform.isInvertible())
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->drawPattern(image, tileRect, patternTransform, phase, spacing, op, destRect, blendMode);
+        return;
+    }
+
     CGContextRef context = platformContext();
     CGContextStateSaver stateSaver(context);
     CGContextClipToRect(context, destRect);
@@ -379,6 +394,11 @@ void GraphicsContext::drawRect(const FloatRect& rect, float borderThickness)
     if (paintingDisabled())
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->drawRect(rect, borderThickness);
+        return;
+    }
+
     // FIXME: this function does not handle patterns and gradients like drawPath does, it probably should.
     ASSERT(!rect.isEmpty());
 
@@ -412,6 +432,11 @@ void GraphicsContext::drawLine(const FloatPoint& point1, const FloatPoint& point
     if (strokeStyle() == NoStroke)
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->drawLine(point1, point2);
+        return;
+    }
+
     float thickness = strokeThickness();
     bool isVerticalLine = (point1.x() + thickness == point2.x());
     float strokeWidth = isVerticalLine ? point2.y() - point1.y() : point2.x() - point1.x();
@@ -497,6 +522,11 @@ void GraphicsContext::drawEllipse(const FloatRect& rect)
     if (paintingDisabled())
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->drawEllipse(rect);
+        return;
+    }
+
     Path path;
     path.addEllipse(rect);
     drawPath(path);
@@ -520,6 +550,11 @@ void GraphicsContext::drawConvexPolygon(size_t numberOfPoints, const FloatPoint*
     if (numberOfPoints <= 1)
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->drawConvexPolygon(numberOfPoints, points, antialiased);
+        return;
+    }
+
     CGContextRef context = platformContext();
 
     if (antialiased != shouldAntialias())
@@ -541,6 +576,11 @@ void GraphicsContext::clipConvexPolygon(size_t numberOfPoints, const FloatPoint*
     if (numberOfPoints <= 1)
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->clipConvexPolygon(numberOfPoints, points, antialias);
+        return;
+    }
+
     CGContextRef context = platformContext();
 
     if (antialias != shouldAntialias())
@@ -559,6 +599,11 @@ void GraphicsContext::applyStrokePattern()
     if (paintingDisabled())
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->applyStrokePattern();
+        return;
+    }
+
     CGContextRef cgContext = platformContext();
     AffineTransform userToBaseCTM = AffineTransform(getUserToBaseCTM(cgContext));
 
@@ -578,6 +623,11 @@ void GraphicsContext::applyFillPattern()
     if (paintingDisabled())
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->applyFillPattern();
+        return;
+    }
+
     CGContextRef cgContext = platformContext();
     AffineTransform userToBaseCTM = AffineTransform(getUserToBaseCTM(cgContext));
 
@@ -624,6 +674,11 @@ void GraphicsContext::drawPath(const Path& path)
     if (paintingDisabled() || path.isEmpty())
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->drawPath(path);
+        return;
+    }
+
     CGContextRef context = platformContext();
     const GraphicsContextState& state = m_state;
 
@@ -661,6 +716,11 @@ void GraphicsContext::fillPath(const Path& path)
     if (paintingDisabled() || path.isEmpty())
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->fillPath(path);
+        return;
+    }
+
     CGContextRef context = platformContext();
 
     if (m_state.fillGradient) {
@@ -715,6 +775,11 @@ void GraphicsContext::strokePath(const Path& path)
     if (paintingDisabled() || path.isEmpty())
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->strokePath(path);
+        return;
+    }
+
     CGContextRef context = platformContext();
 
     CGContextBeginPath(context);
@@ -772,6 +837,11 @@ void GraphicsContext::fillRect(const FloatRect& rect)
     if (paintingDisabled())
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->fillRect(rect);
+        return;
+    }
+
     CGContextRef context = platformContext();
 
     if (m_state.fillGradient) {
@@ -820,6 +890,11 @@ void GraphicsContext::fillRect(const FloatRect& rect, const Color& color)
     if (paintingDisabled())
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->fillRect(rect, color);
+        return;
+    }
+
     CGContextRef context = platformContext();
     Color oldFillColor = fillColor();
 
@@ -849,6 +924,8 @@ void GraphicsContext::platformFillRoundedRect(const FloatRoundedRect& rect, cons
 {
     if (paintingDisabled())
         return;
+    
+    ASSERT(!isRecording());
 
     CGContextRef context = platformContext();
     Color oldFillColor = fillColor();
@@ -891,6 +968,11 @@ void GraphicsContext::fillRectWithRoundedHole(const FloatRect& rect, const Float
     if (paintingDisabled())
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->fillRectWithRoundedHole(rect, roundedHoleRect, color);
+        return;
+    }
+
     CGContextRef context = platformContext();
 
     Path path;
@@ -932,6 +1014,11 @@ void GraphicsContext::clip(const FloatRect& rect)
     if (paintingDisabled())
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->clip(rect);
+        return;
+    }
+
     CGContextClipToRect(platformContext(), rect);
     m_data->clip(rect);
 }
@@ -941,6 +1028,11 @@ void GraphicsContext::clipOut(const FloatRect& rect)
     if (paintingDisabled())
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->clipOut(rect);
+        return;
+    }
+
     // FIXME: Using CGRectInfinite is much faster than getting the clip bounding box. However, due
     // to <rdar://problem/12584492>, CGRectInfinite can't be used with an accelerated context that
     // has certain transforms that aren't just a translation or a scale. And due to <rdar://problem/14634453>
@@ -953,11 +1045,33 @@ void GraphicsContext::clipOut(const FloatRect& rect)
     CGContextEOClip(platformContext());
 }
 
+void GraphicsContext::clipOut(const Path& path)
+{
+    if (paintingDisabled())
+        return;
+
+    if (isRecording()) {
+        m_displayListRecorder->clipOut(path);
+        return;
+    }
+
+    CGContextBeginPath(platformContext());
+    CGContextAddRect(platformContext(), CGContextGetClipBoundingBox(platformContext()));
+    if (!path.isEmpty())
+        CGContextAddPath(platformContext(), path.platformPath());
+    CGContextEOClip(platformContext());
+}
+
 void GraphicsContext::clipPath(const Path& path, WindRule clipRule)
 {
     if (paintingDisabled())
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->clipPath(path, clipRule);
+        return;
+    }
+
     CGContextRef context = platformContext();
     if (path.isEmpty())
         CGContextClipToRect(context, CGRectZero);
@@ -979,6 +1093,12 @@ IntRect GraphicsContext::clipBounds() const
     if (paintingDisabled())
         return IntRect();
 
+    if (isRecording()) {
+        WTFLogAlways("Getting the clip bounds not yet supported with display lists");
+        return IntRect(-2048, -2048, 4096, 4096); // FIXME: display lists.
+    }
+
+
     return enclosingIntRect(CGContextGetClipBoundingBox(platformContext()));
 }
 
@@ -987,6 +1107,8 @@ void GraphicsContext::beginPlatformTransparencyLayer(float opacity)
     if (paintingDisabled())
         return;
 
+    ASSERT(!isRecording());
+
     save();
 
     CGContextRef context = platformContext();
@@ -999,6 +1121,9 @@ void GraphicsContext::endPlatformTransparencyLayer()
 {
     if (paintingDisabled())
         return;
+
+    ASSERT(!isRecording());
+
     CGContextRef context = platformContext();
     CGContextEndTransparencyLayer(context);
 
@@ -1042,6 +1167,8 @@ void GraphicsContext::setPlatformShadow(const FloatSize& offset, float blur, con
 {
     if (paintingDisabled())
         return;
+
+    ASSERT(!isRecording());
     
     // FIXME: we could avoid the shadow setup cost when we know we'll render the shadow ourselves.
 
@@ -1092,6 +1219,13 @@ void GraphicsContext::setMiterLimit(float limit)
 {
     if (paintingDisabled())
         return;
+
+    if (isRecording()) {
+        // Maybe this should be part of the state.
+        m_displayListRecorder->setMiterLimit(limit);
+        return;
+    }
+
     CGContextSetMiterLimit(platformContext(), limit);
 }
 
@@ -1099,6 +1233,12 @@ void GraphicsContext::clearRect(const FloatRect& r)
 {
     if (paintingDisabled())
         return;
+
+    if (isRecording()) {
+        m_displayListRecorder->clearRect(r);
+        return;
+    }
+
     CGContextClearRect(platformContext(), r);
 }
 
@@ -1107,6 +1247,11 @@ void GraphicsContext::strokeRect(const FloatRect& rect, float lineWidth)
     if (paintingDisabled())
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->strokeRect(rect, lineWidth);
+        return;
+    }
+
     CGContextRef context = platformContext();
 
     if (m_state.strokeGradient) {
@@ -1171,6 +1316,12 @@ void GraphicsContext::setLineCap(LineCap cap)
 {
     if (paintingDisabled())
         return;
+
+    if (isRecording()) {
+        m_displayListRecorder->setLineCap(cap);
+        return;
+    }
+
     switch (cap) {
     case ButtCap:
         CGContextSetLineCap(platformContext(), kCGLineCapButt);
@@ -1189,6 +1340,11 @@ void GraphicsContext::setLineDash(const DashArray& dashes, float dashOffset)
     if (paintingDisabled())
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->setLineDash(dashes, dashOffset);
+        return;
+    }
+
     if (dashOffset < 0) {
         float length = 0;
         for (size_t i = 0; i < dashes.size(); ++i)
@@ -1203,6 +1359,12 @@ void GraphicsContext::setLineJoin(LineJoin join)
 {
     if (paintingDisabled())
         return;
+
+    if (isRecording()) {
+        m_displayListRecorder->setLineJoin(join);
+        return;
+    }
+
     switch (join) {
     case MiterJoin:
         CGContextSetLineJoin(platformContext(), kCGLineJoinMiter);
@@ -1221,22 +1383,16 @@ void GraphicsContext::canvasClip(const Path& path, WindRule fillRule)
     clipPath(path, fillRule);
 }
 
-void GraphicsContext::clipOut(const Path& path)
+void GraphicsContext::scale(const FloatSize& size)
 {
     if (paintingDisabled())
         return;
 
-    CGContextBeginPath(platformContext());
-    CGContextAddRect(platformContext(), CGContextGetClipBoundingBox(platformContext()));
-    if (!path.isEmpty())
-        CGContextAddPath(platformContext(), path.platformPath());
-    CGContextEOClip(platformContext());
-}
-
-void GraphicsContext::scale(const FloatSize& size)
-{
-    if (paintingDisabled())
+    if (isRecording()) {
+        m_displayListRecorder->scale(size);
         return;
+    }
+
     CGContextScaleCTM(platformContext(), size.width(), size.height());
     m_data->scale(size);
     m_data->m_userToDeviceTransformKnownToBeIdentity = false;
@@ -1246,6 +1402,12 @@ void GraphicsContext::rotate(float angle)
 {
     if (paintingDisabled())
         return;
+
+    if (isRecording()) {
+        m_displayListRecorder->rotate(angle);
+        return;
+    }
+
     CGContextRotateCTM(platformContext(), angle);
     m_data->rotate(angle);
     m_data->m_userToDeviceTransformKnownToBeIdentity = false;
@@ -1255,6 +1417,12 @@ void GraphicsContext::translate(float x, float y)
 {
     if (paintingDisabled())
         return;
+
+    if (isRecording()) {
+        m_displayListRecorder->translate(x, y);
+        return;
+    }
+
     CGContextTranslateCTM(platformContext(), x, y);
     m_data->translate(x, y);
     m_data->m_userToDeviceTransformKnownToBeIdentity = false;
@@ -1264,6 +1432,12 @@ void GraphicsContext::concatCTM(const AffineTransform& transform)
 {
     if (paintingDisabled())
         return;
+
+    if (isRecording()) {
+        m_displayListRecorder->concatCTM(transform);
+        return;
+    }
+
     CGContextConcatCTM(platformContext(), transform);
     m_data->concatCTM(transform);
     m_data->m_userToDeviceTransformKnownToBeIdentity = false;
@@ -1273,6 +1447,12 @@ void GraphicsContext::setCTM(const AffineTransform& transform)
 {
     if (paintingDisabled())
         return;
+
+    if (isRecording()) {
+        WTFLogAlways("GraphicsContext::setCTM() is not compatible with recording contexts.");
+        return;
+    }
+
     CGContextSetCTM(platformContext(), transform);
     m_data->setCTM(transform);
     m_data->m_userToDeviceTransformKnownToBeIdentity = false;
@@ -1283,6 +1463,11 @@ AffineTransform GraphicsContext::getCTM(IncludeDeviceScale includeScale) const
     if (paintingDisabled())
         return AffineTransform();
 
+    if (isRecording()) {
+        WTFLogAlways("GraphicsContext::getCTM() is not yet compatible with recording contexts.");
+        return AffineTransform();
+    }
+
     // The CTM usually includes the deviceScaleFactor except in WebKit 1 when the
     // content is non-composited, since the scale factor is integrated at a lower
     // level. To guarantee the deviceScale is included, we can use this CG API.
@@ -1297,6 +1482,11 @@ FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& rect, RoundingMo
     if (paintingDisabled())
         return rect;
 
+    if (!isRecording()) {
+        WTFLogAlways("GraphicsContext::roundToDevicePixels() is not yet compatible with recording contexts.");
+        return rect;
+    }
+
     // It is not enough just to round to pixels in device space. The rotation part of the
     // affine transform matrix to device space can mess with this conversion if we have a
     // rotating image like the hands of the world clock widget. We just need the scale, so
@@ -1355,6 +1545,11 @@ void GraphicsContext::drawLinesForText(const FloatPoint& point, const DashArray&
     if (!widths.size())
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->drawLinesForText(point, widths, printing, doubleLines, strokeThickness());
+        return;
+    }
+
     Color localStrokeColor(strokeColor());
 
     FloatRect bounds = computeLineBoundsAndAntialiasingModeForText(point, widths.last(), printing, localStrokeColor);
@@ -1387,6 +1582,11 @@ void GraphicsContext::setURLForRect(const URL& link, const IntRect& destRect)
     if (paintingDisabled())
         return;
 
+    if (isRecording()) {
+        WTFLogAlways("GraphicsContext::setURLForRect() is not yet compatible with recording contexts.");
+        return; // FIXME for display lists.
+    }
+
     RetainPtr<CFURLRef> urlRef = link.createCFURL();
     if (!urlRef)
         return;
@@ -1438,6 +1638,10 @@ void GraphicsContext::setIsCALayerContext(bool isLayerContext)
     if (paintingDisabled())
         return;
 
+    // FIXME
+    if (isRecording())
+        return;
+
     if (isLayerContext)
         m_data->m_contextFlags |= IsLayerCGContext;
     else
@@ -1449,6 +1653,10 @@ bool GraphicsContext::isCALayerContext() const
     if (paintingDisabled())
         return false;
 
+    // FIXME
+    if (isRecording())
+        return false;
+
     return m_data->m_contextFlags & IsLayerCGContext;
 }
 
@@ -1457,6 +1665,10 @@ void GraphicsContext::setIsAcceleratedContext(bool isAccelerated)
     if (paintingDisabled())
         return;
 
+    // FIXME
+    if (isRecording())
+        return;
+
     if (isAccelerated)
         m_data->m_contextFlags |= IsAcceleratedCGContext;
     else
@@ -1468,6 +1680,10 @@ bool GraphicsContext::isAcceleratedContext() const
     if (paintingDisabled())
         return false;
 
+    // FIXME
+    if (isRecording())
+        return false;
+
     return m_data->m_contextFlags & IsAcceleratedCGContext;
 }
 
@@ -1476,6 +1692,8 @@ void GraphicsContext::setPlatformTextDrawingMode(TextDrawingModeFlags mode)
     if (paintingDisabled())
         return;
 
+    ASSERT(!isRecording());
+
     CGContextRef context = platformContext();
     switch (mode) {
     case TextModeFill:
@@ -1496,6 +1714,9 @@ void GraphicsContext::setPlatformStrokeColor(const Color& color)
 {
     if (paintingDisabled())
         return;
+
+    ASSERT(!isRecording());
+
     setCGStrokeColor(platformContext(), color);
 }
 
@@ -1503,6 +1724,9 @@ void GraphicsContext::setPlatformStrokeThickness(float thickness)
 {
     if (paintingDisabled())
         return;
+
+    ASSERT(!isRecording());
+
     CGContextSetLineWidth(platformContext(), std::max(thickness, 0.f));
 }
 
@@ -1510,6 +1734,9 @@ void GraphicsContext::setPlatformFillColor(const Color& color)
 {
     if (paintingDisabled())
         return;
+
+    ASSERT(!isRecording());
+
     setCGFillColor(platformContext(), color);
 }
 
@@ -1517,6 +1744,9 @@ void GraphicsContext::setPlatformShouldAntialias(bool enable)
 {
     if (paintingDisabled())
         return;
+
+    ASSERT(!isRecording());
+
     CGContextSetShouldAntialias(platformContext(), enable);
 }
 
@@ -1524,6 +1754,9 @@ void GraphicsContext::setPlatformShouldSmoothFonts(bool enable)
 {
     if (paintingDisabled())
         return;
+
+    ASSERT(!isRecording());
+
     CGContextSetShouldSmoothFonts(platformContext(), enable);
 }
 
@@ -1531,6 +1764,9 @@ void GraphicsContext::setPlatformAlpha(float alpha)
 {
     if (paintingDisabled())
         return;
+
+    ASSERT(!isRecording());
+
     CGContextSetAlpha(platformContext(), alpha);
 }
 
@@ -1539,6 +1775,8 @@ void GraphicsContext::setPlatformCompositeOperation(CompositeOperator mode, Blen
     if (paintingDisabled())
         return;
 
+    ASSERT(!isRecording());
+
     CGBlendMode target = kCGBlendModeNormal;
     if (blendMode != BlendModeNormal) {
         switch (blendMode) {
@@ -1650,6 +1888,8 @@ void GraphicsContext::platformApplyDeviceScaleFactor(float deviceScaleFactor)
     if (paintingDisabled())
         return;
 
+    ASSERT(!isRecording());
+
     // CoreGraphics expects the base CTM of a HiDPI context to have the scale factor applied to it.
     // Failing to change the base level CTM will cause certain CG features, such as focus rings,
     // to draw with a scale factor of 1 rather than the actual scale factor.
@@ -1661,6 +1901,8 @@ void GraphicsContext::platformFillEllipse(const FloatRect& ellipse)
     if (paintingDisabled())
         return;
 
+    ASSERT(!isRecording());
+
     // CGContextFillEllipseInRect only supports solid colors.
     if (m_state.fillGradient || m_state.fillPattern) {
         fillEllipseAsPath(ellipse);
@@ -1676,6 +1918,8 @@ void GraphicsContext::platformStrokeEllipse(const FloatRect& ellipse)
     if (paintingDisabled())
         return;
 
+    ASSERT(!isRecording());
+
     // CGContextStrokeEllipseInRect only supports solid colors.
     if (m_state.strokeGradient || m_state.strokePattern) {
         strokeEllipseAsPath(ellipse);