Diff
Modified: trunk/Source/WebCore/ChangeLog (175158 => 175159)
--- trunk/Source/WebCore/ChangeLog 2014-10-24 03:35:27 UTC (rev 175158)
+++ trunk/Source/WebCore/ChangeLog 2014-10-24 06:58:13 UTC (rev 175159)
@@ -1,3 +1,45 @@
+2014-10-23 Carlos Garcia Campos <[email protected]>
+
+ [GTK][Cairo] Remove GTK dependency of WidgetBackingStoreGtkX11
+ https://bugs.webkit.org/show_bug.cgi?id=138004
+
+ Reviewed by Gustavo Noronha Silva.
+
+ Rename all WidgetBackingStore* classes as
+ BackingStoreBackendCairo* since all of them are actually
+ BackingStore backends based on cairo, and move them from
+ platform/cairo and platform/gtk to platform/graphics/cairo.
+ BackingStoreBackendCairo is the base class that contains common
+ members like the surface and size. BackingStoreBackendCairoImpl is
+ the implementation using only cairo, and BackingStoreBackendCairoX11
+ using xlib. BackingStoreBackendCairoX11 receives all the X11
+ information it needs as constructor parameters, instead of using a
+ GtkWidget and GTK+ X11 API. BackingStoreBackendCairoImpl receives
+ the surface already created as constructor parameter, so that it
+ doesn't have any platform specific code now.
+
+ * PlatformEfl.cmake: Update compilation files.
+ * PlatformGTK.cmake: Ditto.
+ * platform/cairo/WidgetBackingStoreCairo.cpp: Removed.
+ * platform/graphics/cairo/BackingStoreBackendCairo.h: Renamed from Source/WebCore/platform/cairo/WidgetBackingStore.h.
+ (WebCore::BackingStoreBackendCairo::~BackingStoreBackendCairo):
+ (WebCore::BackingStoreBackendCairo::surface):
+ (WebCore::BackingStoreBackendCairo::size):
+ (WebCore::BackingStoreBackendCairo::BackingStoreBackendCairo):
+ * platform/graphics/cairo/BackingStoreBackendCairoImpl.cpp: Added.
+ (WebCore::BackingStoreBackendCairoImpl::BackingStoreBackendCairoImpl):
+ (WebCore::BackingStoreBackendCairoImpl::~BackingStoreBackendCairoImpl):
+ (WebCore::BackingStoreBackendCairoImpl::scroll):
+ * platform/graphics/cairo/BackingStoreBackendCairoImpl.h: Renamed from Source/WebCore/platform/cairo/WidgetBackingStoreCairo.h.
+ * platform/graphics/cairo/BackingStoreBackendCairoX11.cpp: Renamed from Source/WebCore/platform/gtk/WidgetBackingStoreGtkX11.cpp.
+ (WebCore::BackingStoreBackendCairoX11::BackingStoreBackendCairoX11):
+ (WebCore::BackingStoreBackendCairoX11::~BackingStoreBackendCairoX11):
+ (WebCore::BackingStoreBackendCairoX11::scroll):
+ * platform/graphics/cairo/BackingStoreBackendCairoX11.h: Renamed from Source/WebCore/platform/gtk/WidgetBackingStoreGtkX11.h.
+ * platform/graphics/cairo/CairoUtilities.cpp:
+ (WebCore::cairoSurfaceGetDeviceScale):
+ * platform/graphics/cairo/CairoUtilities.h:
+
2014-10-23 Zalan Bujtas <[email protected]>
WebContent crash at WebCore::RenderTextControl::textFormControlElement const.
Modified: trunk/Source/WebCore/PlatformEfl.cmake (175158 => 175159)
--- trunk/Source/WebCore/PlatformEfl.cmake 2014-10-24 03:35:27 UTC (rev 175158)
+++ trunk/Source/WebCore/PlatformEfl.cmake 2014-10-24 06:58:13 UTC (rev 175159)
@@ -73,8 +73,6 @@
platform/audio/gstreamer/FFTFrameGStreamer.cpp
platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp
- platform/cairo/WidgetBackingStoreCairo.cpp
-
platform/efl/BatteryProviderEfl.cpp
platform/efl/CursorEfl.cpp
platform/efl/DragDataEfl.cpp
@@ -109,6 +107,7 @@
platform/graphics/ImageSource.cpp
platform/graphics/WOFFFileFormat.cpp
+ platform/graphics/cairo/BackingStoreBackendCairoImpl.cpp
platform/graphics/cairo/BitmapImageCairo.cpp
platform/graphics/cairo/CairoUtilities.cpp
platform/graphics/cairo/DrawingBufferCairo.cpp
Modified: trunk/Source/WebCore/PlatformGTK.cmake (175158 => 175159)
--- trunk/Source/WebCore/PlatformGTK.cmake 2014-10-24 03:35:27 UTC (rev 175158)
+++ trunk/Source/WebCore/PlatformGTK.cmake 2014-10-24 06:58:13 UTC (rev 175159)
@@ -67,6 +67,8 @@
platform/graphics/OpenGLShims.cpp
platform/graphics/WOFFFileFormat.cpp
+ platform/graphics/cairo/BackingStoreBackendCairoImpl.cpp
+ platform/graphics/cairo/BackingStoreBackendCairoX11.cpp
platform/graphics/cairo/BitmapImageCairo.cpp
platform/graphics/cairo/CairoUtilities.cpp
platform/graphics/cairo/DrawingBufferCairo.cpp
@@ -197,8 +199,6 @@
page/gtk/DragControllerGtk.cpp
page/gtk/EventHandlerGtk.cpp
- platform/cairo/WidgetBackingStoreCairo.cpp
-
platform/graphics/GLContext.cpp
platform/graphics/egl/GLContextEGL.cpp
@@ -236,7 +236,6 @@
platform/gtk/ScrollbarThemeGtk.cpp
platform/gtk/SharedTimerGtk.cpp
platform/gtk/SoundGtk.cpp
- platform/gtk/WidgetBackingStoreGtkX11.cpp
platform/gtk/WidgetGtk.cpp
rendering/RenderThemeGtk.cpp
Copied: trunk/Source/WebCore/platform/graphics/cairo/BackingStoreBackendCairo.h (from rev 175158, trunk/Source/WebCore/platform/cairo/WidgetBackingStore.h) (0 => 175159)
--- trunk/Source/WebCore/platform/graphics/cairo/BackingStoreBackendCairo.h (rev 0)
+++ trunk/Source/WebCore/platform/graphics/cairo/BackingStoreBackendCairo.h 2014-10-24 06:58:13 UTC (rev 175159)
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2011,2014 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef BackingStoreBackendCairo_h
+#define BackingStoreBackendCairo_h
+
+#if USE(CAIRO)
+
+#include "IntRect.h"
+#include "RefPtrCairo.h"
+#include <wtf/FastMalloc.h>
+#include <wtf/Noncopyable.h>
+
+typedef struct _cairo_surface cairo_surface_t;
+
+namespace WebCore {
+
+class BackingStoreBackendCairo {
+ WTF_MAKE_NONCOPYABLE(BackingStoreBackendCairo);
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ virtual ~BackingStoreBackendCairo() { }
+
+ cairo_surface_t* surface() const { return m_surface.get(); }
+ const IntSize& size() const { return m_size; }
+
+ virtual void scroll(const IntRect& scrollRect, const IntSize& scrollOffset) = 0;
+
+protected:
+ BackingStoreBackendCairo(const IntSize& size)
+ : m_size(size)
+ {
+ }
+
+ RefPtr<cairo_surface_t> m_surface;
+ IntSize m_size;
+};
+
+#endif // USE(CAIRO)
+
+} // namespace WebCore
+
+#endif // BackingStoreBackendCairo_h
Added: trunk/Source/WebCore/platform/graphics/cairo/BackingStoreBackendCairoImpl.cpp (0 => 175159)
--- trunk/Source/WebCore/platform/graphics/cairo/BackingStoreBackendCairoImpl.cpp (rev 0)
+++ trunk/Source/WebCore/platform/graphics/cairo/BackingStoreBackendCairoImpl.cpp 2014-10-24 06:58:13 UTC (rev 175159)
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2011,2014 Igalia S.L.
+ * Copyright (C) 2011 Samsung Electronics
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+#include "BackingStoreBackendCairoImpl.h"
+
+#if USE(CAIRO)
+
+#include "CairoUtilities.h"
+
+namespace WebCore {
+
+BackingStoreBackendCairoImpl::BackingStoreBackendCairoImpl(cairo_surface_t* surface, const IntSize& size)
+ : BackingStoreBackendCairo(size)
+{
+ m_surface = surface;
+
+ // We keep two copies of the surface here, which will double the memory usage, but increase
+ // scrolling performance since we do not have to keep reallocating a memory region during
+ // quick scrolling requests.
+ double xScale, yScale;
+ cairoSurfaceGetDeviceScale(m_surface.get(), xScale, yScale);
+ IntSize scaledSize = size;
+ scaledSize.scale(xScale, yScale);
+ m_scrollSurface = adoptRef(cairo_surface_create_similar(surface, CAIRO_CONTENT_COLOR_ALPHA, scaledSize.width(), scaledSize.height()));
+}
+
+BackingStoreBackendCairoImpl::~BackingStoreBackendCairoImpl()
+{
+}
+
+void BackingStoreBackendCairoImpl::scroll(const IntRect& scrollRect, const IntSize& scrollOffset)
+{
+ IntRect targetRect = scrollRect;
+ targetRect.move(scrollOffset);
+ targetRect.shiftMaxXEdgeTo(targetRect.maxX() - scrollOffset.width());
+ targetRect.shiftMaxYEdgeTo(targetRect.maxY() - scrollOffset.height());
+ if (targetRect.isEmpty())
+ return;
+
+ copyRectFromOneSurfaceToAnother(m_surface.get(), m_scrollSurface.get(), scrollOffset, targetRect);
+ copyRectFromOneSurfaceToAnother(m_scrollSurface.get(), m_surface.get(), IntSize(), targetRect);
+}
+
+} // namespace WebCore
+
+#endif // USE(CAIRO)
Copied: trunk/Source/WebCore/platform/graphics/cairo/BackingStoreBackendCairoImpl.h (from rev 175158, trunk/Source/WebCore/platform/cairo/WidgetBackingStoreCairo.h) (0 => 175159)
--- trunk/Source/WebCore/platform/graphics/cairo/BackingStoreBackendCairoImpl.h (rev 0)
+++ trunk/Source/WebCore/platform/graphics/cairo/BackingStoreBackendCairoImpl.h 2014-10-24 06:58:13 UTC (rev 175159)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2013,2014 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef BackingStoreBackendCairoImpl_h
+#define BackingStoreBackendCairoImpl_h
+
+#include "BackingStoreBackendCairo.h"
+
+#if USE(CAIRO)
+
+namespace WebCore {
+
+class BackingStoreBackendCairoImpl final : public BackingStoreBackendCairo {
+public:
+ BackingStoreBackendCairoImpl(cairo_surface_t*, const IntSize&);
+ virtual ~BackingStoreBackendCairoImpl();
+
+ void scroll(const IntRect&, const IntSize&) override;
+
+private:
+ RefPtr<cairo_surface_t> m_scrollSurface;
+};
+
+} // namespace WebCore
+
+#endif // USE(CAIRO)
+
+#endif // BackingStoreBackendCairoImpl_h
Copied: trunk/Source/WebCore/platform/graphics/cairo/BackingStoreBackendCairoX11.cpp (from rev 175158, trunk/Source/WebCore/platform/gtk/WidgetBackingStoreGtkX11.cpp) (0 => 175159)
--- trunk/Source/WebCore/platform/graphics/cairo/BackingStoreBackendCairoX11.cpp (rev 0)
+++ trunk/Source/WebCore/platform/graphics/cairo/BackingStoreBackendCairoX11.cpp 2014-10-24 06:58:13 UTC (rev 175159)
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2011,2014 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+#include "BackingStoreBackendCairoX11.h"
+
+#if USE(CAIRO) && PLATFORM(X11)
+
+#include "CairoUtilities.h"
+#include <cairo-xlib.h>
+
+namespace WebCore {
+
+BackingStoreBackendCairoX11::BackingStoreBackendCairoX11(Display* display, unsigned long rootWindowID, Visual* visual, int depth, const IntSize& size, float deviceScaleFactor)
+ : BackingStoreBackendCairo(size)
+ , m_display(display)
+{
+ IntSize scaledSize = size;
+ scaledSize.scale(deviceScaleFactor);
+
+ m_pixmap = XCreatePixmap(m_display, rootWindowID, scaledSize.width(), scaledSize.height(), depth);
+ m_gc = XCreateGC(m_display, m_pixmap, 0, nullptr);
+
+ m_surface = adoptRef(cairo_xlib_surface_create(m_display, m_pixmap, visual, scaledSize.width(), scaledSize.height()));
+ cairoSurfaceSetDeviceScale(m_surface.get(), deviceScaleFactor, deviceScaleFactor);
+}
+
+BackingStoreBackendCairoX11::~BackingStoreBackendCairoX11()
+{
+ // The pixmap needs to exist when the surface is destroyed, so begin by clearing it.
+ m_surface.clear();
+ XFreePixmap(m_display, m_pixmap);
+ XFreeGC(m_display, m_gc);
+}
+
+void BackingStoreBackendCairoX11::scroll(const IntRect& scrollRect, const IntSize& scrollOffset)
+{
+ IntRect targetRect = scrollRect;
+ targetRect.move(scrollOffset);
+ targetRect.intersect(scrollRect);
+ if (targetRect.isEmpty())
+ return;
+
+ double xScale, yScale;
+ cairoSurfaceGetDeviceScale(m_surface.get(), xScale, yScale);
+ ASSERT(xScale == yScale);
+
+ IntSize scaledScrollOffset = scrollOffset;
+ targetRect.scale(xScale);
+ scaledScrollOffset.scale(xScale, yScale);
+
+ cairo_surface_flush(m_surface.get());
+ XCopyArea(m_display, m_pixmap, m_pixmap, m_gc,
+ targetRect.x() - scaledScrollOffset.width(), targetRect.y() - scaledScrollOffset.height(),
+ targetRect.width(), targetRect.height(), targetRect.x(), targetRect.y());
+ cairo_surface_mark_dirty_rectangle(m_surface.get(), targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height());
+}
+
+} // namespace WebCore
+
+#endif // USE(CAIRO) && PLATFORM(X11)
Copied: trunk/Source/WebCore/platform/graphics/cairo/BackingStoreBackendCairoX11.h (from rev 175158, trunk/Source/WebCore/platform/gtk/WidgetBackingStoreGtkX11.h) (0 => 175159)
--- trunk/Source/WebCore/platform/graphics/cairo/BackingStoreBackendCairoX11.h (rev 0)
+++ trunk/Source/WebCore/platform/graphics/cairo/BackingStoreBackendCairoX11.h 2014-10-24 06:58:13 UTC (rev 175159)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2013,2014 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef BackingStoreBackendCairoX11_h
+#define BackingStoreBackendCairoX11_h
+
+#include "BackingStoreBackendCairo.h"
+
+#if USE(CAIRO) && PLATFORM(X11)
+#include <X11/Xlib.h>
+
+namespace WebCore {
+
+class BackingStoreBackendCairoX11 final : public BackingStoreBackendCairo {
+public:
+ BackingStoreBackendCairoX11(Display*, unsigned long rootWindowID, Visual*, int depth, const IntSize&, float deviceScaleFactor);
+ virtual ~BackingStoreBackendCairoX11();
+
+ void scroll(const IntRect& scrollRect, const IntSize& scrollOffset) override;
+
+private:
+ Display* m_display;
+ Pixmap m_pixmap;
+ GC m_gc;
+};
+
+} // namespace WebCore
+
+#endif // USE(CAIRO) && PLATFORM(X11)
+
+#endif // GtkWidgetBackingStoreX11_h
Modified: trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp (175158 => 175159)
--- trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp 2014-10-24 03:35:27 UTC (rev 175158)
+++ trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp 2014-10-24 06:58:13 UTC (rev 175159)
@@ -294,4 +294,16 @@
ASSERT_UNUSED(yScale, 1 == yScale);
#endif
}
+
+void cairoSurfaceGetDeviceScale(cairo_surface_t* surface, double& xScale, double& yScale)
+{
+#if HAVE(CAIRO_SURFACE_SET_DEVICE_SCALE)
+ cairo_surface_get_device_scale(surface, &xScale, &yScale);
+#else
+ UNUSED_PARAM(surface);
+ xScale = 1;
+ yScale = 1;
+#endif
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.h (175158 => 175159)
--- trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.h 2014-10-24 03:35:27 UTC (rev 175158)
+++ trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.h 2014-10-24 06:58:13 UTC (rev 175159)
@@ -61,6 +61,7 @@
IntSize cairoSurfaceSize(cairo_surface_t*);
void flipImageSurfaceVertically(cairo_surface_t*);
void cairoSurfaceSetDeviceScale(cairo_surface_t*, double xScale, double yScale);
+void cairoSurfaceGetDeviceScale(cairo_surface_t*, double& xScale, double& yScale);
} // namespace WebCore
Deleted: trunk/Source/WebCore/platform/gtk/WidgetBackingStoreGtkX11.cpp (175158 => 175159)
--- trunk/Source/WebCore/platform/gtk/WidgetBackingStoreGtkX11.cpp 2014-10-24 03:35:27 UTC (rev 175158)
+++ trunk/Source/WebCore/platform/gtk/WidgetBackingStoreGtkX11.cpp 2014-10-24 06:58:13 UTC (rev 175159)
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) 2011, Igalia S.L.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "config.h"
-#include "WidgetBackingStoreGtkX11.h"
-
-#if PLATFORM(GTK) && PLATFORM(X11) && defined(GDK_WINDOWING_X11)
-
-#include "CairoUtilities.h"
-#include "GtkVersioning.h"
-#include "RefPtrCairo.h"
-#include <cairo-xlib.h>
-#include <cairo.h>
-#include <gdk/gdkx.h>
-
-namespace WebCore {
-
-WidgetBackingStoreGtkX11::WidgetBackingStoreGtkX11(GtkWidget* widget, const IntSize& size, float deviceScaleFactor)
- : WidgetBackingStore(size, deviceScaleFactor)
-{
- IntSize scaledSize = size;
- scaledSize.scale(deviceScaleFactor);
-
- GdkVisual* visual = gtk_widget_get_visual(widget);
- GdkScreen* screen = gdk_visual_get_screen(visual);
- m_display = GDK_SCREEN_XDISPLAY(screen);
- m_pixmap = XCreatePixmap(m_display, GDK_WINDOW_XID(gdk_screen_get_root_window(screen)),
- scaledSize.width(), scaledSize.height(), gdk_visual_get_depth(visual));
- m_gc = XCreateGC(m_display, m_pixmap, 0, 0);
-
- m_surface = adoptRef(cairo_xlib_surface_create(m_display, m_pixmap,
- GDK_VISUAL_XVISUAL(visual), scaledSize.width(), scaledSize.height()));
-
- cairoSurfaceSetDeviceScale(m_surface.get(), deviceScaleFactor, deviceScaleFactor);
-}
-
-WidgetBackingStoreGtkX11::~WidgetBackingStoreGtkX11()
-{
- // The pixmap needs to exist when the surface is destroyed, so begin by clearing it.
- m_surface.clear();
- XFreePixmap(m_display, m_pixmap);
- XFreeGC(m_display, m_gc);
-}
-
-cairo_surface_t* WidgetBackingStoreGtkX11::cairoSurface()
-{
- return m_surface.get();
-}
-
-void WidgetBackingStoreGtkX11::scroll(const IntRect& scrollRect, const IntSize& scrollOffset)
-{
- IntRect targetRect(scrollRect);
- targetRect.move(scrollOffset);
- targetRect.intersect(scrollRect);
- if (targetRect.isEmpty())
- return;
-
- targetRect.scale(m_deviceScaleFactor);
-
- IntSize scaledScrollOffset = scrollOffset;
- scaledScrollOffset.scale(m_deviceScaleFactor);
-
- cairo_surface_flush(m_surface.get());
- XCopyArea(m_display, m_pixmap, m_pixmap, m_gc,
- targetRect.x() - scaledScrollOffset.width(), targetRect.y() - scaledScrollOffset.height(),
- targetRect.width(), targetRect.height(),
- targetRect.x(), targetRect.y());
- cairo_surface_mark_dirty_rectangle(m_surface.get(),
- targetRect.x(), targetRect.y(),
- targetRect.width(), targetRect.height());
-}
-
-} // namespace WebCore
-
-#endif // PLATFORM(GTK) && PLATFORM(X11) && defined(GDK_WINDOWING_X11)
Deleted: trunk/Source/WebCore/platform/gtk/WidgetBackingStoreGtkX11.h (175158 => 175159)
--- trunk/Source/WebCore/platform/gtk/WidgetBackingStoreGtkX11.h 2014-10-24 03:35:27 UTC (rev 175158)
+++ trunk/Source/WebCore/platform/gtk/WidgetBackingStoreGtkX11.h 2014-10-24 06:58:13 UTC (rev 175159)
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2013, Igalia S.L.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef WidgetBackingStoreGtkX11_h
-#define WidgetBackingStoreGtkX11_h
-
-#include "WidgetBackingStore.h"
-#include <wtf/RefPtr.h>
-
-#if PLATFORM(GTK) && PLATFORM(X11) && defined(GDK_WINDOWING_X11)
-#include <X11/Xlib.h>
-
-namespace WebCore {
-
-class WidgetBackingStoreGtkX11 : public WidgetBackingStore {
-
-public:
- WidgetBackingStoreGtkX11(GtkWidget*, const IntSize&, float deviceScaleFactor);
- ~WidgetBackingStoreGtkX11();
- cairo_surface_t* cairoSurface();
- void scroll(const IntRect& scrollRect, const IntSize& scrollOffset);
-
-private:
- Display* m_display;
- Pixmap m_pixmap;
- GC m_gc;
- RefPtr<cairo_surface_t> m_surface;
-};
-
-} // namespace WebCore
-
-#endif // PLATFORM(GTK) && PLATFORM(X11) && defined(GDK_WINDOWING_X11)
-
-#endif // GtkWidgetBackingStoreX11_h
Modified: trunk/Source/WebKit2/ChangeLog (175158 => 175159)
--- trunk/Source/WebKit2/ChangeLog 2014-10-24 03:35:27 UTC (rev 175158)
+++ trunk/Source/WebKit2/ChangeLog 2014-10-24 06:58:13 UTC (rev 175159)
@@ -1,3 +1,22 @@
+2014-10-23 Carlos Garcia Campos <[email protected]>
+
+ [GTK][Cairo] Remove GTK dependency of WidgetBackingStoreGtkX11
+ https://bugs.webkit.org/show_bug.cgi?id=138004
+
+ Reviewed by Gustavo Noronha Silva.
+
+ * UIProcess/BackingStore.h: Rename m_backingStore as m_backend,
+ since it's a bit confusing that a BackingStore class has a
+ m_backingStore member and WidgetBackingStore has been renamed as
+ BackingStoreBackendCairo.
+ * UIProcess/cairo/BackingStoreCairo.cpp:
+ (WebKit::BackingStore::createBackend): Helper function to create
+ the BackingStore backend depending on the platform.
+ (WebKit::BackingStore::paint): Use m_backend instead of m_backingStore.
+ (WebKit::BackingStore::incorporateUpdate): Ditto.
+ (WebKit::BackingStore::scroll): Ditto.
+ (WebKit::createBackingStoreForGTK): Deleted.
+
2014-10-23 Benjamin Poulain <[email protected]>
Fix a bad find-and-replace in r175153
Modified: trunk/Source/WebKit2/UIProcess/BackingStore.h (175158 => 175159)
--- trunk/Source/WebKit2/UIProcess/BackingStore.h 2014-10-24 03:35:27 UTC (rev 175158)
+++ trunk/Source/WebKit2/UIProcess/BackingStore.h 2014-10-24 06:58:13 UTC (rev 175159)
@@ -30,8 +30,7 @@
#include <wtf/Noncopyable.h>
#if USE(CAIRO)
-#include <RefPtrCairo.h>
-#include <WebCore/WidgetBackingStore.h>
+#include <WebCore/BackingStoreBackendCairo.h>
#endif
namespace WebKit {
@@ -61,12 +60,15 @@
void incorporateUpdate(ShareableBitmap*, const UpdateInfo&);
void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset);
+#if USE(CAIRO)
+ std::unique_ptr<WebCore::BackingStoreBackendCairo> createBackend();
+#endif
+
WebCore::IntSize m_size;
float m_deviceScaleFactor;
WebPageProxy& m_webPageProxy;
-
#if USE(CAIRO)
- std::unique_ptr<WebCore::WidgetBackingStore> m_backingStore;
+ std::unique_ptr<WebCore::BackingStoreBackendCairo> m_backend;
#endif
};
Modified: trunk/Source/WebKit2/UIProcess/cairo/BackingStoreCairo.cpp (175158 => 175159)
--- trunk/Source/WebKit2/UIProcess/cairo/BackingStoreCairo.cpp 2014-10-24 03:35:27 UTC (rev 175158)
+++ trunk/Source/WebKit2/UIProcess/cairo/BackingStoreCairo.cpp 2014-10-24 06:58:13 UTC (rev 175159)
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2011 Apple Inc. All rights reserved.
- * Copyright (C) 2011 Igalia S.L.
+ * Copyright (C) 2011,2014 Igalia S.L.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -30,62 +30,69 @@
#include "ShareableBitmap.h"
#include "UpdateInfo.h"
#include "WebPageProxy.h"
+#include <WebCore/BackingStoreBackendCairoImpl.h>
+#include <WebCore/CairoUtilities.h>
#include <WebCore/GraphicsContext.h>
-#include <WebCore/WidgetBackingStoreCairo.h>
+#include <WebCore/RefPtrCairo.h>
#include <cairo.h>
#if PLATFORM(GTK) && PLATFORM(X11) && defined(GDK_WINDOWING_X11)
-#include <WebCore/WidgetBackingStoreGtkX11.h>
+#include <WebCore/BackingStoreBackendCairoX11.h>
#include <gdk/gdkx.h>
#endif
-#if PLATFORM(EFL)
-#include "EwkView.h"
-#endif
-
using namespace WebCore;
namespace WebKit {
-#if PLATFORM(GTK)
-static std::unique_ptr<WidgetBackingStore> createBackingStoreForGTK(GtkWidget* widget, const IntSize& size, float deviceScaleFactor)
+std::unique_ptr<BackingStoreBackendCairo> BackingStore::createBackend()
{
-#if PLATFORM(X11) && defined(GDK_WINDOWING_X11)
+#if PLATFORM(GTK) && defined(GDK_WINDOWING_X11)
GdkDisplay* display = gdk_display_manager_get_default_display(gdk_display_manager_get());
- if (GDK_IS_X11_DISPLAY(display))
- return std::make_unique<WidgetBackingStoreGtkX11>(widget, size, deviceScaleFactor);
+ if (GDK_IS_X11_DISPLAY(display)) {
+ GdkVisual* visual = gtk_widget_get_visual(m_webPageProxy.viewWidget());
+ GdkScreen* screen = gdk_visual_get_screen(visual);
+ return std::make_unique<BackingStoreBackendCairoX11>(GDK_SCREEN_XDISPLAY(screen), GDK_WINDOW_XID(gdk_screen_get_root_window(screen)),
+ GDK_VISUAL_XVISUAL(visual), gdk_visual_get_depth(visual), m_size, m_deviceScaleFactor);
+ }
#endif
- return std::make_unique<WidgetBackingStoreCairo>(widget, size, deviceScaleFactor);
-}
+
+ IntSize scaledSize = m_size;
+ scaledSize.scale(m_deviceScaleFactor);
+
+#if PLATFORM(GTK)
+ RefPtr<cairo_surface_t> surface = adoptRef(gdk_window_create_similar_surface(gtk_widget_get_window(m_webPageProxy.viewWidget()),
+ CAIRO_CONTENT_COLOR_ALPHA, scaledSize.width(), scaledSize.height()));
+#else
+ RefPtr<cairo_surface_t> surface = adoptRef(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, scaledSize.width(), scaledSize.height()));
#endif
+ cairoSurfaceSetDeviceScale(surface.get(), m_deviceScaleFactor, m_deviceScaleFactor);
+ return std::make_unique<BackingStoreBackendCairoImpl>(surface.get(), m_size);
+}
+
void BackingStore::paint(cairo_t* context, const IntRect& rect)
{
- ASSERT(m_backingStore);
+ ASSERT(m_backend);
cairo_set_operator(context, CAIRO_OPERATOR_SOURCE);
- cairo_set_source_surface(context, m_backingStore->cairoSurface(), 0, 0);
+ cairo_set_source_surface(context, m_backend->surface(), 0, 0);
cairo_rectangle(context, rect.x(), rect.y(), rect.width(), rect.height());
cairo_fill(context);
}
void BackingStore::incorporateUpdate(ShareableBitmap* bitmap, const UpdateInfo& updateInfo)
{
- if (!m_backingStore)
-#if PLATFORM(EFL)
- m_backingStore = std::make_unique<WidgetBackingStoreCairo>(EwkView::toEvasObject(toAPI(&m_webPageProxy)), size(), deviceScaleFactor());
-#else
- m_backingStore = createBackingStoreForGTK(m_webPageProxy.viewWidget(), size(), deviceScaleFactor());
-#endif
+ if (!m_backend)
+ m_backend = createBackend();
scroll(updateInfo.scrollRect, updateInfo.scrollOffset);
// Paint all update rects.
IntPoint updateRectLocation = updateInfo.updateRectBounds.location();
- RefPtr<cairo_t> context(adoptRef(cairo_create(m_backingStore->cairoSurface())));
+ RefPtr<cairo_t> context = adoptRef(cairo_create(m_backend->surface()));
GraphicsContext graphicsContext(context.get());
- for (size_t i = 0; i < updateInfo.updateRects.size(); ++i) {
- IntRect updateRect = updateInfo.updateRects[i];
+ for (const auto& updateRect : updateInfo.updateRects) {
IntRect srcRect = updateRect;
srcRect.move(-updateRectLocation.x(), -updateRectLocation.y());
bitmap->paint(graphicsContext, deviceScaleFactor(), updateRect.location(), srcRect);
@@ -97,8 +104,8 @@
if (scrollOffset.isZero())
return;
- ASSERT(m_backingStore);
- m_backingStore->scroll(scrollRect, scrollOffset);
+ ASSERT(m_backend);
+ m_backend->scroll(scrollRect, scrollOffset);
}
} // namespace WebKit