Changeset 188522 in webkit


Ignore:
Timestamp:
Aug 17, 2015 8:36:16 AM (9 years ago)
Author:
commit-queue@webkit.org
Message:

Fix possible EGL and GLX makeCurrent problem of GLPlatformContext and GLPlatformSurface
https://bugs.webkit.org/show_bug.cgi?id=147695

Patch by Jinyoung Hur <hur.ims@navercorp.com> on 2015-08-17
Reviewed by Gyuyoung Kim.

GLPLatformContext::makeCurrent is implemented to do no-op when it thinks, comparing with a static
variable declared in GLPlatformContext.cpp, there is no changes. This can lead to not-working
makeCurrent when other part of codes, e.g., Cairo-gl, change EGL or GLX current context by calling
something like eglMakeCurrent. So modify GLPLatformContext::makeCurrent to use the return value of
eglGetCurrentContext or glXGetCurrentContext as a comparing target rather than a static variable.
In addition, GLPlatformSurface::isCurrentDrawable is also modified to use eglGetCurrentSurface or
glXGetCurrentDrawable rather than a static variable.

There are no tests because already existing GL tests will verify this change.

  • platform/graphics/opengl/GLPlatformContext.cpp:

(WebCore::GLPlatformContext::makeCurrent):
(WebCore::GLPlatformContext::releaseCurrent):
(WebCore::GLCurrentContextWrapper::GLCurrentContextWrapper): Deleted.
(WebCore::GLPlatformContext::~GLPlatformContext): Deleted.
(WebCore::GLPlatformContext::isCurrentContext): Deleted.
(WebCore::GLPlatformContext::getCurrent): Deleted.

  • platform/graphics/opengl/GLPlatformContext.h:
  • platform/graphics/opengl/GLPlatformSurface.cpp:

(WebCore::GLPlatformSurface::~GLPlatformSurface): Deleted.
(WebCore::GLPlatformSurface::isCurrentDrawable): Deleted.
(WebCore::GLPlatformSurface::onMakeCurrent): Deleted.
(WebCore::GLPlatformSurface::destroy): Deleted.

  • platform/graphics/opengl/GLPlatformSurface.h:
  • platform/graphics/surfaces/egl/EGLSurface.cpp:

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

  • platform/graphics/surfaces/egl/EGLSurface.h:
  • platform/graphics/surfaces/glx/GLXSurface.cpp:

(WebCore::GLXTransportSurface::isCurrentContext):
(WebCore::GLXOffScreenSurface::isCurrentContext):

  • platform/graphics/surfaces/glx/GLXSurface.h:
