Diff
Modified: trunk/Source/WebCore/ChangeLog (227593 => 227594)
--- trunk/Source/WebCore/ChangeLog 2018-01-25 07:14:56 UTC (rev 227593)
+++ trunk/Source/WebCore/ChangeLog 2018-01-25 07:18:24 UTC (rev 227594)
@@ -1,3 +1,137 @@
+2018-01-24 Zan Dobersek <zdober...@igalia.com>
+
+ [Cairo] Use GraphicsContextImplCairo for ImageBuffer context
+ https://bugs.webkit.org/show_bug.cgi?id=181977
+
+ Reviewed by Carlos Garcia Campos.
+
+ Enhance the GraphicsContextImpl interface to the point of enabling the
+ Cairo-based implementation to be used for GraphicsContext construction
+ in ImageBufferCairo.cpp.
+
+ In order to enable GraphicsContextImpl implementations to properly
+ manage PlatformGraphicsContext objects, the hasPlatformContext() and
+ platformContext() methods are added. Cairo implementation returns true
+ in the first method, and returns pointer to the PlatformContextCairo
+ object in the second. The DisplayList::Recorder, due to its recording
+ nature, doesn't manage such an object, so it returns false and nullptr,
+ respectively.
+
+ GraphicsContextImpl also gains the setCTM(), getCTM(), clipBounds() and
+ roundToDevicePixels() methods, corresponding to the GraphicsContext
+ methods that now invoke these new methods on any existing m_impl object.
+ GraphicsContextImplCairo implementations mimic the existing behavior in
+ the Cairo-specific GraphicsContext methods, but DisplayList::Recorder
+ implementations remain no-op, logging the invocation but doing nothing
+ otherwise.
+
+ drawImage() and drawTiledImage() methods on the GraphicsContextImpl
+ interface are changed to return the ImageDrawResult value, corresponding
+ to what's been done in the method. In DisplayList::Recorder, the methods
+ return ImageDrawResult::DidRecord, while in GraphicsContextImplCairo the
+ methods return the return result of Image::draw() or Image::drawTiled()
+ call.
+
+ To make the protected Image::draw() and Image::drawTiled() methods
+ accessible, invocations of those are packed into static drawImageImpl()
+ and drawTiledImageImpl() functions on the GraphicsContextImpl class.
+ This makes it possible to simply declare GraphicsContextImpl class as a
+ friend class of Image, and not every specific GraphicsContextImpl
+ derivation. Implementations of these functions mirror behavior of the
+ drawImage() and drawTiledImage() methods on the GraphicsContext class,
+ when an m_impl object isn't present, constructing a scope-tied
+ InterpolationQualityMaintainer object and invoking the relevant Image
+ method.
+
+ To make immediate use of the new GraphicsContextImplCairo functionality,
+ the GraphicsContext construction in Cairo-specific ImageBuffer
+ implementation now uses a factory function that returns a new
+ GraphicsContextImplCairo object through which the given
+ PlatformContextCairo is used for painting.
+
+ No new tests -- no change in functionality.
+
+ * platform/graphics/GraphicsContext.cpp:
+ (WebCore::GraphicsContext::hasPlatformContext const):
+ (WebCore::GraphicsContext::drawImage):
+ (WebCore::GraphicsContext::drawTiledImage):
+ * platform/graphics/GraphicsContext.h:
+ (WebCore::GraphicsContext::hasPlatformContext const): Deleted.
+ * platform/graphics/GraphicsContextImpl.cpp:
+ (WebCore::GraphicsContextImpl::drawImageImpl):
+ (WebCore::GraphicsContextImpl::drawTiledImageImpl):
+ * platform/graphics/GraphicsContextImpl.h:
+ * platform/graphics/Image.h:
+ * platform/graphics/cairo/GraphicsContextCairo.cpp:
+ (WebCore::GraphicsContext::getCTM const):
+ (WebCore::GraphicsContext::platformContext const):
+ (WebCore::GraphicsContext::clipBounds const):
+ (WebCore::GraphicsContext::roundToDevicePixels):
+ (WebCore::GraphicsContext::setCTM):
+ * platform/graphics/cairo/GraphicsContextImplCairo.cpp:
+ (WebCore::m_private):
+ (WebCore::GraphicsContextImplCairo::~GraphicsContextImplCairo):
+ (WebCore::GraphicsContextImplCairo::hasPlatformContext const):
+ (WebCore::GraphicsContextImplCairo::platformContext const):
+ (WebCore::GraphicsContextImplCairo::updateState):
+ (WebCore::GraphicsContextImplCairo::setLineCap):
+ (WebCore::GraphicsContextImplCairo::setLineDash):
+ (WebCore::GraphicsContextImplCairo::setLineJoin):
+ (WebCore::GraphicsContextImplCairo::setMiterLimit):
+ (WebCore::GraphicsContextImplCairo::fillRect):
+ (WebCore::GraphicsContextImplCairo::fillRoundedRect):
+ (WebCore::GraphicsContextImplCairo::fillRectWithRoundedHole):
+ (WebCore::GraphicsContextImplCairo::fillPath):
+ (WebCore::GraphicsContextImplCairo::fillEllipse):
+ (WebCore::GraphicsContextImplCairo::strokeRect):
+ (WebCore::GraphicsContextImplCairo::strokePath):
+ (WebCore::GraphicsContextImplCairo::strokeEllipse):
+ (WebCore::GraphicsContextImplCairo::clearRect):
+ (WebCore::GraphicsContextImplCairo::drawGlyphs):
+ (WebCore::GraphicsContextImplCairo::drawImage):
+ (WebCore::GraphicsContextImplCairo::drawTiledImage):
+ (WebCore::GraphicsContextImplCairo::drawNativeImage):
+ (WebCore::GraphicsContextImplCairo::drawPattern):
+ (WebCore::GraphicsContextImplCairo::drawRect):
+ (WebCore::GraphicsContextImplCairo::drawLine):
+ (WebCore::GraphicsContextImplCairo::drawLinesForText):
+ (WebCore::GraphicsContextImplCairo::drawLineForDocumentMarker):
+ (WebCore::GraphicsContextImplCairo::drawEllipse):
+ (WebCore::GraphicsContextImplCairo::drawFocusRing):
+ (WebCore::GraphicsContextImplCairo::save):
+ (WebCore::GraphicsContextImplCairo::restore):
+ (WebCore::GraphicsContextImplCairo::translate):
+ (WebCore::GraphicsContextImplCairo::rotate):
+ (WebCore::GraphicsContextImplCairo::scale):
+ (WebCore::GraphicsContextImplCairo::concatCTM):
+ (WebCore::GraphicsContextImplCairo::setCTM):
+ (WebCore::GraphicsContextImplCairo::getCTM):
+ (WebCore::GraphicsContextImplCairo::beginTransparencyLayer):
+ (WebCore::GraphicsContextImplCairo::endTransparencyLayer):
+ (WebCore::GraphicsContextImplCairo::clip):
+ (WebCore::GraphicsContextImplCairo::clipOut):
+ (WebCore::GraphicsContextImplCairo::clipPath):
+ (WebCore::GraphicsContextImplCairo::clipBounds):
+ (WebCore::GraphicsContextImplCairo::roundToDevicePixels):
+ (WebCore::m_platformContext): Deleted.
+ * platform/graphics/cairo/GraphicsContextImplCairo.h:
+ * platform/graphics/cairo/ImageBufferCairo.cpp:
+ (WebCore::ImageBuffer::ImageBuffer):
+ * platform/graphics/cg/GraphicsContextCG.cpp:
+ (WebCore::GraphicsContext::clipBounds const):
+ (WebCore::GraphicsContext::setCTM):
+ (WebCore::GraphicsContext::getCTM const):
+ (WebCore::GraphicsContext::roundToDevicePixels):
+ * platform/graphics/displaylists/DisplayListRecorder.cpp:
+ (WebCore::DisplayList::Recorder::drawImage):
+ (WebCore::DisplayList::Recorder::drawTiledImage):
+ (WebCore::DisplayList::Recorder::drawNativeImage):
+ (WebCore::DisplayList::Recorder::setCTM):
+ (WebCore::DisplayList::Recorder::getCTM):
+ (WebCore::DisplayList::Recorder::clipBounds):
+ (WebCore::DisplayList::Recorder::roundToDevicePixels):
+ * platform/graphics/displaylists/DisplayListRecorder.h:
+
2018-01-24 Christopher Reid <chris.r...@sony.com>
Linker error in ShareableBitmapCairo.cpp undefined reference to WebCore::Cairo::ShadowState::ShadowState
Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp (227593 => 227594)
--- trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp 2018-01-25 07:14:56 UTC (rev 227593)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp 2018-01-25 07:18:24 UTC (rev 227594)
@@ -348,6 +348,13 @@
platformDestroy();
}
+bool GraphicsContext::hasPlatformContext() const
+{
+ if (m_impl)
+ return m_impl->hasPlatformContext();
+ return !!m_data;
+}
+
void GraphicsContext::save()
{
if (paintingDisabled())
@@ -709,10 +716,8 @@
if (paintingDisabled())
return ImageDrawResult::DidNothing;
- if (m_impl) {
- m_impl->drawImage(image, destination, source, imagePaintingOptions);
- return ImageDrawResult::DidRecord;
- }
+ if (m_impl)
+ return m_impl->drawImage(image, destination, source, imagePaintingOptions);
InterpolationQualityMaintainer interpolationQualityForThisScope(*this, imagePaintingOptions.m_interpolationQuality);
return image.draw(*this, destination, source, imagePaintingOptions.m_compositeOperator, imagePaintingOptions.m_blendMode, imagePaintingOptions.m_decodingMode, imagePaintingOptions.m_orientationDescription);
@@ -723,10 +728,8 @@
if (paintingDisabled())
return ImageDrawResult::DidNothing;
- if (m_impl) {
- m_impl->drawTiledImage(image, destination, source, tileSize, spacing, imagePaintingOptions);
- return ImageDrawResult::DidRecord;
- }
+ if (m_impl)
+ return m_impl->drawTiledImage(image, destination, source, tileSize, spacing, imagePaintingOptions);
InterpolationQualityMaintainer interpolationQualityForThisScope(*this, imagePaintingOptions.m_interpolationQuality);
return image.drawTiled(*this, destination, source, tileSize, spacing, imagePaintingOptions.m_compositeOperator, imagePaintingOptions.m_blendMode, imagePaintingOptions.m_decodingMode);
@@ -738,10 +741,8 @@
if (paintingDisabled())
return ImageDrawResult::DidNothing;
- if (m_impl) {
- m_impl->drawTiledImage(image, destination, source, tileScaleFactor, hRule, vRule, imagePaintingOptions);
- return ImageDrawResult::DidRecord;
- }
+ if (m_impl)
+ return m_impl->drawTiledImage(image, destination, source, tileScaleFactor, hRule, vRule, imagePaintingOptions);
if (hRule == Image::StretchTile && vRule == Image::StretchTile) {
// Just do a scale.
Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.h (227593 => 227594)
--- trunk/Source/WebCore/platform/graphics/GraphicsContext.h 2018-01-25 07:14:56 UTC (rev 227593)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.h 2018-01-25 07:18:24 UTC (rev 227594)
@@ -265,7 +265,7 @@
};
GraphicsContext(NonPaintingReasons);
- bool hasPlatformContext() const { return m_data; }
+ bool hasPlatformContext() const;
WEBCORE_EXPORT PlatformGraphicsContext* platformContext() const;
bool paintingDisabled() const { return !m_data && !m_impl; }
Modified: trunk/Source/WebCore/platform/graphics/GraphicsContextImpl.cpp (227593 => 227594)
--- trunk/Source/WebCore/platform/graphics/GraphicsContextImpl.cpp 2018-01-25 07:14:56 UTC (rev 227593)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContextImpl.cpp 2018-01-25 07:18:24 UTC (rev 227594)
@@ -37,4 +37,27 @@
{
}
+ImageDrawResult GraphicsContextImpl::drawImageImpl(GraphicsContext& context, Image& image, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions& imagePaintingOptions)
+{
+ InterpolationQualityMaintainer interpolationQualityForThisScope(context, imagePaintingOptions.m_interpolationQuality);
+ return image.draw(context, destination, source, imagePaintingOptions.m_compositeOperator, imagePaintingOptions.m_blendMode, imagePaintingOptions.m_decodingMode, imagePaintingOptions.m_orientationDescription);
+}
+
+ImageDrawResult GraphicsContextImpl::drawTiledImageImpl(GraphicsContext& context, Image& image, const FloatRect& destination, const FloatPoint& source, const FloatSize& tileSize, const FloatSize& spacing, const ImagePaintingOptions& imagePaintingOptions)
+{
+ InterpolationQualityMaintainer interpolationQualityForThisScope(context, imagePaintingOptions.m_interpolationQuality);
+ return image.drawTiled(context, destination, source, tileSize, spacing, imagePaintingOptions.m_compositeOperator, imagePaintingOptions.m_blendMode, imagePaintingOptions.m_decodingMode);
+}
+
+ImageDrawResult GraphicsContextImpl::drawTiledImageImpl(GraphicsContext& context, Image& image, const FloatRect& destination, const FloatRect& source, const FloatSize& tileScaleFactor, Image::TileRule hRule, Image::TileRule vRule, const ImagePaintingOptions& imagePaintingOptions)
+{
+ if (hRule == Image::StretchTile && vRule == Image::StretchTile) {
+ // Just do a scale.
+ return drawImageImpl(context, image, destination, source, imagePaintingOptions);
+ }
+
+ InterpolationQualityMaintainer interpolationQualityForThisScope(context, imagePaintingOptions.m_interpolationQuality);
+ return image.drawTiled(context, destination, source, tileScaleFactor, hRule, vRule, imagePaintingOptions.m_compositeOperator);
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/GraphicsContextImpl.h (227593 => 227594)
--- trunk/Source/WebCore/platform/graphics/GraphicsContextImpl.h 2018-01-25 07:14:56 UTC (rev 227593)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContextImpl.h 2018-01-25 07:18:24 UTC (rev 227594)
@@ -37,6 +37,9 @@
GraphicsContext& graphicsContext() const { return m_graphicsContext; }
+ virtual bool hasPlatformContext() const = 0;
+ virtual PlatformGraphicsContext* platformContext() const = 0;
+
virtual void updateState(const GraphicsContextState&, GraphicsContextState::StateChangeFlags) = 0;
virtual void clearShadow() = 0;
@@ -65,9 +68,9 @@
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;
+ virtual ImageDrawResult drawImage(Image&, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions&) = 0;
+ virtual ImageDrawResult drawTiledImage(Image&, const FloatRect& destination, const FloatPoint& source, const FloatSize& tileSize, const FloatSize& spacing, const ImagePaintingOptions&) = 0;
+ virtual ImageDrawResult 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
@@ -90,6 +93,8 @@
virtual void rotate(float angleInRadians) = 0;
virtual void scale(const FloatSize&) = 0;
virtual void concatCTM(const AffineTransform&) = 0;
+ virtual void setCTM(const AffineTransform&) = 0;
+ virtual AffineTransform getCTM(GraphicsContext::IncludeDeviceScale) = 0;
virtual void beginTransparencyLayer(float opacity) = 0;
virtual void endTransparencyLayer() = 0;
@@ -98,9 +103,17 @@
virtual void clipOut(const FloatRect&) = 0;
virtual void clipOut(const Path&) = 0;
virtual void clipPath(const Path&, WindRule) = 0;
+ virtual IntRect clipBounds() = 0;
virtual void applyDeviceScaleFactor(float) = 0;
+ virtual FloatRect roundToDevicePixels(const FloatRect&, GraphicsContext::RoundingMode) = 0;
+
+protected:
+ static ImageDrawResult drawImageImpl(GraphicsContext&, Image&, const FloatRect&, const FloatRect&, const ImagePaintingOptions&);
+ static ImageDrawResult drawTiledImageImpl(GraphicsContext&, Image&, const FloatRect&, const FloatPoint&, const FloatSize&, const FloatSize&, const ImagePaintingOptions&);
+ static ImageDrawResult drawTiledImageImpl(GraphicsContext&, Image&, const FloatRect&, const FloatRect&, const FloatSize&, Image::TileRule, Image::TileRule, const ImagePaintingOptions&);
+
private:
friend class GraphicsContext;
GraphicsContext& m_graphicsContext;
Modified: trunk/Source/WebCore/platform/graphics/Image.h (227593 => 227594)
--- trunk/Source/WebCore/platform/graphics/Image.h 2018-01-25 07:14:56 UTC (rev 227593)
+++ trunk/Source/WebCore/platform/graphics/Image.h 2018-01-25 07:18:24 UTC (rev 227594)
@@ -66,6 +66,7 @@
class FloatPoint;
class FloatSize;
class GraphicsContext;
+class GraphicsContextImpl;
class SharedBuffer;
class URL;
struct Length;
@@ -75,6 +76,7 @@
class Image : public RefCounted<Image> {
friend class GraphicsContext;
+ friend class GraphicsContextImpl;
public:
virtual ~Image();
Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp (227593 => 227594)
--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp 2018-01-25 07:14:56 UTC (rev 227593)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp 2018-01-25 07:18:24 UTC (rev 227594)
@@ -80,15 +80,13 @@
}
}
-AffineTransform GraphicsContext::getCTM(IncludeDeviceScale) const
+AffineTransform GraphicsContext::getCTM(IncludeDeviceScale includeScale) const
{
if (paintingDisabled())
return AffineTransform();
- if (m_impl) {
- WTFLogAlways("GraphicsContext::getCTM() is not yet compatible with recording contexts.");
- return AffineTransform();
- }
+ if (m_impl)
+ return m_impl->getCTM(includeScale);
ASSERT(hasPlatformContext());
return Cairo::State::getCTM(*platformContext());
@@ -96,6 +94,8 @@
PlatformContextCairo* GraphicsContext::platformContext() const
{
+ if (m_impl)
+ return m_impl->platformContext();
return &m_data->platformContext;
}
@@ -284,10 +284,8 @@
if (paintingDisabled())
return IntRect();
- if (m_impl) {
- WTFLogAlways("Getting the clip bounds not yet supported with display lists");
- return IntRect(-2048, -2048, 4096, 4096); // FIXME: display lists.
- }
+ if (m_impl)
+ return m_impl->clipBounds();
ASSERT(hasPlatformContext());
return Cairo::State::getClipBounds(*platformContext());
@@ -362,15 +360,13 @@
Cairo::drawLineForDocumentMarker(*platformContext(), origin, width, style);
}
-FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& rect, RoundingMode)
+FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& rect, RoundingMode roundingMode)
{
if (paintingDisabled())
return rect;
- if (m_impl) {
- WTFLogAlways("GraphicsContext::roundToDevicePixels() is not yet compatible with recording contexts.");
- return rect;
- }
+ if (m_impl)
+ return m_impl->roundToDevicePixels(rect, roundingMode);
return Cairo::State::roundToDevicePixels(*platformContext(), rect);
}
@@ -444,7 +440,7 @@
return;
if (m_impl) {
- WTFLogAlways("GraphicsContext::setCTM() is not compatible with recording contexts.");
+ m_impl->setCTM(transform);
return;
}
Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.cpp (227593 => 227594)
--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.cpp 2018-01-25 07:14:56 UTC (rev 227593)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.cpp 2018-01-25 07:18:24 UTC (rev 227594)
@@ -29,130 +29,268 @@
#if USE(CAIRO)
+#include "CairoOperations.h"
+#include "Font.h"
+#include "GlyphBuffer.h"
+#include "GraphicsContextPlatformPrivateCairo.h"
+
namespace WebCore {
GraphicsContextImplCairo::GraphicsContextImplCairo(GraphicsContext& context, PlatformContextCairo& platformContext)
: GraphicsContextImpl(context, FloatRect { }, AffineTransform { })
, m_platformContext(platformContext)
+ , m_private(std::make_unique<GraphicsContextPlatformPrivate>(m_platformContext))
{
+ m_platformContext.setGraphicsContextPrivate(m_private.get());
+ m_private->syncContext(m_platformContext.cr());
}
-GraphicsContextImplCairo::~GraphicsContextImplCairo() = default;
+GraphicsContextImplCairo::~GraphicsContextImplCairo()
+{
+ m_platformContext.setGraphicsContextPrivate(nullptr);
+}
-void GraphicsContextImplCairo::updateState(const GraphicsContextState&, GraphicsContextState::StateChangeFlags)
+bool GraphicsContextImplCairo::hasPlatformContext() const
{
+ return true;
}
+PlatformContextCairo* GraphicsContextImplCairo::platformContext() const
+{
+ return &m_platformContext;
+}
+
+void GraphicsContextImplCairo::updateState(const GraphicsContextState& state, GraphicsContextState::StateChangeFlags flags)
+{
+ if (flags & GraphicsContextState::StrokeThicknessChange)
+ Cairo::State::setStrokeThickness(m_platformContext, state.strokeThickness);
+
+ if (flags & GraphicsContextState::StrokeStyleChange)
+ Cairo::State::setStrokeStyle(m_platformContext, state.strokeStyle);
+
+ if (flags & GraphicsContextState::ShadowChange) {
+ if (state.shadowsIgnoreTransforms) {
+ // Meaning that this graphics context is associated with a CanvasRenderingContext
+ // We flip the height since CG and HTML5 Canvas have opposite Y axis
+ auto& mutableState = const_cast<GraphicsContextState&>(graphicsContext().state());
+ auto& shadowOffset = state.shadowOffset;
+ mutableState.shadowOffset = { shadowOffset.width(), -shadowOffset.height() };
+ }
+ }
+
+ if (flags & GraphicsContextState::CompositeOperationChange)
+ Cairo::State::setCompositeOperation(m_platformContext, state.compositeOperator, state.blendMode);
+
+ if (flags & GraphicsContextState::ShouldAntialiasChange)
+ Cairo::State::setShouldAntialias(m_platformContext, state.shouldAntialias);
+}
+
void GraphicsContextImplCairo::clearShadow()
{
}
-void GraphicsContextImplCairo::setLineCap(LineCap)
+void GraphicsContextImplCairo::setLineCap(LineCap lineCap)
{
+ Cairo::setLineCap(m_platformContext, lineCap);
}
-void GraphicsContextImplCairo::setLineDash(const DashArray&, float)
+void GraphicsContextImplCairo::setLineDash(const DashArray& dashes, float dashOffset)
{
+ Cairo::setLineDash(m_platformContext, dashes, dashOffset);
}
-void GraphicsContextImplCairo::setLineJoin(LineJoin)
+void GraphicsContextImplCairo::setLineJoin(LineJoin lineJoin)
{
+ Cairo::setLineJoin(m_platformContext, lineJoin);
}
-void GraphicsContextImplCairo::setMiterLimit(float)
+void GraphicsContextImplCairo::setMiterLimit(float miterLimit)
{
+ Cairo::setMiterLimit(m_platformContext, miterLimit);
}
-void GraphicsContextImplCairo::fillRect(const FloatRect&)
+void GraphicsContextImplCairo::fillRect(const FloatRect& rect)
{
+ auto& context = graphicsContext();
+ auto& state = context.state();
+ Cairo::fillRect(m_platformContext, rect, Cairo::FillSource(state), Cairo::ShadowState(state), context);
}
-void GraphicsContextImplCairo::fillRect(const FloatRect&, const Color&)
+void GraphicsContextImplCairo::fillRect(const FloatRect& rect, const Color& color)
{
+ auto& context = graphicsContext();
+ Cairo::fillRect(m_platformContext, rect, color, Cairo::ShadowState(context.state()), context);
}
-void GraphicsContextImplCairo::fillRect(const FloatRect&, Gradient&)
+void GraphicsContextImplCairo::fillRect(const FloatRect& rect, Gradient& gradient)
{
+ RefPtr<cairo_pattern_t> platformGradient = adoptRef(gradient.createPlatformGradient(1.0));
+
+ Cairo::save(m_platformContext);
+ Cairo::fillRect(m_platformContext, rect, platformGradient.get());
+ Cairo::restore(m_platformContext);
}
-void GraphicsContextImplCairo::fillRect(const FloatRect&, const Color&, CompositeOperator, BlendMode)
+void GraphicsContextImplCairo::fillRect(const FloatRect& rect, const Color& color, CompositeOperator compositeOperator, BlendMode blendMode)
{
+ auto& context = graphicsContext();
+ CompositeOperator previousOperator = context.state().compositeOperator;
+
+ Cairo::State::setCompositeOperation(m_platformContext, compositeOperator, blendMode);
+ Cairo::fillRect(m_platformContext, rect, color, Cairo::ShadowState(context.state()), context);
+ Cairo::State::setCompositeOperation(m_platformContext, previousOperator, BlendModeNormal);
}
-void GraphicsContextImplCairo::fillRoundedRect(const FloatRoundedRect&, const Color&, BlendMode)
+void GraphicsContextImplCairo::fillRoundedRect(const FloatRoundedRect& rect, const Color& color, BlendMode blendMode)
{
+ auto& context = graphicsContext();
+
+ CompositeOperator previousOperator = context.compositeOperation();
+ Cairo::State::setCompositeOperation(m_platformContext, previousOperator, blendMode);
+
+ Cairo::ShadowState shadowState(context.state());
+
+ if (rect.isRounded())
+ Cairo::fillRoundedRect(m_platformContext, rect, color, shadowState, context);
+ else
+ Cairo::fillRect(m_platformContext, rect.rect(), color, shadowState, context);
+
+ Cairo::State::setCompositeOperation(m_platformContext, previousOperator, BlendModeNormal);
}
-void GraphicsContextImplCairo::fillRectWithRoundedHole(const FloatRect&, const FloatRoundedRect&, const Color&)
+void GraphicsContextImplCairo::fillRectWithRoundedHole(const FloatRect& rect, const FloatRoundedRect& roundedHoleRect, const Color&)
{
+ auto& context = graphicsContext();
+ Cairo::fillRectWithRoundedHole(m_platformContext, rect, roundedHoleRect, { }, Cairo::ShadowState(context.state()), context);
}
-void GraphicsContextImplCairo::fillPath(const Path&)
+void GraphicsContextImplCairo::fillPath(const Path& path)
{
+ auto& context = graphicsContext();
+ auto& state = context.state();
+ Cairo::fillPath(m_platformContext, path, Cairo::FillSource(state), Cairo::ShadowState(state), context);
}
-void GraphicsContextImplCairo::fillEllipse(const FloatRect&)
+void GraphicsContextImplCairo::fillEllipse(const FloatRect& rect)
{
+ Path path;
+ path.addEllipse(rect);
+ fillPath(path);
}
-void GraphicsContextImplCairo::strokeRect(const FloatRect&, float)
+void GraphicsContextImplCairo::strokeRect(const FloatRect& rect, float lineWidth)
{
+ auto& context = graphicsContext();
+ auto& state = context.state();
+ Cairo::strokeRect(m_platformContext, rect, lineWidth, Cairo::StrokeSource(state), Cairo::ShadowState(state), context);
}
-void GraphicsContextImplCairo::strokePath(const Path&)
+void GraphicsContextImplCairo::strokePath(const Path& path)
{
+ auto& context = graphicsContext();
+ auto& state = context.state();
+ Cairo::strokePath(m_platformContext, path, Cairo::StrokeSource(state), Cairo::ShadowState(state), context);
}
-void GraphicsContextImplCairo::strokeEllipse(const FloatRect&)
+void GraphicsContextImplCairo::strokeEllipse(const FloatRect& rect)
{
+ Path path;
+ path.addEllipse(rect);
+ strokePath(path);
}
-void GraphicsContextImplCairo::clearRect(const FloatRect&)
+void GraphicsContextImplCairo::clearRect(const FloatRect& rect)
{
+ Cairo::clearRect(m_platformContext, rect);
}
-void GraphicsContextImplCairo::drawGlyphs(const Font&, const GlyphBuffer&, unsigned, unsigned, const FloatPoint&, FontSmoothingMode)
+void GraphicsContextImplCairo::drawGlyphs(const Font& font, const GlyphBuffer& glyphBuffer, unsigned from, unsigned numGlyphs, const FloatPoint& point, FontSmoothingMode fontSmoothing)
{
+ UNUSED_PARAM(fontSmoothing);
+ if (!font.platformData().size())
+ return;
+
+ auto xOffset = point.x();
+ Vector<cairo_glyph_t> glyphs(numGlyphs);
+ {
+ ASSERT(from + numGlyphs <= glyphBuffer.size());
+ auto* glyphsData = glyphBuffer.glyphs(from);
+ auto* advances = glyphBuffer.advances(from);
+
+ auto yOffset = point.y();
+ for (size_t i = 0; i < numGlyphs; ++i) {
+ glyphs[i] = { glyphsData[i], xOffset, yOffset };
+ xOffset += advances[i].width();
+ }
+ }
+
+ cairo_scaled_font_t* scaledFont = font.platformData().scaledFont();
+ double syntheticBoldOffset = font.syntheticBoldOffset();
+
+ auto& context = graphicsContext();
+ auto& state = context.state();
+ Cairo::drawGlyphs(m_platformContext, Cairo::FillSource(state), Cairo::StrokeSource(state),
+ Cairo::ShadowState(state), point, scaledFont, syntheticBoldOffset, glyphs, xOffset,
+ state.textDrawingMode, state.strokeThickness, state.shadowOffset, state.shadowColor, context);
}
-void GraphicsContextImplCairo::drawImage(Image&, const FloatRect&, const FloatRect&, const ImagePaintingOptions&)
+ImageDrawResult GraphicsContextImplCairo::drawImage(Image& image, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions& imagePaintingOptions)
{
+ return GraphicsContextImpl::drawImageImpl(graphicsContext(), image, destination, source, imagePaintingOptions);
}
-void GraphicsContextImplCairo::drawTiledImage(Image&, const FloatRect&, const FloatPoint&, const FloatSize&, const FloatSize&, const ImagePaintingOptions&)
+ImageDrawResult GraphicsContextImplCairo::drawTiledImage(Image& image, const FloatRect& destination, const FloatPoint& source, const FloatSize& tileSize, const FloatSize& spacing, const ImagePaintingOptions& imagePaintingOptions)
{
+ return GraphicsContextImpl::drawTiledImageImpl(graphicsContext(), image, destination, source, tileSize, spacing, imagePaintingOptions);
}
-void GraphicsContextImplCairo::drawTiledImage(Image&, const FloatRect&, const FloatRect&, const FloatSize&, Image::TileRule, Image::TileRule, const ImagePaintingOptions&)
+ImageDrawResult GraphicsContextImplCairo::drawTiledImage(Image& image, const FloatRect& destination, const FloatRect& source, const FloatSize& tileScaleFactor, Image::TileRule hRule, Image::TileRule vRule, const ImagePaintingOptions& imagePaintingOptions)
{
+ return GraphicsContextImpl::drawTiledImageImpl(graphicsContext(), image, destination, source, tileScaleFactor, hRule, vRule, imagePaintingOptions);
}
-void GraphicsContextImplCairo::drawNativeImage(const NativeImagePtr&, const FloatSize&, const FloatRect&, const FloatRect&, CompositeOperator, BlendMode, ImageOrientation)
+void GraphicsContextImplCairo::drawNativeImage(const NativeImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator compositeOperator, BlendMode blendMode, ImageOrientation orientation)
{
+ UNUSED_PARAM(imageSize);
+ auto& context = graphicsContext();
+ auto& state = context.state();
+ Cairo::drawNativeImage(m_platformContext, image.get(), destRect, srcRect, compositeOperator, blendMode, orientation, state.imageInterpolationQuality, state.alpha, Cairo::ShadowState(state), graphicsContext());
}
-void GraphicsContextImplCairo::drawPattern(Image&, const FloatRect&, const FloatRect&, const AffineTransform&, const FloatPoint&, const FloatSize&, CompositeOperator, BlendMode)
+void GraphicsContextImplCairo::drawPattern(Image& image, const FloatRect& destRect, const FloatRect& tileRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize&, CompositeOperator compositeOperator, BlendMode blendMode)
{
+ if (auto surface = image.nativeImageForCurrentFrame())
+ Cairo::drawPattern(m_platformContext, surface.get(), IntSize(image.size()), destRect, tileRect, patternTransform, phase, compositeOperator, blendMode);
}
-void GraphicsContextImplCairo::drawRect(const FloatRect&, float)
+void GraphicsContextImplCairo::drawRect(const FloatRect& rect, float borderThickness)
{
+ auto& state = graphicsContext().state();
+ Cairo::drawRect(m_platformContext, rect, borderThickness, state.fillColor, state.strokeStyle, state.strokeColor);
}
-void GraphicsContextImplCairo::drawLine(const FloatPoint&, const FloatPoint&)
+void GraphicsContextImplCairo::drawLine(const FloatPoint& point1, const FloatPoint& point2)
{
+ auto& state = graphicsContext().state();
+ Cairo::drawLine(m_platformContext, point1, point2, state.strokeStyle, state.strokeColor, state.strokeThickness, state.shouldAntialias);
}
-void GraphicsContextImplCairo::drawLinesForText(const FloatPoint&, const DashArray&, bool, bool, float)
+void GraphicsContextImplCairo::drawLinesForText(const FloatPoint& point, const DashArray& widths, bool printing, bool doubleUnderlines, float strokeThickness)
{
+ UNUSED_PARAM(strokeThickness);
+ auto& state = graphicsContext().state();
+ Cairo::drawLinesForText(m_platformContext, point, widths, printing, doubleUnderlines, state.strokeColor, state.strokeThickness);
}
-void GraphicsContextImplCairo::drawLineForDocumentMarker(const FloatPoint&, float, GraphicsContext::DocumentMarkerLineStyle)
+void GraphicsContextImplCairo::drawLineForDocumentMarker(const FloatPoint& origin, float width, GraphicsContext::DocumentMarkerLineStyle style)
{
+ Cairo::drawLineForDocumentMarker(m_platformContext, origin, width, style);
}
-void GraphicsContextImplCairo::drawEllipse(const FloatRect&)
+void GraphicsContextImplCairo::drawEllipse(const FloatRect& rect)
{
+ auto& state = graphicsContext().state();
+ Cairo::drawEllipse(*platformContext(), rect, state.fillColor, state.strokeStyle, state.strokeColor, state.strokeThickness);
}
void GraphicsContextImplCairo::drawPath(const Path&)
@@ -159,66 +297,102 @@
{
}
-void GraphicsContextImplCairo::drawFocusRing(const Path&, float, float, const Color&)
+void GraphicsContextImplCairo::drawFocusRing(const Path& path, float width, float offset, const Color& color)
{
+ UNUSED_PARAM(offset);
+ Cairo::drawFocusRing(m_platformContext, path, width, color);
}
-void GraphicsContextImplCairo::drawFocusRing(const Vector<FloatRect>&, float, float, const Color&)
+void GraphicsContextImplCairo::drawFocusRing(const Vector<FloatRect>& rects, float width, float offset, const Color& color)
{
+ UNUSED_PARAM(offset);
+ Cairo::drawFocusRing(m_platformContext, rects, width, color);
}
void GraphicsContextImplCairo::save()
{
+ Cairo::save(m_platformContext);
}
void GraphicsContextImplCairo::restore()
{
+ Cairo::restore(m_platformContext);
}
-void GraphicsContextImplCairo::translate(float, float)
+void GraphicsContextImplCairo::translate(float x, float y)
{
+ Cairo::translate(m_platformContext, x, y);
}
-void GraphicsContextImplCairo::rotate(float)
+void GraphicsContextImplCairo::rotate(float angleInRadians)
{
+ Cairo::rotate(m_platformContext, angleInRadians);
}
-void GraphicsContextImplCairo::scale(const FloatSize&)
+void GraphicsContextImplCairo::scale(const FloatSize& size)
{
+ Cairo::scale(m_platformContext, size);
}
-void GraphicsContextImplCairo::concatCTM(const AffineTransform&)
+void GraphicsContextImplCairo::concatCTM(const AffineTransform& transform)
{
+ Cairo::concatCTM(m_platformContext, transform);
}
-void GraphicsContextImplCairo::beginTransparencyLayer(float)
+void GraphicsContextImplCairo::setCTM(const AffineTransform& transform)
{
+ Cairo::State::setCTM(m_platformContext, transform);
}
+AffineTransform GraphicsContextImplCairo::getCTM(GraphicsContext::IncludeDeviceScale)
+{
+ return Cairo::State::getCTM(m_platformContext);
+}
+
+void GraphicsContextImplCairo::beginTransparencyLayer(float opacity)
+{
+ Cairo::beginTransparencyLayer(m_platformContext, opacity);
+}
+
void GraphicsContextImplCairo::endTransparencyLayer()
{
+ Cairo::endTransparencyLayer(m_platformContext);
}
-void GraphicsContextImplCairo::clip(const FloatRect&)
+void GraphicsContextImplCairo::clip(const FloatRect& rect)
{
+ Cairo::clip(m_platformContext, rect);
}
-void GraphicsContextImplCairo::clipOut(const FloatRect&)
+void GraphicsContextImplCairo::clipOut(const FloatRect& rect)
{
+ Cairo::clipOut(m_platformContext, rect);
}
-void GraphicsContextImplCairo::clipOut(const Path&)
+void GraphicsContextImplCairo::clipOut(const Path& path)
{
+ Cairo::clipOut(m_platformContext, path);
}
-void GraphicsContextImplCairo::clipPath(const Path&, WindRule)
+void GraphicsContextImplCairo::clipPath(const Path& path, WindRule clipRule)
{
+ Cairo::clipPath(m_platformContext, path, clipRule);
}
+IntRect GraphicsContextImplCairo::clipBounds()
+{
+ return Cairo::State::getClipBounds(m_platformContext);
+}
+
void GraphicsContextImplCairo::applyDeviceScaleFactor(float)
{
}
+FloatRect GraphicsContextImplCairo::roundToDevicePixels(const FloatRect& rect, GraphicsContext::RoundingMode)
+{
+ return Cairo::State::roundToDevicePixels(m_platformContext, rect);
+}
+
} // namespace WebCore
#endif // USE(CAIRO)
Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.h (227593 => 227594)
--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.h 2018-01-25 07:14:56 UTC (rev 227593)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.h 2018-01-25 07:18:24 UTC (rev 227594)
@@ -41,6 +41,9 @@
GraphicsContextImplCairo(GraphicsContext&, PlatformContextCairo&);
virtual ~GraphicsContextImplCairo();
+ bool hasPlatformContext() const override;
+ PlatformContextCairo* platformContext() const override;
+
void updateState(const GraphicsContextState&, GraphicsContextState::StateChangeFlags) override;
void clearShadow() override;
@@ -64,9 +67,9 @@
void drawGlyphs(const Font&, const GlyphBuffer&, unsigned, unsigned, const FloatPoint&, FontSmoothingMode) override;
- void drawImage(Image&, const FloatRect&, const FloatRect&, const ImagePaintingOptions&) override;
- void drawTiledImage(Image&, const FloatRect&, const FloatPoint&, const FloatSize&, const FloatSize&, const ImagePaintingOptions&) override;
- void drawTiledImage(Image&, const FloatRect&, const FloatRect&, const FloatSize&, Image::TileRule, Image::TileRule, const ImagePaintingOptions&) override;
+ ImageDrawResult drawImage(Image&, const FloatRect&, const FloatRect&, const ImagePaintingOptions&) override;
+ ImageDrawResult drawTiledImage(Image&, const FloatRect&, const FloatPoint&, const FloatSize&, const FloatSize&, const ImagePaintingOptions&) override;
+ ImageDrawResult drawTiledImage(Image&, const FloatRect&, const FloatRect&, const FloatSize&, Image::TileRule, Image::TileRule, const ImagePaintingOptions&) override;
void drawNativeImage(const NativeImagePtr&, const FloatSize&, const FloatRect&, const FloatRect&, CompositeOperator, BlendMode, ImageOrientation) override;
void drawPattern(Image&, const FloatRect&, const FloatRect&, const AffineTransform&, const FloatPoint&, const FloatSize&, CompositeOperator, BlendMode = BlendModeNormal) override;
@@ -87,6 +90,8 @@
void rotate(float) override;
void scale(const FloatSize&) override;
void concatCTM(const AffineTransform&) override;
+ void setCTM(const AffineTransform&) override;
+ AffineTransform getCTM(GraphicsContext::IncludeDeviceScale) override;
void beginTransparencyLayer(float) override;
void endTransparencyLayer() override;
@@ -95,11 +100,15 @@
void clipOut(const FloatRect&) override;
void clipOut(const Path&) override;
void clipPath(const Path&, WindRule) override;
+ IntRect clipBounds() override;
void applyDeviceScaleFactor(float) override;
+ FloatRect roundToDevicePixels(const FloatRect&, GraphicsContext::RoundingMode) override;
+
private:
PlatformContextCairo& m_platformContext;
+ std::unique_ptr<GraphicsContextPlatformPrivate> m_private;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp (227593 => 227594)
--- trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp 2018-01-25 07:14:56 UTC (rev 227593)
+++ trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp 2018-01-25 07:18:24 UTC (rev 227594)
@@ -35,6 +35,7 @@
#include "CairoUtilities.h"
#include "Color.h"
#include "GraphicsContext.h"
+#include "GraphicsContextImplCairo.h"
#include "MIMETypeRegistry.h"
#include "NotImplemented.h"
#include "Pattern.h"
@@ -246,7 +247,8 @@
RefPtr<cairo_t> cr = adoptRef(cairo_create(m_data.m_surface.get()));
m_data.m_platformContext.setCr(cr.get());
- m_data.m_context = std::make_unique<GraphicsContext>(&m_data.m_platformContext);
+ m_data.m_context = std::make_unique<GraphicsContext>(
+ [this](GraphicsContext& context) { return std::make_unique<GraphicsContextImplCairo>(context, m_data.m_platformContext); });
success = true;
}
Modified: trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp (227593 => 227594)
--- trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp 2018-01-25 07:14:56 UTC (rev 227593)
+++ trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp 2018-01-25 07:18:24 UTC (rev 227594)
@@ -1142,10 +1142,8 @@
if (paintingDisabled())
return IntRect();
- if (m_impl) {
- WTFLogAlways("Getting the clip bounds not yet supported with display lists");
- return IntRect(-2048, -2048, 4096, 4096); // FIXME: display lists.
- }
+ if (m_impl)
+ return m_impl->clipBounds();
return enclosingIntRect(CGContextGetClipBoundingBox(platformContext()));
}
@@ -1497,7 +1495,7 @@
return;
if (m_impl) {
- WTFLogAlways("GraphicsContext::setCTM() is not compatible with recording contexts.");
+ m_impl->setCTM(transform);
return;
}
@@ -1511,10 +1509,8 @@
if (paintingDisabled())
return AffineTransform();
- if (m_impl) {
- WTFLogAlways("GraphicsContext::getCTM() is not yet compatible with recording contexts.");
- return AffineTransform();
- }
+ if (m_impl)
+ return m_impl->getCTM(includeScale);
// 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
@@ -1530,10 +1526,8 @@
if (paintingDisabled())
return rect;
- if (m_impl) {
- WTFLogAlways("GraphicsContext::roundToDevicePixels() is not yet compatible with recording contexts.");
- return rect;
- }
+ if (m_impl)
+ return m_impl->roundToDevicePixels(rect, roundingMode);
// 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
Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp (227593 => 227594)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp 2018-01-25 07:14:56 UTC (rev 227593)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp 2018-01-25 07:18:24 UTC (rev 227594)
@@ -105,18 +105,27 @@
updateItemExtent(newItem);
}
-void Recorder::drawImage(Image& image, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions& imagePaintingOptions)
+ImageDrawResult Recorder::drawImage(Image& image, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions& imagePaintingOptions)
{
DrawingItem& newItem = downcast<DrawingItem>(appendItem(DrawImage::create(image, destination, source, imagePaintingOptions)));
updateItemExtent(newItem);
+ return ImageDrawResult::DidRecord;
}
-void Recorder::drawTiledImage(Image& image, const FloatRect& destination, const FloatPoint& source, const FloatSize& tileSize, const FloatSize& spacing, const ImagePaintingOptions& imagePaintingOptions)
+ImageDrawResult Recorder::drawTiledImage(Image& image, const FloatRect& destination, const FloatPoint& source, const FloatSize& tileSize, const FloatSize& spacing, const ImagePaintingOptions& imagePaintingOptions)
{
DrawingItem& newItem = downcast<DrawingItem>(appendItem(DrawTiledImage::create(image, destination, source, tileSize, spacing, imagePaintingOptions)));
updateItemExtent(newItem);
+ return ImageDrawResult::DidRecord;
}
+ImageDrawResult Recorder::drawTiledImage(Image& image, const FloatRect& destination, const FloatRect& source, const FloatSize& tileScaleFactor, Image::TileRule hRule, Image::TileRule vRule, const ImagePaintingOptions& imagePaintingOptions)
+{
+ DrawingItem& newItem = downcast<DrawingItem>(appendItem(DrawTiledScaledImage::create(image, destination, source, tileScaleFactor, hRule, vRule, imagePaintingOptions)));
+ updateItemExtent(newItem);
+ return ImageDrawResult::DidRecord;
+}
+
#if USE(CG) || USE(CAIRO)
void Recorder::drawNativeImage(const NativeImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator op, BlendMode blendMode, ImageOrientation orientation)
{
@@ -125,12 +134,6 @@
}
#endif
-void Recorder::drawTiledImage(Image& image, const FloatRect& destination, const FloatRect& source, const FloatSize& tileScaleFactor, Image::TileRule hRule, Image::TileRule vRule, const ImagePaintingOptions& imagePaintingOptions)
-{
- DrawingItem& newItem = downcast<DrawingItem>(appendItem(DrawTiledScaledImage::create(image, destination, source, tileScaleFactor, hRule, vRule, imagePaintingOptions)));
- updateItemExtent(newItem);
-}
-
void Recorder::drawPattern(Image& image, const FloatRect& destRect, const FloatRect& tileRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, CompositeOperator op, BlendMode blendMode)
{
DrawingItem& newItem = downcast<DrawingItem>(appendItem(DrawPattern::create(image, destRect, tileRect, patternTransform, phase, spacing, op, blendMode)));
@@ -193,6 +196,17 @@
appendItem(ConcatenateCTM::create(transform));
}
+void Recorder::setCTM(const AffineTransform&)
+{
+ WTFLogAlways("GraphicsContext::setCTM() is not compatible with DisplayList::Recorder.");
+}
+
+AffineTransform Recorder::getCTM(GraphicsContext::IncludeDeviceScale)
+{
+ WTFLogAlways("GraphicsContext::getCTM() is not yet compatible with DisplayList::Recorder.");
+ return { };
+}
+
void Recorder::beginTransparencyLayer(float opacity)
{
DrawingItem& newItem = downcast<DrawingItem>(appendItem(BeginTransparencyLayer::create(opacity)));
@@ -358,6 +372,12 @@
appendItem(ClipPath::create(path, windRule));
}
+IntRect Recorder::clipBounds()
+{
+ WTFLogAlways("Getting the clip bounds not yet supported with DisplayList::Recorder.");
+ return IntRect(-2048, -2048, 4096, 4096);
+}
+
void Recorder::applyDeviceScaleFactor(float deviceScaleFactor)
{
// FIXME: this changes the baseCTM, which will invalidate all of our cached extents.
@@ -365,6 +385,12 @@
appendItem(ApplyDeviceScaleFactor::create(deviceScaleFactor));
}
+FloatRect Recorder::roundToDevicePixels(const FloatRect& rect, GraphicsContext::RoundingMode)
+{
+ WTFLogAlways("GraphicsContext::roundToDevicePixels() is not yet compatible with DisplayList::Recorder.");
+ return rect;
+}
+
Item& Recorder::appendItem(Ref<Item>&& item)
{
willAppendItem(item.get());
Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h (227593 => 227594)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h 2018-01-25 07:14:56 UTC (rev 227593)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h 2018-01-25 07:18:24 UTC (rev 227594)
@@ -56,6 +56,9 @@
size_t itemCount() const { return m_displayList.itemCount(); }
private:
+ bool hasPlatformContext() const override { return false; }
+ PlatformGraphicsContext* platformContext() const override { return nullptr; }
+
void updateState(const GraphicsContextState&, GraphicsContextState::StateChangeFlags) override;
void clearShadow() override;
@@ -84,9 +87,9 @@
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&) 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;
+ ImageDrawResult drawImage(Image&, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions&) override;
+ ImageDrawResult drawTiledImage(Image&, const FloatRect& destination, const FloatPoint& source, const FloatSize& tileSize, const FloatSize& spacing, const ImagePaintingOptions&) override;
+ ImageDrawResult 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) override;
#endif
@@ -109,6 +112,8 @@
void rotate(float angleInRadians) override;
void scale(const FloatSize&) override;
void concatCTM(const AffineTransform&) override;
+ void setCTM(const AffineTransform&) override;
+ AffineTransform getCTM(GraphicsContext::IncludeDeviceScale) override;
void beginTransparencyLayer(float opacity) override;
void endTransparencyLayer() override;
@@ -117,9 +122,12 @@
void clipOut(const FloatRect&) override;
void clipOut(const Path&) override;
void clipPath(const Path&, WindRule) override;
+ IntRect clipBounds() override;
void applyDeviceScaleFactor(float) override;
+ FloatRect roundToDevicePixels(const FloatRect&, GraphicsContext::RoundingMode) override;
+
Item& appendItem(Ref<Item>&&);
void willAppendItem(const Item&);