Add a GraphicsContextImpl and use it for DispayList::Recorder
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 4 Nov 2017 23:43:55 +0000 (23:43 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 4 Nov 2017 23:43:55 +0000 (23:43 +0000)
https://bugs.webkit.org/show_bug.cgi?id=179286

Reviewed by Sam Weinig.

Start moving towards a model when GraphicsContext has a pointer to an implementation
("pimpl") by adding GraphicsContextImpl, and converting display list recording to
be an implementation of a GraphicsContextImpl.

No behavior change.

* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::DisplayListDrawingContext::DisplayListDrawingContext):
* platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::GraphicsContext):
(WebCore::GraphicsContext::save):
(WebCore::GraphicsContext::restore):
(WebCore::GraphicsContext::setStrokeThickness):
(WebCore::GraphicsContext::setStrokeStyle):
(WebCore::GraphicsContext::setStrokeColor):
(WebCore::GraphicsContext::setShadow):
(WebCore::GraphicsContext::setLegacyShadow):
(WebCore::GraphicsContext::clearShadow):
(WebCore::GraphicsContext::setFillColor):
(WebCore::GraphicsContext::setShadowsIgnoreTransforms):
(WebCore::GraphicsContext::setShouldAntialias):
(WebCore::GraphicsContext::setShouldSmoothFonts):
(WebCore::GraphicsContext::setShouldSubpixelQuantizeFonts):
(WebCore::GraphicsContext::setImageInterpolationQuality):
(WebCore::GraphicsContext::setStrokePattern):
(WebCore::GraphicsContext::setFillPattern):
(WebCore::GraphicsContext::setStrokeGradient):
(WebCore::GraphicsContext::setFillRule):
(WebCore::GraphicsContext::setFillGradient):
(WebCore::GraphicsContext::beginTransparencyLayer):
(WebCore::GraphicsContext::endTransparencyLayer):
(WebCore::GraphicsContext::drawGlyphs):
(WebCore::GraphicsContext::drawImage):
(WebCore::GraphicsContext::drawTiledImage):
(WebCore::GraphicsContext::setTextDrawingMode):
(WebCore::GraphicsContext::fillRect):
(WebCore::GraphicsContext::fillRoundedRect):
(WebCore::GraphicsContext::setAlpha):
(WebCore::GraphicsContext::setCompositeOperation):
(WebCore::GraphicsContext::setDrawLuminanceMask):
(WebCore::GraphicsContext::applyDeviceScaleFactor):
(WebCore::GraphicsContext::fillEllipse):
(WebCore::GraphicsContext::strokeEllipse):
* platform/graphics/GraphicsContext.h:
(WebCore::GraphicsContext::hasPlatformContext const):
(WebCore::GraphicsContext::paintingDisabled const):
(WebCore::GraphicsContext::setDisplayListRecorder): Deleted.
(WebCore::GraphicsContext::isRecording const): Deleted.
* platform/graphics/GraphicsContextImpl.cpp: Added.
(WebCore::GraphicsContextImpl::GraphicsContextImpl):
(WebCore::GraphicsContextImpl::~GraphicsContextImpl):
* platform/graphics/GraphicsContextImpl.h: Added.
(WebCore::GraphicsContextImpl::graphicsContext const):
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::recursiveCommitChanges):
* platform/graphics/cairo/GraphicsContextCairo.cpp:
(WebCore::GraphicsContext::getCTM const):
(WebCore::GraphicsContext::savePlatformState):
(WebCore::GraphicsContext::restorePlatformState):
(WebCore::GraphicsContext::drawRect):
(WebCore::GraphicsContext::drawNativeImage):
(WebCore::GraphicsContext::drawLine):
(WebCore::GraphicsContext::drawEllipse):
(WebCore::GraphicsContext::fillPath):
(WebCore::GraphicsContext::strokePath):
(WebCore::GraphicsContext::fillRect):
(WebCore::GraphicsContext::clip):
(WebCore::GraphicsContext::clipPath):
(WebCore::GraphicsContext::clipBounds const):
(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::setMiterLimit):
(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 const):
* 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::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 const):
(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 const):
(WebCore::GraphicsContext::roundToDevicePixels):
(WebCore::GraphicsContext::drawLinesForText):
(WebCore::GraphicsContext::setURLForRect):
(WebCore::GraphicsContext::setIsCALayerContext):
(WebCore::GraphicsContext::isCALayerContext const):
(WebCore::GraphicsContext::setIsAcceleratedContext):
(WebCore::GraphicsContext::isAcceleratedContext const):
(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):
(WebCore::GraphicsContext::setDestinationForRect):
(WebCore::GraphicsContext::addDestinationAtPoint):
* platform/graphics/cocoa/GraphicsContextCocoa.mm:
(WebCore::GraphicsContext::drawFocusRing):
* platform/graphics/displaylists/DisplayListRecorder.cpp:
(WebCore::DisplayList::Recorder::Recorder):
(WebCore::DisplayList::Recorder::updateItemExtent const):
(WebCore::DisplayList::Recorder::extentFromLocalBounds const):
* platform/graphics/displaylists/DisplayListRecorder.h:
(WebCore::DisplayList::Recorder::itemCount const):
* rendering/RenderTheme.cpp:
(WebCore::RenderTheme::paint):

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

16 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Sources.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
Source/WebCore/platform/graphics/GraphicsContext.cpp
Source/WebCore/platform/graphics/GraphicsContext.h
Source/WebCore/platform/graphics/GraphicsContextImpl.cpp [new file with mode: 0644]
Source/WebCore/platform/graphics/GraphicsContextImpl.h [new file with mode: 0644]
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
Source/WebCore/platform/graphics/cocoa/GraphicsContextCocoa.mm
Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp
Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h
Source/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp
Source/WebCore/rendering/RenderTheme.cpp

index 9210beb..6e387f4 100644 (file)
@@ -1,3 +1,171 @@
+2017-11-04  Simon Fraser  <simon.fraser@apple.com>
+
+        Add a GraphicsContextImpl and use it for DispayList::Recorder
+        https://bugs.webkit.org/show_bug.cgi?id=179286
+
+        Reviewed by Sam Weinig.
+
+        Start moving towards a model when GraphicsContext has a pointer to an implementation
+        ("pimpl") by adding GraphicsContextImpl, and converting display list recording to
+        be an implementation of a GraphicsContextImpl.
+
+        No behavior change.
+
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * html/canvas/CanvasRenderingContext2D.cpp:
+        (WebCore::DisplayListDrawingContext::DisplayListDrawingContext):
+        * platform/graphics/GraphicsContext.cpp:
+        (WebCore::GraphicsContext::GraphicsContext):
+        (WebCore::GraphicsContext::save):
+        (WebCore::GraphicsContext::restore):
+        (WebCore::GraphicsContext::setStrokeThickness):
+        (WebCore::GraphicsContext::setStrokeStyle):
+        (WebCore::GraphicsContext::setStrokeColor):
+        (WebCore::GraphicsContext::setShadow):
+        (WebCore::GraphicsContext::setLegacyShadow):
+        (WebCore::GraphicsContext::clearShadow):
+        (WebCore::GraphicsContext::setFillColor):
+        (WebCore::GraphicsContext::setShadowsIgnoreTransforms):
+        (WebCore::GraphicsContext::setShouldAntialias):
+        (WebCore::GraphicsContext::setShouldSmoothFonts):
+        (WebCore::GraphicsContext::setShouldSubpixelQuantizeFonts):
+        (WebCore::GraphicsContext::setImageInterpolationQuality):
+        (WebCore::GraphicsContext::setStrokePattern):
+        (WebCore::GraphicsContext::setFillPattern):
+        (WebCore::GraphicsContext::setStrokeGradient):
+        (WebCore::GraphicsContext::setFillRule):
+        (WebCore::GraphicsContext::setFillGradient):
+        (WebCore::GraphicsContext::beginTransparencyLayer):
+        (WebCore::GraphicsContext::endTransparencyLayer):
+        (WebCore::GraphicsContext::drawGlyphs):
+        (WebCore::GraphicsContext::drawImage):
+        (WebCore::GraphicsContext::drawTiledImage):
+        (WebCore::GraphicsContext::setTextDrawingMode):
+        (WebCore::GraphicsContext::fillRect):
+        (WebCore::GraphicsContext::fillRoundedRect):
+        (WebCore::GraphicsContext::setAlpha):
+        (WebCore::GraphicsContext::setCompositeOperation):
+        (WebCore::GraphicsContext::setDrawLuminanceMask):
+        (WebCore::GraphicsContext::applyDeviceScaleFactor):
+        (WebCore::GraphicsContext::fillEllipse):
+        (WebCore::GraphicsContext::strokeEllipse):
+        * platform/graphics/GraphicsContext.h:
+        (WebCore::GraphicsContext::hasPlatformContext const):
+        (WebCore::GraphicsContext::paintingDisabled const):
+        (WebCore::GraphicsContext::setDisplayListRecorder): Deleted.
+        (WebCore::GraphicsContext::isRecording const): Deleted.
+        * platform/graphics/GraphicsContextImpl.cpp: Added.
+        (WebCore::GraphicsContextImpl::GraphicsContextImpl):
+        (WebCore::GraphicsContextImpl::~GraphicsContextImpl):
+        * platform/graphics/GraphicsContextImpl.h: Added.
+        (WebCore::GraphicsContextImpl::graphicsContext const):
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayerCA::recursiveCommitChanges):
+        * platform/graphics/cairo/GraphicsContextCairo.cpp:
+        (WebCore::GraphicsContext::getCTM const):
+        (WebCore::GraphicsContext::savePlatformState):
+        (WebCore::GraphicsContext::restorePlatformState):
+        (WebCore::GraphicsContext::drawRect):
+        (WebCore::GraphicsContext::drawNativeImage):
+        (WebCore::GraphicsContext::drawLine):
+        (WebCore::GraphicsContext::drawEllipse):
+        (WebCore::GraphicsContext::fillPath):
+        (WebCore::GraphicsContext::strokePath):
+        (WebCore::GraphicsContext::fillRect):
+        (WebCore::GraphicsContext::clip):
+        (WebCore::GraphicsContext::clipPath):
+        (WebCore::GraphicsContext::clipBounds const):
+        (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::setMiterLimit):
+        (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 const):
+        * 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::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 const):
+        (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 const):
+        (WebCore::GraphicsContext::roundToDevicePixels):
+        (WebCore::GraphicsContext::drawLinesForText):
+        (WebCore::GraphicsContext::setURLForRect):
+        (WebCore::GraphicsContext::setIsCALayerContext):
+        (WebCore::GraphicsContext::isCALayerContext const):
+        (WebCore::GraphicsContext::setIsAcceleratedContext):
+        (WebCore::GraphicsContext::isAcceleratedContext const):
+        (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):
+        (WebCore::GraphicsContext::setDestinationForRect):
+        (WebCore::GraphicsContext::addDestinationAtPoint):
+        * platform/graphics/cocoa/GraphicsContextCocoa.mm:
+        (WebCore::GraphicsContext::drawFocusRing):
+        * platform/graphics/displaylists/DisplayListRecorder.cpp:
+        (WebCore::DisplayList::Recorder::Recorder):
+        (WebCore::DisplayList::Recorder::updateItemExtent const):
+        (WebCore::DisplayList::Recorder::extentFromLocalBounds const):
+        * platform/graphics/displaylists/DisplayListRecorder.h:
+        (WebCore::DisplayList::Recorder::itemCount const):
+        * rendering/RenderTheme.cpp:
+        (WebCore::RenderTheme::paint):
+
 2017-11-04  Zalan Bujtas  <zalan@apple.com>
 
         [LayoutState cleanup] Move all LayoutState* classes to LayoutState.h/cpp