Location:
trunk/Source/WebCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r188520 r188522  
     12015-08-17  Jinyoung Hur  <hur.ims@navercorp.com>
     2
     3        Fix possible EGL and GLX makeCurrent problem of GLPlatformContext and GLPlatformSurface
     4        https://bugs.webkit.org/show_bug.cgi?id=147695
     5
     6        Reviewed by Gyuyoung Kim.
     7
     8        GLPLatformContext::makeCurrent is implemented to do no-op when it thinks, comparing with a static
     9        variable declared in GLPlatformContext.cpp, there is no changes. This can lead to not-working
     10        makeCurrent when other part of codes, e.g., Cairo-gl, change EGL or GLX current context by calling
     11        something like eglMakeCurrent. So modify GLPLatformContext::makeCurrent to use the return value of
     12        eglGetCurrentContext or glXGetCurrentContext as a comparing target rather than a static variable.
     13        In addition, GLPlatformSurface::isCurrentDrawable is also modified to use eglGetCurrentSurface or
     14        glXGetCurrentDrawable rather than a static variable.
     15
     16        There are no tests because already existing GL tests will verify this change.
     17
     18        * platform/graphics/opengl/GLPlatformContext.cpp:
     19        (WebCore::GLPlatformContext::makeCurrent):
     20        (WebCore::GLPlatformContext::releaseCurrent):
     21        (WebCore::GLCurrentContextWrapper::GLCurrentContextWrapper): Deleted.
     22        (WebCore::GLPlatformContext::~GLPlatformContext): Deleted.
     23        (WebCore::GLPlatformContext::isCurrentContext): Deleted.
     24        (WebCore::GLPlatformContext::getCurrent): Deleted.
     25        * platform/graphics/opengl/GLPlatformContext.h:
     26        * platform/graphics/opengl/GLPlatformSurface.cpp:
     27        (WebCore::GLPlatformSurface::~GLPlatformSurface): Deleted.
     28        (WebCore::GLPlatformSurface::isCurrentDrawable): Deleted.
     29        (WebCore::GLPlatformSurface::onMakeCurrent): Deleted.
     30        (WebCore::GLPlatformSurface::destroy): Deleted.
     31        * platform/graphics/opengl/GLPlatformSurface.h:
     32        * platform/graphics/surfaces/egl/EGLSurface.cpp:
     33        (WebCore::EGLTransportSurface::isCurrentDrawable):
     34        (WebCore::EGLOffScreenSurface::isCurrentDrawable):
     35        * platform/graphics/surfaces/egl/EGLSurface.h:
     36        * platform/graphics/surfaces/glx/GLXSurface.cpp:
     37        (WebCore::GLXTransportSurface::isCurrentContext):
     38        (WebCore::GLXOffScreenSurface::isCurrentContext):
     39        * platform/graphics/surfaces/glx/GLXSurface.h:
     40
    1412015-08-15  Chris Dumez  <cdumez@apple.com>
    242
  • trunk/Source/WebCore/platform/graphics/opengl/GLPlatformContext.cpp

    r183432 r188522  
    4444static PFNGLGETGRAPHICSRESETSTATUSARBPROC glGetGraphicsResetStatus = 0;
    4545#endif
    46 static GLPlatformContext* m_currentContext = 0;
    4746
    4847class GLCurrentContextWrapper : public GLPlatformContext {
     
    5756        m_contextHandle = eglGetCurrentContext();
    5857#endif
    59         if (m_contextHandle)
    60             m_currentContext = this;
    6158    }
    6259
    6360    virtual ~GLCurrentContextWrapper() { }
     61
     62    bool isCurrentContext() const override
     63    {
     64        return true;
     65    }
    6466};
    6567
     
    186188GLPlatformContext::~GLPlatformContext()
    187189{
    188     if (this == m_currentContext)
    189         m_currentContext = 0;
    190190}
    191191
     
    194194    m_contextLost = false;
    195195
    196     if (m_currentContext == this && (!surface || surface->isCurrentDrawable()))
    197         return true;
    198 
    199     m_currentContext = 0;
     196    if (isCurrentContext() && (!surface || surface->isCurrentDrawable()))
     197        return true;
     198
     199    GLPlatformContext* currentContext = 0;
    200200
    201201    if (!surface || (surface && !surface->drawable()))
    202202        platformReleaseCurrent();
    203203    else if (platformMakeCurrent(surface)) {
    204         m_currentContext = this;
     204        currentContext = this;
    205205        surface->onMakeCurrent();
    206206    }
     
    229229    }
    230230
    231     return m_currentContext;
     231    return currentContext;
    232232}
    233233
     
    239239void GLPlatformContext::releaseCurrent()
    240240{
    241     if (this == m_currentContext) {
    242         m_currentContext = 0;
     241    if (isCurrentContext())
    243242        platformReleaseCurrent();
    244     }
    245243}
    246244
     
    250248}
    251249
    252 bool GLPlatformContext::isCurrentContext() const
     250bool GLPlatformContext::initialize(GLPlatformSurface*, PlatformContext)
    253251{
    254252    return true;
    255 }
    256 
    257 bool GLPlatformContext::initialize(GLPlatformSurface*, PlatformContext)
    258 {
    259     return true;
    260 }
    261 
    262 GLPlatformContext* GLPlatformContext::getCurrent()
    263 {
    264     return m_currentContext;
    265253}
    266254
  • trunk/Source/WebCore/platform/graphics/opengl/GLPlatformContext.h

    r166889 r188522  
    7474    virtual PlatformContext handle() const;
    7575
    76     virtual bool isCurrentContext() const;
     76    virtual bool isCurrentContext() const = 0;
    7777
    7878    bool isValid() const;
     
    8080    // Destroys any GL resources associated with this context.
    8181    virtual void destroy();
    82 
    83     static GLPlatformContext* getCurrent();
    8482
    8583protected:
  • trunk/Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp

    r183868 r188522  
    4141namespace WebCore {
    4242
    43 static GLPlatformSurface* m_currentDrawable = 0;
    44 
    4543std::unique_ptr<GLPlatformSurface> GLPlatformSurface::createOffScreenSurface(SurfaceAttributes attributes)
    4644{
     
    6967GLPlatformSurface::~GLPlatformSurface()
    7068{
    71     if (m_currentDrawable == this)
    72         m_currentDrawable = 0;
    7369}
    7470
     
    9894}
    9995
    100 bool GLPlatformSurface::isCurrentDrawable() const
    101 {
    102     return m_currentDrawable == this;
    103 }
    104 
    10596void GLPlatformSurface::onMakeCurrent()
    10697{
    107     m_currentDrawable = this;
    10898}
    10999
     
    118108void GLPlatformSurface::destroy()
    119109{
    120     if (m_currentDrawable == this)
    121         m_currentDrawable = 0;
    122110}
    123111
  • trunk/Source/WebCore/platform/graphics/opengl/GLPlatformSurface.h

    r183868 r188522  
    6464    virtual void swapBuffers();
    6565
    66     virtual bool isCurrentDrawable() const;
     66    virtual bool isCurrentDrawable() const = 0;
     67
    6768    virtual void onMakeCurrent();
    6869
  • trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.cpp

    r183868 r188522  
    8787}
    8888
     89bool EGLTransportSurface::isCurrentDrawable() const
     90{
     91    return m_drawable == eglGetCurrentSurface(EGL_DRAW);
     92}
     93
    8994EGLTransportSurface::~EGLTransportSurface()
    9095{
     
    139144}
    140145
     146bool EGLOffScreenSurface::isCurrentDrawable() const
     147{
     148    return m_drawable == eglGetCurrentSurface(EGL_DRAW);
     149}
     150
    141151PlatformSurfaceConfig EGLOffScreenSurface::configuration()
    142152{
  • trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.h

    r177429 r188522  
    4545    virtual void destroy() override;
    4646    virtual GLPlatformSurface::SurfaceAttributes attributes() const override;
     47    virtual bool isCurrentDrawable() const override;
    4748
    4849protected:
     
    5859    virtual void destroy() override;
    5960    virtual GLPlatformSurface::SurfaceAttributes attributes() const override;
     61    virtual bool isCurrentDrawable() const override;
    6062
    6163protected:
  • trunk/Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.cpp

    r184197 r188522  
    129129}
    130130
     131bool GLXTransportSurface::isCurrentDrawable() const
     132{
     133    return m_drawable == glXGetCurrentDrawable();
     134}
     135
    131136GLXOffScreenSurface::GLXOffScreenSurface(SurfaceAttributes surfaceAttributes)
    132137    : GLPlatformSurface(surfaceAttributes)
     
    166171{
    167172    return m_configSelector->pixmapContextConfig();
     173}
     174
     175bool GLXOffScreenSurface::isCurrentDrawable() const
     176{
     177    return m_drawable == glXGetCurrentDrawable();
    168178}
    169179
  • trunk/Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.h

    r177429 r188522  
    4444    virtual void setGeometry(const IntRect&) override;
    4545    virtual GLPlatformSurface::SurfaceAttributes attributes() const override;
     46    virtual bool isCurrentDrawable() const override;
    4647    virtual void destroy() override;
    4748
     
    5657    virtual ~GLXOffScreenSurface();
    5758    virtual PlatformSurfaceConfig configuration() override;
     59    virtual bool isCurrentDrawable() const override;
    5860    virtual void destroy() override;
    5961
Note: See TracChangeset for help on using the changeset viewer.