Changeset 169445 in webkit
- Timestamp:
- May 29, 2014 8:10:54 AM (10 years ago)
- Location:
- trunk/Source
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r169440 r169445 1 2014-05-29 Owen Taylor <otaylor@redhat.com> 2 3 [GTK] Add HighDPI support for non-accelerated compositing contents 4 https://bugs.webkit.org/show_bug.cgi?id=131562 5 6 Reviewed by Anders Carlsson. 7 8 No new tests. This will be tested once we have the proper dependencies in the WebKit testing 9 JHBuild. 10 11 * platform/cairo/WidgetBackingStore.h: 12 (WebCore::WidgetBackingStore::WidgetBackingStore): Accept a device scale argument. 13 * platform/cairo/WidgetBackingStoreCairo.cpp: Use the device scale argument to make the surface the proper size and set the surface device scale. 14 * platform/cairo/WidgetBackingStoreCairo.h: Accept a device scale argument. 15 * platform/graphics/cairo/CairoUtilities.cpp: Add a new helper to set the device scale if Cairo built against is new enough. 16 * platform/graphics/cairo/CairoUtilities.h: 17 * platform/gtk/GtkVersioning.h: Add the HAVE_GTK_SCALE_FACTOR macro. 18 * platform/gtk/WidgetBackingStoreGtkX11.cpp: Use the device scale argument to make the surface the proper size and set the surface device scale. 19 * platform/gtk/WidgetBackingStoreGtkX11.h: Accept a device scale argument. 20 1 21 2014-05-28 Brent Fulgham <bfulgham@apple.com> 2 22 -
trunk/Source/WebCore/platform/cairo/WidgetBackingStore.h
r167195 r169445 50 50 virtual void scroll(const IntRect& scrollRect, const IntSize& scrollOffset) = 0; 51 51 const IntSize& size() { return m_size; } 52 WidgetBackingStore(const IntSize& size) : m_size(size) { } 52 53 WidgetBackingStore(const IntSize& size, float deviceScaleFactor) 54 : m_size(size) 55 , m_deviceScaleFactor(deviceScaleFactor) 56 { } 57 53 58 virtual ~WidgetBackingStore() { } 54 59 55 pr ivate:60 protected: 56 61 IntSize m_size; 62 float m_deviceScaleFactor; 57 63 }; 58 64 -
trunk/Source/WebCore/platform/cairo/WidgetBackingStoreCairo.cpp
r167195 r169445 27 27 namespace WebCore { 28 28 29 static PassRefPtr<cairo_surface_t> createSurfaceForBackingStore(PlatformWidget widget, const IntSize& size)29 static PassRefPtr<cairo_surface_t> createSurfaceForBackingStore(PlatformWidget widget, IntSize size, float deviceScaleFactor) 30 30 { 31 size.scale(deviceScaleFactor); 32 31 33 #if PLATFORM(GTK) 32 34 return adoptRef(gdk_window_create_similar_surface(gtk_widget_get_window(widget), CAIRO_CONTENT_COLOR_ALPHA, size.width(), size.height())); … … 37 39 } 38 40 39 PassOwnPtr<WidgetBackingStore> WidgetBackingStoreCairo::create(PlatformWidget widget, const IntSize& size )41 PassOwnPtr<WidgetBackingStore> WidgetBackingStoreCairo::create(PlatformWidget widget, const IntSize& size, float deviceScaleFactor) 40 42 { 41 return adoptPtr(new WidgetBackingStoreCairo(widget, size ));43 return adoptPtr(new WidgetBackingStoreCairo(widget, size, deviceScaleFactor)); 42 44 } 43 45 … … 45 47 // scrolling performance since we do not have to keep reallocating a memory region during 46 48 // quick scrolling requests. 47 WidgetBackingStoreCairo::WidgetBackingStoreCairo(PlatformWidget widget, const IntSize& size) 48 : WidgetBackingStore(size) 49 , m_surface(createSurfaceForBackingStore(widget, size)) 50 , m_scrollSurface(createSurfaceForBackingStore(widget, size)) 51 49 WidgetBackingStoreCairo::WidgetBackingStoreCairo(PlatformWidget widget, const IntSize& size, float deviceScaleFactor) 50 : WidgetBackingStore(size, deviceScaleFactor) 51 , m_surface(createSurfaceForBackingStore(widget, size, deviceScaleFactor)) 52 , m_scrollSurface(createSurfaceForBackingStore(widget, size, deviceScaleFactor)) 52 53 { 54 cairoSurfaceSetDeviceScale(m_surface.get(), deviceScaleFactor, deviceScaleFactor); 53 55 } 54 56 -
trunk/Source/WebCore/platform/cairo/WidgetBackingStoreCairo.h
r167195 r169445 28 28 29 29 public: 30 static PassOwnPtr<WidgetBackingStore> create(PlatformWidget, const IntSize& );31 WidgetBackingStoreCairo(PlatformWidget, const IntSize& );30 static PassOwnPtr<WidgetBackingStore> create(PlatformWidget, const IntSize&, float deviceScaleFactor); 31 WidgetBackingStoreCairo(PlatformWidget, const IntSize&, float deviceScaleFactor); 32 32 ~WidgetBackingStoreCairo(); 33 33 cairo_surface_t* cairoSurface(); -
trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp
r167342 r169445 37 37 #include "PlatformPathCairo.h" 38 38 #include "RefPtrCairo.h" 39 #include <wtf/Assertions.h> 39 40 #include <wtf/Vector.h> 40 41 … … 283 284 } 284 285 286 void cairoSurfaceSetDeviceScale(cairo_surface_t* surface, double xScale, double yScale) 287 { 288 // This function was added pretty much simultaneous to when 1.13 was branched. 289 #if HAVE(CAIRO_SURFACE_SET_DEVICE_SCALE) 290 cairo_surface_set_device_scale(surface, xScale, yScale); 291 #else 292 UNUSED_PARAM(surface); 293 ASSERT_UNUSED(xScale, 1 == xScale); 294 ASSERT_UNUSED(yScale, 1 == yScale); 295 #endif 296 } 285 297 } // namespace WebCore -
trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.h
r167342 r169445 32 32 #include <cairo.h> 33 33 34 // This function was added pretty much simultaneous to when 1.13 was branched. 35 #define HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE CAIRO_VERSION_MAJOR > 1 || (CAIRO_VERSION_MAJOR == 1 && CAIRO_VERSION_MINOR >= 13) 36 34 37 namespace WebCore { 35 38 class AffineTransform; … … 58 61 IntSize cairoSurfaceSize(cairo_surface_t*); 59 62 void flipImageSurfaceVertically(cairo_surface_t*); 63 void cairoSurfaceSetDeviceScale(cairo_surface_t*, double xScale, double yScale); 60 64 61 65 } // namespace WebCore -
trunk/Source/WebCore/platform/gtk/WidgetBackingStoreGtkX11.cpp
r167195 r169445 20 20 #include "WidgetBackingStoreGtkX11.h" 21 21 22 #include "CairoUtilities.h" 22 23 #include "GtkVersioning.h" 23 24 #include "RefPtrCairo.h" … … 28 29 namespace WebCore { 29 30 30 PassOwnPtr<WidgetBackingStore> WidgetBackingStoreGtkX11::create(GtkWidget* widget, const IntSize& size )31 PassOwnPtr<WidgetBackingStore> WidgetBackingStoreGtkX11::create(GtkWidget* widget, const IntSize& size, float deviceScaleFactor) 31 32 { 32 return adoptPtr(new WidgetBackingStoreGtkX11(widget, size ));33 return adoptPtr(new WidgetBackingStoreGtkX11(widget, size, deviceScaleFactor)); 33 34 } 34 35 35 WidgetBackingStoreGtkX11::WidgetBackingStoreGtkX11(GtkWidget* widget, const IntSize& size )36 : WidgetBackingStore(size )36 WidgetBackingStoreGtkX11::WidgetBackingStoreGtkX11(GtkWidget* widget, const IntSize& size, float deviceScaleFactor) 37 : WidgetBackingStore(size, deviceScaleFactor) 37 38 { 39 IntSize scaledSize = size; 40 scaledSize.scale(deviceScaleFactor); 41 38 42 GdkVisual* visual = gtk_widget_get_visual(widget); 39 43 GdkScreen* screen = gdk_visual_get_screen(visual); 40 44 m_display = GDK_SCREEN_XDISPLAY(screen); 41 45 m_pixmap = XCreatePixmap(m_display, GDK_WINDOW_XID(gdk_screen_get_root_window(screen)), 42 s ize.width(), size.height(), gdk_visual_get_depth(visual));46 scaledSize.width(), scaledSize.height(), gdk_visual_get_depth(visual)); 43 47 m_gc = XCreateGC(m_display, m_pixmap, 0, 0); 44 48 45 49 m_surface = adoptRef(cairo_xlib_surface_create(m_display, m_pixmap, 46 GDK_VISUAL_XVISUAL(visual), size.width(), size.height())); 50 GDK_VISUAL_XVISUAL(visual), scaledSize.width(), scaledSize.height())); 51 52 cairoSurfaceSetDeviceScale(m_surface.get(), deviceScaleFactor, deviceScaleFactor); 47 53 } 48 54 … … 68 74 return; 69 75 76 targetRect.scale(m_deviceScaleFactor); 77 78 IntSize scaledScrollOffset = scrollOffset; 79 scaledScrollOffset.scale(m_deviceScaleFactor); 80 70 81 cairo_surface_flush(m_surface.get()); 71 82 XCopyArea(m_display, m_pixmap, m_pixmap, m_gc, 72 targetRect.x() - sc rollOffset.width(), targetRect.y() - scrollOffset.height(),83 targetRect.x() - scaledScrollOffset.width(), targetRect.y() - scaledScrollOffset.height(), 73 84 targetRect.width(), targetRect.height(), 74 85 targetRect.x(), targetRect.y()); -
trunk/Source/WebCore/platform/gtk/WidgetBackingStoreGtkX11.h
r167195 r169445 30 30 31 31 public: 32 static PassOwnPtr<WidgetBackingStore> create(GtkWidget*, const IntSize& );33 WidgetBackingStoreGtkX11(GtkWidget*, const IntSize& );32 static PassOwnPtr<WidgetBackingStore> create(GtkWidget*, const IntSize&, float deviceScaleFactor); 33 WidgetBackingStoreGtkX11(GtkWidget*, const IntSize&, float deviceScaleFactor); 34 34 ~WidgetBackingStoreGtkX11(); 35 35 cairo_surface_t* cairoSurface(); -
trunk/Source/WebKit2/ChangeLog
r169444 r169445 1 2014-05-29 Owen Taylor <otaylor@redhat.com> 2 3 [GTK] Add HighDPI support for non-accelerated compositing contents 4 https://bugs.webkit.org/show_bug.cgi?id=131562 5 6 Reviewed by Anders Carlsson. 7 8 * UIProcess/API/gtk/WebKitWebViewBase.cpp: 9 (deviceScaleFactorChanged): Added this callback to pass scale changes to the page proxy. 10 (webkitWebViewBaseCreateWebPage): Attach the callback to the notify signal. 11 * UIProcess/WebPageProxy.cpp: 12 * UIProcess/cairo/BackingStoreCairo.cpp: 13 (WebKit::WebPageProxy::setCustomDeviceScaleFactor): Do not set a 14 custom device scale factor for cairo when it's not supported. 15 (WebKit::createBackingStoreForGTK): Pass the scale factor to the WebCore backing store. 16 (WebKit::BackingStore::incorporateUpdate): Ditto. 17 1 18 2014-05-28 Carlos Garcia Campos <cgarcia@igalia.com> 2 19 -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp
r169439 r169445 47 47 #include "WebPreferences.h" 48 48 #include "WebViewBaseInputMethodFilter.h" 49 #include <WebCore/CairoUtilities.h> 49 50 #include <WebCore/ClipboardUtilitiesGtk.h> 50 51 #include <WebCore/DataObjectGtk.h> … … 78 79 #include <WebCore/RedirectedXCompositeWindow.h> 79 80 #endif 81 82 // gtk_widget_get_scale_factor() appeared in GTK 3.10, but we also need 83 // to make sure we have cairo new enough to support cairo_surface_set_device_scale 84 #define HAVE_GTK_SCALE_FACTOR HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE && GTK_CHECK_VERSION(3, 10, 0) 80 85 81 86 using namespace WebKit; … … 966 971 } 967 972 973 #if HAVE(GTK_SCALE_FACTOR) 974 static void deviceScaleFactorChanged(WebKitWebViewBase* webkitWebViewBase) 975 { 976 webkitWebViewBase->priv->pageProxy->setIntrinsicDeviceScaleFactor(gtk_widget_get_scale_factor(GTK_WIDGET(webkitWebViewBase))); 977 } 978 #endif // HAVE(GTK_SCALE_FACTOR) 979 968 980 void webkitWebViewBaseCreateWebPage(WebKitWebViewBase* webkitWebViewBase, WebContext* context, WebPageGroup* pageGroup, WebPageProxy* relatedPage) 969 981 { … … 979 991 if (priv->redirectedWindow) 980 992 priv->pageProxy->setAcceleratedCompositingWindowId(priv->redirectedWindow->windowId()); 993 #endif 994 995 #if HAVE(GTK_SCALE_FACTOR) 996 // We attach this here, because changes in scale factor are passed directly to the page proxy. 997 priv->pageProxy->setIntrinsicDeviceScaleFactor(gtk_widget_get_scale_factor(GTK_WIDGET(webkitWebViewBase))); 998 g_signal_connect(webkitWebViewBase, "notify::scale-factor", G_CALLBACK(deviceScaleFactorChanged), nullptr); 981 999 #endif 982 1000 -
trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp
r169439 r169445 140 140 #endif 141 141 142 #if USE(CAIRO) 143 #include <WebCore/CairoUtilities.h> 144 #endif 145 142 146 // This controls what strategy we use for mouse wheel coalescing. 143 147 #define MERGE_WHEEL_EVENTS 1 … … 1845 1849 if (!isValid()) 1846 1850 return; 1851 1852 // FIXME: Remove this once we bump cairo requirements to support HiDPI. 1853 // https://bugs.webkit.org/show_bug.cgi?id=133378 1854 #if USE(CAIRO) && !HAVE(CAIRO_SURFACE_SET_DEVICE_SCALE) 1855 return; 1856 #endif 1847 1857 1848 1858 if (m_customDeviceScaleFactor == customScaleFactor) -
trunk/Source/WebKit2/UIProcess/cairo/BackingStoreCairo.cpp
r167195 r169445 49 49 50 50 #if PLATFORM(GTK) 51 static OwnPtr<WidgetBackingStore> createBackingStoreForGTK(GtkWidget* widget, const IntSize& size )51 static OwnPtr<WidgetBackingStore> createBackingStoreForGTK(GtkWidget* widget, const IntSize& size, float deviceScaleFactor) 52 52 { 53 53 #if PLATFORM(X11) && defined(GDK_WINDOWING_X11) 54 54 GdkDisplay* display = gdk_display_manager_get_default_display(gdk_display_manager_get()); 55 55 if (GDK_IS_X11_DISPLAY(display)) 56 return WebCore::WidgetBackingStoreGtkX11::create(widget, size );56 return WebCore::WidgetBackingStoreGtkX11::create(widget, size, deviceScaleFactor); 57 57 #endif 58 return WebCore::WidgetBackingStoreCairo::create(widget, size );58 return WebCore::WidgetBackingStoreCairo::create(widget, size, deviceScaleFactor); 59 59 } 60 60 #endif … … 74 74 if (!m_backingStore) 75 75 #if PLATFORM(EFL) 76 m_backingStore = WidgetBackingStoreCairo::create(EwkView::toEvasObject(toAPI(m_webPageProxy)), size() );76 m_backingStore = WidgetBackingStoreCairo::create(EwkView::toEvasObject(toAPI(m_webPageProxy)), size(), deviceScaleFactor()); 77 77 #else 78 m_backingStore = createBackingStoreForGTK(m_webPageProxy->viewWidget(), size() );78 m_backingStore = createBackingStoreForGTK(m_webPageProxy->viewWidget(), size(), deviceScaleFactor()); 79 79 #endif 80 80 … … 89 89 IntRect srcRect = updateRect; 90 90 srcRect.move(-updateRectLocation.x(), -updateRectLocation.y()); 91 bitmap->paint(graphicsContext, updateRect.location(), srcRect);91 bitmap->paint(graphicsContext, deviceScaleFactor(), updateRect.location(), srcRect); 92 92 } 93 93 }
Note: See TracChangeset
for help on using the changeset viewer.