Changeset 147222 in webkit
- Timestamp:
- Mar 29, 2013 9:07:15 AM (11 years ago)
- Location:
- trunk/Source
- Files:
-
- 1 added
- 9 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r147221 r147222 1 2013-03-29 Kondapally Kalyan <kalyan.kondapally@intel.com> 2 3 [EFL][EGL] Add support for creating offscreen surface. 4 https://bugs.webkit.org/show_bug.cgi?id=113359 5 6 Reviewed by Noam Rosenthal. 7 8 This is in preparation for enabling EGL and GLES2 9 support for EFL port. This patch adds support for using 10 EGLPixmapSurface as an offscreensurface. 11 12 * PlatformEfl.cmake: 13 * platform/graphics/opengl/GLPlatformSurface.cpp: 14 (WebCore::GLPlatformSurface::createOffScreenSurface): 15 * platform/graphics/surfaces/efl/GLTransportSurface.cpp: 16 (WebCore::GLTransportSurface::createTransportSurface): 17 * platform/graphics/surfaces/egl/EGLConfigSelector.cpp: 18 (WebCore::EGLConfigSelector::EGLConfigSelector): 19 (WebCore::EGLConfigSelector::pixmapContextConfig): 20 (WebCore::EGLConfigSelector::surfaceContextConfig): 21 (WebCore::EGLConfigSelector::nativeVisualId): 22 (WebCore::EGLConfigSelector::reset): 23 (WebCore::EGLConfigSelector::createConfig): 24 * platform/graphics/surfaces/egl/EGLConfigSelector.h: 25 (EGLConfigSelector): 26 27 Added logic to select EGLConfig supporting alpha and 28 opaque as needed. Moved Code related to display to 29 EGLHelper class. 30 31 * platform/graphics/surfaces/egl/EGLHelper.cpp: Added. 32 (WebCore): 33 (EGLDisplayConnection): 34 (WebCore::EGLDisplayConnection::EGLDisplayConnection): 35 (WebCore::EGLDisplayConnection::~EGLDisplayConnection): 36 (WebCore::EGLDisplayConnection::display): 37 (WebCore::EGLDisplayConnection::terminate): 38 (WebCore::EGLHelper::eglDisplay): 39 * platform/graphics/surfaces/egl/EGLHelper.h: Copied from Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.h. 40 (WebCore): 41 (EGLHelper): 42 * platform/graphics/surfaces/egl/EGLSurface.cpp: 43 (WebCore::EGLTransportSurface::createTransportSurface): 44 (WebCore::EGLTransportSurface::EGLTransportSurface): 45 (WebCore::EGLTransportSurface::attributes): 46 (WebCore::EGLTransportSurface::~EGLTransportSurface): 47 (WebCore::EGLTransportSurface::destroy): 48 (WebCore::EGLTransportSurface::configuration): 49 (WebCore::EGLOffScreenSurface::createOffScreenSurface): 50 (WebCore::EGLOffScreenSurface::EGLOffScreenSurface): 51 (WebCore::EGLOffScreenSurface::~EGLOffScreenSurface): 52 (WebCore::EGLOffScreenSurface::attributes): 53 (WebCore::EGLOffScreenSurface::configuration): 54 (WebCore::EGLOffScreenSurface::destroy): 55 * platform/graphics/surfaces/egl/EGLSurface.h: 56 (WebCore): 57 (EGLTransportSurface): 58 (EGLOffScreenSurface): 59 * platform/graphics/surfaces/egl/EGLXSurface.cpp: Copied from Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.cpp. 60 (WebCore): 61 (WebCore::EGLWindowTransportSurface::EGLWindowTransportSurface): 62 (WebCore::EGLWindowTransportSurface::~EGLWindowTransportSurface): 63 (WebCore::EGLWindowTransportSurface::swapBuffers): 64 (WebCore::EGLWindowTransportSurface::destroy): 65 (WebCore::EGLPixmapSurface::EGLPixmapSurface): 66 (WebCore::EGLPixmapSurface::~EGLPixmapSurface): 67 (WebCore::EGLPixmapSurface::destroy): 68 * platform/graphics/surfaces/egl/EGLXSurface.h: Copied from Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.h. 69 (WebCore): 70 (EGLWindowTransportSurface): 71 (EGLPixmapSurface): 72 73 EGLPixmapSurface implementation. 74 1 75 2013-03-29 Sheriff Bot <webkit.review.bot@gmail.com> 2 76 -
trunk/Source/WebCore/PlatformEfl.cmake
r146855 r147222 329 329 platform/graphics/surfaces/egl/EGLConfigSelector.cpp 330 330 platform/graphics/surfaces/egl/EGLContext.cpp 331 platform/graphics/surfaces/egl/EGLHelper.cpp 331 332 platform/graphics/surfaces/egl/EGLSurface.cpp 333 platform/graphics/surfaces/egl/EGLXSurface.cpp 332 334 ) 333 335 else () -
trunk/Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp
r146730 r147222 45 45 PassOwnPtr<GLPlatformSurface> GLPlatformSurface::createOffScreenSurface(SurfaceAttributes attributes) 46 46 { 47 OwnPtr<GLPlatformSurface> surface; 47 48 #if USE(GLX) 48 OwnPtr<GLPlatformSurface> surface = adoptPtr(new GLXOffScreenSurface(attributes)); 49 surface = adoptPtr(new GLXOffScreenSurface(attributes)); 50 #else 51 surface = EGLOffScreenSurface::createOffScreenSurface(attributes); 52 #endif 49 53 50 if (surface ->drawable())54 if (surface && surface->drawable()) 51 55 return surface.release(); 52 #else53 UNUSED_PARAM(attributes);54 #endif55 56 56 57 return nullptr; -
trunk/Source/WebCore/platform/graphics/surfaces/efl/GLTransportSurface.cpp
r146640 r147222 48 48 PassOwnPtr<GLTransportSurface> GLTransportSurface::createTransportSurface(const IntSize& size, SurfaceAttributes attributes) 49 49 { 50 OwnPtr<GLTransportSurface> surface; 50 51 #if USE(GLX) 51 OwnPtr<GLTransportSurface>surface = adoptPtr(new GLXTransportSurface(size, attributes));52 surface = adoptPtr(new GLXTransportSurface(size, attributes)); 52 53 #elif USE(EGL) 53 OwnPtr<GLTransportSurface> surface = adoptPtr(new EGLWindowTransportSurface(attributes));54 surface = EGLTransportSurface::createTransportSurface(size, attributes); 54 55 #endif 55 56 -
trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLConfigSelector.cpp
r143704 r147222 29 29 #if USE(EGL) 30 30 31 #include "EGLHelper.h" 32 31 33 namespace WebCore { 32 34 33 SharedEGLDisplay* SharedEGLDisplay::m_staticSharedEGLDisplay = 0; 34 35 static EGLint configAttributeList[] = { 36 #if USE(OPENGL_ES_2) 37 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, 38 #else 39 EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT, 40 #endif 41 EGL_RED_SIZE, 8, 42 EGL_GREEN_SIZE, 8, 43 EGL_BLUE_SIZE, 8, 44 EGL_STENCIL_SIZE, 8, 45 EGL_ALPHA_SIZE, 0, 46 EGL_SURFACE_TYPE, EGL_NONE, 47 EGL_NONE 48 }; 49 50 void SharedEGLDisplay::deref() 51 { 52 if (derefBase()) { 53 m_staticSharedEGLDisplay = 0; 54 delete this; 55 } 56 } 57 58 EGLDisplay SharedEGLDisplay::sharedEGLDisplay() const 59 { 60 return m_eglDisplay; 61 } 62 63 SharedEGLDisplay::SharedEGLDisplay(NativeSharedDisplay* display) 64 : m_eglDisplay(EGL_NO_DISPLAY) 65 { 66 if (display) 67 m_eglDisplay = eglGetDisplay(reinterpret_cast<EGLNativeDisplayType>(display)); 68 else 69 m_eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); 70 71 if (m_eglDisplay == EGL_NO_DISPLAY) { 72 LOG_ERROR("EGLDisplay Initialization failed."); 73 return; 74 } 75 76 EGLBoolean success; 77 success = eglInitialize(m_eglDisplay, 0, 0); 78 79 if (success != EGL_TRUE) { 80 LOG_ERROR("EGLInitialization failed."); 81 m_eglDisplay = EGL_NO_DISPLAY; 82 } 83 84 success = eglBindAPI(eglAPIVersion); 85 86 if (success != EGL_TRUE) { 87 LOG_ERROR("Failed to set EGL API(%d).", eglGetError()); 88 m_eglDisplay = EGL_NO_DISPLAY; 89 } 90 } 91 92 void SharedEGLDisplay::cleanup() 93 { 94 if (m_eglDisplay == EGL_NO_DISPLAY) 95 return; 96 97 eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); 98 eglTerminate(m_eglDisplay); 99 m_eglDisplay = EGL_NO_DISPLAY; 100 } 101 102 SharedEGLDisplay::~SharedEGLDisplay() 103 { 104 cleanup(); 105 } 106 107 EGLConfigSelector::EGLConfigSelector(GLPlatformSurface::SurfaceAttributes attributes, NativeSharedDisplay* display) 108 : m_pbufferFBConfig(0) 35 EGLConfigSelector::EGLConfigSelector(GLPlatformSurface::SurfaceAttributes attributes) 36 : m_pixmapFBConfig(0) 109 37 , m_surfaceContextFBConfig(0) 110 38 , m_attributes(attributes) 111 39 { 112 m_sharedDisplay = SharedEGLDisplay::create(display);40 m_sharedDisplay = EGLHelper::eglDisplay(); 113 41 } 114 42 … … 117 45 } 118 46 119 PlatformDisplay EGLConfigSelector::display() const 47 EGLConfig EGLConfigSelector::pixmapContextConfig() 120 48 { 121 return m_sharedDisplay->sharedEGLDisplay();122 } 49 if (!m_pixmapFBConfig) 50 m_pixmapFBConfig = createConfig(EGL_PIXMAP_BIT); 123 51 124 EGLConfig EGLConfigSelector::pBufferContextConfig() 125 { 126 if (!m_pbufferFBConfig) { 127 configAttributeList[11] = m_attributes & GLPlatformSurface::SupportAlpha ? 8 : 0; 128 configAttributeList[13] = EGL_PIXMAP_BIT; 129 m_pbufferFBConfig = createConfig(configAttributeList); 130 } 131 132 return m_pbufferFBConfig; 52 return m_pixmapFBConfig; 133 53 } 134 54 135 55 EGLConfig EGLConfigSelector::surfaceContextConfig() 136 56 { 137 if (!m_surfaceContextFBConfig) { 138 configAttributeList[11] = m_attributes & GLPlatformSurface::SupportAlpha ? 8 : 0; 139 configAttributeList[13] = EGL_WINDOW_BIT; 140 m_surfaceContextFBConfig = createConfig(configAttributeList); 141 } 57 if (!m_surfaceContextFBConfig) 58 m_surfaceContextFBConfig = createConfig(EGL_WINDOW_BIT); 142 59 143 60 return m_surfaceContextFBConfig; … … 146 63 EGLint EGLConfigSelector::nativeVisualId(const EGLConfig& config) const 147 64 { 148 if ( display()== EGL_NO_DISPLAY)65 if (m_sharedDisplay == EGL_NO_DISPLAY) 149 66 return -1; 150 67 151 68 EGLint eglValue = 0; 152 eglGetConfigAttrib( display(), config, EGL_NATIVE_VISUAL_ID, &eglValue);69 eglGetConfigAttrib(m_sharedDisplay, config, EGL_NATIVE_VISUAL_ID, &eglValue); 153 70 154 71 return eglValue; … … 163 80 { 164 81 m_surfaceContextFBConfig = 0; 165 m_p bufferFBConfig = 0;82 m_pixmapFBConfig = 0; 166 83 } 167 84 168 EGLConfig EGLConfigSelector::createConfig( const int attributes[])85 EGLConfig EGLConfigSelector::createConfig(EGLint expectedSurfaceType) 169 86 { 170 if ( display()== EGL_NO_DISPLAY)87 if (m_sharedDisplay == EGL_NO_DISPLAY) 171 88 return 0; 172 89 173 int numConfigs; 90 EGLint numConfigs; 91 92 eglGetConfigs(m_sharedDisplay, 0, 0, &numConfigs); 93 94 if (!numConfigs) { 95 LOG_ERROR("Failed to retrieve number of EGL configs."); 96 return 0; 97 } 98 99 EGLConfig configs[numConfigs]; 100 eglGetConfigs(m_sharedDisplay, configs, numConfigs, &numConfigs); 101 102 if (!numConfigs) { 103 LOG_ERROR("Failed to retrieve any EGL configs."); 104 return 0; 105 } 106 174 107 EGLConfig config = 0; 108 EGLint alpha, surface, red, green, blue, renderType; 109 EGLint expectedAlpha = m_attributes & GLPlatformSurface::SupportAlpha ? 8 : 0; 110 EGLint expectedRed = 8; 111 EGLint expectedBlue = 8; 112 EGLint expectedGreen = 8; 113 #if USE(OPENGL_ES_2) 114 EGLint expectedRenderType = EGL_OPENGL_ES2_BIT; 115 #else 116 EGLint expectedRenderType = EGL_OPENGL_BIT, 117 #endif 175 118 176 if (!eglChooseConfig(display(), attributes, &config, 1, &numConfigs)) 177 LOG_ERROR("Failed to get supported configirations."); 119 for (int i = 0; i < numConfigs; i++) { 120 EGLConfig tempConfig = configs[i]; 121 eglGetConfigAttrib(m_sharedDisplay, tempConfig, EGL_RENDERABLE_TYPE, &renderType); 178 122 179 if (numConfigs != 1) { 180 LOG_ERROR("EGLChooseConfig didn't return exactly one config but (%d).", numConfigs); 181 config = 0; 123 if (!(renderType & expectedRenderType)) 124 continue; 125 126 eglGetConfigAttrib(m_sharedDisplay, tempConfig, EGL_ALPHA_SIZE, &alpha); 127 128 if (alpha != expectedAlpha) 129 continue; 130 131 eglGetConfigAttrib(m_sharedDisplay, tempConfig, EGL_RED_SIZE, &red); 132 133 if (red != expectedRed) 134 continue; 135 136 eglGetConfigAttrib(m_sharedDisplay, tempConfig, EGL_GREEN_SIZE, &green); 137 138 if (green != expectedGreen) 139 continue; 140 141 eglGetConfigAttrib(m_sharedDisplay, tempConfig, EGL_BLUE_SIZE, &blue); 142 143 if (blue != expectedBlue) 144 continue; 145 146 eglGetConfigAttrib(m_sharedDisplay, tempConfig, EGL_SURFACE_TYPE, &surface); 147 148 if (surface & expectedSurfaceType) { 149 config = configs[i]; 150 break; 151 } 182 152 } 153 154 if ((m_attributes & GLPlatformSurface::SupportAlpha) && !config) { 155 LOG_ERROR("Failed to retrieve EGL Configuration with alpha. Trying to find one without alpha support."); 156 m_attributes &= ~GLPlatformSurface::SupportAlpha; 157 config = createConfig(expectedSurfaceType); 158 } 159 160 if (!config) 161 LOG_ERROR("Failed to find a valid EGL Configuration."); 183 162 184 163 return config; -
trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLConfigSelector.h
r143704 r147222 32 32 #include <opengl/GLPlatformSurface.h> 33 33 #include <wtf/Noncopyable.h> 34 #include <wtf/PassRefPtr.h>35 #include <wtf/RefCounted.h>36 #include <wtf/RefPtr.h>37 34 38 35 namespace WebCore { 39 36 40 typedef Display NativeSharedDisplay;41 42 class SharedEGLDisplay : public WTF::RefCountedBase {43 WTF_MAKE_NONCOPYABLE(SharedEGLDisplay);44 45 public:46 static PassRefPtr<SharedEGLDisplay> create(NativeSharedDisplay* display)47 {48 if (!m_staticSharedEGLDisplay)49 m_staticSharedEGLDisplay = new SharedEGLDisplay(display);50 else51 m_staticSharedEGLDisplay->ref();52 53 return adoptRef(m_staticSharedEGLDisplay);54 }55 56 void deref();57 EGLDisplay sharedEGLDisplay() const;58 59 protected:60 SharedEGLDisplay(NativeSharedDisplay*);61 void cleanup();62 virtual ~SharedEGLDisplay();63 64 static SharedEGLDisplay* m_staticSharedEGLDisplay;65 EGLDisplay m_eglDisplay;66 };67 68 37 class EGLConfigSelector { 69 38 WTF_MAKE_NONCOPYABLE(EGLConfigSelector); 70 71 39 public: 72 EGLConfigSelector(GLPlatformSurface::SurfaceAttributes , NativeSharedDisplay* = 0);40 EGLConfigSelector(GLPlatformSurface::SurfaceAttributes); 73 41 virtual ~EGLConfigSelector(); 74 PlatformDisplay display() const; 75 virtual EGLConfig pBufferContextConfig(); 42 virtual EGLConfig pixmapContextConfig(); 76 43 virtual EGLConfig surfaceContextConfig(); 77 44 EGLint nativeVisualId(const EGLConfig&) const; … … 80 47 81 48 private: 82 EGLConfig createConfig( const int attributes[]);49 EGLConfig createConfig(EGLint expectedSurfaceType); 83 50 84 51 protected: 85 EGLConfig m_p bufferFBConfig;52 EGLConfig m_pixmapFBConfig; 86 53 EGLConfig m_surfaceContextFBConfig; 87 RefPtr<SharedEGLDisplay> m_sharedDisplay;88 54 unsigned m_attributes : 3; 55 PlatformDisplay m_sharedDisplay; 89 56 }; 90 57 -
trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLHelper.h
r147221 r147222 1 1 /* 2 * Copyright (C) 201 2Intel Corporation. All rights reserved.2 * Copyright (C) 2013 Intel Corporation. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 #ifndef EGL Surface_h27 #define EGL Surface_h26 #ifndef EGLHelper_h 27 #define EGLHelper_h 28 28 29 #if USE(EGL) && USE(GRAPHICS_SURFACE)29 #if USE(EGL) 30 30 31 #include "EGLConfigSelector.h" 32 #include "GLTransportSurface.h" 31 #if PLATFORM(X11) 32 #include <glx/X11Helper.h> 33 #endif 33 34 34 #include <glx/X11Helper.h> 35 #include <wtf/Noncopyable.h> 36 #include <wtf/PassOwnPtr.h> 35 #include <opengl/GLDefs.h> 37 36 38 37 namespace WebCore { 39 38 39 #if PLATFORM(X11) 40 40 typedef X11Helper NativeWrapper; 41 typedef Display NativeSharedDisplay; 42 #else 43 typedef void NativeSharedDisplay; 44 #endif 41 45 42 // Contents of the surface are backed by native window. 43 class EGLWindowTransportSurface : public GLTransportSurface { 44 46 class EGLHelper { 45 47 public: 46 EGLWindowTransportSurface(const IntSize&, SurfaceAttributes); 47 virtual ~EGLWindowTransportSurface(); 48 virtual PlatformSurfaceConfig configuration() OVERRIDE; 49 virtual void setGeometry(const IntRect& newRect) OVERRIDE; 50 virtual void swapBuffers() OVERRIDE; 51 virtual void destroy() OVERRIDE; 52 virtual GLPlatformSurface::SurfaceAttributes attributes() const OVERRIDE; 53 54 private: 55 void freeEGLResources(); 56 OwnPtr<EGLConfigSelector> m_configSelector; 48 static PlatformDisplay eglDisplay(); 57 49 }; 58 50 -
trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.cpp
r146458 r147222 29 29 #if USE(EGL) && USE(GRAPHICS_SURFACE) 30 30 31 #include "EGLConfigSelector.h" 32 #include "EGLHelper.h" 33 #include "GLPlatformContext.h" 34 35 #if PLATFORM(X11) 36 #include "EGLXSurface.h" 37 #endif 38 31 39 namespace WebCore { 32 40 33 EGLWindowTransportSurface::EGLWindowTransportSurface(const IntSize& size, SurfaceAttributes attributes) 41 PassOwnPtr<GLTransportSurface> EGLTransportSurface::createTransportSurface(const IntSize& size, SurfaceAttributes attributes) 42 { 43 OwnPtr<GLTransportSurface> surface; 44 #if PLATFORM(X11) 45 surface = adoptPtr(new EGLWindowTransportSurface(size, attributes)); 46 #endif 47 48 if (surface) 49 return surface.release(); 50 51 return nullptr; 52 } 53 54 EGLTransportSurface::EGLTransportSurface(const IntSize& size, SurfaceAttributes attributes) 34 55 : GLTransportSurface(size, attributes) 35 56 { 36 m_configSelector = adoptPtr(new EGLConfigSelector(attributes, NativeWrapper::nativeDisplay())); 37 m_sharedDisplay = m_configSelector->display(); 57 m_sharedDisplay = EGLHelper::eglDisplay(); 38 58 39 if (m_sharedDisplay == EGL_NO_DISPLAY) { 40 m_configSelector = nullptr; 59 if (m_sharedDisplay == EGL_NO_DISPLAY) 41 60 return; 42 }43 61 44 EGLConfig config = m_configSelector->surfaceContextConfig(); 45 46 if (!config) { 47 destroy(); 48 return; 49 } 50 51 EGLint visualId = m_configSelector->nativeVisualId(config); 52 53 if (visualId == -1) { 54 destroy(); 55 return; 56 } 57 58 NativeWrapper::createOffScreenWindow(&m_bufferHandle, (attributes & GLPlatformSurface::SupportAlpha), visualId); 59 60 if (!m_bufferHandle) { 61 destroy(); 62 return; 63 } 64 65 m_drawable = eglCreateWindowSurface(m_sharedDisplay, m_configSelector->surfaceContextConfig(), (EGLNativeWindowType)m_bufferHandle, 0); 66 67 if (m_drawable == EGL_NO_SURFACE) { 68 LOG_ERROR("Failed to create EGL surface(%d).", eglGetError()); 69 destroy(); 70 } 62 m_configSelector = adoptPtr(new EGLConfigSelector(attributes)); 71 63 } 72 64 73 GLPlatformSurface::SurfaceAttributes EGL WindowTransportSurface::attributes() const65 GLPlatformSurface::SurfaceAttributes EGLTransportSurface::attributes() const 74 66 { 75 67 return m_configSelector->attributes(); 76 68 } 77 69 78 EGL WindowTransportSurface::~EGLWindowTransportSurface()70 EGLTransportSurface::~EGLTransportSurface() 79 71 { 80 72 } 81 73 82 PlatformSurfaceConfig EGLWindowTransportSurface::configuration() 74 void EGLTransportSurface::destroy() 75 { 76 if (m_drawable == EGL_NO_SURFACE || m_sharedDisplay == EGL_NO_DISPLAY) 77 return; 78 79 GLTransportSurface::destroy(); 80 81 if (m_drawable) { 82 eglDestroySurface(m_sharedDisplay, m_drawable); 83 m_drawable = EGL_NO_SURFACE; 84 } 85 86 m_configSelector = nullptr; 87 } 88 89 PlatformSurfaceConfig EGLTransportSurface::configuration() 83 90 { 84 91 return m_configSelector->surfaceContextConfig(); 85 92 } 86 93 87 void EGLWindowTransportSurface::swapBuffers()94 PassOwnPtr<GLPlatformSurface> EGLOffScreenSurface::createOffScreenSurface(SurfaceAttributes attributes) 88 95 { 89 if (!m_drawable) 96 OwnPtr<GLPlatformSurface> surface; 97 #if PLATFORM(X11) 98 surface = adoptPtr(new EGLPixmapSurface(attributes)); 99 #endif 100 101 if (surface) 102 return surface.release(); 103 104 return nullptr; 105 } 106 107 EGLOffScreenSurface::EGLOffScreenSurface(SurfaceAttributes surfaceAttributes) 108 : GLPlatformSurface(surfaceAttributes) 109 { 110 m_sharedDisplay = EGLHelper::eglDisplay(); 111 112 if (m_sharedDisplay == EGL_NO_DISPLAY) 90 113 return; 91 114 92 EGLBoolean success = eglBindAPI(eglAPIVersion); 115 m_configSelector = adoptPtr(new EGLConfigSelector(surfaceAttributes)); 116 } 93 117 94 if (success != EGL_TRUE) { 95 LOG_ERROR("Failed to set EGL API(%d).", eglGetError()); 96 destroy(); 118 EGLOffScreenSurface::~EGLOffScreenSurface() 119 { 120 } 121 122 GLPlatformSurface::SurfaceAttributes EGLOffScreenSurface::attributes() const 123 { 124 return m_configSelector->attributes(); 125 } 126 127 PlatformSurfaceConfig EGLOffScreenSurface::configuration() 128 { 129 return m_configSelector->pixmapContextConfig(); 130 } 131 132 void EGLOffScreenSurface::destroy() 133 { 134 if (m_sharedDisplay == EGL_NO_DISPLAY || m_drawable == EGL_NO_SURFACE) 135 return; 136 137 if (m_drawable) { 138 eglDestroySurface(m_sharedDisplay, m_drawable); 139 m_drawable = EGL_NO_SURFACE; 97 140 } 98 141 99 success = eglSwapBuffers(m_sharedDisplay, m_drawable); 100 101 if (success != EGL_TRUE) { 102 LOG_ERROR("Failed to SwapBuffers(%d).", eglGetError()); 103 destroy(); 104 } 105 } 106 107 void EGLWindowTransportSurface::destroy() 108 { 109 GLTransportSurface::destroy(); 110 NativeWrapper::destroyWindow(m_bufferHandle); 111 freeEGLResources(); 112 m_bufferHandle = 0; 113 } 114 115 void EGLWindowTransportSurface::freeEGLResources() 116 { 117 if (m_drawable == EGL_NO_SURFACE || m_sharedDisplay == EGL_NO_DISPLAY) 118 return; 119 120 EGLBoolean eglResult = eglBindAPI(eglAPIVersion); 121 122 if (eglResult != EGL_TRUE) { 123 LOG_ERROR("Failed to set EGL API(%d).", eglGetError()); 124 return; 125 } 126 127 eglDestroySurface(m_sharedDisplay, m_drawable); 128 m_drawable = EGL_NO_SURFACE; 129 } 130 131 void EGLWindowTransportSurface::setGeometry(const IntRect& newRect) 132 { 133 GLTransportSurface::setGeometry(newRect); 134 NativeWrapper::resizeWindow(newRect, m_bufferHandle); 142 m_configSelector = nullptr; 135 143 } 136 144 -
trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.h
r146458 r147222 29 29 #if USE(EGL) && USE(GRAPHICS_SURFACE) 30 30 31 #include "EGLConfigSelector.h"32 31 #include "GLTransportSurface.h" 33 32 34 #include <glx/X11Helper.h>35 33 #include <wtf/Noncopyable.h> 36 34 #include <wtf/PassOwnPtr.h> … … 38 36 namespace WebCore { 39 37 40 typedef X11Helper NativeWrapper;38 class EGLConfigSelector; 41 39 42 // Contents of the surface are backed by native window. 43 class EGLWindowTransportSurface : public GLTransportSurface { 44 40 class EGLTransportSurface : public GLTransportSurface { 45 41 public: 46 EGLWindowTransportSurface(const IntSize&, SurfaceAttributes);47 virtual ~EGL WindowTransportSurface();42 static PassOwnPtr<GLTransportSurface> createTransportSurface(const IntSize&, SurfaceAttributes); 43 virtual ~EGLTransportSurface(); 48 44 virtual PlatformSurfaceConfig configuration() OVERRIDE; 49 virtual void setGeometry(const IntRect& newRect) OVERRIDE;50 virtual void swapBuffers() OVERRIDE;51 45 virtual void destroy() OVERRIDE; 52 46 virtual GLPlatformSurface::SurfaceAttributes attributes() const OVERRIDE; 53 47 54 private: 55 void freeEGLResources(); 48 protected: 49 EGLTransportSurface(const IntSize&, SurfaceAttributes); 50 OwnPtr<EGLConfigSelector> m_configSelector; 51 }; 52 53 class EGLOffScreenSurface : public GLPlatformSurface { 54 public: 55 static PassOwnPtr<GLPlatformSurface> createOffScreenSurface(SurfaceAttributes); 56 virtual ~EGLOffScreenSurface(); 57 virtual PlatformSurfaceConfig configuration() OVERRIDE; 58 virtual void destroy() OVERRIDE; 59 virtual GLPlatformSurface::SurfaceAttributes attributes() const OVERRIDE; 60 61 protected: 62 EGLOffScreenSurface(SurfaceAttributes); 56 63 OwnPtr<EGLConfigSelector> m_configSelector; 57 64 }; -
trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLXSurface.cpp
r147221 r147222 1 1 /* 2 * Copyright (C) 201 2Intel Corporation. All rights reserved.2 * Copyright (C) 2013 Intel Corporation. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 25 25 26 26 #include "config.h" 27 #include "EGL Surface.h"27 #include "EGLXSurface.h" 28 28 29 #if USE(EGL) && USE(GRAPHICS_SURFACE) 29 #if PLATFORM(X11) && USE(EGL) && USE(GRAPHICS_SURFACE) 30 31 #include "EGLConfigSelector.h" 30 32 31 33 namespace WebCore { 32 34 33 EGLWindowTransportSurface::EGLWindowTransportSurface(const IntSize& size, SurfaceAttributes attributes)34 : GLTransportSurface(size, attributes)35 EGLWindowTransportSurface::EGLWindowTransportSurface(const IntSize& size, GLPlatformSurface::SurfaceAttributes attributes) 36 : EGLTransportSurface(size, attributes) 35 37 { 36 m_configSelector = adoptPtr(new EGLConfigSelector(attributes, NativeWrapper::nativeDisplay()));37 m_sharedDisplay = m_configSelector->display();38 if (!m_configSelector) 39 return; 38 40 39 if ( m_sharedDisplay == EGL_NO_DISPLAY) {40 m_configSelector = nullptr;41 if (!m_configSelector->surfaceContextConfig()) { 42 destroy(); 41 43 return; 42 44 } 43 45 44 EGLConfig config = m_configSelector->surfaceContextConfig(); 46 EGLint visualId = m_configSelector->nativeVisualId(m_configSelector->surfaceContextConfig()); 47 48 if (visualId == -1) { 49 destroy(); 50 return; 51 } 52 53 NativeWrapper::createOffScreenWindow(&m_bufferHandle, visualId, m_configSelector->attributes() & GLPlatformSurface::SupportAlpha, size); 54 55 if (!m_bufferHandle) { 56 destroy(); 57 return; 58 } 59 60 m_drawable = eglCreateWindowSurface(m_sharedDisplay, m_configSelector->surfaceContextConfig(), static_cast<EGLNativeWindowType>(m_bufferHandle), 0); 61 62 if (m_drawable == EGL_NO_SURFACE) { 63 LOG_ERROR("Failed to create EGL surface(%d).", eglGetError()); 64 destroy(); 65 } 66 } 67 68 EGLWindowTransportSurface::~EGLWindowTransportSurface() 69 { 70 } 71 72 void EGLWindowTransportSurface::swapBuffers() 73 { 74 if (!eglSwapBuffers(m_sharedDisplay, m_drawable)) 75 LOG_ERROR("Failed to SwapBuffers(%d).", eglGetError()); 76 } 77 78 void EGLWindowTransportSurface::destroy() 79 { 80 EGLTransportSurface::destroy(); 81 82 if (m_bufferHandle) { 83 NativeWrapper::destroyWindow(m_bufferHandle); 84 m_bufferHandle = 0; 85 } 86 } 87 88 EGLPixmapSurface::EGLPixmapSurface(GLPlatformSurface::SurfaceAttributes surfaceAttributes) 89 : EGLOffScreenSurface(surfaceAttributes) 90 { 91 if (!m_configSelector) 92 return; 93 94 EGLConfig config = m_configSelector->pixmapContextConfig(); 45 95 46 96 if (!config) { … … 56 106 } 57 107 58 NativeWrapper::createOffScreenWindow(&m_bufferHandle, (attributes & GLPlatformSurface::SupportAlpha), visualId); 108 NativePixmap pixmap; 109 NativeWrapper::createPixmap(&pixmap, visualId, m_configSelector->attributes() & GLPlatformSurface::SupportAlpha); 110 m_bufferHandle = pixmap; 59 111 60 112 if (!m_bufferHandle) { … … 63 115 } 64 116 65 m_drawable = eglCreate WindowSurface(m_sharedDisplay, m_configSelector->surfaceContextConfig(), (EGLNativeWindowType)m_bufferHandle, 0);117 m_drawable = eglCreatePixmapSurface(m_sharedDisplay, config, static_cast<EGLNativePixmapType>(m_bufferHandle), 0); 66 118 67 119 if (m_drawable == EGL_NO_SURFACE) { … … 71 123 } 72 124 73 GLPlatformSurface::SurfaceAttributes EGLWindowTransportSurface::attributes() const 74 { 75 return m_configSelector->attributes(); 76 } 77 78 EGLWindowTransportSurface::~EGLWindowTransportSurface() 125 EGLPixmapSurface::~EGLPixmapSurface() 79 126 { 80 127 } 81 128 82 PlatformSurfaceConfig EGLWindowTransportSurface::configuration()129 void EGLPixmapSurface::destroy() 83 130 { 84 return m_configSelector->surfaceContextConfig(); 85 } 131 EGLOffScreenSurface::destroy(); 86 132 87 void EGLWindowTransportSurface::swapBuffers() 88 { 89 if (!m_drawable) 90 return; 91 92 EGLBoolean success = eglBindAPI(eglAPIVersion); 93 94 if (success != EGL_TRUE) { 95 LOG_ERROR("Failed to set EGL API(%d).", eglGetError()); 96 destroy(); 133 if (m_bufferHandle) { 134 NativeWrapper::destroyPixmap(m_bufferHandle); 135 m_bufferHandle = 0; 97 136 } 98 99 success = eglSwapBuffers(m_sharedDisplay, m_drawable);100 101 if (success != EGL_TRUE) {102 LOG_ERROR("Failed to SwapBuffers(%d).", eglGetError());103 destroy();104 }105 }106 107 void EGLWindowTransportSurface::destroy()108 {109 GLTransportSurface::destroy();110 NativeWrapper::destroyWindow(m_bufferHandle);111 freeEGLResources();112 m_bufferHandle = 0;113 }114 115 void EGLWindowTransportSurface::freeEGLResources()116 {117 if (m_drawable == EGL_NO_SURFACE || m_sharedDisplay == EGL_NO_DISPLAY)118 return;119 120 EGLBoolean eglResult = eglBindAPI(eglAPIVersion);121 122 if (eglResult != EGL_TRUE) {123 LOG_ERROR("Failed to set EGL API(%d).", eglGetError());124 return;125 }126 127 eglDestroySurface(m_sharedDisplay, m_drawable);128 m_drawable = EGL_NO_SURFACE;129 }130 131 void EGLWindowTransportSurface::setGeometry(const IntRect& newRect)132 {133 GLTransportSurface::setGeometry(newRect);134 NativeWrapper::resizeWindow(newRect, m_bufferHandle);135 137 } 136 138 -
trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLXSurface.h
r147221 r147222 1 1 /* 2 * Copyright (C) 201 2Intel Corporation. All rights reserved.2 * Copyright (C) 2013 Intel Corporation. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 #ifndef EGL Surface_h27 #define EGL Surface_h26 #ifndef EGLXSurface_h 27 #define EGLXSurface_h 28 28 29 #if USE(EGL) && USE(GRAPHICS_SURFACE)29 #if PLATFORM(X11) && USE(EGL) && USE(GRAPHICS_SURFACE) 30 30 31 #include "EGLConfigSelector.h" 32 #include "GLTransportSurface.h" 33 31 #include "EGLSurface.h" 34 32 #include <glx/X11Helper.h> 35 #include <wtf/Noncopyable.h>36 #include <wtf/PassOwnPtr.h>37 33 38 34 namespace WebCore { 39 35 40 36 typedef X11Helper NativeWrapper; 37 typedef Pixmap NativePixmap; 41 38 42 39 // Contents of the surface are backed by native window. 43 class EGLWindowTransportSurface : public GLTransportSurface { 44 40 class EGLWindowTransportSurface : public EGLTransportSurface { 45 41 public: 46 EGLWindowTransportSurface(const IntSize&, SurfaceAttributes);42 EGLWindowTransportSurface(const IntSize&, GLPlatformSurface::SurfaceAttributes); 47 43 virtual ~EGLWindowTransportSurface(); 48 virtual PlatformSurfaceConfig configuration() OVERRIDE;49 virtual void setGeometry(const IntRect& newRect) OVERRIDE;50 44 virtual void swapBuffers() OVERRIDE; 51 45 virtual void destroy() OVERRIDE; 52 virtual GLPlatformSurface::SurfaceAttributes attributes() const OVERRIDE;46 }; 53 47 54 private: 55 void freeEGLResources(); 56 OwnPtr<EGLConfigSelector> m_configSelector; 48 class EGLPixmapSurface : public EGLOffScreenSurface { 49 public: 50 EGLPixmapSurface(GLPlatformSurface::SurfaceAttributes); 51 virtual ~EGLPixmapSurface(); 52 virtual void destroy() OVERRIDE; 57 53 }; 58 54 -
trunk/Source/cmake/OptionsEfl.cmake
r146980 r147222 115 115 list(APPEND ECORE_ADDITIONAL_COMPONENTS X) 116 116 add_definitions(-DHAVE_ECORE_X) 117 add_definitions(-DWTF_PLATFORM_X11=1) 117 118 endif () 118 119
Note: See TracChangeset
for help on using the changeset viewer.