Changeset 183731 in webkit
- Timestamp:
- May 3, 2015 8:20:34 AM (9 years ago)
- Location:
- trunk/Source
- Files:
-
- 5 added
- 14 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r183729 r183731 1 2015-05-03 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK][EFL] Unify platform display handling 4 https://bugs.webkit.org/show_bug.cgi?id=144517 5 6 Reviewed by Martin Robinson. 7 8 There are several places were we are handling the X display 9 connection: 10 11 - GLContext::sharedX11Display() creates a new connection. 12 - X11Helper::nativeDisplay() creates a new connection. 13 - BackingStoreBackendCairoX11 uses the GTK+ shared connection. 14 - NetscapePlugin::x11HostDisplay() uses the GTK+/ecore shared connection 15 - The rest of the GTK+ code uses the shared GTK+ connection 16 17 And then we also have WaylandDisplay and the code to check if the 18 current display is wayland or X11. 19 We could unify all these to share the same connection to reduce 20 the amount of ifdefs and ensure a single connection. That will 21 also allow us to use "smart pointers" for the X resources that 22 need a Display* to be freed. 23 24 * PlatformEfl.cmake: Add new files to compilation. 25 * PlatformGTK.cmake: Move some files to WebCore_SOURCES sinc ethey 26 don't use GTK+ anymore, and add new files to compilation. 27 * platform/graphics/GLContext.cpp: 28 (WebCore::GLContext::cleanupActiveContextsAtExit): Remove the 29 custom X11 connection. 30 (WebCore::GLContext::createContextForWindow): Check if the shared 31 display is Wayland to create a EGL context in such case. 32 * platform/graphics/PlatformDisplay.cpp: Added. 33 (WebCore::PlatformDisplay::createPlatformDisplay): Creates the 34 shared display, using the GTK+/ecore shared connection. 35 (WebCore::PlatformDisplay::sharedDisplay): Return the shared display. 36 * platform/graphics/PlatformDisplay.h: Added. 37 * platform/graphics/egl/GLContextEGL.cpp: 38 (WebCore::sharedEGLDisplay): Use PlatformDisplay::sharedDisplay() 39 to get the native display. 40 (WebCore::GLContextEGL::createPixmapContext): Ditto. 41 * platform/graphics/glx/GLContextGLX.cpp: 42 (WebCore::GLContextGLX::createWindowContext): Ditto. 43 (WebCore::GLContextGLX::createPbufferContext): Ditto. 44 (WebCore::GLContextGLX::createPixmapContext): Ditto. 45 (WebCore::GLContextGLX::createContext): Ditto. 46 (WebCore::GLContextGLX::~GLContextGLX): Ditto. 47 (WebCore::GLContextGLX::defaultFrameBufferSize): Ditto. 48 (WebCore::GLContextGLX::makeContextCurrent): Ditto. 49 (WebCore::GLContextGLX::swapBuffers): Ditto. 50 (WebCore::GLContextGLX::cairoDevice): Ditto. 51 * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp: 52 (WebCore::MediaPlayerPrivateGStreamerBase::ensureGstGLContext): Ditto. 53 * platform/graphics/surfaces/glx/X11Helper.cpp: 54 (WebCore::X11Helper::nativeDisplay): Ditto. 55 * platform/graphics/wayland/PlatformDisplayWayland.cpp: Renamed from Source/WebCore/platform/graphics/wayland/WaylandDisplay.cpp. 56 (WebCore::PlatformDisplayWayland::globalCallback): 57 (WebCore::PlatformDisplayWayland::globalRemoveCallback): 58 (WebCore::PlatformDisplayWayland::create): Renamed instance() as 59 create() since the single instance is now handled by PlatformDisplay. 60 (WebCore::PlatformDisplayWayland::PlatformDisplayWayland): 61 (WebCore::PlatformDisplayWayland::createSurface): 62 (WebCore::PlatformDisplayWayland::createSharingGLContext): 63 * platform/graphics/wayland/PlatformDisplayWayland.h: Renamed from Source/WebCore/platform/graphics/wayland/WaylandDisplay.h. 64 * platform/graphics/x11/PlatformDisplayX11.cpp: Added. 65 (WebCore::PlatformDisplayX11::PlatformDisplayX11): 66 (WebCore::PlatformDisplayX11::~PlatformDisplayX11): 67 * platform/graphics/x11/PlatformDisplayX11.h: Added. 68 * platform/gtk/GtkUtilities.cpp: 69 (WebCore::getDisplaySystemType): Deleted. 70 * platform/gtk/GtkUtilities.h: 71 1 72 2015-05-03 Carlos Garcia Campos <cgarcia@igalia.com> 2 73 -
trunk/Source/WebCore/PlatformEfl.cmake
r183697 r183731 18 18 "${WEBCORE_DIR}/platform/graphics/texmap" 19 19 "${WEBCORE_DIR}/platform/graphics/texmap/coordinated" 20 "${WEBCORE_DIR}/platform/graphics/x11" 20 21 "${WEBCORE_DIR}/platform/linux" 21 22 "${WEBCORE_DIR}/platform/mediastream/openwebrtc" … … 108 109 109 110 platform/graphics/ImageSource.cpp 111 platform/graphics/PlatformDisplay.cpp 110 112 platform/graphics/WOFFFileFormat.cpp 111 113 … … 195 197 platform/graphics/texmap/coordinated/TiledBackingStore.cpp 196 198 platform/graphics/texmap/coordinated/UpdateAtlas.cpp 199 200 platform/graphics/x11/PlatformDisplayX11.cpp 197 201 198 202 platform/image-decoders/ImageDecoder.cpp -
trunk/Source/WebCore/PlatformGTK.cmake
r183697 r183731 18 18 "${WEBCORE_DIR}/platform/graphics/opentype" 19 19 "${WEBCORE_DIR}/platform/graphics/wayland" 20 "${WEBCORE_DIR}/platform/graphics/x11" 20 21 "${WEBCORE_DIR}/platform/linux" 21 22 "${WEBCORE_DIR}/platform/mediastream/openwebrtc" … … 64 65 platform/geoclue/GeolocationProviderGeoclue2.cpp 65 66 67 platform/graphics/GLContext.cpp 66 68 platform/graphics/GraphicsContext3DPrivate.cpp 67 69 platform/graphics/ImageSource.cpp … … 88 90 platform/graphics/cairo/TransformationMatrixCairo.cpp 89 91 92 platform/graphics/egl/GLContextEGL.cpp 93 90 94 platform/graphics/freetype/FontCacheFreeType.cpp 91 95 platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp 92 96 platform/graphics/freetype/GlyphPageTreeNodeFreeType.cpp 93 97 platform/graphics/freetype/SimpleFontDataFreeType.cpp 98 99 platform/graphics/glx/GLContextGLX.cpp 94 100 95 101 platform/graphics/gstreamer/AudioTrackPrivateGStreamer.cpp … … 120 126 platform/graphics/opentype/OpenTypeVerticalData.cpp 121 127 128 platform/graphics/x11/PlatformDisplayX11.cpp 129 122 130 platform/gtk/ErrorsGtk.cpp 123 131 platform/gtk/EventLoopGtk.cpp … … 192 200 page/gtk/EventHandlerGtk.cpp 193 201 194 platform/graphics/GLContext.cpp 195 196 platform/graphics/egl/GLContextEGL.cpp 202 platform/graphics/PlatformDisplay.cpp 197 203 198 204 platform/graphics/freetype/FontPlatformDataFreeType.cpp 199 200 platform/graphics/glx/GLContextGLX.cpp201 205 202 206 platform/graphics/gtk/ColorGtk.cpp … … 473 477 if (ENABLE_WAYLAND_TARGET) 474 478 list(APPEND WebCorePlatformGTK_SOURCES 475 platform/graphics/wayland/ WaylandDisplay.cpp479 platform/graphics/wayland/PlatformDisplayWayland.cpp 476 480 platform/graphics/wayland/WaylandEventSource.cpp 477 481 platform/graphics/wayland/WaylandSurface.cpp -
trunk/Source/WebCore/platform/graphics/GLContext.cpp
r183639 r183731 23 23 #include "GLContext.h" 24 24 25 #include "PlatformDisplay.h" 26 #include <wtf/ThreadSpecific.h> 27 25 28 #if USE(EGL) 26 29 #include "GLContextEGL.h" … … 29 32 #if USE(GLX) 30 33 #include "GLContextGLX.h" 31 #endif32 33 #include <wtf/ThreadSpecific.h>34 35 #if PLATFORM(X11)36 #include <X11/Xlib.h>37 #endif38 39 #if PLATFORM(GTK)40 #include <gdk/gdk.h>41 #if PLATFORM(WAYLAND) && !defined(GTK_API_VERSION_2) && defined(GDK_WINDOWING_WAYLAND)42 #include <gdk/gdkwayland.h>43 #endif44 34 #endif 45 35 … … 75 65 76 66 #if PLATFORM(X11) 77 // We do not want to call glXMakeContextCurrent using different Display pointers,78 // because it might lead to crashes in some drivers (fglrx). We use a shared display79 // pointer here.80 static Display* gSharedX11Display = 0;81 Display* GLContext::sharedX11Display()82 {83 if (!gSharedX11Display)84 gSharedX11Display = XOpenDisplay(0);85 return gSharedX11Display;86 }87 88 void GLContext::cleanupSharedX11Display()89 {90 if (!gSharedX11Display)91 return;92 XCloseDisplay(gSharedX11Display);93 gSharedX11Display = 0;94 }95 96 67 // Because of driver bugs, exiting the program when there are active pbuffers 97 68 // can crash the X server (this has been observed with the official Nvidia drivers). … … 138 109 for (size_t i = 0; i < contextList.size(); ++i) 139 110 delete contextList[i]; 140 141 cleanupSharedX11Display();142 111 } 143 112 #endif // PLATFORM(X11) … … 146 115 std::unique_ptr<GLContext> GLContext::createContextForWindow(GLNativeWindowType windowHandle, GLContext* sharingContext) 147 116 { 148 #if PLATFORM(GTK) && PLATFORM(WAYLAND) && !defined(GTK_API_VERSION_2) && defined(GDK_WINDOWING_WAYLAND) && USE(EGL) 149 GdkDisplay* display = gdk_display_manager_get_default_display(gdk_display_manager_get()); 150 151 if (GDK_IS_WAYLAND_DISPLAY(display)) { 117 #if PLATFORM(WAYLAND) && USE(EGL) 118 if (PlatformDisplay::sharedDisplay().type() == PlatformDisplay::Type::Wayland) { 152 119 if (auto eglContext = GLContextEGL::createContext(windowHandle, sharingContext)) 153 120 return WTF::move(eglContext); -
trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp
r183432 r183731 35 35 #endif 36 36 37 #if PLATFORM(GTK) 38 #include "GtkUtilities.h" 39 #if PLATFORM(WAYLAND) && !defined(GTK_API_VERSION_2) 40 #include "WaylandDisplay.h" 41 #endif 37 #if PLATFORM(X11) 38 #include "PlatformDisplayX11.h" 39 #endif 40 41 #if PLATFORM(WAYLAND) 42 #include "PlatformDisplayWayland.h" 42 43 #endif 43 44 … … 65 66 if (!initialized) { 66 67 initialized = true; 67 #if PLATFORM(GTK) && PLATFORM(WAYLAND) && !defined(GTK_API_VERSION_2) 68 if (getDisplaySystemType() == DisplaySystemType::Wayland && WaylandDisplay::instance()) 69 gSharedEGLDisplay = eglGetDisplay(WaylandDisplay::instance()->nativeDisplay()); 68 69 const auto& sharedDisplay = PlatformDisplay::sharedDisplay(); 70 #if PLATFORM(WAYLAND) 71 if (is<PlatformDisplayWayland>(sharedDisplay)) 72 gSharedEGLDisplay = eglGetDisplay(downcast<PlatformDisplayWayland>(sharedDisplay).native()); 70 73 else // Note that this branch continutes outside this #if-guarded segment. 71 74 #endif 72 75 #if PLATFORM(X11) 73 gSharedEGLDisplay = eglGetDisplay( GLContext::sharedX11Display());76 gSharedEGLDisplay = eglGetDisplay(downcast<PlatformDisplayX11>(sharedDisplay).native()); 74 77 #else 75 78 gSharedEGLDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); … … 187 190 return nullptr; 188 191 189 Pixmap pixmap = XCreatePixmap(sharedX11Display(), DefaultRootWindow(sharedX11Display()), 1, 1, depth); 192 Display* x11Display = downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native(); 193 Pixmap pixmap = XCreatePixmap(x11Display, DefaultRootWindow(x11Display), 1, 1, depth); 190 194 if (!pixmap) 191 195 return nullptr; -
trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.cpp
r183432 r183731 23 23 #include "GraphicsContext3D.h" 24 24 #include "OpenGLShims.h" 25 #include "PlatformDisplayX11.h" 25 26 #include <GL/glx.h> 26 27 #include <cairo.h> … … 34 35 std::unique_ptr<GLContextGLX> GLContextGLX::createWindowContext(XID window, GLContext* sharingContext) 35 36 { 36 Display* display = sharedX11Display();37 Display* display = downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native(); 37 38 XWindowAttributes attributes; 38 39 if (!XGetWindowAttributes(display, window, &attributes)) … … 73 74 74 75 int returnedElements; 75 Display* display = sharedX11Display();76 Display* display = downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native(); 76 77 GLXFBConfig* configs = glXChooseFBConfig(display, 0, fbConfigAttributes, &returnedElements); 77 78 if (!returnedElements) { … … 113 114 }; 114 115 115 Display* display = sharedX11Display();116 Display* display = downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native(); 116 117 XVisualInfo* visualInfo = glXChooseVisual(display, DefaultScreen(display), visualAttributes); 117 118 if (!visualInfo) … … 143 144 std::unique_ptr<GLContextGLX> GLContextGLX::createContext(XID window, GLContext* sharingContext) 144 145 { 145 if (!sharedX11Display())146 return nullptr;147 148 146 static bool initialized = false; 149 147 static bool success = true; … … 192 190 cairo_device_destroy(m_cairoDevice); 193 191 192 Display* display = downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native(); 194 193 if (m_context) { 195 194 // This may be necessary to prevent crashes with NVidia's closed source drivers. Originally 196 195 // from Mozilla's 3D canvas implementation at: http://bitbucket.org/ilmari/canvas3d/ 197 196 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 198 glXMakeCurrent( sharedX11Display(), None, None);199 glXDestroyContext( sharedX11Display(), m_context);197 glXMakeCurrent(display, None, None); 198 glXDestroyContext(display, m_context); 200 199 } 201 200 202 201 if (m_pbuffer) { 203 glXDestroyPbuffer( sharedX11Display(), m_pbuffer);202 glXDestroyPbuffer(display, m_pbuffer); 204 203 m_pbuffer = 0; 205 204 } 206 205 if (m_glxPixmap) { 207 glXDestroyGLXPixmap( sharedX11Display(), m_glxPixmap);206 glXDestroyGLXPixmap(display, m_glxPixmap); 208 207 m_glxPixmap = 0; 209 208 } 210 209 if (m_pixmap) { 211 XFreePixmap( sharedX11Display(), m_pixmap);210 XFreePixmap(display, m_pixmap); 212 211 m_pixmap = 0; 213 212 } … … 227 226 Window rootWindow; 228 227 unsigned int width, height, borderWidth, depth; 229 if (!XGetGeometry(sharedX11Display(), m_window, &rootWindow, &x, &y, &width, &height, &borderWidth, &depth)) 228 Display* display = downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native(); 229 if (!XGetGeometry(display, m_window, &rootWindow, &x, &y, &width, &height, &borderWidth, &depth)) 230 230 return IntSize(); 231 231 … … 241 241 return true; 242 242 243 Display* display = downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native(); 243 244 if (m_window) 244 return glXMakeCurrent( sharedX11Display(), m_window, m_context);245 return glXMakeCurrent(display, m_window, m_context); 245 246 246 247 if (m_pbuffer) 247 return glXMakeCurrent( sharedX11Display(), m_pbuffer, m_context);248 249 return ::glXMakeCurrent( sharedX11Display(), m_glxPixmap, m_context);248 return glXMakeCurrent(display, m_pbuffer, m_context); 249 250 return ::glXMakeCurrent(display, m_glxPixmap, m_context); 250 251 } 251 252 … … 253 254 { 254 255 if (m_window) 255 glXSwapBuffers( sharedX11Display(), m_window);256 glXSwapBuffers(downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native(), m_window); 256 257 } 257 258 … … 267 268 268 269 #if ENABLE(ACCELERATED_2D_CANVAS) 269 m_cairoDevice = cairo_glx_device_create( sharedX11Display(), m_context);270 m_cairoDevice = cairo_glx_device_create(downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native(), m_context); 270 271 #endif 271 272 -
trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp
r182229 r183731 72 72 #endif 73 73 74 #if PLATFORM(X11) 75 #include "PlatformDisplayX11.h" 76 #elif PLATFORM(WAYLAND) 77 #include "PlatformDisplayWayland.h" 78 #endif 79 74 80 // gstglapi.h may include eglplatform.h and it includes X.h, which 75 81 // defines None, breaking MediaPlayer::None enum … … 229 235 230 236 if (!m_glDisplay) { 237 const auto& sharedDisplay = PlatformDisplay::sharedDisplay(); 231 238 #if PLATFORM(X11) 232 Display* display = GLContext::sharedX11Display(); 233 m_glDisplay = GST_GL_DISPLAY(gst_gl_display_x11_new_with_display(display)); 239 m_glDisplay = GST_GL_DISPLAY(gst_gl_display_x11_new_with_display(downcast<PlatformDisplayX11>(sharedDisplay).native())); 234 240 #elif PLATFORM(WAYLAND) 235 EGLDisplay display = WaylandDisplay::instance()->eglDisplay(); 236 m_glDisplay = GST_GL_DISPLAY(gst_gl_display_egl_new_with_egl_display(display)); 241 m_glDisplay = GST_GL_DISPLAY(gst_gl_display_egl_new_with_egl_display(downcast<PlatformDisplayWayland>(sharedDisplay).native())); 237 242 #endif 238 243 } -
trunk/Source/WebCore/platform/graphics/surfaces/glx/X11Helper.cpp
r183265 r183731 27 27 #include "X11Helper.h" 28 28 29 #include "PlatformDisplayX11.h" 30 29 31 namespace WebCore { 30 32 … … 54 56 } 55 57 56 struct DisplayConnection {57 DisplayConnection()58 {59 m_display = XOpenDisplay(0);60 61 if (!m_display)62 LOG_ERROR("Failed to make connection with X");63 }64 65 ~DisplayConnection()66 {67 XCloseDisplay(m_display);68 }69 70 Display* display() { return m_display; }71 private:72 Display* m_display;73 };74 75 58 struct OffScreenRootWindow { 76 59 … … 332 315 Display* X11Helper::nativeDisplay() 333 316 { 334 // Display connection will only be broken at program shutdown. 335 static DisplayConnection displayConnection; 336 return displayConnection.display(); 317 return downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native(); 337 318 } 338 319 -
trunk/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.cpp
r183730 r183731 25 25 26 26 #include "config.h" 27 #include " WaylandDisplay.h"27 #include "PlatformDisplayWayland.h" 28 28 29 29 #if PLATFORM(WAYLAND) … … 36 36 namespace WebCore { 37 37 38 const struct wl_registry_listener WaylandDisplay::m_registryListener = {39 WaylandDisplay::globalCallback,40 WaylandDisplay::globalRemoveCallback38 const struct wl_registry_listener PlatformDisplayWayland::m_registryListener = { 39 PlatformDisplayWayland::globalCallback, 40 PlatformDisplayWayland::globalRemoveCallback 41 41 }; 42 42 43 void WaylandDisplay::globalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t)43 void PlatformDisplayWayland::globalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t) 44 44 { 45 auto display = static_cast< WaylandDisplay*>(data);45 auto display = static_cast<PlatformDisplayWayland*>(data); 46 46 if (!std::strcmp(interface, "wl_compositor")) 47 47 display->m_compositor = static_cast<struct wl_compositor*>(wl_registry_bind(registry, name, &wl_compositor_interface, 1)); … … 50 50 } 51 51 52 void WaylandDisplay::globalRemoveCallback(void*, struct wl_registry*, uint32_t)52 void PlatformDisplayWayland::globalRemoveCallback(void*, struct wl_registry*, uint32_t) 53 53 { 54 54 // FIXME: if this can happen without the UI Process getting shut down … … 56 56 } 57 57 58 WaylandDisplay* WaylandDisplay::instance()58 std::unique_ptr<PlatformDisplayWayland> PlatformDisplayWayland::create() 59 59 { 60 static WaylandDisplay* display = nullptr;61 static bool initialized = false;62 if (initialized)63 return display;64 65 initialized = true;66 60 struct wl_display* wlDisplay = wl_display_connect("webkitgtk-wayland-compositor-socket"); 67 61 if (!wlDisplay) 68 62 return nullptr; 69 63 70 display = new WaylandDisplay(wlDisplay); 71 if (!display->isInitialized()) { 72 delete display; 64 auto display = std::make_unique<PlatformDisplayWayland>(wlDisplay); 65 if (!display->isInitialized()) 73 66 return nullptr; 74 }75 67 76 return display;68 return WTF::move(display); 77 69 } 78 70 79 WaylandDisplay::WaylandDisplay(struct wl_display* wlDisplay)71 PlatformDisplayWayland::PlatformDisplayWayland(struct wl_display* wlDisplay) 80 72 : m_display(wlDisplay) 81 73 , m_registry(wl_display_get_registry(m_display)) … … 97 89 m_eglDisplay = eglGetDisplay(m_display); 98 90 if (m_eglDisplay == EGL_NO_DISPLAY) { 99 g_warning(" WaylandDisplayinitialization: failed to acquire EGL display.");91 g_warning("PlatformDisplayWayland initialization: failed to acquire EGL display."); 100 92 return; 101 93 } 102 94 103 95 if (eglInitialize(m_eglDisplay, 0, 0) == EGL_FALSE) { 104 g_warning(" WaylandDisplayinitialization: failed to initialize the EGL display.");96 g_warning("PlatformDisplayWayland initialization: failed to initialize the EGL display."); 105 97 return; 106 98 } 107 99 108 100 if (eglBindAPI(EGL_OPENGL_ES_API) == EGL_FALSE) { 109 g_warning(" WaylandDisplayinitialization: failed to set EGL_OPENGL_ES_API as the rendering API.");101 g_warning("PlatformDisplayWayland initialization: failed to set EGL_OPENGL_ES_API as the rendering API."); 110 102 return; 111 103 } … … 113 105 EGLint numberOfConfigs; 114 106 if (!eglChooseConfig(m_eglDisplay, configAttributes, &m_eglConfig, 1, &numberOfConfigs) || numberOfConfigs != 1) { 115 g_warning(" WaylandDisplayinitialization: failed to find the desired EGL configuration.");107 g_warning("PlatformDisplayWayland initialization: failed to find the desired EGL configuration."); 116 108 return; 117 109 } … … 120 112 } 121 113 122 std::unique_ptr<WaylandSurface> WaylandDisplay::createSurface(const IntSize& size, int widgetId)114 std::unique_ptr<WaylandSurface> PlatformDisplayWayland::createSurface(const IntSize& size, int widgetId) 123 115 { 124 116 struct wl_surface* wlSurface = wl_compositor_create_surface(m_compositor); … … 132 124 } 133 125 134 std::unique_ptr<GLContextEGL> WaylandDisplay::createSharingGLContext()126 std::unique_ptr<GLContextEGL> PlatformDisplayWayland::createSharingGLContext() 135 127 { 136 128 struct wl_surface* wlSurface = wl_compositor_create_surface(m_compositor); -
trunk/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.h
r183730 r183731 24 24 */ 25 25 26 #ifndef WaylandDisplay_h27 #define WaylandDisplay_h26 #ifndef PlatformDisplayWayland_h 27 #define PlatformDisplayWayland_h 28 28 29 29 #if PLATFORM(WAYLAND) 30 30 31 #include "PlatformDisplay.h" 31 32 #include "WebKitGtkWaylandClientProtocol.h" 32 33 #include <memory> 33 34 #include <wayland-client.h> 34 35 35 #include <wayland-egl.h> 36 36 #include <EGL/egl.h> … … 42 42 class WaylandSurface; 43 43 44 class WaylandDisplay {44 class PlatformDisplayWayland final: public PlatformDisplay { 45 45 public: 46 static WaylandDisplay* instance(); 46 static std::unique_ptr<PlatformDisplayWayland> create(); 47 virtual ~PlatformDisplayWayland(); 47 48 48 struct wl_display* native Display() const { return m_display; }49 struct wl_display* native() const { return m_display; } 49 50 EGLDisplay eglDisplay() const { return m_eglDisplay; } 50 51 … … 58 59 static void globalRemoveCallback(void* data, struct wl_registry*, uint32_t name); 59 60 60 WaylandDisplay(struct wl_display*);61 PlatformDisplayWayland(struct wl_display*); 61 62 bool isInitialized() { return m_compositor && m_webkitgtk && m_eglDisplay != EGL_NO_DISPLAY && m_eglConfigChosen; } 63 64 Type type() const override { return PlatformDisplay::Type::Wayland; } 62 65 63 66 struct wl_display* m_display; … … 75 78 #endif // PLATFORM(WAYLAND) 76 79 77 #endif // WaylandDisplay_h80 #endif // PlatformDisplayWayland_h -
trunk/Source/WebCore/platform/gtk/GtkUtilities.cpp
r183584 r183731 24 24 #include <wtf/gobject/GUniquePtr.h> 25 25 #include <wtf/gobject/GlibUtilities.h> 26 27 #if PLATFORM(X11)28 #include <gdk/gdkx.h>29 #endif30 #if PLATFORM(WAYLAND) && !defined(GTK_API_VERSION_2)31 #include <gdk/gdkwayland.h>32 #endif33 26 34 27 namespace WebCore { … … 62 55 } 63 56 64 DisplaySystemType getDisplaySystemType()65 {66 #if defined(GTK_API_VERSION_2)67 return DisplaySystemType::X11;68 #else69 static DisplaySystemType type = [] {70 GdkDisplay* display = gdk_display_manager_get_default_display(gdk_display_manager_get());71 #if PLATFORM(X11)72 if (GDK_IS_X11_DISPLAY(display))73 return DisplaySystemType::X11;74 #endif75 #if PLATFORM(WAYLAND)76 if (GDK_IS_WAYLAND_DISPLAY(display))77 return DisplaySystemType::Wayland;78 #endif79 ASSERT_NOT_REACHED();80 return DisplaySystemType::X11;81 }();82 return type;83 #endif84 }85 86 57 #if defined(DEVELOPMENT_BUILD) 87 58 static CString topLevelPath() -
trunk/Source/WebCore/platform/gtk/GtkUtilities.h
r183584 r183731 29 29 bool widgetIsOnscreenToplevelWindow(GtkWidget*); 30 30 31 enum class DisplaySystemType {32 X11,33 Wayland34 };35 36 DisplaySystemType getDisplaySystemType();37 38 31 #if defined(DEVELOPMENT_BUILD) 39 32 CString webkitBuildDirectory(); -
trunk/Source/WebKit2/ChangeLog
r183730 r183731 1 2015-05-03 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK][EFL] Unify platform display handling 4 https://bugs.webkit.org/show_bug.cgi?id=144517 5 6 Reviewed by Martin Robinson. 7 8 * UIProcess/API/gtk/WebKitWebViewBase.cpp: 9 (webkitWebViewBaseRealize): Use PlatformDisplay::sharedDisplay() 10 to checkt the display type. 11 (webkitWebViewBaseCreateWebPage): Ditto. 12 * UIProcess/cairo/BackingStoreCairo.cpp: 13 (WebKit::BackingStore::createBackend): Pass the native X11 shared 14 display to BackingStoreBackendCairoX11. 15 * WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp: 16 (WebKit::NetscapePlugin::x11HostDisplay): Return the native X11 17 shared display. 18 1 19 2015-05-03 Carlos Garcia Campos <cgarcia@igalia.com> 2 20 -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp
r182176 r183731 55 55 #include <WebCore/NotImplemented.h> 56 56 #include <WebCore/PasteboardHelper.h> 57 #include <WebCore/PlatformDisplay.h> 57 58 #include <WebCore/RefPtrCairo.h> 58 59 #include <WebCore/Region.h> … … 321 322 322 323 #if USE(REDIRECTED_XCOMPOSITE_WINDOW) 323 GdkDisplay* display = gdk_display_manager_get_default_display(gdk_display_manager_get()); 324 if (GDK_IS_X11_DISPLAY(display)) { 324 if (PlatformDisplay::sharedDisplay().type() == PlatformDisplay::Type::X11) { 325 325 priv->redirectedWindow = RedirectedXCompositeWindow::create( 326 326 gtk_widget_get_parent_window(widget), … … 1134 1134 // FIXME: Accelerated compositing under Wayland is not yet supported. 1135 1135 // https://bugs.webkit.org/show_bug.cgi?id=115803 1136 GdkDisplay* display = gdk_display_manager_get_default_display(gdk_display_manager_get()); 1137 if (GDK_IS_WAYLAND_DISPLAY(display)) 1136 if (PlatformDisplay::sharedDisplay().type() == PlatformDisplay::Type::Wayland) 1138 1137 preferences->setAcceleratedCompositingEnabled(false); 1139 1138 #endif -
trunk/Source/WebKit2/UIProcess/cairo/BackingStoreCairo.cpp
r181789 r183731 39 39 #if PLATFORM(GTK) && PLATFORM(X11) && defined(GDK_WINDOWING_X11) 40 40 #include <WebCore/BackingStoreBackendCairoX11.h> 41 #include <WebCore/PlatformDisplayX11.h> 41 42 #include <gdk/gdkx.h> 42 43 #endif … … 49 50 { 50 51 #if PLATFORM(GTK) && PLATFORM(X11) 51 GdkDisplay* display = gdk_display_manager_get_default_display(gdk_display_manager_get());52 if ( GDK_IS_X11_DISPLAY(display)) {52 const auto& sharedDisplay = PlatformDisplay::sharedDisplay(); 53 if (is<PlatformDisplayX11>(sharedDisplay)) { 53 54 GdkVisual* visual = gtk_widget_get_visual(m_webPageProxy.viewWidget()); 54 55 GdkScreen* screen = gdk_visual_get_screen(visual); 55 return std::make_unique<BackingStoreBackendCairoX11>(GDK_SCREEN_XDISPLAY(screen), GDK_WINDOW_XID(gdk_screen_get_root_window(screen)), 56 ASSERT(downcast<PlatformDisplayX11>(sharedDisplay).native() == GDK_SCREEN_XDISPLAY(screen)); 57 return std::make_unique<BackingStoreBackendCairoX11>(downcast<PlatformDisplayX11>(sharedDisplay).native(), GDK_WINDOW_XID(gdk_screen_get_root_window(screen)), 56 58 GDK_VISUAL_XVISUAL(visual), gdk_visual_get_depth(visual), m_size, m_deviceScaleFactor); 57 59 } -
trunk/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp
r182963 r183731 34 34 #include <WebCore/GraphicsContext.h> 35 35 #include <WebCore/NotImplemented.h> 36 #include <WebCore/PlatformDisplayX11.h> 36 37 37 38 #if PLATFORM(GTK) … … 104 105 Display* NetscapePlugin::x11HostDisplay() 105 106 { 106 #if PLATFORM(GTK) 107 return GDK_DISPLAY_XDISPLAY(gdk_display_get_default()); 108 #elif PLATFORM(EFL) && defined(HAVE_ECORE_X) 109 return static_cast<Display*>(ecore_x_display_get()); 110 #else 111 return 0; 112 #endif 107 return downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native(); 113 108 } 114 109
Note: See TracChangeset
for help on using the changeset viewer.