index 0099a33..038a0a5 100644 (file)
@@ -1505,6 +1505,7 @@ platform/graphics/GeometryUtilities.cpp
 platform/graphics/Gradient.cpp
 platform/graphics/GradientImage.cpp
 platform/graphics/GraphicsContext.cpp
+platform/graphics/GraphicsContextImpl.cpp
 platform/graphics/GraphicsLayer.cpp
 platform/graphics/GraphicsLayerTransform.cpp
 platform/graphics/GraphicsLayerUpdater.cpp
index 2aab26a..3a69b60 100644 (file)
                0C45342610CDBBFA00869157 /* JSWebGLUniformLocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebGLUniformLocation.h; sourceTree = "<group>"; };
                0E7058ED1BC5BC190045A507 /* SearchPopupMenuCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SearchPopupMenuCocoa.mm; sourceTree = "<group>"; };
                0E7058F31BC5CCD70045A507 /* SearchPopupMenuCocoa.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SearchPopupMenuCocoa.h; sourceTree = "<group>"; };
+               0F00123F1FAD87D600531D76 /* GraphicsContextImpl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GraphicsContextImpl.h; sourceTree = "<group>"; };
+               0F0012401FAD881000531D76 /* GraphicsContextImpl.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContextImpl.cpp; sourceTree = "<group>"; };
                0F03C0731884695E00A5F8CA /* SystemMemory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SystemMemory.h; sourceTree = "<group>"; };
                0F099D0617B968A100FF84B9 /* WebCoreTypedArrayController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebCoreTypedArrayController.cpp; sourceTree = "<group>"; };
                0F099D0717B968A100FF84B9 /* WebCoreTypedArrayController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreTypedArrayController.h; sourceTree = "<group>"; };
                                6E21C6BF1126338500A7BE02 /* GraphicsContext3D.cpp */,
                                49C7B9FB1042D3650009D447 /* GraphicsContext3D.h */,
                                7C330A011DF8FAC600D3395C /* GraphicsContext3DAttributes.h */,
+                               0F0012401FAD881000531D76 /* GraphicsContextImpl.cpp */,
+                               0F00123F1FAD87D600531D76 /* GraphicsContextImpl.h */,
                                0F580B090F12A2690051D689 /* GraphicsLayer.cpp */,
                                0F580B0A0F12A2690051D689 /* GraphicsLayer.h */,
                                0F580B0B0F12A2690051D689 /* GraphicsLayerClient.h */,
index 4a10ae1..296adf2 100644 (file)
@@ -89,11 +89,12 @@ struct DisplayListDrawingContext {
     WTF_MAKE_FAST_ALLOCATED;
 public:
     GraphicsContext context;
-    DisplayList::Recorder recorder;
     DisplayList::DisplayList displayList;
     
     DisplayListDrawingContext(const FloatRect& clip)
-        : recorder(context, displayList, clip, AffineTransform())
+        : context([&](GraphicsContext& context) {
+            return std::make_unique<DisplayList::Recorder>(context, displayList, clip, AffineTransform());
+        })
     {
     }
 };
index 436df54..643d404 100644 (file)
@@ -28,9 +28,9 @@
 
 #include "BidiResolver.h"
 #include "BitmapImage.h"
-#include "DisplayListRecorder.h"
 #include "FloatRoundedRect.h"
 #include "Gradient.h"
+#include "GraphicsContextImpl.h"
 #include "ImageBuffer.h"
 #include "IntRect.h"
 #include "RoundedRect.h"
@@ -336,6 +336,11 @@ GraphicsContext::GraphicsContext(PlatformGraphicsContext* platformGraphicsContex
     platformInit(platformGraphicsContext);
 }
 
