- Revision
- 227726
- Author
- zandober...@gmail.com
- Date
- 2018-01-29 02:56:09 -0800 (Mon, 29 Jan 2018)
Log Message
[Cairo] Remove the GraphicsContext(cairo_t*) constructor
https://bugs.webkit.org/show_bug.cgi?id=182234
Reviewed by Carlos Garcia Campos.
Source/WebCore:
Instead of using the GraphicsContext(cairo_t*) constructor, leverage the
GraphicsContextImplCairo class and work with an existing Cairo context
through that GraphicsContextImpl implementation.
A new GraphicsContextImplCairo constructor is added, expecting pointer
to the cairo_t object. With that, a PlatformContextCairo object is
created, with ownership of that object now being handled by the
GraphicsContextImplCairo class.
Call sites of the GraphicsContext(cairo_t*) constructor are adjusted to
instead provide a factory function that returns a fresh
GraphicsContextImplCairo object, passing that cairo_t object to its
constructor.
No new tests -- no change in behavior.
* platform/graphics/GraphicsContext.h:
* platform/graphics/cairo/GraphicsContextCairo.cpp:
(WebCore::GraphicsContext::GraphicsContext): Deleted.
* platform/graphics/cairo/GraphicsContextImplCairo.cpp:
(WebCore::GraphicsContextImplCairo::GraphicsContextImplCairo):
(WebCore::m_private):
* platform/graphics/cairo/GraphicsContextImplCairo.h:
* platform/graphics/cairo/PathCairo.cpp:
(WebCore::Path::strokeBoundingRect const):
(WebCore::Path::strokeContains const):
* platform/graphics/win/ImageCairoWin.cpp:
(WebCore::BitmapImage::getHBITMAPOfSize):
Source/WebKit:
Call sites of the GraphicsContext(cairo_t*) constructor are adjusted to
instead provide a factory function that returns a fresh
GraphicsContextImplCairo object, passing that cairo_t object to its
constructor.
* Shared/cairo/ShareableBitmapCairo.cpp:
(WebKit::ShareableBitmap::createGraphicsContext):
* UIProcess/cairo/BackingStoreCairo.cpp:
(WebKit::BackingStore::incorporateUpdate):
* WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp:
(WebKit::WebPrintOperationGtk::renderPage):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (227725 => 227726)
--- trunk/Source/WebCore/ChangeLog 2018-01-29 10:43:13 UTC (rev 227725)
+++ trunk/Source/WebCore/ChangeLog 2018-01-29 10:56:09 UTC (rev 227726)
@@ -1,3 +1,39 @@
+2018-01-29 Zan Dobersek <zdober...@igalia.com>
+
+ [Cairo] Remove the GraphicsContext(cairo_t*) constructor
+ https://bugs.webkit.org/show_bug.cgi?id=182234
+
+ Reviewed by Carlos Garcia Campos.
+
+ Instead of using the GraphicsContext(cairo_t*) constructor, leverage the
+ GraphicsContextImplCairo class and work with an existing Cairo context
+ through that GraphicsContextImpl implementation.
+
+ A new GraphicsContextImplCairo constructor is added, expecting pointer
+ to the cairo_t object. With that, a PlatformContextCairo object is
+ created, with ownership of that object now being handled by the
+ GraphicsContextImplCairo class.
+
+ Call sites of the GraphicsContext(cairo_t*) constructor are adjusted to
+ instead provide a factory function that returns a fresh
+ GraphicsContextImplCairo object, passing that cairo_t object to its
+ constructor.
+
+ No new tests -- no change in behavior.
+
+ * platform/graphics/GraphicsContext.h:
+ * platform/graphics/cairo/GraphicsContextCairo.cpp:
+ (WebCore::GraphicsContext::GraphicsContext): Deleted.
+ * platform/graphics/cairo/GraphicsContextImplCairo.cpp:
+ (WebCore::GraphicsContextImplCairo::GraphicsContextImplCairo):
+ (WebCore::m_private):
+ * platform/graphics/cairo/GraphicsContextImplCairo.h:
+ * platform/graphics/cairo/PathCairo.cpp:
+ (WebCore::Path::strokeBoundingRect const):
+ (WebCore::Path::strokeContains const):
+ * platform/graphics/win/ImageCairoWin.cpp:
+ (WebCore::BitmapImage::getHBITMAPOfSize):
+
2018-01-28 Minsheng Liu <lam...@liu.ms>
Overflow of formulas is hidden for display mathematics
Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.h (227725 => 227726)
--- trunk/Source/WebCore/platform/graphics/GraphicsContext.h 2018-01-29 10:43:13 UTC (rev 227725)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.h 2018-01-29 10:56:09 UTC (rev 227726)
@@ -576,10 +576,6 @@
#endif // PLATFORM(WIN)
#endif // OS(WINDOWS)
-#if USE(CAIRO)
- WEBCORE_EXPORT GraphicsContext(cairo_t*);
-#endif
-
static void adjustLineToPixelBoundaries(FloatPoint& p1, FloatPoint& p2, float strokeWidth, StrokeStyle);
bool supportsInternalLinks() const;
Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp (227725 => 227726)
--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp 2018-01-29 10:43:13 UTC (rev 227725)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp 2018-01-29 10:56:09 UTC (rev 227726)
@@ -53,15 +53,6 @@
namespace WebCore {
-GraphicsContext::GraphicsContext(cairo_t* cr)
-{
- if (!cr)
- return;
-
- m_data = new GraphicsContextPlatformPrivate(std::make_unique<PlatformContextCairo>(cr));
- m_data->platformContext.setGraphicsContextPrivate(m_data);
-}
-
void GraphicsContext::platformInit(PlatformContextCairo* platformContext)
{
if (!platformContext)
Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.cpp (227725 => 227726)
--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.cpp 2018-01-29 10:43:13 UTC (rev 227725)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.cpp 2018-01-29 10:56:09 UTC (rev 227726)
@@ -45,6 +45,16 @@
m_private->syncContext(m_platformContext.cr());
}
+GraphicsContextImplCairo::GraphicsContextImplCairo(GraphicsContext& context, cairo_t* cairoContext)
+ : GraphicsContextImpl(context, FloatRect { }, AffineTransform { })
+ , m_ownedPlatformContext(std::make_unique<PlatformContextCairo>(cairoContext))
+ , m_platformContext(*m_ownedPlatformContext)
+ , m_private(std::make_unique<GraphicsContextPlatformPrivate>(m_platformContext))
+{
+ m_platformContext.setGraphicsContextPrivate(m_private.get());
+ m_private->syncContext(m_platformContext.cr());
+}
+
GraphicsContextImplCairo::~GraphicsContextImplCairo()
{
m_platformContext.setGraphicsContextPrivate(nullptr);
Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.h (227725 => 227726)
--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.h 2018-01-29 10:43:13 UTC (rev 227725)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.h 2018-01-29 10:56:09 UTC (rev 227726)
@@ -39,6 +39,7 @@
class GraphicsContextImplCairo final : public GraphicsContextImpl {
public:
GraphicsContextImplCairo(GraphicsContext&, PlatformContextCairo&);
+ GraphicsContextImplCairo(GraphicsContext&, cairo_t*);
virtual ~GraphicsContextImplCairo();
bool hasPlatformContext() const override;
@@ -107,7 +108,9 @@
FloatRect roundToDevicePixels(const FloatRect&, GraphicsContext::RoundingMode) override;
private:
+ std::unique_ptr<PlatformContextCairo> m_ownedPlatformContext;
PlatformContextCairo& m_platformContext;
+
std::unique_ptr<GraphicsContextPlatformPrivate> m_private;
};
Modified: trunk/Source/WebCore/platform/graphics/cairo/PathCairo.cpp (227725 => 227726)
--- trunk/Source/WebCore/platform/graphics/cairo/PathCairo.cpp 2018-01-29 10:43:13 UTC (rev 227725)
+++ trunk/Source/WebCore/platform/graphics/cairo/PathCairo.cpp 2018-01-29 10:56:09 UTC (rev 227726)
@@ -30,7 +30,7 @@
#include "CairoUtilities.h"
#include "FloatRect.h"
-#include "GraphicsContext.h"
+#include "GraphicsContextImplCairo.h"
#include "PlatformPathCairo.h"
#include "StrokeStyleApplier.h"
#include <math.h>
@@ -373,7 +373,11 @@
cairo_t* cr = platformPath()->context();
if (applier) {
- GraphicsContext gc(cr);
+ GraphicsContext gc(
+ [cr](GraphicsContext& context)
+ {
+ return std::make_unique<GraphicsContextImplCairo>(context, cr);
+ });
applier->strokeStyle(&gc);
}
@@ -401,8 +405,14 @@
ASSERT(applier);
cairo_t* cr = platformPath()->context();
- GraphicsContext gc(cr);
- applier->strokeStyle(&gc);
+ {
+ GraphicsContext gc(
+ [cr](GraphicsContext& context)
+ {
+ return std::make_unique<GraphicsContextImplCairo>(context, cr);
+ });
+ applier->strokeStyle(&gc);
+ }
return cairo_in_stroke(cr, point.x(), point.y());
}
Modified: trunk/Source/WebCore/platform/graphics/win/ImageCairoWin.cpp (227725 => 227726)
--- trunk/Source/WebCore/platform/graphics/win/ImageCairoWin.cpp 2018-01-29 10:43:13 UTC (rev 227725)
+++ trunk/Source/WebCore/platform/graphics/win/ImageCairoWin.cpp 2018-01-29 10:56:09 UTC (rev 227726)
@@ -26,7 +26,7 @@
#include "config.h"
#include "Image.h"
#include "BitmapImage.h"
-#include "GraphicsContext.h"
+#include "GraphicsContextImplCairo.h"
#include "RefPtrCairo.h"
#include <cairo.h>
#include <cairo-win32.h>
@@ -75,7 +75,11 @@
cairo_t* targetRef = cairo_create(image);
cairo_surface_destroy(image);
- GraphicsContext gc(targetRef);
+ GraphicsContext gc(
+ [targetRef](GraphicsContext& context)
+ {
+ return std::make_unique<GraphicsContextImplCairo>(context, targetRef);
+ });
FloatSize imageSize = BitmapImage::size();
if (size)
Modified: trunk/Source/WebKit/ChangeLog (227725 => 227726)
--- trunk/Source/WebKit/ChangeLog 2018-01-29 10:43:13 UTC (rev 227725)
+++ trunk/Source/WebKit/ChangeLog 2018-01-29 10:56:09 UTC (rev 227726)
@@ -1,3 +1,22 @@
+2018-01-29 Zan Dobersek <zdober...@igalia.com>
+
+ [Cairo] Remove the GraphicsContext(cairo_t*) constructor
+ https://bugs.webkit.org/show_bug.cgi?id=182234
+
+ Reviewed by Carlos Garcia Campos.
+
+ Call sites of the GraphicsContext(cairo_t*) constructor are adjusted to
+ instead provide a factory function that returns a fresh
+ GraphicsContextImplCairo object, passing that cairo_t object to its
+ constructor.
+
+ * Shared/cairo/ShareableBitmapCairo.cpp:
+ (WebKit::ShareableBitmap::createGraphicsContext):
+ * UIProcess/cairo/BackingStoreCairo.cpp:
+ (WebKit::BackingStore::incorporateUpdate):
+ * WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp:
+ (WebKit::WebPrintOperationGtk::renderPage):
+
2018-01-26 Megan Gardner <megan_gard...@apple.com>
Don't retain focus for input peripheral views
Modified: trunk/Source/WebKit/Shared/cairo/ShareableBitmapCairo.cpp (227725 => 227726)
--- trunk/Source/WebKit/Shared/cairo/ShareableBitmapCairo.cpp 2018-01-29 10:43:13 UTC (rev 227725)
+++ trunk/Source/WebKit/Shared/cairo/ShareableBitmapCairo.cpp 2018-01-29 10:56:09 UTC (rev 227726)
@@ -31,7 +31,7 @@
#include <WebCore/BitmapImage.h>
#include <WebCore/CairoOperations.h>
#include <WebCore/CairoUtilities.h>
-#include <WebCore/GraphicsContext.h>
+#include <WebCore/GraphicsContextImplCairo.h>
#include <WebCore/PlatformContextCairo.h>
#include <WebCore/NotImplemented.h>
@@ -61,7 +61,10 @@
{
RefPtr<cairo_surface_t> image = createCairoSurface();
RefPtr<cairo_t> bitmapContext = adoptRef(cairo_create(image.get()));
- return std::make_unique<GraphicsContext>(bitmapContext.get());
+ return std::make_unique<GraphicsContext>(
+ [bitmapContext = WTFMove(bitmapContext)](GraphicsContext& context) {
+ return std::make_unique<GraphicsContextImplCairo>(context, bitmapContext.get());
+ });
}
void ShareableBitmap::paint(GraphicsContext& context, const IntPoint& dstPoint, const IntRect& srcRect)
Modified: trunk/Source/WebKit/UIProcess/cairo/BackingStoreCairo.cpp (227725 => 227726)
--- trunk/Source/WebKit/UIProcess/cairo/BackingStoreCairo.cpp 2018-01-29 10:43:13 UTC (rev 227725)
+++ trunk/Source/WebKit/UIProcess/cairo/BackingStoreCairo.cpp 2018-01-29 10:56:09 UTC (rev 227726)
@@ -32,7 +32,8 @@
#include "WebPageProxy.h"
#include <WebCore/BackingStoreBackendCairoImpl.h>
#include <WebCore/CairoUtilities.h>
-#include <WebCore/GraphicsContext.h>
+#include <WebCore/GraphicsContextImplCairo.h>
+#include <WebCore/PlatformContextCairo.h>
#include <WebCore/RefPtrCairo.h>
#include <cairo.h>
@@ -87,8 +88,12 @@
// Paint all update rects.
IntPoint updateRectLocation = updateInfo.updateRectBounds.location();
- RefPtr<cairo_t> context = adoptRef(cairo_create(m_backend->surface()));
- GraphicsContext graphicsContext(context.get());
+ 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());
+ });
for (const auto& updateRect : updateInfo.updateRects) {
IntRect srcRect = updateRect;
srcRect.move(-updateRectLocation.x(), -updateRectLocation.y());
Modified: trunk/Source/WebKit/WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp (227725 => 227726)
--- trunk/Source/WebKit/WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp 2018-01-29 10:43:13 UTC (rev 227725)
+++ trunk/Source/WebKit/WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp 2018-01-29 10:56:09 UTC (rev 227726)
@@ -34,6 +34,7 @@
#include <WebCore/DocumentLoader.h>
#include <WebCore/Frame.h>
#include <WebCore/FrameLoader.h>
+#include <WebCore/GraphicsContextImplCairo.h>
#include <WebCore/IntRect.h>
#include <WebCore/NotImplemented.h>
#include <WebCore/PlatformContextCairo.h>
@@ -665,8 +666,11 @@
prepareContextToDraw();
double pageWidth = gtk_page_setup_get_page_width(m_pageSetup.get(), GTK_UNIT_INCH) * m_xDPI;
- WebCore::PlatformContextCairo platformContext(m_cairoContext.get());
- WebCore::GraphicsContext graphicsContext(&platformContext);
+ WebCore::GraphicsContext graphicsContext(
+ [cairoContext = m_cairoContext.get()](WebCore::GraphicsContext& context)
+ {
+ return std::make_unique<WebCore::GraphicsContextImplCairo>(context, cairoContext);
+ });
m_printContext->spoolPage(graphicsContext, pageNumber, pageWidth / m_scale);
cairo_restore(m_cairoContext.get());