Changeset 217208 in webkit
- Timestamp:
- May 22, 2017 12:30:39 AM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r217203 r217208 1 2017-05-21 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [WPE] Use surfaceless context for sharing and offscreen context if available 4 https://bugs.webkit.org/show_bug.cgi?id=172268 5 6 Reviewed by Žan Doberšek. 7 8 Like GTK+ port does, WPE should use surfaceless contexts when possible, and only create a native offscreen 9 context as a fallback. We don't need to do anything special in WPE port, just to make it consistent with the 10 Wayland and X11 implementations. We should also avoid including EGL.h in headers, we added 11 GLContextEGLWayland.cpp and GLContextEGLX11.cpp to avoid that. PlatformDisplayWPE::EGLOffscreenTarget is quite 12 simple and only used by GLContextEGLWPE, so we could move it there like we do for Wayland and X11. 13 14 * platform/graphics/GLContext.h: Remove EGL header includes. 15 * platform/graphics/egl/GLContextEGL.cpp: 16 (WebCore::GLContextEGL::createWindowContext): Use createWindowSurfaceWPE() in WPE. 17 (WebCore::GLContextEGL::createContext): Use createWPEContext in WPE. 18 (WebCore::GLContextEGL::createSharingContext): Move the WPE code below to ensure we try 19 createSurfacelessContext() first. 20 * platform/graphics/egl/GLContextEGL.h: 21 * platform/graphics/egl/GLContextEGLWPE.cpp: 22 (WebCore::GLContextEGL::GLContextEGL): Add constructor for WPE that receives a struct wpe_renderer_backend_egl_offscreen_target* 23 (WebCore::GLContextEGL::createWindowSurfaceWPE): Added implementation here because eglCreateWindowSurface needs 24 the platform specific EGL includes and definitions. 25 (WebCore::GLContextEGL::createWPEContext): Create a GLContext using WPE backend API directly here. 26 (WebCore::GLContextEGL::destroyWPETarget): Add null check. 27 * platform/graphics/wpe/PlatformDisplayWPE.cpp: Remove EGLOffscreenTarget. 28 * platform/graphics/wpe/PlatformDisplayWPE.h: 29 1 30 2017-05-21 Michael Catanzaro <mcatanzaro@igalia.com> 2 31 -
trunk/Source/WebCore/platform/graphics/GLContext.h
r216497 r217208 25 25 #include <wtf/Noncopyable.h> 26 26 27 #if USE(EGL) && !PLATFORM(GTK) 28 #if PLATFORM(WPE) 29 // FIXME: For now default to the GBM EGL platform, but this should really be 30 // somehow deducible from the build configuration. 31 #define __GBM__ 1 32 #include <EGL/eglplatform.h> 33 #else 27 #if USE(EGL) && !PLATFORM(GTK) && !PLATFORM(WPE) 34 28 #include "eglplatform.h" 35 #endif36 29 typedef EGLNativeWindowType GLNativeWindowType; 37 30 #else -
trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp
r216497 r217208 116 116 surface = createWindowSurfaceWayland(display, config, window); 117 117 #endif 118 #elif PLATFORM(WPE) 119 if (platformDisplay.type() == PlatformDisplay::Type::WPE) 120 surface = createWindowSurfaceWPE(display, config, window); 118 121 #else 119 122 surface = eglCreateWindowSurface(display, config, static_cast<EGLNativeWindowType>(window), nullptr); … … 190 193 context = createWaylandContext(platformDisplay, eglSharingContext); 191 194 #endif 195 #if PLATFORM(WPE) 196 if (platformDisplay.type() == PlatformDisplay::Type::WPE) 197 context = createWPEContext(platformDisplay, eglSharingContext); 198 #endif 192 199 } 193 200 if (!context) … … 204 211 if (eglBindAPI(gEGLAPIVersion) == EGL_FALSE) 205 212 return nullptr; 206 207 #if PLATFORM(WPE)208 if (platformDisplay.type() == PlatformDisplay::Type::WPE) {209 if (auto context = createWPEContext(platformDisplay))210 return context;211 }212 #endif213 213 214 214 auto context = createSurfacelessContext(platformDisplay); … … 222 222 context = createWaylandContext(platformDisplay); 223 223 #endif 224 #if PLATFORM(WPE) 225 if (platformDisplay.type() == PlatformDisplay::Type::WPE) 226 context = createWPEContext(platformDisplay); 227 #endif 224 228 } 225 229 if (!context) -
trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.h
r216497 r217208 34 34 35 35 #if PLATFORM(WPE) 36 #include "PlatformDisplayWPE.h" 36 struct wpe_renderer_backend_egl_offscreen_target; 37 37 #endif 38 38 … … 79 79 #endif 80 80 #if PLATFORM(WPE) 81 GLContextEGL(PlatformDisplay&, EGLContext, EGLSurface, struct wpe_renderer_backend_egl_offscreen_target*); 81 82 void destroyWPETarget(); 82 83 #endif … … 95 96 #if PLATFORM(WPE) 96 97 static std::unique_ptr<GLContextEGL> createWPEContext(PlatformDisplay&, EGLContext sharingContext = nullptr); 98 static EGLSurface createWindowSurfaceWPE(EGLDisplay, EGLConfig, GLNativeWindowType); 97 99 #endif 98 100 … … 110 112 #endif 111 113 #if PLATFORM(WPE) 112 st d::unique_ptr<PlatformDisplayWPE::EGLOffscreenTarget> m_wpeTarget;114 struct wpe_renderer_backend_egl_offscreen_target* m_wpeTarget { nullptr }; 113 115 #endif 114 116 #if USE(CAIRO) -
trunk/Source/WebCore/platform/graphics/egl/GLContextEGLWPE.cpp
r216930 r217208 23 23 24 24 #include "PlatformDisplayWPE.h" 25 // FIXME: For now default to the GBM EGL platform, but this should really be 26 // somehow deducible from the build configuration. 27 #define __GBM__ 1 28 #include <EGL/egl.h> 29 #include <wpe/renderer-backend-egl.h> 25 30 26 31 namespace WebCore { 27 32 33 GLContextEGL::GLContextEGL(PlatformDisplay& display, EGLContext context, EGLSurface surface, struct wpe_renderer_backend_egl_offscreen_target* target) 34 : GLContext(display) 35 , m_context(context) 36 , m_surface(surface) 37 , m_type(WindowSurface) 38 , m_wpeTarget(target) 39 { 40 } 41 42 EGLSurface GLContextEGL::createWindowSurfaceWPE(EGLDisplay display, EGLConfig config, GLNativeWindowType window) 43 { 44 return eglCreateWindowSurface(display, config, reinterpret_cast<EGLNativeWindowType>(window), nullptr); 45 } 46 28 47 std::unique_ptr<GLContextEGL> GLContextEGL::createWPEContext(PlatformDisplay& platformDisplay, EGLContext sharingContext) 29 48 { 30 auto offscreenTarget = downcast<PlatformDisplayWPE>(platformDisplay).createEGLOffscreenTarget(); 49 EGLDisplay display = platformDisplay.eglDisplay(); 50 EGLConfig config; 51 if (!getEGLConfig(display, &config, WindowSurface)) 52 return nullptr; 31 53 32 std::unique_ptr<GLContextEGL> context; 33 if (offscreenTarget->nativeWindow()) 34 context = createWindowContext(offscreenTarget->nativeWindow(), platformDisplay, sharingContext); 35 if (!context) 36 context = createPbufferContext(platformDisplay, sharingContext); 54 static const EGLint contextAttributes[] = { 55 #if USE(OPENGL_ES_2) 56 EGL_CONTEXT_CLIENT_VERSION, 2, 57 #endif 58 EGL_NONE 59 }; 37 60 38 // FIXME: if available, we could also fallback to the surfaceless-based GLContext 39 // before falling back to the pbuffer-based one. 61 EGLContext context = eglCreateContext(display, config, sharingContext, contextAttributes); 62 if (context == EGL_NO_CONTEXT) 63 return nullptr; 40 64 41 if (context) 42 context->m_wpeTarget = WTFMove(offscreenTarget); 43 return context; 65 auto* target = wpe_renderer_backend_egl_offscreen_target_create(); 66 wpe_renderer_backend_egl_offscreen_target_initialize(target, downcast<PlatformDisplayWPE>(platformDisplay).backend()); 67 EGLNativeWindowType window = wpe_renderer_backend_egl_offscreen_target_get_native_window(target); 68 if (!window) { 69 wpe_renderer_backend_egl_offscreen_target_destroy(target); 70 return nullptr; 71 } 72 73 EGLSurface surface = eglCreateWindowSurface(display, config, static_cast<EGLNativeWindowType>(window), nullptr); 74 if (surface == EGL_NO_SURFACE) { 75 eglDestroyContext(display, context); 76 wpe_renderer_backend_egl_offscreen_target_destroy(target); 77 return nullptr; 78 } 79 80 return std::unique_ptr<GLContextEGL>(new GLContextEGL(platformDisplay, context, surface, target)); 44 81 } 45 82 46 83 void GLContextEGL::destroyWPETarget() 47 84 { 48 m_wpeTarget = nullptr; 85 if (m_wpeTarget) 86 wpe_renderer_backend_egl_offscreen_target_destroy(m_wpeTarget); 49 87 } 50 88 -
trunk/Source/WebCore/platform/graphics/wpe/PlatformDisplayWPE.cpp
r217123 r217208 30 30 31 31 #include "GLContextEGL.h" 32 #include "IntSize.h" 32 // FIXME: For now default to the GBM EGL platform, but this should really be 33 // somehow deducible from the build configuration. 34 #define __GBM__ 1 33 35 #include <EGL/egl.h> 34 36 #include <wpe/renderer-backend-egl.h> … … 56 58 } 57 59 58 std::unique_ptr<PlatformDisplayWPE::EGLOffscreenTarget> PlatformDisplayWPE::createEGLOffscreenTarget()59 {60 return std::make_unique<EGLOffscreenTarget>(*this);61 }62 63 PlatformDisplayWPE::EGLOffscreenTarget::EGLOffscreenTarget(const PlatformDisplayWPE& display)64 {65 m_target = wpe_renderer_backend_egl_offscreen_target_create();66 wpe_renderer_backend_egl_offscreen_target_initialize(m_target, display.m_backend);67 }68 69 PlatformDisplayWPE::EGLOffscreenTarget::~EGLOffscreenTarget()70 {71 wpe_renderer_backend_egl_offscreen_target_destroy(m_target);72 }73 74 EGLNativeWindowType PlatformDisplayWPE::EGLOffscreenTarget::nativeWindow() const75 {76 return wpe_renderer_backend_egl_offscreen_target_get_native_window(m_target);77 }78 79 60 } // namespace WebCore 80 61 -
trunk/Source/WebCore/platform/graphics/wpe/PlatformDisplayWPE.h
r217123 r217208 30 30 #include "PlatformDisplay.h" 31 31 32 // FIXME: For now default to the GBM EGL platform, but this should really be33 // somehow deducible from the build configuration.34 #define __GBM__ 135 #include <EGL/eglplatform.h>36 37 32 struct wpe_renderer_backend_egl; 38 struct wpe_renderer_backend_egl_target;39 struct wpe_renderer_backend_egl_offscreen_target;40 33 41 34 namespace WebCore { 42 43 class GLContext;44 class IntSize;45 35 46 36 class PlatformDisplayWPE final : public PlatformDisplay { … … 50 40 51 41 void initialize(int); 52 53 class EGLOffscreenTarget {54 public:55 EGLOffscreenTarget(const PlatformDisplayWPE&);56 ~EGLOffscreenTarget();57 58 EGLNativeWindowType nativeWindow() const;59 60 private:61 struct wpe_renderer_backend_egl_offscreen_target* m_target;62 };63 64 std::unique_ptr<EGLOffscreenTarget> createEGLOffscreenTarget();65 42 66 43 struct wpe_renderer_backend_egl* backend() const { return m_backend; }
Note: See TracChangeset
for help on using the changeset viewer.