Changeset 142587 in webkit


Ignore:
Timestamp:
Feb 11, 2013 11:26:45 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

[Qt][EFL][WebGL] Minor refactoring of GraphicsSurface/GraphicsSurfaceGLX
https://bugs.webkit.org/show_bug.cgi?id=108686

Patch by Viatcheslav Ostapenko <sl.ostapenko@samsung.com> on 2013-02-11
Reviewed by Noam Rosenthal.

Remove unused platformSurface()/m_platformSurface from GraphicsSurface.
Move m_texture from GraphicsSurface to GLX GraphicsSurfacePrivate to match
Win and Mac implementations.

No new tests, refactoring only.

  • platform/graphics/surfaces/GraphicsSurface.cpp:

(WebCore::GraphicsSurface::GraphicsSurface):

  • platform/graphics/surfaces/GraphicsSurface.h:

(GraphicsSurface):

  • platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp:

(WebCore::GraphicsSurfacePrivate::GraphicsSurfacePrivate):
(WebCore::GraphicsSurfacePrivate::swapBuffers):
(WebCore::GraphicsSurfacePrivate::surface):
(GraphicsSurfacePrivate):
(WebCore::GraphicsSurfacePrivate::textureID):
(WebCore::GraphicsSurfacePrivate::clear):
(WebCore::GraphicsSurface::platformExport):
(WebCore::GraphicsSurface::platformGetTextureID):
(WebCore::GraphicsSurface::platformSwapBuffers):
(WebCore::GraphicsSurface::platformCreate):
(WebCore::GraphicsSurface::platformImport):
(WebCore::GraphicsSurface::platformDestroy):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r142586 r142587  
     12013-02-11  Viatcheslav Ostapenko  <sl.ostapenko@samsung.com>
     2
     3        [Qt][EFL][WebGL] Minor refactoring of GraphicsSurface/GraphicsSurfaceGLX
     4        https://bugs.webkit.org/show_bug.cgi?id=108686
     5
     6        Reviewed by Noam Rosenthal.
     7
     8        Remove unused platformSurface()/m_platformSurface from GraphicsSurface.
     9        Move m_texture from GraphicsSurface to GLX GraphicsSurfacePrivate to match
     10        Win and Mac implementations.
     11
     12        No new tests, refactoring only.
     13
     14        * platform/graphics/surfaces/GraphicsSurface.cpp:
     15        (WebCore::GraphicsSurface::GraphicsSurface):
     16        * platform/graphics/surfaces/GraphicsSurface.h:
     17        (GraphicsSurface):
     18        * platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp:
     19        (WebCore::GraphicsSurfacePrivate::GraphicsSurfacePrivate):
     20        (WebCore::GraphicsSurfacePrivate::swapBuffers):
     21        (WebCore::GraphicsSurfacePrivate::surface):
     22        (GraphicsSurfacePrivate):
     23        (WebCore::GraphicsSurfacePrivate::textureID):
     24        (WebCore::GraphicsSurfacePrivate::clear):
     25        (WebCore::GraphicsSurface::platformExport):
     26        (WebCore::GraphicsSurface::platformGetTextureID):
     27        (WebCore::GraphicsSurface::platformSwapBuffers):
     28        (WebCore::GraphicsSurface::platformCreate):
     29        (WebCore::GraphicsSurface::platformImport):
     30        (WebCore::GraphicsSurface::platformDestroy):
     31
    1322013-02-11  Viatcheslav Ostapenko  <sl.ostapenko@samsung.com>
    233
  • trunk/Source/WebCore/platform/graphics/surfaces/GraphicsSurface.cpp

    r137058 r142587  
    8686GraphicsSurface::GraphicsSurface(const IntSize&, Flags flags)
    8787    : m_flags(flags)
    88     , m_platformSurface(0)
    89     , m_texture(0)
    9088    , m_fbo(0)
    9189    , m_private(0)
  • trunk/Source/WebCore/platform/graphics/surfaces/GraphicsSurface.h

    r135706 r142587  
    7474
    7575    Flags flags() const { return m_flags; }
    76     PlatformGraphicsSurface platformSurface() const { return m_platformSurface; }
    7776    IntSize size() const;
    7877
     
    120119
    121120private:
    122     PlatformGraphicsSurface m_platformSurface;
    123     uint32_t m_texture;
    124121    uint32_t m_fbo;
    125122    GraphicsSurfacePrivate* m_private;
  • trunk/Source/WebCore/platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp

    r142355 r142587  
    7474        , m_detachedSurface(0)
    7575        , m_isReceiver(false)
     76        , m_texture(0)
    7677    {
    7778        GLXContext shareContextObject = 0;
     
    108109        , m_detachedSurface(0)
    109110        , m_isReceiver(true)
     111        , m_texture(0)
    110112    {
    111113        m_configSelector = adoptPtr(new GLXConfigSelector());
     
    191193    void swapBuffers()
    192194    {
    193         // The buffers are being switched on the writing side, the reading side just reads
    194         // whatever texture the XWindow contains.
    195         if (m_isReceiver)
     195        if (isReceiver()) {
     196            if (isMesaGLX() && textureID()) {
     197                glBindTexture(GL_TEXTURE_2D, textureID());
     198                // Mesa doesn't re-bind texture to the front buffer on glXSwapBufer
     199                // Manually release previous lock and rebind texture to surface to ensure frame updates.
     200                pGlXReleaseTexImageEXT(display(), glxPixmap(), GLX_FRONT_EXT);
     201                pGlXBindTexImageEXT(display(), glxPixmap(), GLX_FRONT_EXT, 0);
     202            }
     203
    196204            return;
     205        }
    197206
    198207        GLXContext glContext = glXGetCurrentContext();
     
    262271    TextureMapperGL::Flags flags() const { return m_flags; }
    263272
     273    Window surface() const { return m_surface; }
     274
     275    GLuint textureID() const
     276    {
     277        if (m_texture)
     278            return m_texture;
     279
     280        GLXPixmap pixmap = glxPixmap();
     281        if (!pixmap)
     282            return 0;
     283
     284        GLuint texture;
     285        glGenTextures(1, &texture);
     286        glBindTexture(GL_TEXTURE_2D, texture);
     287        glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
     288        glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
     289        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
     290        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
     291        pGlXBindTexImageEXT(display(), pixmap, GLX_FRONT_EXT, 0);
     292        const_cast<GraphicsSurfacePrivate*>(this)->m_texture = texture;
     293
     294        return texture;
     295    }
    264296private:
    265297    void clear()
    266298    {
     299        if (m_texture) {
     300            pGlXReleaseTexImageEXT(display(), glxPixmap(), GLX_FRONT_EXT);
     301            glDeleteTextures(1, &m_texture);
     302        }
     303
    267304        if (m_glxPixmap) {
    268305            glXDestroyPixmap(display(), m_glxPixmap);
     
    301338    bool m_isReceiver;
    302339    TextureMapperGL::Flags m_flags;
     340    GLuint m_texture;
    303341};
    304342
     
    323361GraphicsSurfaceToken GraphicsSurface::platformExport()
    324362{
    325     return GraphicsSurfaceToken(m_platformSurface);
     363    return GraphicsSurfaceToken(m_private->surface());
    326364}
    327365
    328366uint32_t GraphicsSurface::platformGetTextureID()
    329367{
    330     if (!m_texture) {
    331         GLXPixmap pixmap = m_private->glxPixmap();
    332         if (!pixmap)
    333             return 0;
    334 
    335         glGenTextures(1, &m_texture);
    336         glBindTexture(GL_TEXTURE_2D, m_texture);
    337         glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    338         glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    339         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    340         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    341         pGlXBindTexImageEXT(m_private->display(), pixmap, GLX_FRONT_EXT, 0);
    342     }
    343 
    344     return m_texture;
     368    return m_private->textureID();
    345369}
    346370
     
    377401uint32_t GraphicsSurface::platformSwapBuffers()
    378402{
    379     if (m_private->isReceiver()) {
    380         if (isMesaGLX() && platformGetTextureID()) {
    381             glBindTexture(GL_TEXTURE_2D, platformGetTextureID());
    382             // Mesa doesn't re-bind texture to the front buffer on glXSwapBufer
    383             // Manually release previous lock and rebind texture to surface to get frame update.
    384             pGlXReleaseTexImageEXT(m_private->display(), m_private->glxPixmap(), GLX_FRONT_EXT);
    385             pGlXBindTexImageEXT(m_private->display(), m_private->glxPixmap(), GLX_FRONT_EXT, 0);
    386         }
    387         return 0;
    388     }
    389 
    390403    m_private->swapBuffers();
    391404    return 0;
     
    411424        return PassRefPtr<GraphicsSurface>();
    412425
    413     surface->m_platformSurface = surface->m_private->createSurface(size);
     426    surface->m_private->createSurface(size);
    414427
    415428    return surface;
     
    425438
    426439    RefPtr<GraphicsSurface> surface = adoptRef(new GraphicsSurface(size, flags));
    427     surface->m_platformSurface = token.frontBufferHandle;
    428 
    429     surface->m_private = new GraphicsSurfacePrivate(surface->m_platformSurface);
     440
     441    surface->m_private = new GraphicsSurfacePrivate(token.frontBufferHandle);
    430442    if (!resolveGLMethods())
    431443        return PassRefPtr<GraphicsSurface>();
     
    447459void GraphicsSurface::platformDestroy()
    448460{
    449     if (m_texture) {
    450         pGlXReleaseTexImageEXT(m_private->display(), m_private->glxPixmap(), GLX_FRONT_EXT);
    451         glDeleteTextures(1, &m_texture);
    452     }
    453 
    454461    delete m_private;
    455462    m_private = 0;
Note: See TracChangeset for help on using the changeset viewer.