Changeset 147222 in webkit


Ignore:
Timestamp:
Mar 29, 2013 9:07:15 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

[EFL][EGL] Add support for creating offscreen surface.
https://bugs.webkit.org/show_bug.cgi?id=113359

Patch by Kondapally Kalyan <kalyan.kondapally@intel.com> on 2013-03-29
Reviewed by Noam Rosenthal.

This is in preparation for enabling EGL and GLES2
support for EFL port. This patch adds support for using
EGLPixmapSurface as an offscreensurface.

  • PlatformEfl.cmake:
  • platform/graphics/opengl/GLPlatformSurface.cpp:

(WebCore::GLPlatformSurface::createOffScreenSurface):

  • platform/graphics/surfaces/efl/GLTransportSurface.cpp:

(WebCore::GLTransportSurface::createTransportSurface):

  • platform/graphics/surfaces/egl/EGLConfigSelector.cpp:

(WebCore::EGLConfigSelector::EGLConfigSelector):
(WebCore::EGLConfigSelector::pixmapContextConfig):
(WebCore::EGLConfigSelector::surfaceContextConfig):
(WebCore::EGLConfigSelector::nativeVisualId):
(WebCore::EGLConfigSelector::reset):
(WebCore::EGLConfigSelector::createConfig):

  • platform/graphics/surfaces/egl/EGLConfigSelector.h:

(EGLConfigSelector):

Added logic to select EGLConfig supporting alpha and
opaque as needed. Moved Code related to display to
EGLHelper class.

  • platform/graphics/surfaces/egl/EGLHelper.cpp: Added.

(WebCore):
(EGLDisplayConnection):
(WebCore::EGLDisplayConnection::EGLDisplayConnection):
(WebCore::EGLDisplayConnection::~EGLDisplayConnection):
(WebCore::EGLDisplayConnection::display):
(WebCore::EGLDisplayConnection::terminate):
(WebCore::EGLHelper::eglDisplay):

  • platform/graphics/surfaces/egl/EGLHelper.h: Copied from Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.h.

(WebCore):
(EGLHelper):

  • platform/graphics/surfaces/egl/EGLSurface.cpp:

(WebCore::EGLTransportSurface::createTransportSurface):
(WebCore::EGLTransportSurface::EGLTransportSurface):
(WebCore::EGLTransportSurface::attributes):
(WebCore::EGLTransportSurface::~EGLTransportSurface):
(WebCore::EGLTransportSurface::destroy):
(WebCore::EGLTransportSurface::configuration):
(WebCore::EGLOffScreenSurface::createOffScreenSurface):
(WebCore::EGLOffScreenSurface::EGLOffScreenSurface):
(WebCore::EGLOffScreenSurface::~EGLOffScreenSurface):
(WebCore::EGLOffScreenSurface::attributes):
(WebCore::EGLOffScreenSurface::configuration):
(WebCore::EGLOffScreenSurface::destroy):

  • platform/graphics/surfaces/egl/EGLSurface.h:

(WebCore):
(EGLTransportSurface):
(EGLOffScreenSurface):

  • platform/graphics/surfaces/egl/EGLXSurface.cpp: Copied from Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.cpp.

(WebCore):
(WebCore::EGLWindowTransportSurface::EGLWindowTransportSurface):
(WebCore::EGLWindowTransportSurface::~EGLWindowTransportSurface):
(WebCore::EGLWindowTransportSurface::swapBuffers):
(WebCore::EGLWindowTransportSurface::destroy):
(WebCore::EGLPixmapSurface::EGLPixmapSurface):
(WebCore::EGLPixmapSurface::~EGLPixmapSurface):
(WebCore::EGLPixmapSurface::destroy):

  • platform/graphics/surfaces/egl/EGLXSurface.h: Copied from Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.h.

(WebCore):
(EGLWindowTransportSurface):
(EGLPixmapSurface):

EGLPixmapSurface implementation.