+GraphicsContext::GraphicsContext(const GraphicsContextImplFactory& factoryFunction)
+    : m_impl(factoryFunction(*this))
+{
+}
+
 GraphicsContext::~GraphicsContext()
 {
     ASSERT(m_stack.isEmpty());
@@ -350,8 +355,8 @@ void GraphicsContext::save()
 
     m_stack.append(m_state);
 
-    if (isRecording()) {
-        m_displayListRecorder->save();
+    if (m_impl) {
+        m_impl->save();
         return;
     }
 
@@ -376,8 +381,8 @@ void GraphicsContext::restore()
     if (m_stack.isEmpty())
         m_stack.clear();
 
-    if (isRecording()) {
-        m_displayListRecorder->restore();
+    if (m_impl) {
+        m_impl->restore();
         return;
     }
 
@@ -407,8 +412,8 @@ void GraphicsContext::drawRaisedEllipse(const FloatRect& rect, const Color& elli
 void GraphicsContext::setStrokeThickness(float thickness)
 {
     m_state.strokeThickness = thickness;
-    if (isRecording()) {
-        m_displayListRecorder->updateState(m_state, GraphicsContextState::StrokeThicknessChange);
+    if (m_impl) {
+        m_impl->updateState(m_state, GraphicsContextState::StrokeThicknessChange);
         return;
     }
 
@@ -418,8 +423,8 @@ void GraphicsContext::setStrokeThickness(float thickness)
 void GraphicsContext::setStrokeStyle(StrokeStyle style)
 {
     m_state.strokeStyle = style;
-    if (isRecording()) {
-        m_displayListRecorder->updateState(m_state, GraphicsContextState::StrokeStyleChange);
+    if (m_impl) {
+        m_impl->updateState(m_state, GraphicsContextState::StrokeStyleChange);
         return;
     }
     setPlatformStrokeStyle(style);
@@ -430,8 +435,8 @@ void GraphicsContext::setStrokeColor(const Color& color)
     m_state.strokeColor = color;
     m_state.strokeGradient = nullptr;
     m_state.strokePattern = nullptr;
-    if (isRecording()) {
-        m_displayListRecorder->updateState(m_state, GraphicsContextState::StrokeColorChange);
+    if (m_impl) {
+        m_impl->updateState(m_state, GraphicsContextState::StrokeColorChange);
         return;
     }
     setPlatformStrokeColor(color);
@@ -445,8 +450,8 @@ void GraphicsContext::setShadow(const FloatSize& offset, float blur, const Color
 #if USE(CG)
     m_state.shadowsUseLegacyRadius = false;
 #endif
-    if (isRecording()) {
-        m_displayListRecorder->updateState(m_state, GraphicsContextState::ShadowChange);
+    if (m_impl) {
+        m_impl->updateState(m_state, GraphicsContextState::ShadowChange);
         return;
     }
     setPlatformShadow(offset, blur, color);
@@ -460,8 +465,8 @@ void GraphicsContext::setLegacyShadow(const FloatSize& offset, float blur, const
 #if USE(CG)
     m_state.shadowsUseLegacyRadius = true;
 #endif
-    if (isRecording()) {
-        m_displayListRecorder->updateState(m_state, GraphicsContextState::ShadowChange);
+    if (m_impl) {
+        m_impl->updateState(m_state, GraphicsContextState::ShadowChange);
         return;
     }
     setPlatformShadow(offset, blur, color);
@@ -476,8 +481,8 @@ void GraphicsContext::clearShadow()
     m_state.shadowsUseLegacyRadius = false;
 #endif
 
-    if (isRecording()) {
-        m_displayListRecorder->clearShadow();
+    if (m_impl) {
+        m_impl->clearShadow();
         return;
     }
     clearPlatformShadow();
@@ -516,8 +521,8 @@ void GraphicsContext::setFillColor(const Color& color)
     m_state.fillGradient = nullptr;
     m_state.fillPattern = nullptr;
 
-    if (isRecording()) {
-        m_displayListRecorder->updateState(m_state, GraphicsContextState::FillColorChange);
+    if (m_impl) {
+        m_impl->updateState(m_state, GraphicsContextState::FillColorChange);
         return;
     }
 
@@ -527,16 +532,16 @@ void GraphicsContext::setFillColor(const Color& color)
 void GraphicsContext::setShadowsIgnoreTransforms(bool shadowsIgnoreTransforms)
 {
     m_state.shadowsIgnoreTransforms = shadowsIgnoreTransforms;
-    if (isRecording())
-        m_displayListRecorder->updateState(m_state, GraphicsContextState::ShadowsIgnoreTransformsChange);
+    if (m_impl)
+        m_impl->updateState(m_state, GraphicsContextState::ShadowsIgnoreTransformsChange);
 }
 
 void GraphicsContext::setShouldAntialias(bool shouldAntialias)
 {
     m_state.shouldAntialias = shouldAntialias;
 
-    if (isRecording()) {
-        m_displayListRecorder->updateState(m_state, GraphicsContextState::ShouldAntialiasChange);
+    if (m_impl) {
+        m_impl->updateState(m_state, GraphicsContextState::ShouldAntialiasChange);
         return;
     }
 
@@ -547,8 +552,8 @@ void GraphicsContext::setShouldSmoothFonts(bool shouldSmoothFonts)
 {
     m_state.shouldSmoothFonts = shouldSmoothFonts;
     
-    if (isRecording()) {
-        m_displayListRecorder->updateState(m_state, GraphicsContextState::ShouldSmoothFontsChange);
+    if (m_impl) {
+        m_impl->updateState(m_state, GraphicsContextState::ShouldSmoothFontsChange);
         return;
     }
     
@@ -558,8 +563,8 @@ void GraphicsContext::setShouldSmoothFonts(bool shouldSmoothFonts)
 void GraphicsContext::setShouldSubpixelQuantizeFonts(bool shouldSubpixelQuantizeFonts)
 {
     m_state.shouldSubpixelQuantizeFonts = shouldSubpixelQuantizeFonts;
-    if (isRecording())
-        m_displayListRecorder->updateState(m_state, GraphicsContextState::ShouldSubpixelQuantizeFontsChange);
+    if (m_impl)
+        m_impl->updateState(m_state, GraphicsContextState::ShouldSubpixelQuantizeFontsChange);
 }
 
 void GraphicsContext::setImageInterpolationQuality(InterpolationQuality imageInterpolationQuality)
@@ -569,8 +574,8 @@ void GraphicsContext::setImageInterpolationQuality(InterpolationQuality imageInt
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->updateState(m_state, GraphicsContextState::ImageInterpolationQualityChange);
+    if (m_impl) {
+        m_impl->updateState(m_state, GraphicsContextState::ImageInterpolationQualityChange);
         return;
     }
 
@@ -581,45 +586,45 @@ void GraphicsContext::setStrokePattern(Ref<Pattern>&& pattern)
 {
     m_state.strokeGradient = nullptr;
     m_state.strokePattern = WTFMove(pattern);
-    if (isRecording())
-        m_displayListRecorder->updateState(m_state, GraphicsContextState::StrokePatternChange);
+    if (m_impl)
+        m_impl->updateState(m_state, GraphicsContextState::StrokePatternChange);
 }
 
 void GraphicsContext::setFillPattern(Ref<Pattern>&& pattern)
 {
     m_state.fillGradient = nullptr;
     m_state.fillPattern = WTFMove(pattern);
-    if (isRecording())
-        m_displayListRecorder->updateState(m_state, GraphicsContextState::FillPatternChange);
+    if (m_impl)
+        m_impl->updateState(m_state, GraphicsContextState::FillPatternChange);
 }
 
 void GraphicsContext::setStrokeGradient(Ref<Gradient>&& gradient)
 {
     m_state.strokeGradient = WTFMove(gradient);
     m_state.strokePattern = nullptr;
-    if (isRecording())
-        m_displayListRecorder->updateState(m_state, GraphicsContextState::StrokeGradientChange);
+    if (m_impl)
+        m_impl->updateState(m_state, GraphicsContextState::StrokeGradientChange);
 }
 
 void GraphicsContext::setFillRule(WindRule fillRule)
 {
     m_state.fillRule = fillRule;
-    if (isRecording())
-        m_displayListRecorder->updateState(m_state, GraphicsContextState::FillRuleChange);
+    if (m_impl)
+        m_impl->updateState(m_state, GraphicsContextState::FillRuleChange);
 }
 
 void GraphicsContext::setFillGradient(Ref<Gradient>&& gradient)
 {
     m_state.fillGradient = WTFMove(gradient);
     m_state.fillPattern = nullptr;
-    if (isRecording())
-        m_displayListRecorder->updateState(m_state, GraphicsContextState::FillGradientChange); // FIXME: also fill pattern?
+    if (m_impl)
+        m_impl->updateState(m_state, GraphicsContextState::FillGradientChange); // FIXME: also fill pattern?
 }
 
 void GraphicsContext::beginTransparencyLayer(float opacity)
 {
-    if (isRecording()) {
-        m_displayListRecorder->beginTransparencyLayer(opacity);
+    if (m_impl) {
+        m_impl->beginTransparencyLayer(opacity);
         return;
     }
     beginPlatformTransparencyLayer(opacity);
@@ -628,8 +633,8 @@ void GraphicsContext::beginTransparencyLayer(float opacity)
 
 void GraphicsContext::endTransparencyLayer()
 {
-    if (isRecording()) {
-        m_displayListRecorder->endTransparencyLayer();
+    if (m_impl) {
+        m_impl->endTransparencyLayer();
         return;
     }
     endPlatformTransparencyLayer();
@@ -651,8 +656,8 @@ void GraphicsContext::drawGlyphs(const FontCascade& fontCascade, const Font& fon
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->drawGlyphs(font, buffer, from, numGlyphs, point, fontCascade.fontDescription().fontSmoothing());
+    if (m_impl) {
+        m_impl->drawGlyphs(font, buffer, from, numGlyphs, point, fontCascade.fontDescription().fontSmoothing());
         return;
     }
 
@@ -722,8 +727,8 @@ ImageDrawResult GraphicsContext::drawImage(Image& image, const FloatRect& destin
     if (paintingDisabled())
         return ImageDrawResult::DidNothing;
 
-    if (isRecording()) {
-        m_displayListRecorder->drawImage(image, destination, source, imagePaintingOptions);
+    if (m_impl) {
+        m_impl->drawImage(image, destination, source, imagePaintingOptions);
         return ImageDrawResult::DidRecord;
     }
 
@@ -736,8 +741,8 @@ ImageDrawResult GraphicsContext::drawTiledImage(Image& image, const FloatRect& d
     if (paintingDisabled())
         return ImageDrawResult::DidNothing;
 
-    if (isRecording()) {
-        m_displayListRecorder->drawTiledImage(image, destination, source, tileSize, spacing, imagePaintingOptions);
+    if (m_impl) {
+        m_impl->drawTiledImage(image, destination, source, tileSize, spacing, imagePaintingOptions);
         return ImageDrawResult::DidRecord;
     }
 
@@ -751,8 +756,8 @@ ImageDrawResult GraphicsContext::drawTiledImage(Image& image, const FloatRect& d
     if (paintingDisabled())
         return ImageDrawResult::DidNothing;
 
-    if (isRecording()) {
-        m_displayListRecorder->drawTiledImage(image, destination, source, tileScaleFactor, hRule, vRule, imagePaintingOptions);
+    if (m_impl) {
+        m_impl->drawTiledImage(image, destination, source, tileScaleFactor, hRule, vRule, imagePaintingOptions);
         return ImageDrawResult::DidRecord;
     }
 
@@ -848,8 +853,8 @@ void GraphicsContext::setTextDrawingMode(TextDrawingModeFlags mode)
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->updateState(m_state, GraphicsContextState::TextDrawingModeChange);
+    if (m_impl) {
+        m_impl->updateState(m_state, GraphicsContextState::TextDrawingModeChange);
         return;
     }
     setPlatformTextDrawingMode(mode);
@@ -860,8 +865,8 @@ void GraphicsContext::fillRect(const FloatRect& rect, Gradient& gradient)
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->fillRect(rect, gradient);
+    if (m_impl) {
+        m_impl->fillRect(rect, gradient);
         return;
     }
 
@@ -873,8 +878,8 @@ void GraphicsContext::fillRect(const FloatRect& rect, const Color& color, Compos
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->fillRect(rect, color, op, blendMode);
+    if (m_impl) {
+        m_impl->fillRect(rect, color, op, blendMode);
         return;
     }
 
@@ -889,8 +894,8 @@ void GraphicsContext::fillRoundedRect(const FloatRoundedRect& rect, const Color&
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->fillRoundedRect(rect, color, blendMode);
+    if (m_impl) {
+        m_impl->fillRoundedRect(rect, color, blendMode);
         return;
     }
 
@@ -932,8 +937,8 @@ void GraphicsContext::fillRectWithRoundedHole(const IntRect& rect, const FloatRo
 void GraphicsContext::setAlpha(float alpha)
 {
     m_state.alpha = alpha;
-    if (isRecording()) {
-        m_displayListRecorder->updateState(m_state, GraphicsContextState::AlphaChange);
+    if (m_impl) {
+        m_impl->updateState(m_state, GraphicsContextState::AlphaChange);
         return;
     }
     setPlatformAlpha(alpha);
@@ -943,8 +948,8 @@ void GraphicsContext::setCompositeOperation(CompositeOperator compositeOperation
 {
     m_state.compositeOperator = compositeOperation;
     m_state.blendMode = blendMode;
-    if (isRecording()) {
-        m_displayListRecorder->updateState(m_state, GraphicsContextState::CompositeOperationChange);
+    if (m_impl) {
+        m_impl->updateState(m_state, GraphicsContextState::CompositeOperationChange);
         return;
     }
     setPlatformCompositeOperation(compositeOperation, blendMode);
@@ -953,8 +958,8 @@ void GraphicsContext::setCompositeOperation(CompositeOperator compositeOperation
 void GraphicsContext::setDrawLuminanceMask(bool drawLuminanceMask)
 {
     m_state.drawLuminanceMask = drawLuminanceMask;
-    if (isRecording())
-        m_displayListRecorder->updateState(m_state, GraphicsContextState::DrawLuminanceMaskChange);
+    if (m_impl)
+        m_impl->updateState(m_state, GraphicsContextState::DrawLuminanceMaskChange);
 }
 
 #if !USE(CG) && !USE(DIRECT2D)
@@ -1022,8 +1027,8 @@ void GraphicsContext::applyDeviceScaleFactor(float deviceScaleFactor)
 {
     scale(deviceScaleFactor);
 
-    if (isRecording()) {
-        m_displayListRecorder->applyDeviceScaleFactor(deviceScaleFactor);
+    if (m_impl) {
+        m_impl->applyDeviceScaleFactor(deviceScaleFactor);
         return;
     }
 
@@ -1045,8 +1050,8 @@ FloatSize GraphicsContext::scaleFactorForDrawing(const FloatRect& destRect, cons
 
 void GraphicsContext::fillEllipse(const FloatRect& ellipse)
 {
-    if (isRecording()) {
-        m_displayListRecorder->fillEllipse(ellipse);
+    if (m_impl) {
+        m_impl->fillEllipse(ellipse);
         return;
     }
 
@@ -1055,8 +1060,8 @@ void GraphicsContext::fillEllipse(const FloatRect& ellipse)
 
 void GraphicsContext::strokeEllipse(const FloatRect& ellipse)
 {
-    if (isRecording()) {
-        m_displayListRecorder->strokeEllipse(ellipse);
+    if (m_impl) {
+        m_impl->strokeEllipse(ellipse);
         return;
     }
 
index 2373d03..913c463 100644 (file)
@@ -80,6 +80,7 @@ const int cMisspellingLinePatternGapWidth = 1;
 class AffineTransform;
 class FloatRoundedRect;
 class Gradient;
+class GraphicsContextImpl;
 class GraphicsContextPlatformPrivate;
 class ImageBuffer;
 class IntRect;
@@ -251,6 +252,10 @@ class GraphicsContext {
     WTF_MAKE_NONCOPYABLE(GraphicsContext); WTF_MAKE_FAST_ALLOCATED;
 public:
     WEBCORE_EXPORT GraphicsContext(PlatformGraphicsContext*);
+    
+    using GraphicsContextImplFactory = WTF::Function<std::unique_ptr<GraphicsContextImpl>(GraphicsContext&)>;
+    WEBCORE_EXPORT GraphicsContext(const GraphicsContextImplFactory&);
+
     GraphicsContext() = default;
     WEBCORE_EXPORT ~GraphicsContext();
     
@@ -260,14 +265,12 @@ public:
     };
     GraphicsContext(NonPaintingReasons);
 
+    bool hasPlatformContext() const { return m_data; }
     WEBCORE_EXPORT PlatformGraphicsContext* platformContext() const;
 
-    bool paintingDisabled() const { return !m_data && !isRecording(); }
+    bool paintingDisabled() const { return !m_data && !m_impl; }
     bool updatingControlTints() const { return m_nonPaintingReasons == NonPaintingReasons::UpdatingControlTints; }
 
-    void setDisplayListRecorder(DisplayList::Recorder* recorder) { m_displayListRecorder = recorder; }
-    bool isRecording() const { return m_displayListRecorder; }
-
     void setStrokeThickness(float);
     float strokeThickness() const { return m_state.strokeThickness; }
 
@@ -640,7 +643,7 @@ private:
     Vector<FloatPoint> centerLineAndCutOffCorners(bool isVerticalLine, float cornerWidth, FloatPoint point1, FloatPoint point2) const;
 
     GraphicsContextPlatformPrivate* m_data { nullptr };
-    DisplayList::Recorder* m_displayListRecorder { nullptr };
+    std::unique_ptr<GraphicsContextImpl> m_impl;
 
     GraphicsContextState m_state;
     Vector<GraphicsContextState, 1> m_stack;
diff --git a/Source/WebCore/platform/graphics/GraphicsContextImpl.cpp b/Source/WebCore/platform/graphics/GraphicsContextImpl.cpp
new file mode 100644 (file)
index 0000000..116ecbe
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+#include "GraphicsContextImpl.h"
+
+namespace WebCore {
+
+GraphicsContextImpl::GraphicsContextImpl(GraphicsContext& context, const FloatRect&, const AffineTransform&)
+    : m_graphicsContext(context)
+{
+}
+
+GraphicsContextImpl::~GraphicsContextImpl()
+{
+}
+
+} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/GraphicsContextImpl.h b/Source/WebCore/platform/graphics/GraphicsContextImpl.h
new file mode 100644 (file)
index 0000000..c3b400c
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#pragma once
+
+#include "GraphicsContext.h"
+
+namespace WebCore {
+
+class GraphicsContextImpl {
+    WTF_MAKE_NONCOPYABLE(GraphicsContextImpl);
+public:
+    GraphicsContextImpl(GraphicsContext&, const FloatRect& initialClip, const AffineTransform&);
+    virtual ~GraphicsContextImpl();
+
+    GraphicsContext& graphicsContext() const { return m_graphicsContext; }
+
+    virtual void updateState(const GraphicsContextState&, GraphicsContextState::StateChangeFlags) = 0;
+    virtual void clearShadow() = 0;
+
+    virtual void setLineCap(LineCap) = 0;
+    virtual void setLineDash(const DashArray&, float dashOffset) = 0;
+    virtual void setLineJoin(LineJoin) = 0;
+    virtual void setMiterLimit(float) = 0;
+
+    virtual void fillRect(const FloatRect&) = 0;
+    virtual void fillRect(const FloatRect&, const Color&) = 0;
+    virtual void fillRect(const FloatRect&, Gradient&) = 0;
+    virtual void fillRect(const FloatRect&, const Color&, CompositeOperator, BlendMode) = 0;
+    virtual void fillRoundedRect(const FloatRoundedRect&, const Color&, BlendMode) = 0;
+    virtual void fillRectWithRoundedHole(const FloatRect&, const FloatRoundedRect& roundedHoleRect, const Color&) = 0;
+    virtual void fillPath(const Path&) = 0;
+    virtual void fillEllipse(const FloatRect&) = 0;
+    virtual void strokeRect(const FloatRect&, float lineWidth) = 0;
+    virtual void strokePath(const Path&) = 0;
+    virtual void strokeEllipse(const FloatRect&) = 0;
+    virtual void clearRect(const FloatRect&) = 0;
+
+#if USE(CG)
+    virtual void applyStrokePattern() = 0;
+    virtual void applyFillPattern() = 0;
+#endif
+
+    virtual void drawGlyphs(const Font&, const GlyphBuffer&, unsigned from, unsigned numGlyphs, const FloatPoint& anchorPoint, FontSmoothingMode) = 0;
+
+    virtual void drawImage(Image&, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions&) = 0;
+    virtual void drawTiledImage(Image&, const FloatRect& destination, const FloatPoint& source, const FloatSize& tileSize, const FloatSize& spacing, const ImagePaintingOptions&) = 0;
+    virtual void drawTiledImage(Image&, const FloatRect& destination, const FloatRect& source, const FloatSize& tileScaleFactor, Image::TileRule hRule, Image::TileRule vRule, const ImagePaintingOptions&) = 0;
+#if USE(CG) || USE(CAIRO)
+    virtual void drawNativeImage(const NativeImagePtr&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator, BlendMode, ImageOrientation) = 0;
+#endif
+    virtual void drawPattern(Image&, const FloatRect& destRect, const FloatRect& srcRect, const AffineTransform&, const FloatPoint& phase, const FloatSize& spacing, CompositeOperator, BlendMode = BlendModeNormal) = 0;
+
+    virtual void drawRect(const FloatRect&, float borderThickness) = 0;
+    virtual void drawLine(const FloatPoint&, const FloatPoint&) = 0;
+    virtual void drawLinesForText(const FloatPoint&, const DashArray& widths, bool printing, bool doubleLines, float strokeThickness) = 0;
+    virtual void drawLineForDocumentMarker(const FloatPoint&, float width, GraphicsContext::DocumentMarkerLineStyle) = 0;
+    virtual void drawEllipse(const FloatRect&) = 0;
+    virtual void drawPath(const Path&) = 0;
+
+    virtual void drawFocusRing(const Path&, float width, float offset, const Color&) = 0;
+    virtual void drawFocusRing(const Vector<FloatRect>&, float width, float offset, const Color&) = 0;
+
+    virtual void save() = 0;
+    virtual void restore() = 0;
+
+    virtual void translate(float x, float y) = 0;
+    virtual void rotate(float angleInRadians) = 0;
+    virtual void scale(const FloatSize&) = 0;
+    virtual void concatCTM(const AffineTransform&) = 0;
+
+    virtual void beginTransparencyLayer(float opacity) = 0;
+    virtual void endTransparencyLayer() = 0;
+
+    virtual void clip(const FloatRect&) = 0;
+    virtual void clipOut(const FloatRect&) = 0;
+    virtual void clipOut(const Path&) = 0;
+    virtual void clipPath(const Path&, WindRule) = 0;
+    
+    virtual void applyDeviceScaleFactor(float) = 0;
+
+private:
+    friend class GraphicsContext;
+    GraphicsContext& m_graphicsContext;
+};
+
+} // namespace WebCore
index ea93cc5..6e15f04 100644 (file)
@@ -1550,9 +1550,9 @@ void GraphicsLayerCA::recursiveCommitChanges(const CommitState& commitState, con
         
         FloatRect initialClip(boundsOrigin(), size());
 
-        GraphicsContext context;
-        // The Recorder is large, so heap-allocate.
-        std::unique_ptr<DisplayList::Recorder> recorder = std::make_unique<DisplayList::Recorder>(context, *m_displayList, initialClip, AffineTransform());
+        GraphicsContext context([&](GraphicsContext& context) {
+            return std::make_unique<DisplayList::Recorder>(context, *m_displayList, initialClip, AffineTransform());
+        });
         paintGraphicsLayerContents(context, FloatRect(FloatPoint(), size()));
     }
 }
index e36a647..ae71a6f 100644 (file)
@@ -195,7 +195,7 @@ AffineTransform GraphicsContext::getCTM(IncludeDeviceScale) const
     if (paintingDisabled())
         return AffineTransform();
 
-    if (isRecording()) {
+    if (m_impl) {
         WTFLogAlways("GraphicsContext::getCTM() is not yet compatible with recording contexts.");
         return AffineTransform();
     }
@@ -213,14 +213,14 @@ PlatformContextCairo* GraphicsContext::platformContext() const
 
 void GraphicsContext::savePlatformState()
 {
-    ASSERT(!isRecording());
+    ASSERT(hasPlatformContext());
     platformContext()->save();
     m_data->save();
 }
 
 void GraphicsContext::restorePlatformState()
 {
-    ASSERT(!isRecording());
+    ASSERT(hasPlatformContext());
     platformContext()->restore();
     m_data->restore();
 
@@ -236,8 +236,8 @@ void GraphicsContext::drawRect(const FloatRect& rect, float borderThickness)
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->drawRect(rect, borderThickness);
+    if (m_impl) {
+        m_impl->drawRect(rect, borderThickness);
         return;
     }
 
@@ -265,8 +265,8 @@ void GraphicsContext::drawNativeImage(const NativeImagePtr& image, const FloatSi
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->drawNativeImage(image, imageSize, destRect, srcRect, op, blendMode, orientation);
+    if (m_impl) {
+        m_impl->drawNativeImage(image, imageSize, destRect, srcRect, op, blendMode, orientation);
         return;
     }
 
@@ -305,8 +305,8 @@ void GraphicsContext::drawLine(const FloatPoint& point1, const FloatPoint& point
     if (strokeStyle() == NoStroke)
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->drawLine(point1, point2);
+    if (m_impl) {
+        m_impl->drawLine(point1, point2);
         return;
     }
 
@@ -374,8 +374,8 @@ void GraphicsContext::drawEllipse(const FloatRect& rect)
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->drawEllipse(rect);
+    if (m_impl) {
+        m_impl->drawEllipse(rect);
         return;
     }
 
@@ -406,8 +406,8 @@ void GraphicsContext::fillPath(const Path& path)
     if (paintingDisabled() || path.isEmpty())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->fillPath(path);
+    if (m_impl) {
+        m_impl->fillPath(path);
         return;
     }
 
@@ -421,8 +421,8 @@ void GraphicsContext::strokePath(const Path& path)
     if (paintingDisabled() || path.isEmpty())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->strokePath(path);
+    if (m_impl) {
+        m_impl->strokePath(path);
         return;
     }
 
@@ -436,8 +436,8 @@ void GraphicsContext::fillRect(const FloatRect& rect)
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->fillRect(rect);
+    if (m_impl) {
+        m_impl->fillRect(rect);
         return;
     }
 
@@ -451,8 +451,8 @@ void GraphicsContext::fillRect(const FloatRect& rect, const Color& color)
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->fillRect(rect, color);
+    if (m_impl) {
+        m_impl->fillRect(rect, color);
         return;
     }
 
@@ -467,8 +467,8 @@ void GraphicsContext::clip(const FloatRect& rect)
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->clip(rect);
+    if (m_impl) {
+        m_impl->clip(rect);
         return;
     }
 
@@ -494,8 +494,8 @@ void GraphicsContext::clipPath(const Path& path, WindRule clipRule)
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->clipPath(path, clipRule);
+    if (m_impl) {
+        m_impl->clipPath(path, clipRule);
         return;
     }
 
@@ -527,7 +527,7 @@ IntRect GraphicsContext::clipBounds() const
     if (paintingDisabled())
         return IntRect();
 
-    if (isRecording()) {
+    if (m_impl) {
         WTFLogAlways("Getting the clip bounds not yet supported with display lists");
         return IntRect(-2048, -2048, 4096, 4096); // FIXME: display lists.
     }
@@ -635,8 +635,8 @@ void GraphicsContext::drawLinesForText(const FloatPoint& point, const DashArray&
     if (widths.size() <= 0)
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->drawLinesForText(point, widths, printing, doubleUnderlines, strokeThickness());
+    if (m_impl) {
+        m_impl->drawLinesForText(point, widths, printing, doubleUnderlines, strokeThickness());
         return;
     }
 
@@ -700,7 +700,7 @@ FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& frect, RoundingM
     if (paintingDisabled())
         return frect;
 
-    if (isRecording()) {
+    if (m_impl) {
         WTFLogAlways("GraphicsContext::roundToDevicePixels() is not yet compatible with recording contexts.");
         return frect;
     }
@@ -745,8 +745,8 @@ void GraphicsContext::translate(float x, float y)
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->translate(x, y);
+    if (m_impl) {
+        m_impl->translate(x, y);
         return;
     }
 
@@ -772,7 +772,7 @@ void GraphicsContext::setPlatformStrokeThickness(float strokeThickness)
     if (paintingDisabled())
         return;
 
-    ASSERT(!isRecording());
+    ASSERT(hasPlatformContext());
 
     cairo_set_line_width(platformContext()->cr(), strokeThickness);
 }
@@ -785,7 +785,7 @@ void GraphicsContext::setPlatformStrokeStyle(StrokeStyle strokeStyle)
     if (paintingDisabled())
         return;
 
-    ASSERT(!isRecording());
+    ASSERT(hasPlatformContext());
 
     switch (strokeStyle) {
     case NoStroke:
@@ -816,8 +816,8 @@ void GraphicsContext::concatCTM(const AffineTransform& transform)
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->concatCTM(transform);
+    if (m_impl) {
+        m_impl->concatCTM(transform);
         return;
     }
 
@@ -832,7 +832,7 @@ void GraphicsContext::setCTM(const AffineTransform& transform)
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
+    if (m_impl) {
         WTFLogAlways("GraphicsContext::setCTM() is not compatible with recording contexts.");
         return;
     }
@@ -874,7 +874,7 @@ void GraphicsContext::beginPlatformTransparencyLayer(float opacity)
     if (paintingDisabled())
         return;
 
-    ASSERT(!isRecording());
+    ASSERT(hasPlatformContext());
 
     cairo_t* cr = platformContext()->cr();
     cairo_push_group(cr);
@@ -886,7 +886,7 @@ void GraphicsContext::endPlatformTransparencyLayer()
     if (paintingDisabled())
         return;
 
-    ASSERT(!isRecording());
+    ASSERT(hasPlatformContext());
 
     cairo_t* cr = platformContext()->cr();
 
@@ -905,8 +905,8 @@ void GraphicsContext::clearRect(const FloatRect& rect)
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->clearRect(rect);
+    if (m_impl) {
+        m_impl->clearRect(rect);
         return;
     }
 
@@ -924,8 +924,8 @@ void GraphicsContext::strokeRect(const FloatRect& rect, float width)
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->strokeRect(rect, width);
+    if (m_impl) {
+        m_impl->strokeRect(rect, width);
         return;
     }
 
@@ -942,8 +942,8 @@ void GraphicsContext::setLineCap(LineCap lineCap)
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->setLineCap(lineCap);
+    if (m_impl) {
+        m_impl->setLineCap(lineCap);
         return;
     }
 
@@ -976,8 +976,8 @@ void GraphicsContext::setLineDash(const DashArray& dashes, float dashOffset)
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->setLineDash(dashes, dashOffset);
+    if (m_impl) {
+        m_impl->setLineDash(dashes, dashOffset);
         return;
     }
 
@@ -992,8 +992,8 @@ void GraphicsContext::setLineJoin(LineJoin lineJoin)
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->setLineJoin(lineJoin);
+    if (m_impl) {
+        m_impl->setLineJoin(lineJoin);
         return;
     }
 
@@ -1017,9 +1017,9 @@ void GraphicsContext::setMiterLimit(float miter)
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
+    if (m_impl) {
         // Maybe this should be part of the state.
-        m_displayListRecorder->setMiterLimit(miter);
+        m_impl->setMiterLimit(miter);
         return;
     }
 
@@ -1049,8 +1049,8 @@ void GraphicsContext::clipOut(const Path& path)
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->clipOut(path);
+    if (m_impl) {
+        m_impl->clipOut(path);
         return;
     }
 
@@ -1071,8 +1071,8 @@ void GraphicsContext::rotate(float radians)
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->rotate(radians);
+    if (m_impl) {
+        m_impl->rotate(radians);
         return;
     }
 
@@ -1085,8 +1085,8 @@ void GraphicsContext::scale(const FloatSize& size)
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->scale(size);
+    if (m_impl) {
+        m_impl->scale(size);
         return;
     }
 
@@ -1099,8 +1099,8 @@ void GraphicsContext::clipOut(const FloatRect& r)
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->clipOut(r);
+    if (m_impl) {
+        m_impl->clipOut(r);
         return;
     }
 
@@ -1120,7 +1120,7 @@ void GraphicsContext::platformFillRoundedRect(const FloatRoundedRect& rect, cons
     if (paintingDisabled())
         return;
 
-    ASSERT(!isRecording());
+    ASSERT(hasPlatformContext());
 
     if (hasShadow())
         platformContext()->shadowBlur().drawRectShadow(*this, rect);
@@ -1140,8 +1140,8 @@ void GraphicsContext::fillRectWithRoundedHole(const FloatRect& rect, const Float
     if (paintingDisabled() || !color.isValid())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->fillRectWithRoundedHole(rect, roundedHoleRect, color);
+    if (m_impl) {
+        m_impl->fillRectWithRoundedHole(rect, roundedHoleRect, color);
         return;
     }
 
@@ -1167,8 +1167,8 @@ void GraphicsContext::drawPattern(Image& image, const FloatRect& destRect, const
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->drawPattern(image, destRect, tileRect, patternTransform, phase, spacing, op, blendMode);
+    if (m_impl) {
+        m_impl->drawPattern(image, destRect, tileRect, patternTransform, phase, spacing, op, blendMode);
         return;
     }
 
@@ -1185,7 +1185,7 @@ void GraphicsContext::setPlatformShouldAntialias(bool enable)
     if (paintingDisabled())
         return;
 
-    ASSERT(!isRecording());
+    ASSERT(hasPlatformContext());
 
     // When true, use the default Cairo backend antialias mode (usually this
     // enables standard 'grayscale' antialiasing); false to explicitly disable
@@ -1195,14 +1195,14 @@ void GraphicsContext::setPlatformShouldAntialias(bool enable)
 
 void GraphicsContext::setPlatformImageInterpolationQuality(InterpolationQuality quality)
 {
-    ASSERT(!isRecording());
+    ASSERT(hasPlatformContext());
 
     platformContext()->setImageInterpolationQuality(quality);
 }
 
 bool GraphicsContext::isAcceleratedContext() const
 {
-    if (isRecording())
+    if (!hasPlatformContext())
         return false;
 
     return cairo_surface_get_type(cairo_get_target(platformContext()->cr())) == CAIRO_SURFACE_TYPE_GL;
index 7cfafce..fc291e2 100644 (file)
@@ -165,7 +165,7 @@ CGContextRef GraphicsContext::platformContext() const
 void GraphicsContext::savePlatformState()
 {
     ASSERT(!paintingDisabled());
-    ASSERT(!isRecording());
+    ASSERT(hasPlatformContext());
 
     // 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).
@@ -176,7 +176,7 @@ void GraphicsContext::savePlatformState()
 void GraphicsContext::restorePlatformState()
 {
     ASSERT(!paintingDisabled());
-    ASSERT(!isRecording());
+    ASSERT(hasPlatformContext());
 
     // 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).
@@ -190,8 +190,8 @@ void GraphicsContext::drawNativeImage(const RetainPtr<CGImageRef>& image, const
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->drawNativeImage(image, imageSize, destRect, srcRect, op, blendMode, orientation);
+    if (m_impl) {
+        m_impl->drawNativeImage(image, imageSize, destRect, srcRect, op, blendMode, orientation);
         return;
     }
 
@@ -325,8 +325,8 @@ void GraphicsContext::drawPattern(Image& image, const FloatRect& destRect, const
     if (paintingDisabled() || !patternTransform.isInvertible())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->drawPattern(image, destRect, tileRect, patternTransform, phase, spacing, op, blendMode);
+    if (m_impl) {
+        m_impl->drawPattern(image, destRect, tileRect, patternTransform, phase, spacing, op, blendMode);
         return;
     }
 
@@ -430,8 +430,8 @@ void GraphicsContext::drawRect(const FloatRect& rect, float borderThickness)
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->drawRect(rect, borderThickness);
+    if (m_impl) {
+        m_impl->drawRect(rect, borderThickness);
         return;
     }
 
@@ -468,8 +468,8 @@ void GraphicsContext::drawLine(const FloatPoint& point1, const FloatPoint& point
     if (strokeStyle() == NoStroke)
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->drawLine(point1, point2);
+    if (m_impl) {
+        m_impl->drawLine(point1, point2);
         return;
     }
 
@@ -533,8 +533,8 @@ void GraphicsContext::drawEllipse(const FloatRect& rect)
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->drawEllipse(rect);
+    if (m_impl) {
+        m_impl->drawEllipse(rect);
         return;
     }
 
@@ -548,8 +548,8 @@ void GraphicsContext::applyStrokePattern()
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->applyStrokePattern();
+    if (m_impl) {
+        m_impl->applyStrokePattern();
         return;
     }
 
@@ -572,8 +572,8 @@ void GraphicsContext::applyFillPattern()
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->applyFillPattern();
+    if (m_impl) {
+        m_impl->applyFillPattern();
         return;
     }
 
@@ -623,8 +623,8 @@ void GraphicsContext::drawPath(const Path& path)
     if (paintingDisabled() || path.isEmpty())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->drawPath(path);
+    if (m_impl) {
+        m_impl->drawPath(path);
         return;
     }
 
@@ -657,8 +657,8 @@ void GraphicsContext::fillPath(const Path& path)
     if (paintingDisabled() || path.isEmpty())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->fillPath(path);
+    if (m_impl) {
+        m_impl->fillPath(path);
         return;
     }
 
@@ -720,8 +720,8 @@ void GraphicsContext::strokePath(const Path& path)
     if (paintingDisabled() || path.isEmpty())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->strokePath(path);
+    if (m_impl) {
+        m_impl->strokePath(path);
         return;
     }
 
@@ -782,8 +782,8 @@ void GraphicsContext::fillRect(const FloatRect& rect)
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->fillRect(rect);
+    if (m_impl) {
+        m_impl->fillRect(rect);
         return;
     }
 
@@ -835,8 +835,8 @@ void GraphicsContext::fillRect(const FloatRect& rect, const Color& color)
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->fillRect(rect, color);
+    if (m_impl) {
+        m_impl->fillRect(rect, color);
         return;
     }
 
@@ -870,7 +870,7 @@ void GraphicsContext::platformFillRoundedRect(const FloatRoundedRect& rect, cons
     if (paintingDisabled())
         return;
     
-    ASSERT(!isRecording());
+    ASSERT(hasPlatformContext());
 
     CGContextRef context = platformContext();
     Color oldFillColor = fillColor();
@@ -913,8 +913,8 @@ void GraphicsContext::fillRectWithRoundedHole(const FloatRect& rect, const Float
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->fillRectWithRoundedHole(rect, roundedHoleRect, color);
+    if (m_impl) {
+        m_impl->fillRectWithRoundedHole(rect, roundedHoleRect, color);
         return;
     }
 
@@ -959,8 +959,8 @@ void GraphicsContext::clip(const FloatRect& rect)
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->clip(rect);
+    if (m_impl) {
+        m_impl->clip(rect);
         return;
     }
 
@@ -973,8 +973,8 @@ void GraphicsContext::clipOut(const FloatRect& rect)
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->clipOut(rect);
+    if (m_impl) {
+        m_impl->clipOut(rect);
         return;
     }
 
@@ -995,8 +995,8 @@ void GraphicsContext::clipOut(const Path& path)
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->clipOut(path);
+    if (m_impl) {
+        m_impl->clipOut(path);
         return;
     }
 
@@ -1012,8 +1012,8 @@ void GraphicsContext::clipPath(const Path& path, WindRule clipRule)
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->clipPath(path, clipRule);
+    if (m_impl) {
+        m_impl->clipPath(path, clipRule);
         return;
     }
 
@@ -1038,7 +1038,7 @@ IntRect GraphicsContext::clipBounds() const
     if (paintingDisabled())
         return IntRect();
 
-    if (isRecording()) {
+    if (m_impl) {
         WTFLogAlways("Getting the clip bounds not yet supported with display lists");
         return IntRect(-2048, -2048, 4096, 4096); // FIXME: display lists.
     }
@@ -1051,7 +1051,7 @@ void GraphicsContext::beginPlatformTransparencyLayer(float opacity)
     if (paintingDisabled())
         return;
 
-    ASSERT(!isRecording());
+    ASSERT(hasPlatformContext());
 
     save();
 
@@ -1066,7 +1066,7 @@ void GraphicsContext::endPlatformTransparencyLayer()
     if (paintingDisabled())
         return;
 
-    ASSERT(!isRecording());
+    ASSERT(hasPlatformContext());
 
     CGContextRef context = platformContext();
     CGContextEndTransparencyLayer(context);
@@ -1112,7 +1112,7 @@ void GraphicsContext::setPlatformShadow(const FloatSize& offset, float blur, con
     if (paintingDisabled())
         return;
 
-    ASSERT(!isRecording());
+    ASSERT(hasPlatformContext());
     
     // FIXME: we could avoid the shadow setup cost when we know we'll render the shadow ourselves.
 
@@ -1164,9 +1164,9 @@ void GraphicsContext::setMiterLimit(float limit)
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
+    if (m_impl) {
         // Maybe this should be part of the state.
-        m_displayListRecorder->setMiterLimit(limit);
+        m_impl->setMiterLimit(limit);
         return;
     }
 
@@ -1178,8 +1178,8 @@ void GraphicsContext::clearRect(const FloatRect& r)
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->clearRect(r);
+    if (m_impl) {
+        m_impl->clearRect(r);
         return;
     }
 
@@ -1191,8 +1191,8 @@ void GraphicsContext::strokeRect(const FloatRect& rect, float lineWidth)
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->strokeRect(rect, lineWidth);
+    if (m_impl) {
+        m_impl->strokeRect(rect, lineWidth);
         return;
     }
 
@@ -1261,8 +1261,8 @@ void GraphicsContext::setLineCap(LineCap cap)
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->setLineCap(cap);
+    if (m_impl) {
+        m_impl->setLineCap(cap);
         return;
     }
 
@@ -1284,8 +1284,8 @@ void GraphicsContext::setLineDash(const DashArray& dashes, float dashOffset)
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->setLineDash(dashes, dashOffset);
+    if (m_impl) {
+        m_impl->setLineDash(dashes, dashOffset);
         return;
     }
 
@@ -1304,8 +1304,8 @@ void GraphicsContext::setLineJoin(LineJoin join)
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->setLineJoin(join);
+    if (m_impl) {
+        m_impl->setLineJoin(join);
         return;
     }
 
@@ -1332,8 +1332,8 @@ void GraphicsContext::scale(const FloatSize& size)
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->scale(size);
+    if (m_impl) {
+        m_impl->scale(size);
         return;
     }
 
@@ -1347,8 +1347,8 @@ void GraphicsContext::rotate(float angle)
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->rotate(angle);
+    if (m_impl) {
+        m_impl->rotate(angle);
         return;
     }
 
@@ -1362,8 +1362,8 @@ void GraphicsContext::translate(float x, float y)
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->translate(x, y);
+    if (m_impl) {
+        m_impl->translate(x, y);
         return;
     }
 
@@ -1377,8 +1377,8 @@ void GraphicsContext::concatCTM(const AffineTransform& transform)
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->concatCTM(transform);
+    if (m_impl) {
+        m_impl->concatCTM(transform);
         return;
     }
 
@@ -1392,7 +1392,7 @@ void GraphicsContext::setCTM(const AffineTransform& transform)
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
+    if (m_impl) {
         WTFLogAlways("GraphicsContext::setCTM() is not compatible with recording contexts.");
         return;
     }
@@ -1407,7 +1407,7 @@ AffineTransform GraphicsContext::getCTM(IncludeDeviceScale includeScale) const
     if (paintingDisabled())
         return AffineTransform();
 
-    if (isRecording()) {
+    if (m_impl) {
         WTFLogAlways("GraphicsContext::getCTM() is not yet compatible with recording contexts.");
         return AffineTransform();
     }
@@ -1426,7 +1426,7 @@ FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& rect, RoundingMo
     if (paintingDisabled())
         return rect;
 
-    if (isRecording()) {
+    if (m_impl) {
         WTFLogAlways("GraphicsContext::roundToDevicePixels() is not yet compatible with recording contexts.");
         return rect;
     }
@@ -1489,8 +1489,8 @@ void GraphicsContext::drawLinesForText(const FloatPoint& point, const DashArray&
     if (!widths.size())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->drawLinesForText(point, widths, printing, doubleLines, strokeThickness());
+    if (m_impl) {
+        m_impl->drawLinesForText(point, widths, printing, doubleLines, strokeThickness());
         return;
     }
 
@@ -1550,7 +1550,7 @@ void GraphicsContext::setURLForRect(const URL& link, const FloatRect& destRect)
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
+    if (m_impl) {
         WTFLogAlways("GraphicsContext::setURLForRect() is not yet compatible with recording contexts.");
         return; // FIXME for display lists.
     }
@@ -1603,7 +1603,7 @@ void GraphicsContext::setIsCALayerContext(bool isLayerContext)
         return;
 
     // FIXME
-    if (isRecording())
+    if (m_impl)
         return;
 
     if (isLayerContext)
@@ -1618,7 +1618,7 @@ bool GraphicsContext::isCALayerContext() const
         return false;
 
     // FIXME
-    if (isRecording())
+    if (m_impl)
         return false;
 
     return m_data->m_contextFlags & IsLayerCGContext;
@@ -1630,7 +1630,7 @@ void GraphicsContext::setIsAcceleratedContext(bool isAccelerated)
         return;
 
     // FIXME
-    if (isRecording())
+    if (m_impl)
         return;
 
     if (isAccelerated)
@@ -1645,7 +1645,7 @@ bool GraphicsContext::isAcceleratedContext() const
         return false;
 
     // FIXME
-    if (isRecording())
+    if (m_impl)
         return false;
 
     return m_data->m_contextFlags & IsAcceleratedCGContext;
@@ -1656,7 +1656,7 @@ void GraphicsContext::setPlatformTextDrawingMode(TextDrawingModeFlags mode)
     if (paintingDisabled())
         return;
 
-    ASSERT(!isRecording());
+    ASSERT(hasPlatformContext());
 
     CGContextRef context = platformContext();
     switch (mode) {
@@ -1679,7 +1679,7 @@ void GraphicsContext::setPlatformStrokeColor(const Color& color)
     if (paintingDisabled())
         return;
 
-    ASSERT(!isRecording());
+    ASSERT(hasPlatformContext());
 
     setCGStrokeColor(platformContext(), color);
 }
@@ -1689,7 +1689,7 @@ void GraphicsContext::setPlatformStrokeThickness(float thickness)
     if (paintingDisabled())
         return;
 
-    ASSERT(!isRecording());
+    ASSERT(hasPlatformContext());
 
     CGContextSetLineWidth(platformContext(), std::max(thickness, 0.f));
 }
@@ -1699,7 +1699,7 @@ void GraphicsContext::setPlatformFillColor(const Color& color)
     if (paintingDisabled())
         return;
 
-    ASSERT(!isRecording());
+    ASSERT(hasPlatformContext());
 
     setCGFillColor(platformContext(), color);
 }
@@ -1709,7 +1709,7 @@ void GraphicsContext::setPlatformShouldAntialias(bool enable)
     if (paintingDisabled())
         return;
 
-    ASSERT(!isRecording());
+    ASSERT(hasPlatformContext());
 
     CGContextSetShouldAntialias(platformContext(), enable);
 }
@@ -1719,7 +1719,7 @@ void GraphicsContext::setPlatformShouldSmoothFonts(bool enable)
     if (paintingDisabled())
         return;
 
-    ASSERT(!isRecording());
+    ASSERT(hasPlatformContext());
 
     CGContextSetShouldSmoothFonts(platformContext(), enable);
 }
@@ -1729,7 +1729,7 @@ void GraphicsContext::setPlatformAlpha(float alpha)
     if (paintingDisabled())
         return;
 
-    ASSERT(!isRecording());
+    ASSERT(hasPlatformContext());
 
     CGContextSetAlpha(platformContext(), alpha);
 }
@@ -1739,7 +1739,7 @@ void GraphicsContext::setPlatformCompositeOperation(CompositeOperator mode, Blen
     if (paintingDisabled())
         return;
 
-    ASSERT(!isRecording());
+    ASSERT(hasPlatformContext());
 
     CGBlendMode target = kCGBlendModeNormal;
     if (blendMode != BlendModeNormal) {
@@ -1852,7 +1852,7 @@ void GraphicsContext::platformApplyDeviceScaleFactor(float deviceScaleFactor)
     if (paintingDisabled())
         return;
 
-    ASSERT(!isRecording());
+    ASSERT(hasPlatformContext());
 
     // 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,
@@ -1865,7 +1865,7 @@ void GraphicsContext::platformFillEllipse(const FloatRect& ellipse)
     if (paintingDisabled())
         return;
 
-    ASSERT(!isRecording());
+    ASSERT(hasPlatformContext());
 
     // CGContextFillEllipseInRect only supports solid colors.
     if (m_state.fillGradient || m_state.fillPattern) {
@@ -1882,7 +1882,7 @@ void GraphicsContext::platformStrokeEllipse(const FloatRect& ellipse)
     if (paintingDisabled())
         return;
 
-    ASSERT(!isRecording());
+    ASSERT(hasPlatformContext());
 
     // CGContextStrokeEllipseInRect only supports solid colors.
     if (m_state.strokeGradient || m_state.strokePattern) {
@@ -1904,6 +1904,8 @@ void GraphicsContext::setDestinationForRect(const String& name, const FloatRect&
     if (paintingDisabled())
         return;
 
+    ASSERT(hasPlatformContext());
+
     CGContextRef context = platformContext();
 
     FloatRect rect = destRect;
@@ -1918,6 +1920,8 @@ void GraphicsContext::addDestinationAtPoint(const String& name, const FloatPoint
     if (paintingDisabled())
         return;
 
+    ASSERT(hasPlatformContext());
+
     CGContextRef context = platformContext();
 
     CGPoint transformedPoint = CGPointApplyAffineTransform(position, CGContextGetCTM(context));
index 1c0a760..33c4800 100644 (file)
@@ -119,8 +119,8 @@ void GraphicsContext::drawFocusRing(const Path& path, float width, float offset,
     if (paintingDisabled() || path.isNull())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->drawFocusRing(path, width, offset, color);
+    if (m_impl) {
+        m_impl->drawFocusRing(path, width, offset, color);
         return;
     }
 
@@ -139,7 +139,7 @@ void GraphicsContext::drawFocusRing(const Path& path, double timeOffset, bool& n
     if (paintingDisabled() || path.isNull())
         return;
 
-    if (isRecording()) // FIXME: implement animated focus ring drawing.
+    if (m_impl) // FIXME: implement animated focus ring drawing.
         return;
 
     needsRedraw = drawFocusRingToContextAtTime(platformContext(), path.platformPath(), timeOffset);
@@ -150,7 +150,7 @@ void GraphicsContext::drawFocusRing(const Vector<FloatRect>& rects, double timeO
     if (paintingDisabled())
         return;
 
-    if (isRecording()) // FIXME: implement animated focus ring drawing.
+    if (m_impl) // FIXME: implement animated focus ring drawing.
         return;
 
     RetainPtr<CGMutablePathRef> focusRingPath = adoptCF(CGPathCreateMutable());
@@ -167,8 +167,8 @@ void GraphicsContext::drawFocusRing(const Vector<FloatRect>& rects, float width,
     if (paintingDisabled())
         return;
 
-    if (isRecording()) {
-        m_displayListRecorder->drawFocusRing(rects, width, offset, color);
+    if (m_impl) {
+        m_impl->drawFocusRing(rects, width, offset, color);
         return;
     }
 
index 37bd41e..d8761be 100644 (file)
@@ -37,11 +37,10 @@ namespace WebCore {
 namespace DisplayList {
 
 Recorder::Recorder(GraphicsContext& context, DisplayList& displayList, const FloatRect& initialClip, const AffineTransform& baseCTM)
-    : m_graphicsContext(context)
+    : GraphicsContextImpl(context, initialClip, baseCTM)
     , m_displayList(displayList)
 {
     LOG_WITH_STREAM(DisplayLists, stream << "\nRecording with clip " << initialClip);
-    m_graphicsContext.setDisplayListRecorder(this);
     m_stateStack.append(ContextState(baseCTM, initialClip));
 }
 
@@ -374,7 +373,7 @@ Item& Recorder::appendItem(Ref<Item>&& item)
 
 void Recorder::updateItemExtent(DrawingItem& item) const
 {
-    if (std::optional<FloatRect> rect = item.localBounds(m_graphicsContext))
+    if (std::optional<FloatRect> rect = item.localBounds(graphicsContext()))
         item.setExtent(extentFromLocalBounds(rect.value()));
 }
 
@@ -396,7 +395,7 @@ FloatRect Recorder::extentFromLocalBounds(const FloatRect& rect) const
     FloatSize shadowOffset;
     float shadowRadius;
     Color shadowColor;
-    if (m_graphicsContext.getShadow(shadowOffset, shadowRadius, shadowColor)) {
+    if (graphicsContext().getShadow(shadowOffset, shadowRadius, shadowColor)) {
         FloatRect shadowExtent= bounds;
         shadowExtent.move(shadowOffset);
         shadowExtent.inflate(shadowPaintingExtent(shadowRadius));
index 6a29023..f9e49a5 100644 (file)
@@ -26,7 +26,7 @@
 #pragma once
 
 #include "DisplayList.h"
-#include "GraphicsContext.h" // For InterpolationQuality.
+#include "GraphicsContextImpl.h"
 #include "Image.h" // For Image::TileRule.
 #include "TextFlags.h"
 #include <wtf/Noncopyable.h>
@@ -47,79 +47,79 @@ namespace DisplayList {
 
 class DrawingItem;
 
-class Recorder {
+class Recorder : public GraphicsContextImpl {
     WTF_MAKE_NONCOPYABLE(Recorder);
 public:
     Recorder(GraphicsContext&, DisplayList&, const FloatRect& initialClip, const AffineTransform&);
-    ~Recorder();
-
-    void updateState(const GraphicsContextState&, GraphicsContextState::StateChangeFlags);
-    void clearShadow();
-
-    void setLineCap(LineCap);
-    void setLineDash(const DashArray&, float dashOffset);
-    void setLineJoin(LineJoin);
-    void setMiterLimit(float);
-
-    void fillRect(const FloatRect&);
-    void fillRect(const FloatRect&, const Color&);
-    void fillRect(const FloatRect&, Gradient&);
-    void fillRect(const FloatRect&, const Color&, CompositeOperator, BlendMode);
-    void fillRoundedRect(const FloatRoundedRect&, const Color&, BlendMode);
-    void fillRectWithRoundedHole(const FloatRect&, const FloatRoundedRect& roundedHoleRect, const Color&);
-    void fillPath(const Path&);
-    void fillEllipse(const FloatRect&);
-    void strokeRect(const FloatRect&, float lineWidth);
-    void strokePath(const Path&);
-    void strokeEllipse(const FloatRect&);
-    void clearRect(const FloatRect&);
+    virtual ~Recorder();
+
+    size_t itemCount() const { return m_displayList.itemCount(); }
+
+private:
+    void updateState(const GraphicsContextState&, GraphicsContextState::StateChangeFlags) override;
+    void clearShadow() override;
+
+    void setLineCap(LineCap) override;
+    void setLineDash(const DashArray&, float dashOffset) override;
+    void setLineJoin(LineJoin) override;
+    void setMiterLimit(float) override;
+
+    void fillRect(const FloatRect&) override;
+    void fillRect(const FloatRect&, const Color&) override;
+    void fillRect(const FloatRect&, Gradient&) override;
+    void fillRect(const FloatRect&, const Color&, CompositeOperator, BlendMode) override;
+    void fillRoundedRect(const FloatRoundedRect&, const Color&, BlendMode) override;
+    void fillRectWithRoundedHole(const FloatRect&, const FloatRoundedRect& roundedHoleRect, const Color&) override;
+    void fillPath(const Path&) override;
+    void fillEllipse(const FloatRect&) override;
+    void strokeRect(const FloatRect&, float lineWidth) override;
+    void strokePath(const Path&) override;
+    void strokeEllipse(const FloatRect&) override;
+    void clearRect(const FloatRect&) override;
 
 #if USE(CG)
-    void applyStrokePattern();
-    void applyFillPattern();
+    void applyStrokePattern() override;
+    void applyFillPattern() override;
 #endif
 
-    void drawGlyphs(const Font&, const GlyphBuffer&, unsigned from, unsigned numGlyphs, const FloatPoint& anchorPoint, FontSmoothingMode);
+    void drawGlyphs(const Font&, const GlyphBuffer&, unsigned from, unsigned numGlyphs, const FloatPoint& anchorPoint, FontSmoothingMode) override;
 
-    void drawImage(Image&, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions&);
-    void drawTiledImage(Image&, const FloatRect& destination, const FloatPoint& source, const FloatSize& tileSize, const FloatSize& spacing, const ImagePaintingOptions&);
-    void drawTiledImage(Image&, const FloatRect& destination, const FloatRect& source, const FloatSize& tileScaleFactor, Image::TileRule hRule, Image::TileRule vRule, const ImagePaintingOptions&);
+    void drawImage(Image&, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions&) override;
+    void drawTiledImage(Image&, const FloatRect& destination, const FloatPoint& source, const FloatSize& tileSize, const FloatSize& spacing, const ImagePaintingOptions&) override;
+    void drawTiledImage(Image&, const FloatRect& destination, const FloatRect& source, const FloatSize& tileScaleFactor, Image::TileRule hRule, Image::TileRule vRule, const ImagePaintingOptions&) override;
 #if USE(CG) || USE(CAIRO)
-    void drawNativeImage(const NativeImagePtr&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator, BlendMode, ImageOrientation);
+    void drawNativeImage(const NativeImagePtr&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator, BlendMode, ImageOrientation) override;
 #endif
-    void drawPattern(Image&, const FloatRect& destRect, const FloatRect& srcRect, const AffineTransform&, const FloatPoint& phase, const FloatSize& spacing, CompositeOperator, BlendMode = BlendModeNormal);
+    void drawPattern(Image&, const FloatRect& destRect, const FloatRect& srcRect, const AffineTransform&, const FloatPoint& phase, const FloatSize& spacing, CompositeOperator, BlendMode = BlendModeNormal) override;
 
-    void drawRect(const FloatRect&, float borderThickness);
-    void drawLine(const FloatPoint&, const FloatPoint&);
-    void drawLinesForText(const FloatPoint&, const DashArray& widths, bool printing, bool doubleLines, float strokeThickness);
-    void drawLineForDocumentMarker(const FloatPoint&, float width, GraphicsContext::DocumentMarkerLineStyle);
-    void drawEllipse(const FloatRect&);
-    void drawPath(const Path&);
+    void drawRect(const FloatRect&, float borderThickness) override;
+    void drawLine(const FloatPoint&, const FloatPoint&) override;
+    void drawLinesForText(const FloatPoint&, const DashArray& widths, bool printing, bool doubleLines, float strokeThickness) override;
+    void drawLineForDocumentMarker(const FloatPoint&, float width, GraphicsContext::DocumentMarkerLineStyle) override;
+    void drawEllipse(const FloatRect&) override;
+    void drawPath(const Path&) override;
 
-    void drawFocusRing(const Path&, float width, float offset, const Color&);
-    void drawFocusRing(const Vector<FloatRect>&, float width, float offset, const Color&);
+    void drawFocusRing(const Path&, float width, float offset, const Color&) override;
+    void drawFocusRing(const Vector<FloatRect>&, float width, float offset, const Color&) override;
 
-    void save();
-    void restore();
+    void save() override;
+    void restore() override;
 
-    void translate(float x, float y);
-    void rotate(float angleInRadians);
-    void scale(const FloatSize&);
-    void concatCTM(const AffineTransform&);
+    void translate(float x, float y) override;
+    void rotate(float angleInRadians) override;
+    void scale(const FloatSize&) override;
+    void concatCTM(const AffineTransform&) override;
 
-    void beginTransparencyLayer(float opacity);
-    void endTransparencyLayer();
+    void beginTransparencyLayer(float opacity) override;
+    void endTransparencyLayer() override;
 
-    void clip(const FloatRect&);
-    void clipOut(const FloatRect&);
-    void clipOut(const Path&);
-    void clipPath(const Path&, WindRule);
+    void clip(const FloatRect&) override;
+    void clipOut(const FloatRect&) override;
+    void clipOut(const Path&) override;
+    void clipPath(const Path&, WindRule) override;
     
-    void applyDeviceScaleFactor(float);
+    void applyDeviceScaleFactor(float) override;
 
-    size_t itemCount() const { return m_displayList.itemCount(); }
-
-private:
     Item& appendItem(Ref<Item>&&);
     void willAppendItem(const Item&);
 
@@ -161,7 +161,6 @@ private:
     const ContextState& currentState() const;
     ContextState& currentState();
 
-    GraphicsContext& m_graphicsContext;
     DisplayList& m_displayList;
 
     Vector<ContextState, 32> m_stateStack;
index 968dcd9..afbfea0 100644 (file)
@@ -29,6 +29,7 @@
 #if USE(CG)
 
 #include "AffineTransform.h"
+#include "GraphicsContextImpl.h"
 #include "GraphicsContextPlatformPrivateCG.h"
 #include "Path.h"
 
index db7c8f7..978e95c 100644 (file)
@@ -283,7 +283,7 @@ bool RenderTheme::paint(const RenderBox& box, ControlStates& controlStates, cons
     if (paintInfo.context().paintingDisabled())
         return false;
 
-    if (UNLIKELY(paintInfo.context().isRecording()))
+    if (UNLIKELY(!paintInfo.context().hasPlatformContext()))
         return false;
 
     ControlPart part = box.style().appearance();