Diff
Modified: trunk/Source/WebCore/ChangeLog (227727 => 227728)
--- trunk/Source/WebCore/ChangeLog 2018-01-29 10:56:57 UTC (rev 227727)
+++ trunk/Source/WebCore/ChangeLog 2018-01-29 14:32:25 UTC (rev 227728)
@@ -1,5 +1,35 @@
2018-01-29 Zan Dobersek <[email protected]>
+ [Cairo] Add GraphicsContextImplCairo::createFactory() helpers
+ https://bugs.webkit.org/show_bug.cgi?id=182238
+
+ Reviewed by Carlos Garcia Campos.
+
+ Instead of duplicating lambdas that return a newly-created
+ GraphicsContextImplCairo object, provide static createFactory() helpers
+ on that class that produce GraphicsContextImplFactory wrappers which are
+ then invoked in the GraphicsContext constructor. The static functions
+ accept either the PlatformContextCairo reference or the cairo_t pointer,
+ invoking the proper GraphicsContextImplCairo constructor in the returned
+ lambda wrapper.
+
+ No new tests -- no change in functionality.
+
+ * platform/graphics/cairo/GraphicsContextImplCairo.cpp:
+ (WebCore::GraphicsContextImplCairo::createFactory):
+ * platform/graphics/cairo/GraphicsContextImplCairo.h:
+ * platform/graphics/cairo/ImageBufferCairo.cpp:
+ (WebCore::ImageBuffer::ImageBuffer):
+ * platform/graphics/cairo/PathCairo.cpp:
+ (WebCore::Path::strokeBoundingRect const):
+ (WebCore::Path::strokeContains const):
+ * platform/graphics/nicosia/NicosiaPaintingContextCairo.cpp:
+ (Nicosia::PaintingContextCairo::PaintingContextCairo):
+ * platform/graphics/win/ImageCairoWin.cpp:
+ (WebCore::BitmapImage::getHBITMAPOfSize):
+
+2018-01-29 Zan Dobersek <[email protected]>
+
Construct GraphicsContext with NonPaintingReasons::NoReason in FrameView::adjustPageHeightDeprecated()
https://bugs.webkit.org/show_bug.cgi?id=182235
Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.cpp (227727 => 227728)
--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.cpp 2018-01-29 10:56:57 UTC (rev 227727)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.cpp 2018-01-29 14:32:25 UTC (rev 227728)
@@ -36,6 +36,24 @@
namespace WebCore {
+GraphicsContext::GraphicsContextImplFactory GraphicsContextImplCairo::createFactory(PlatformContextCairo& platformContext)
+{
+ return GraphicsContext::GraphicsContextImplFactory(
+ [&platformContext](GraphicsContext& context)
+ {
+ return std::make_unique<GraphicsContextImplCairo>(context, platformContext);
+ });
+}
+
+GraphicsContext::GraphicsContextImplFactory GraphicsContextImplCairo::createFactory(cairo_t* cairoContext)
+{
+ return GraphicsContext::GraphicsContextImplFactory(
+ [cairoContext](GraphicsContext& context)
+ {
+ return std::make_unique<GraphicsContextImplCairo>(context, cairoContext);
+ });
+}
+
GraphicsContextImplCairo::GraphicsContextImplCairo(GraphicsContext& context, PlatformContextCairo& platformContext)
: GraphicsContextImpl(context, FloatRect { }, AffineTransform { })
, m_platformContext(platformContext)
Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.h (227727 => 227728)
--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.h 2018-01-29 10:56:57 UTC (rev 227727)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.h 2018-01-29 14:32:25 UTC (rev 227728)
@@ -38,6 +38,9 @@
class GraphicsContextImplCairo final : public GraphicsContextImpl {
public:
+ static GraphicsContext::GraphicsContextImplFactory createFactory(PlatformContextCairo&);
+ static GraphicsContext::GraphicsContextImplFactory createFactory(cairo_t*);
+
GraphicsContextImplCairo(GraphicsContext&, PlatformContextCairo&);
GraphicsContextImplCairo(GraphicsContext&, cairo_t*);
virtual ~GraphicsContextImplCairo();
Modified: trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp (227727 => 227728)
--- trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp 2018-01-29 10:56:57 UTC (rev 227727)
+++ trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp 2018-01-29 14:32:25 UTC (rev 227728)
@@ -247,8 +247,7 @@
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>(
- [this](GraphicsContext& context) { return std::make_unique<GraphicsContextImplCairo>(context, m_data.m_platformContext); });
+ m_data.m_context = std::make_unique<GraphicsContext>(GraphicsContextImplCairo::createFactory(m_data.m_platformContext));
success = true;
}
Modified: trunk/Source/WebCore/platform/graphics/cairo/PathCairo.cpp (227727 => 227728)
--- trunk/Source/WebCore/platform/graphics/cairo/PathCairo.cpp 2018-01-29 10:56:57 UTC (rev 227727)
+++ trunk/Source/WebCore/platform/graphics/cairo/PathCairo.cpp 2018-01-29 14:32:25 UTC (rev 227728)
@@ -373,11 +373,7 @@
cairo_t* cr = platformPath()->context();
if (applier) {
- GraphicsContext gc(
- [cr](GraphicsContext& context)
- {
- return std::make_unique<GraphicsContextImplCairo>(context, cr);
- });
+ GraphicsContext gc(GraphicsContextImplCairo::createFactory(cr));
applier->strokeStyle(&gc);
}
@@ -406,11 +402,7 @@
ASSERT(applier);
cairo_t* cr = platformPath()->context();
{
- GraphicsContext gc(
- [cr](GraphicsContext& context)
- {
- return std::make_unique<GraphicsContextImplCairo>(context, cr);
- });
+ GraphicsContext gc(GraphicsContextImplCairo::createFactory(cr));
applier->strokeStyle(&gc);
}
Modified: trunk/Source/WebCore/platform/graphics/nicosia/NicosiaPaintingContextCairo.cpp (227727 => 227728)
--- trunk/Source/WebCore/platform/graphics/nicosia/NicosiaPaintingContextCairo.cpp 2018-01-29 10:56:57 UTC (rev 227727)
+++ trunk/Source/WebCore/platform/graphics/nicosia/NicosiaPaintingContextCairo.cpp 2018-01-29 14:32:25 UTC (rev 227728)
@@ -69,11 +69,7 @@
m_cairo.context = adoptRef(cairo_create(m_cairo.surface.get()));
m_platformContext = std::make_unique<WebCore::PlatformContextCairo>(m_cairo.context.get());
- m_graphicsContext = std::make_unique<WebCore::GraphicsContext>(
- [this](WebCore::GraphicsContext& context)
- {
- return std::make_unique<WebCore::GraphicsContextImplCairo>(context, *m_platformContext);
- });
+ m_graphicsContext = std::make_unique<WebCore::GraphicsContext>(WebCore::GraphicsContextImplCairo::createFactory(*m_platformContext));
}
PaintingContextCairo::~PaintingContextCairo()
Modified: trunk/Source/WebCore/platform/graphics/win/ImageCairoWin.cpp (227727 => 227728)
--- trunk/Source/WebCore/platform/graphics/win/ImageCairoWin.cpp 2018-01-29 10:56:57 UTC (rev 227727)
+++ trunk/Source/WebCore/platform/graphics/win/ImageCairoWin.cpp 2018-01-29 14:32:25 UTC (rev 227728)
@@ -75,11 +75,7 @@
cairo_t* targetRef = cairo_create(image);
cairo_surface_destroy(image);
- GraphicsContext gc(
- [targetRef](GraphicsContext& context)
- {
- return std::make_unique<GraphicsContextImplCairo>(context, targetRef);
- });
+ GraphicsContext gc(GraphicsContextImplCairo::createFactory(targetRef));
FloatSize imageSize = BitmapImage::size();
if (size)
Modified: trunk/Source/WebKit/ChangeLog (227727 => 227728)
--- trunk/Source/WebKit/ChangeLog 2018-01-29 10:56:57 UTC (rev 227727)
+++ trunk/Source/WebKit/ChangeLog 2018-01-29 14:32:25 UTC (rev 227728)
@@ -1,5 +1,22 @@
2018-01-29 Zan Dobersek <[email protected]>
+ [Cairo] Add GraphicsContextImplCairo::createFactory() helpers
+ https://bugs.webkit.org/show_bug.cgi?id=182238
+
+ Reviewed by Carlos Garcia Campos.
+
+ Use GraphicsContextImplCairo::createFactory() helpers throughout the
+ Cairo-specific GraphicsContext constructors in the WebKit layer.
+
+ * Shared/cairo/ShareableBitmapCairo.cpp:
+ (WebKit::ShareableBitmap::createGraphicsContext):
+ * UIProcess/cairo/BackingStoreCairo.cpp:
+ (WebKit::BackingStore::incorporateUpdate):
+ * WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp:
+ (WebKit::WebPrintOperationGtk::renderPage):
+
+2018-01-29 Zan Dobersek <[email protected]>
+
[Cairo] Remove the GraphicsContext(cairo_t*) constructor
https://bugs.webkit.org/show_bug.cgi?id=182234
Modified: trunk/Source/WebKit/Shared/cairo/ShareableBitmapCairo.cpp (227727 => 227728)
--- trunk/Source/WebKit/Shared/cairo/ShareableBitmapCairo.cpp 2018-01-29 10:56:57 UTC (rev 227727)
+++ trunk/Source/WebKit/Shared/cairo/ShareableBitmapCairo.cpp 2018-01-29 14:32:25 UTC (rev 227728)
@@ -61,10 +61,7 @@
{
RefPtr<cairo_surface_t> image = createCairoSurface();
RefPtr<cairo_t> bitmapContext = adoptRef(cairo_create(image.get()));
- return std::make_unique<GraphicsContext>(
- [bitmapContext = WTFMove(bitmapContext)](GraphicsContext& context) {
- return std::make_unique<GraphicsContextImplCairo>(context, bitmapContext.get());
- });
+ return std::make_unique<GraphicsContext>(GraphicsContextImplCairo::createFactory(bitmapContext.get()));
}
void ShareableBitmap::paint(GraphicsContext& context, const IntPoint& dstPoint, const IntRect& srcRect)
Modified: trunk/Source/WebKit/UIProcess/cairo/BackingStoreCairo.cpp (227727 => 227728)
--- trunk/Source/WebKit/UIProcess/cairo/BackingStoreCairo.cpp 2018-01-29 10:56:57 UTC (rev 227727)
+++ trunk/Source/WebKit/UIProcess/cairo/BackingStoreCairo.cpp 2018-01-29 14:32:25 UTC (rev 227728)
@@ -89,11 +89,7 @@
// Paint all update rects.
IntPoint updateRectLocation = updateInfo.updateRectBounds.location();
RefPtr<cairo_t> cairoContext = adoptRef(cairo_create(m_backend->surface()));
- GraphicsContext graphicsContext(
- [cairoContext = WTFMove(cairoContext)](GraphicsContext& context)
- {
- return std::make_unique<GraphicsContextImplCairo>(context, cairoContext.get());
- });
+ GraphicsContext graphicsContext(GraphicsContextImplCairo::createFactory(cairoContext.get()));
for (const auto& updateRect : updateInfo.updateRects) {
IntRect srcRect = updateRect;
srcRect.move(-updateRectLocation.x(), -updateRectLocation.y());
Modified: trunk/Source/WebKit/WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp (227727 => 227728)
--- trunk/Source/WebKit/WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp 2018-01-29 10:56:57 UTC (rev 227727)
+++ trunk/Source/WebKit/WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp 2018-01-29 14:32:25 UTC (rev 227728)
@@ -666,11 +666,7 @@
prepareContextToDraw();
double pageWidth = gtk_page_setup_get_page_width(m_pageSetup.get(), GTK_UNIT_INCH) * m_xDPI;
- WebCore::GraphicsContext graphicsContext(
- [cairoContext = m_cairoContext.get()](WebCore::GraphicsContext& context)
- {
- return std::make_unique<WebCore::GraphicsContextImplCairo>(context, cairoContext);
- });
+ WebCore::GraphicsContext graphicsContext(WebCore::GraphicsContextImplCairo::createFactory(m_cairoContext.get()));
m_printContext->spoolPage(graphicsContext, pageNumber, pageWidth / m_scale);
cairo_restore(m_cairoContext.get());