Location:
trunk/Source
Files:
1 added
9 edited
3 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r147221 r147222  
     12013-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
    1752013-03-29  Sheriff Bot  <webkit.review.bot@gmail.com>
    276
  • trunk/Source/WebCore/PlatformEfl.cmake

    r146855 r147222  
    329329            platform/graphics/surfaces/egl/EGLConfigSelector.cpp
    330330            platform/graphics/surfaces/egl/EGLContext.cpp
     331            platform/graphics/surfaces/egl/EGLHelper.cpp
    331332            platform/graphics/surfaces/egl/EGLSurface.cpp
     333            platform/graphics/surfaces/egl/EGLXSurface.cpp
    332334        )
    333335    else ()
  • trunk/Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp

    r146730 r147222  
    4545PassOwnPtr<GLPlatformSurface> GLPlatformSurface::createOffScreenSurface(SurfaceAttributes attributes)
    4646{
     47    OwnPtr<GLPlatformSurface> surface;
    4748#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
    4953
    50     if (surface->drawable())
     54    if (surface && surface->drawable())
    5155        return surface.release();
    52 #else
    53     UNUSED_PARAM(attributes);
    54 #endif
    5556
    5657    return nullptr;
  • trunk/Source/WebCore/platform/graphics/surfaces/efl/GLTransportSurface.cpp

    r146640 r147222  
    4848PassOwnPtr<GLTransportSurface> GLTransportSurface::createTransportSurface(const IntSize& size, SurfaceAttributes attributes)
    4949{
     50    OwnPtr<GLTransportSurface> surface;
    5051#if USE(GLX)
    51     OwnPtr<GLTransportSurface> surface = adoptPtr(new GLXTransportSurface(size, attributes));
     52    surface = adoptPtr(new GLXTransportSurface(size, attributes));
    5253#elif USE(EGL)
    53     OwnPtr<GLTransportSurface> surface = adoptPtr(new EGLWindowTransportSurface(attributes));
     54    surface = EGLTransportSurface::createTransportSurface(size, attributes);
    5455#endif
    5556
  • trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLConfigSelector.cpp

    r143704 r147222  
    2929#if USE(EGL)
    3030
     31#include "EGLHelper.h"
     32
    3133namespace WebCore {
    3234
    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)
     35EGLConfigSelector::EGLConfigSelector(GLPlatformSurface::SurfaceAttributes attributes)
     36    : m_pixmapFBConfig(0)
    10937    , m_surfaceContextFBConfig(0)
    11038    , m_attributes(attributes)
    11139{
    112     m_sharedDisplay = SharedEGLDisplay::create(display);
     40    m_sharedDisplay = EGLHelper::eglDisplay();
    11341}
    11442
     
    11745}
    11846
    119 PlatformDisplay EGLConfigSelector::display() const
     47EGLConfig EGLConfigSelector::pixmapContextConfig()
    12048{
    121     return m_sharedDisplay->sharedEGLDisplay();
    122 }
     49    if (!m_pixmapFBConfig)
     50        m_pixmapFBConfig = createConfig(EGL_PIXMAP_BIT);
    12351
    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;
    13353}
    13454
    13555EGLConfig EGLConfigSelector::surfaceContextConfig()
    13656{
    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);
    14259
    14360    return m_surfaceContextFBConfig;
     
    14663EGLint EGLConfigSelector::nativeVisualId(const EGLConfig& config) const
    14764{
    148     if (display() == EGL_NO_DISPLAY)
     65    if (m_sharedDisplay == EGL_NO_DISPLAY)
    14966        return -1;
    15067
    15168    EGLint eglValue = 0;
    152     eglGetConfigAttrib(display(), config, EGL_NATIVE_VISUAL_ID, &eglValue);
     69    eglGetConfigAttrib(m_sharedDisplay, config, EGL_NATIVE_VISUAL_ID, &eglValue);
    15370
    15471    return eglValue;
     
    16380{
    16481    m_surfaceContextFBConfig = 0;
    165     m_pbufferFBConfig = 0;
     82    m_pixmapFBConfig = 0;
    16683}
    16784
    168 EGLConfig EGLConfigSelector::createConfig(const int attributes[])
     85EGLConfig EGLConfigSelector::createConfig(EGLint expectedSurfaceType)
    16986{
    170     if (display() == EGL_NO_DISPLAY)
     87    if (m_sharedDisplay == EGL_NO_DISPLAY)
    17188        return 0;
    17289
    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
    174107    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
    175118
    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);
    178122
    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        }
    182152    }
     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.");
    183162
    184163    return config;
  • trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLConfigSelector.h

    r143704 r147222  
    3232#include <opengl/GLPlatformSurface.h>
    3333#include <wtf/Noncopyable.h>
    34 #include <wtf/PassRefPtr.h>
    35 #include <wtf/RefCounted.h>
    36 #include <wtf/RefPtr.h>
    3734
    3835namespace WebCore {
    3936
    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         else
    51             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 
    6837class EGLConfigSelector {
    6938    WTF_MAKE_NONCOPYABLE(EGLConfigSelector);
    70 
    7139public:
    72     EGLConfigSelector(GLPlatformSurface::SurfaceAttributes, NativeSharedDisplay* = 0);
     40    EGLConfigSelector(GLPlatformSurface::SurfaceAttributes);
    7341    virtual ~EGLConfigSelector();
    74     PlatformDisplay display() const;
    75     virtual EGLConfig pBufferContextConfig();
     42    virtual EGLConfig pixmapContextConfig();
    7643    virtual EGLConfig surfaceContextConfig();
    7744    EGLint nativeVisualId(const EGLConfig&) const;
     
    8047
    8148private:
    82     EGLConfig createConfig(const int attributes[]);
     49    EGLConfig createConfig(EGLint expectedSurfaceType);
    8350
    8451protected:
    85     EGLConfig m_pbufferFBConfig;
     52    EGLConfig m_pixmapFBConfig;
    8653    EGLConfig m_surfaceContextFBConfig;
    87     RefPtr<SharedEGLDisplay> m_sharedDisplay;
    8854    unsigned m_attributes : 3;
     55    PlatformDisplay m_sharedDisplay;
    8956};
    9057
  • trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLHelper.h

    r147221 r147222  
    11/*
    2  * Copyright (C) 2012 Intel Corporation. All rights reserved.
     2 * Copyright (C) 2013 Intel Corporation. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #ifndef EGLSurface_h
    27 #define EGLSurface_h
     26#ifndef EGLHelper_h
     27#define EGLHelper_h
    2828
    29 #if USE(EGL) && USE(GRAPHICS_SURFACE)
     29#if USE(EGL)
    3030
    31 #include "EGLConfigSelector.h"
    32 #include "GLTransportSurface.h"
     31#if PLATFORM(X11)
     32#include <glx/X11Helper.h>
     33#endif
    3334
    34 #include <glx/X11Helper.h>
    35 #include <wtf/Noncopyable.h>
    36 #include <wtf/PassOwnPtr.h>
     35#include <opengl/GLDefs.h>
    3736
    3837namespace WebCore {
    3938
     39#if PLATFORM(X11)
    4040typedef X11Helper NativeWrapper;
     41typedef Display NativeSharedDisplay;
     42#else
     43typedef void NativeSharedDisplay;
     44#endif
    4145
    42 // Contents of the surface are backed by native window.
    43 class EGLWindowTransportSurface : public GLTransportSurface {
    44 
     46class EGLHelper {
    4547public:
    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();
    5749};
    5850
  • trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.cpp

    r146458 r147222  
    2929#if USE(EGL) && USE(GRAPHICS_SURFACE)
    3030
     31#include "EGLConfigSelector.h"
     32#include "EGLHelper.h"
     33#include "GLPlatformContext.h"
     34
     35#if PLATFORM(X11)
     36#include "EGLXSurface.h"
     37#endif
     38
    3139namespace WebCore {
    3240
    33 EGLWindowTransportSurface::EGLWindowTransportSurface(const IntSize& size, SurfaceAttributes attributes)
     41PassOwnPtr<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
     54EGLTransportSurface::EGLTransportSurface(const IntSize& size, SurfaceAttributes attributes)
    3455    : GLTransportSurface(size, attributes)
    3556{
    36     m_configSelector = adoptPtr(new EGLConfigSelector(attributes, NativeWrapper::nativeDisplay()));
    37     m_sharedDisplay = m_configSelector->display();
     57    m_sharedDisplay = EGLHelper::eglDisplay();
    3858
    39     if (m_sharedDisplay == EGL_NO_DISPLAY) {
    40         m_configSelector = nullptr;
     59    if (m_sharedDisplay == EGL_NO_DISPLAY)
    4160        return;
    42     }
    4361
    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));
    7163}
    7264
    73 GLPlatformSurface::SurfaceAttributes EGLWindowTransportSurface::attributes() const
     65GLPlatformSurface::SurfaceAttributes EGLTransportSurface::attributes() const
    7466{
    7567    return m_configSelector->attributes();
    7668}
    7769
    78 EGLWindowTransportSurface::~EGLWindowTransportSurface()
     70EGLTransportSurface::~EGLTransportSurface()
    7971{
    8072}
    8173
    82 PlatformSurfaceConfig EGLWindowTransportSurface::configuration()
     74void 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
     89PlatformSurfaceConfig EGLTransportSurface::configuration()
    8390{
    8491    return m_configSelector->surfaceContextConfig();
    8592}
    8693
    87 void EGLWindowTransportSurface::swapBuffers()
     94PassOwnPtr<GLPlatformSurface> EGLOffScreenSurface::createOffScreenSurface(SurfaceAttributes attributes)
    8895{
    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
     107EGLOffScreenSurface::EGLOffScreenSurface(SurfaceAttributes surfaceAttributes)
     108    : GLPlatformSurface(surfaceAttributes)
     109{
     110    m_sharedDisplay = EGLHelper::eglDisplay();
     111
     112    if (m_sharedDisplay == EGL_NO_DISPLAY)
    90113        return;
    91114
    92     EGLBoolean success = eglBindAPI(eglAPIVersion);
     115    m_configSelector = adoptPtr(new EGLConfigSelector(surfaceAttributes));
     116}
    93117
    94     if (success != EGL_TRUE) {
    95         LOG_ERROR("Failed to set EGL API(%d).", eglGetError());
    96         destroy();
     118EGLOffScreenSurface::~EGLOffScreenSurface()
     119{
     120}
     121
     122GLPlatformSurface::SurfaceAttributes EGLOffScreenSurface::attributes() const
     123{
     124    return m_configSelector->attributes();
     125}
     126
     127PlatformSurfaceConfig EGLOffScreenSurface::configuration()
     128{
     129    return m_configSelector->pixmapContextConfig();
     130}
     131
     132void 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;
    97140    }
    98141
    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;
    135143}
    136144
  • trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.h

    r146458 r147222  
    2929#if USE(EGL) && USE(GRAPHICS_SURFACE)
    3030
    31 #include "EGLConfigSelector.h"
    3231#include "GLTransportSurface.h"
    3332
    34 #include <glx/X11Helper.h>
    3533#include <wtf/Noncopyable.h>
    3634#include <wtf/PassOwnPtr.h>
     
    3836namespace WebCore {
    3937
    40 typedef X11Helper NativeWrapper;
     38class EGLConfigSelector;
    4139
    42 // Contents of the surface are backed by native window.
    43 class EGLWindowTransportSurface : public GLTransportSurface {
    44 
     40class EGLTransportSurface : public GLTransportSurface {
    4541public:
    46     EGLWindowTransportSurface(const IntSize&, SurfaceAttributes);
    47     virtual ~EGLWindowTransportSurface();
     42    static PassOwnPtr<GLTransportSurface> createTransportSurface(const IntSize&, SurfaceAttributes);
     43    virtual ~EGLTransportSurface();
    4844    virtual PlatformSurfaceConfig configuration() OVERRIDE;
    49     virtual void setGeometry(const IntRect& newRect) OVERRIDE;
    50     virtual void swapBuffers() OVERRIDE;
    5145    virtual void destroy() OVERRIDE;
    5246    virtual GLPlatformSurface::SurfaceAttributes attributes() const OVERRIDE;
    5347
    54 private:
    55     void freeEGLResources();
     48protected:
     49    EGLTransportSurface(const IntSize&, SurfaceAttributes);
     50    OwnPtr<EGLConfigSelector> m_configSelector;
     51};
     52
     53class EGLOffScreenSurface : public GLPlatformSurface {
     54public:
     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
     61protected:
     62    EGLOffScreenSurface(SurfaceAttributes);
    5663    OwnPtr<EGLConfigSelector> m_configSelector;
    5764};
  • trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLXSurface.cpp

    r147221 r147222  
    11/*
    2  * Copyright (C) 2012 Intel Corporation. All rights reserved.
     2 * Copyright (C) 2013 Intel Corporation. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2525
    2626#include "config.h"
    27 #include "EGLSurface.h"
     27#include "EGLXSurface.h"
    2828
    29 #if USE(EGL) && USE(GRAPHICS_SURFACE)
     29#if PLATFORM(X11) && USE(EGL) && USE(GRAPHICS_SURFACE)
     30
     31#include "EGLConfigSelector.h"
    3032
    3133namespace WebCore {
    3234
    33 EGLWindowTransportSurface::EGLWindowTransportSurface(const IntSize& size, SurfaceAttributes attributes)
    34     : GLTransportSurface(size, attributes)
     35EGLWindowTransportSurface::EGLWindowTransportSurface(const IntSize& size, GLPlatformSurface::SurfaceAttributes attributes)
     36    : EGLTransportSurface(size, attributes)
    3537{
    36     m_configSelector = adoptPtr(new EGLConfigSelector(attributes, NativeWrapper::nativeDisplay()));
    37     m_sharedDisplay = m_configSelector->display();
     38    if (!m_configSelector)
     39        return;
    3840
    39     if (m_sharedDisplay == EGL_NO_DISPLAY) {
    40         m_configSelector = nullptr;
     41    if (!m_configSelector->surfaceContextConfig()) {
     42        destroy();
    4143        return;
    4244    }
    4345
    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
     68EGLWindowTransportSurface::~EGLWindowTransportSurface()
     69{
     70}
     71
     72void EGLWindowTransportSurface::swapBuffers()
     73{
     74    if (!eglSwapBuffers(m_sharedDisplay, m_drawable))
     75        LOG_ERROR("Failed to SwapBuffers(%d).", eglGetError());
     76}
     77
     78void EGLWindowTransportSurface::destroy()
     79{
     80    EGLTransportSurface::destroy();
     81
     82    if (m_bufferHandle) {
     83        NativeWrapper::destroyWindow(m_bufferHandle);
     84        m_bufferHandle = 0;
     85    }
     86}
     87
     88EGLPixmapSurface::EGLPixmapSurface(GLPlatformSurface::SurfaceAttributes surfaceAttributes)
     89    : EGLOffScreenSurface(surfaceAttributes)
     90{
     91    if (!m_configSelector)
     92        return;
     93
     94    EGLConfig config = m_configSelector->pixmapContextConfig();
    4595
    4696    if (!config) {
     
    56106    }
    57107
    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;
    59111
    60112    if (!m_bufferHandle) {
     
    63115    }
    64116
    65     m_drawable = eglCreateWindowSurface(m_sharedDisplay, m_configSelector->surfaceContextConfig(), (EGLNativeWindowType)m_bufferHandle, 0);
     117    m_drawable = eglCreatePixmapSurface(m_sharedDisplay, config, static_cast<EGLNativePixmapType>(m_bufferHandle), 0);
    66118
    67119    if (m_drawable == EGL_NO_SURFACE) {
     
    71123}
    72124
    73 GLPlatformSurface::SurfaceAttributes EGLWindowTransportSurface::attributes() const
    74 {
    75     return m_configSelector->attributes();
    76 }
    77 
    78 EGLWindowTransportSurface::~EGLWindowTransportSurface()
     125EGLPixmapSurface::~EGLPixmapSurface()
    79126{
    80127}
    81128
    82 PlatformSurfaceConfig EGLWindowTransportSurface::configuration()
     129void EGLPixmapSurface::destroy()
    83130{
    84     return m_configSelector->surfaceContextConfig();
    85 }
     131    EGLOffScreenSurface::destroy();
    86132
    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;
    97136    }
    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);
    135137}
    136138
  • trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLXSurface.h

    r147221 r147222  
    11/*
    2  * Copyright (C) 2012 Intel Corporation. All rights reserved.
     2 * Copyright (C) 2013 Intel Corporation. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #ifndef EGLSurface_h
    27 #define EGLSurface_h
     26#ifndef EGLXSurface_h
     27#define EGLXSurface_h
    2828
    29 #if USE(EGL) && USE(GRAPHICS_SURFACE)
     29#if PLATFORM(X11) && USE(EGL) && USE(GRAPHICS_SURFACE)
    3030
    31 #include "EGLConfigSelector.h"
    32 #include "GLTransportSurface.h"
    33 
     31#include "EGLSurface.h"
    3432#include <glx/X11Helper.h>
    35 #include <wtf/Noncopyable.h>
    36 #include <wtf/PassOwnPtr.h>
    3733
    3834namespace WebCore {
    3935
    4036typedef X11Helper NativeWrapper;
     37typedef Pixmap NativePixmap;
    4138
    4239// Contents of the surface are backed by native window.
    43 class EGLWindowTransportSurface : public GLTransportSurface {
    44 
     40class EGLWindowTransportSurface : public EGLTransportSurface {
    4541public:
    46     EGLWindowTransportSurface(const IntSize&, SurfaceAttributes);
     42    EGLWindowTransportSurface(const IntSize&, GLPlatformSurface::SurfaceAttributes);
    4743    virtual ~EGLWindowTransportSurface();
    48     virtual PlatformSurfaceConfig configuration() OVERRIDE;
    49     virtual void setGeometry(const IntRect& newRect) OVERRIDE;
    5044    virtual void swapBuffers() OVERRIDE;
    5145    virtual void destroy() OVERRIDE;
    52     virtual GLPlatformSurface::SurfaceAttributes attributes() const OVERRIDE;
     46};
    5347
    54 private:
    55     void freeEGLResources();
    56     OwnPtr<EGLConfigSelector> m_configSelector;
     48class EGLPixmapSurface : public EGLOffScreenSurface {
     49public:
     50    EGLPixmapSurface(GLPlatformSurface::SurfaceAttributes);
     51    virtual ~EGLPixmapSurface();
     52    virtual void destroy() OVERRIDE;
    5753};
    5854
  • trunk/Source/cmake/OptionsEfl.cmake

    r146980 r147222  
    115115    list(APPEND ECORE_ADDITIONAL_COMPONENTS X)
    116116    add_definitions(-DHAVE_ECORE_X)
     117    add_definitions(-DWTF_PLATFORM_X11=1)
    117118endif ()
    118119
Note: See TracChangeset for help on using the changeset viewer.