LayerManagerPlugins: Merge CopyGLES and EglImage to GLESTexture for WaylandPlugins
authorNobuhiko Tanibata <ntanibata@jp.adit-jv.com>
Thu, 21 Jun 2012 03:03:45 +0000 (12:03 +0900)
committerMichael Schuldt <michael.schuldt@bmw.de>
Tue, 26 Jun 2012 14:04:54 +0000 (16:04 +0200)
LayerManagerPlugins/Renderers/Graphic/CMakeLists.txt
LayerManagerPlugins/Renderers/Graphic/include/TextureBinders/WaylandCopyGLES.h [deleted file]
LayerManagerPlugins/Renderers/Graphic/include/TextureBinders/WaylandGLESTexture.h [moved from LayerManagerPlugins/Renderers/Graphic/include/TextureBinders/WaylandEglImage.h with 83% similarity]
LayerManagerPlugins/Renderers/Graphic/src/TextureBinders/WaylandCopyGLES.cpp [deleted file]
LayerManagerPlugins/Renderers/Graphic/src/TextureBinders/WaylandEglImage.cpp [deleted file]
LayerManagerPlugins/Renderers/Graphic/src/TextureBinders/WaylandGLESTexture.cpp [new file with mode: 0644]
LayerManagerPlugins/Renderers/Platform/WaylandGLESRenderer/src/WaylandGLESRenderer.cpp

index b6fc83d..ba3885c 100644 (file)
@@ -270,8 +270,7 @@ if (WITH_WAYLAND)
             src/WindowSystems/WaylandBaseWindowSystem.cpp
             src/WindowSystems/WaylandX11WindowSystem.cpp
             src/WindowSystems/WaylandServerinfoProtocol.cpp  
-            src/TextureBinders/WaylandCopyGLES.cpp
-            src/TextureBinders/WaylandEglImage.cpp
+            src/TextureBinders/WaylandGLESTexture.cpp
             src/Transformation/ViewportTransform.cpp
         )
         
@@ -294,8 +293,7 @@ if (WITH_WAYLAND)
             src/WindowSystems/WaylandBaseWindowSystem.cpp
             src/WindowSystems/WaylandFbdevWindowSystem.cpp
             src/WindowSystems/WaylandServerinfoProtocol.cpp  
-            src/TextureBinders/WaylandCopyGLES.cpp
-            src/TextureBinders/WaylandEglImage.cpp
+            src/TextureBinders/WaylandGLESTexture.cpp
             src/Transformation/ViewportTransform.cpp
         )
 
@@ -328,8 +326,7 @@ if (WITH_WAYLAND)
             src/WindowSystems/WaylandBaseWindowSystem.cpp
             src/WindowSystems/WaylandDrmWindowSystem.cpp
             src/WindowSystems/WaylandServerinfoProtocol.cpp
-            src/TextureBinders/WaylandCopyGLES.cpp
-            src/TextureBinders/WaylandEglImage.cpp
+            src/TextureBinders/WaylandGLESTexture.cpp
             src/Transformation/ViewportTransform.cpp
         )
 
@@ -360,8 +357,7 @@ if (WITH_WAYLAND)
 
     install(FILES
                 include/TextureBinders/ITextureBinder.h
-                include/TextureBinders/WaylandCopyGLES.h
-                include/TextureBinders/WaylandEglImage.h
+                include/TextureBinders/WaylandGLESTexture.h
             DESTINATION
                 include/layermanager/graphic/TextureBinders
     )
diff --git a/LayerManagerPlugins/Renderers/Graphic/include/TextureBinders/WaylandCopyGLES.h b/LayerManagerPlugins/Renderers/Graphic/include/TextureBinders/WaylandCopyGLES.h
deleted file mode 100644 (file)
index e79996c..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/***************************************************************************
- *
- * Copyright 2010, 2011 BMW Car IT GmbH  
- * Copyright (C) 2011 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ****************************************************************************/
-
-#ifndef _WAYLANDCOPYGLES_H_
-#define _WAYLANDCOPYGLES_H_
-
-#include "TextureBinders/ITextureBinder.h"
-#include <EGL/egl.h>
-#include <EGL/eglext.h>
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
-
-class WaylandCopyGLES: public ITextureBinder
-{
-public:
-    virtual PlatformSurface* createPlatformSurface(Surface* surface);
-
-    WaylandCopyGLES(EGLDisplay eglDisplay, struct wl_display* waylandDisplay);
-    ~WaylandCopyGLES();
-    bool bindSurfaceTexture(Surface* surface);
-    bool unbindSurfaceTexture(Surface* surface);
-    void createClientBuffer(Surface* surface);
-    void destroyClientBuffer(Surface* surface);
-
-private:
-    EGLDisplay m_eglDisplay;
-    struct wl_display* m_wlDisplay;
-};
-
-#endif /* _WAYLANDCOPYGLES_H_ */
@@ -1,6 +1,6 @@
 /***************************************************************************
  *
- * Copyright 2010,2011 BMW Car IT GmbH
+ * Copyright 2010, 2011 BMW Car IT GmbH
  * Copyright (C) 2011 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
  *
  *
@@ -18,8 +18,8 @@
  *
  ****************************************************************************/
 
-#ifndef _WAYLANDEGLIMAGE_H_
-#define _WAYLANDEGLIMAGE_H_
+#ifndef _WAYLANDGLESTEXTURE_H_
+#define _WAYLANDGLESTEXTURE_H_
 
 #include "TextureBinders/ITextureBinder.h"
 #include <EGL/egl.h>
 #include <GLES2/gl2.h>
 #include <GLES2/gl2ext.h>
 
-class WaylandEglImage: public ITextureBinder
+class WaylandGLESTexture: public ITextureBinder
 {
 public:
     virtual PlatformSurface* createPlatformSurface(Surface* surface);
 
-    WaylandEglImage(EGLDisplay eglDisplay, struct wl_display* wlDisplay);
-    ~WaylandEglImage();
+    WaylandGLESTexture(EGLDisplay eglDisplay, struct wl_display* waylandDisplay);
+    ~WaylandGLESTexture();
     bool bindSurfaceTexture(Surface* surface);
     bool unbindSurfaceTexture(Surface* surface);
     void createClientBuffer(Surface* surface);
@@ -47,4 +47,4 @@ private:
     struct wl_display* m_wlDisplay;
 };
 
-#endif /* _WAYLANDEGLIMAGE_H_ */
+#endif /* _WAYLANDGLESTEXTURE_H_ */
diff --git a/LayerManagerPlugins/Renderers/Graphic/src/TextureBinders/WaylandCopyGLES.cpp b/LayerManagerPlugins/Renderers/Graphic/src/TextureBinders/WaylandCopyGLES.cpp
deleted file mode 100644 (file)
index 635903f..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-/***************************************************************************
-*
-* Copyright 2010, 2011 BMW Car IT GmbH  
-* Copyright (C) 2011 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
-*
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*        http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*
-****************************************************************************/
-
-#include "TextureBinders/WaylandCopyGLES.h"
-#include <EGL/egl.h>
-#include <EGL/eglext.h>
-#include <GLES2/gl2ext.h>
-#include "PlatformSurfaces/EglWaylandPlatformSurface.h"
-#include "Log.h"
-#include "wayland-server.h"
-
-WaylandCopyGLES::WaylandCopyGLES(EGLDisplay eglDisplay, struct wl_display* wlDisplay)
-: m_eglDisplay(eglDisplay)
-, m_wlDisplay(wlDisplay)
-{
-}
-
-WaylandCopyGLES::~WaylandCopyGLES()
-{
-}
-
-bool WaylandCopyGLES::bindSurfaceTexture(Surface* surface)
-{
-    LOG_DEBUG("WaylandCopyGLES", "bindSurfaceTexture IN");
-    EglWaylandPlatformSurface* nativeSurface = (EglWaylandPlatformSurface*)surface->platform;
-    if (nativeSurface && nativeSurface->isReadyForRendering())
-    {
-        struct wl_buffer* buffer = (struct wl_buffer*)surface->getNativeContent();
-        glBindTexture(GL_TEXTURE_2D, nativeSurface->texture);
-        glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,     GL_CLAMP_TO_EDGE);
-        glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,     GL_CLAMP_TO_EDGE);
-        glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-        glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-        LOG_DEBUG("WaylandEglImage", "width:"<<surface->OriginalSourceWidth<<", height:"<<surface->OriginalSourceHeight);
-        unsigned int* pBuf = (unsigned int*)wl_shm_buffer_get_data(buffer);
-        LOG_DEBUG("WaylandEglImage", "buffer:"<<pBuf);
-        {
-            unsigned int* pTmp = (unsigned int*)pBuf;
-            unsigned int col = 0;
-            int cnt = 0;
-            unsigned int* pCnvImg = (unsigned int*)malloc(sizeof(unsigned int) * surface->OriginalSourceWidth * surface->OriginalSourceHeight);
-            unsigned int* pCnvImgTmp = pCnvImg;
-            for (cnt = 0; cnt < surface->OriginalSourceWidth * surface->OriginalSourceHeight; cnt++, pTmp++, pCnvImgTmp++)
-            {
-                col = (unsigned int)*pTmp;
-                // TODO:endian
-                *pCnvImgTmp = (col&0xFF00FF00) | ((col&0x00FF0000)>>16) | ((col&0x000000FF)<<16);
-            }
-            glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, surface->OriginalSourceWidth, surface->OriginalSourceHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, pCnvImg);
-            free(pCnvImg);
-        }
-        LOG_DEBUG("WaylandEglImage", "bindSurfaceTexture OUT");
-        return true;
-    }
-    LOG_DEBUG("WaylandCopyGLES", "bindSurfaceTexture ERROR OUT");
-    return false;
-}
-
-bool WaylandCopyGLES::unbindSurfaceTexture(Surface* surface)
-{
-    LOG_DEBUG("WaylandCopyGLES", "unbindSurfaceTexture:surface" << surface);
-    return true;
-}
-
-void WaylandCopyGLES::createClientBuffer(Surface* surface)
-{
-    LOG_DEBUG("WaylandCopyGLES", "creating client buffer with native display: " << m_wlDisplay << " for native handle: " << surface->getNativeContent());
-    EglWaylandPlatformSurface* nativeSurface = (EglWaylandPlatformSurface*)surface->platform;
-    if (NULL!=nativeSurface)
-    {
-        if (nativeSurface->texture)
-       {
-            glDeleteTextures(1,&nativeSurface->texture);
-            nativeSurface->texture = 0;
-        }
-        glGenTextures(1,&nativeSurface->texture);
-    }
-}
-
-PlatformSurface* WaylandCopyGLES::createPlatformSurface(Surface* surface)
-{
-    return new EglWaylandPlatformSurface(surface);
-}
-
-void WaylandCopyGLES::destroyClientBuffer(Surface* surface)
-{
-    EglWaylandPlatformSurface* nativeSurface = (EglWaylandPlatformSurface*)surface->platform;
-    if (nativeSurface && nativeSurface->texture)
-    {
-        glDeleteTextures(1,&nativeSurface->texture);
-        nativeSurface->texture = 0;
-    }
-}
diff --git a/LayerManagerPlugins/Renderers/Graphic/src/TextureBinders/WaylandEglImage.cpp b/LayerManagerPlugins/Renderers/Graphic/src/TextureBinders/WaylandEglImage.cpp
deleted file mode 100644 (file)
index 08871d5..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-/***************************************************************************
-*
-* Copyright 2010,2011 BMW Car IT GmbH
-* Copyright (C) 2011 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
-*
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*        http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*
-****************************************************************************/
-
-#include "TextureBinders/WaylandEglImage.h"
-#include "config.h"
-#include <EGL/egl.h>
-#include <EGL/eglext.h>
-#include <GLES2/gl2ext.h>
-#include "PlatformSurfaces/EglWaylandPlatformSurface.h"
-#include "Log.h"
-#include "wayland-server.h"
-
-WaylandEglImage::WaylandEglImage(EGLDisplay eglDisplay, struct wl_display* wlDisplay)
-: m_eglDisplay(eglDisplay)
-, m_wlDisplay(wlDisplay)
-{
-    // pseudo require EGL to have been initialised
-    // we dont really need the EGL handle as such
-
-    m_pfGLEglImageTargetTexture2DOES = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)eglGetProcAddress("glEGLImageTargetTexture2DOES");
-    m_pfEglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC)eglGetProcAddress("eglCreateImageKHR");
-    m_pfEglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC)eglGetProcAddress("eglDestroyImageKHR");
-
-    if (!m_pfEglCreateImageKHR || !m_pfEglDestroyImageKHR || !m_pfGLEglImageTargetTexture2DOES)
-    {
-        LOG_ERROR("WaylandEglImage", "Query EGL Extensions failed");
-    }
-}
-
-WaylandEglImage::~WaylandEglImage()
-{
-}
-
-bool WaylandEglImage::bindSurfaceTexture(Surface* surface)
-{
-    EglWaylandPlatformSurface* nativeSurface = (EglWaylandPlatformSurface*)surface->platform;
-    if (nativeSurface && nativeSurface->isReadyForRendering())
-    {
-        glBindTexture(GL_TEXTURE_2D, nativeSurface->texture);
-        if (nativeSurface->eglImage)
-        {
-            glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,     GL_CLAMP_TO_EDGE);
-            glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,     GL_CLAMP_TO_EDGE);
-            glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-            glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-            m_pfGLEglImageTargetTexture2DOES(GL_TEXTURE_2D, nativeSurface->eglImage);
-            return true;
-        }
-    }
-    return false;
-}
-
-bool WaylandEglImage::unbindSurfaceTexture(Surface* surface)
-{
-    (void)surface; // TODO: remove, only prevents warning
-
-    // TODO
-    return true;
-}
-
-void WaylandEglImage::createClientBuffer(Surface* surface)
-{
-    LOG_DEBUG("WaylandEglImage", "creating client buffer with native display: " << m_wlDisplay << " for native handle: " << surface->getNativeContent());
-    EglWaylandPlatformSurface* nativeSurface = (EglWaylandPlatformSurface*)surface->platform;
-    if (NULL!=nativeSurface)
-    {
-        struct wl_buffer* buffer = (struct wl_buffer*)surface->getNativeContent();
-        EGLImageKHR eglImage = 0;
-        LOG_DEBUG("WaylandEglImage", "creating EGL Image from client buffer");
-        if (nativeSurface->eglImage)
-        {
-#ifdef WITH_WAYLAND_DRM
-            if (nativeSurface->texture){
-                glBindTexture(GL_TEXTURE_2D, 0);
-                glDeleteTextures(1,&nativeSurface->texture);
-            }
-#else
-            m_pfEglDestroyImageKHR(m_eglDisplay, nativeSurface->eglImage);
-            glDeleteTextures(1,&nativeSurface->texture);
-#endif // WITH_WAYLAND_DRM
-            nativeSurface->eglImage = 0;
-            nativeSurface->texture = 0;
-        }
-        eglImage = m_pfEglCreateImageKHR(m_eglDisplay,
-                                     EGL_NO_CONTEXT,
-                                     EGL_WAYLAND_BUFFER_WL,
-                                     (EGLClientBuffer)buffer,
-                                     NULL);
-        if (!eglImage)
-        {
-            LOG_DEBUG("WaylandEglImage", "could not allocate EGL Image for window");
-        }
-        else
-        {
-            nativeSurface->eglImage = eglImage;
-            glGenTextures(1,&nativeSurface->texture);
-        }
-    } else {
-        LOG_DEBUG("WaylandEglImage", "native surface is NULL-----------------------------------------------------");
-    }
-}
-
-PlatformSurface* WaylandEglImage::createPlatformSurface(Surface* surface)
-{
-    return new EglWaylandPlatformSurface(surface);
-}
-
-void WaylandEglImage::destroyClientBuffer(Surface* surface)
-{
-    EglWaylandPlatformSurface* nativeSurface = (EglWaylandPlatformSurface*)surface->platform;
-    if (nativeSurface && nativeSurface->eglImage)
-    {
-        m_pfEglDestroyImageKHR(m_eglDisplay, nativeSurface->eglImage);
-        glDeleteTextures(1,&nativeSurface->texture);
-        nativeSurface->eglImage = 0;
-        nativeSurface->texture = 0;
-    }
-}
diff --git a/LayerManagerPlugins/Renderers/Graphic/src/TextureBinders/WaylandGLESTexture.cpp b/LayerManagerPlugins/Renderers/Graphic/src/TextureBinders/WaylandGLESTexture.cpp
new file mode 100644 (file)
index 0000000..2950c2c
--- /dev/null
@@ -0,0 +1,198 @@
+/***************************************************************************
+*
+* Copyright 2010, 2011 BMW Car IT GmbH
+* Copyright (C) 2011 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
+*
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*        http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+****************************************************************************/
+
+#include "TextureBinders/WaylandGLESTexture.h"
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+#include <GLES2/gl2ext.h>
+#include "PlatformSurfaces/EglWaylandPlatformSurface.h"
+#include "Log.h"
+#include "wayland-server.h"
+#include "config.h"
+
+WaylandGLESTexture::WaylandGLESTexture(EGLDisplay eglDisplay, struct wl_display* wlDisplay)
+: m_eglDisplay(eglDisplay)
+, m_wlDisplay(wlDisplay)
+{
+    // pseudo require EGL to have been initialised
+    // we dont really need the EGL handle as such
+
+    m_pfGLEglImageTargetTexture2DOES = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)eglGetProcAddress("glEGLImageTargetTexture2DOES");
+    m_pfEglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC)eglGetProcAddress("eglCreateImageKHR");
+    m_pfEglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC)eglGetProcAddress("eglDestroyImageKHR");
+
+    if (!m_pfEglCreateImageKHR || !m_pfEglDestroyImageKHR || !m_pfGLEglImageTargetTexture2DOES)
+    {
+        LOG_ERROR("WaylandGLESTexture", "Query EGL Extensions failed");
+    }
+}
+
+WaylandGLESTexture::~WaylandGLESTexture()
+{
+}
+
+bool WaylandGLESTexture::bindSurfaceTexture(Surface* surface)
+{
+    LOG_DEBUG("WaylandGLESTexture", "bindSurfaceTexture IN");
+    EglWaylandPlatformSurface* nativeSurface = (EglWaylandPlatformSurface*)surface->platform;
+    if (nativeSurface && nativeSurface->isReadyForRendering())
+    {
+        struct wl_buffer* buffer = (struct wl_buffer*)surface->getNativeContent();
+        if (wl_buffer_is_shm(buffer))
+        {
+            /* Wayland SHM buffer */
+            unsigned int* pBuf = (unsigned int*)wl_shm_buffer_get_data(buffer);
+            if( (NULL != buffer) && (NULL != pBuf) )
+            {
+                LOG_DEBUG("WaylandGLESTexture", "SHM buffer address:"<<pBuf);
+                unsigned int* pTmp = (unsigned int*)pBuf;
+                unsigned int col = 0;
+                int cnt = 0;
+                unsigned int* pCnvImg = (unsigned int*)malloc(sizeof(unsigned int) * surface->OriginalSourceWidth * surface->OriginalSourceHeight);
+                unsigned int* pCnvImgTmp = pCnvImg;
+                for (cnt = 0; cnt < surface->OriginalSourceWidth * surface->OriginalSourceHeight; cnt++, pTmp++, pCnvImgTmp++)
+                {
+                    col = (unsigned int)*pTmp;
+                    // TODO:endian
+                    *pCnvImgTmp = (col&0xFF00FF00) | ((col&0x00FF0000)>>16) | ((col&0x000000FF)<<16);
+                }
+
+                glBindTexture(GL_TEXTURE_2D, nativeSurface->texture);
+                glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,     GL_CLAMP_TO_EDGE);
+                glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,     GL_CLAMP_TO_EDGE);
+                glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+                glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+                glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, surface->OriginalSourceWidth, surface->OriginalSourceHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, pCnvImg);
+                free(pCnvImg);
+            }
+            return true;
+
+        }
+        else
+        {
+            /* Wayland Not SHM buffer */
+            if (nativeSurface->eglImage)
+            {
+                LOG_DEBUG("WaylandGLESTexture", "nativeSurface->eglImage:"<<nativeSurface->eglImage);
+                glBindTexture(GL_TEXTURE_2D, nativeSurface->texture);
+                glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,     GL_CLAMP_TO_EDGE);
+                glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,     GL_CLAMP_TO_EDGE);
+                glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+                glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+                m_pfGLEglImageTargetTexture2DOES(GL_TEXTURE_2D, nativeSurface->eglImage);
+                return true;
+            }
+        }
+
+        LOG_DEBUG("WaylandGLESTexture", "bindSurfaceTexture OUT");
+        return true;
+    }
+    LOG_DEBUG("WaylandGLESTexture", "bindSurfaceTexture ERROR OUT");
+    return false;
+}
+
+bool WaylandGLESTexture::unbindSurfaceTexture(Surface* surface)
+{
+    LOG_DEBUG("WaylandGLESTexture", "unbindSurfaceTexture:surface" << surface);
+    return true;
+}
+
+void WaylandGLESTexture::createClientBuffer(Surface* surface)
+{
+    LOG_DEBUG("WaylandGLESTexture", "creating client buffer with native display: " << m_wlDisplay << " for native handle: " << surface->getNativeContent());
+    EglWaylandPlatformSurface* nativeSurface = (EglWaylandPlatformSurface*)surface->platform;
+
+    if (NULL!=nativeSurface)
+    {
+        struct wl_buffer* buffer = (struct wl_buffer*)surface->getNativeContent();
+        if (wl_buffer_is_shm(buffer))
+        {
+            if (nativeSurface->texture)
+           {
+                glDeleteTextures(1,&nativeSurface->texture);
+                nativeSurface->texture = 0;
+            }
+            glGenTextures(1,&nativeSurface->texture);
+        }
+        else
+        {
+            EGLImageKHR eglImage = 0;
+            LOG_DEBUG("WaylandGLESTexture", "creating EGL Image from client buffer");
+            if (nativeSurface->eglImage)
+            {
+#ifdef WITH_WAYLAND_DRM
+                if (nativeSurface->texture){
+                    glBindTexture(GL_TEXTURE_2D, 0);
+                    glDeleteTextures(1,&nativeSurface->texture);
+                }
+#else
+                m_pfEglDestroyImageKHR(m_eglDisplay, nativeSurface->eglImage);
+                glDeleteTextures(1,&nativeSurface->texture);
+#endif // WITH_WAYLAND_DRM
+                nativeSurface->eglImage = 0;
+                nativeSurface->texture = 0;
+            }
+            eglImage = m_pfEglCreateImageKHR(m_eglDisplay,
+                                         EGL_NO_CONTEXT,
+                                         EGL_WAYLAND_BUFFER_WL,
+                                         (EGLClientBuffer)buffer,
+                                         NULL);
+            if (!eglImage)
+            {
+                LOG_DEBUG("WaylandGLESTexture", "could not allocate EGL Image for window");
+            }
+            else
+            {
+                nativeSurface->eglImage = eglImage;
+                glGenTextures(1,&nativeSurface->texture);
+            }
+        }
+    }
+}
+
+PlatformSurface* WaylandGLESTexture::createPlatformSurface(Surface* surface)
+{
+    return new EglWaylandPlatformSurface(surface);
+}
+
+void WaylandGLESTexture::destroyClientBuffer(Surface* surface)
+{
+    EglWaylandPlatformSurface* nativeSurface = (EglWaylandPlatformSurface*)surface->platform;
+
+    struct wl_buffer* buffer = (struct wl_buffer*)surface->getNativeContent();
+    if (wl_buffer_is_shm(buffer))
+    {
+        if (nativeSurface && nativeSurface->texture)
+        {
+            glDeleteTextures(1,&nativeSurface->texture);
+            nativeSurface->texture = 0;
+        }
+    }
+    else
+    {
+        if (nativeSurface && nativeSurface->eglImage)
+        {
+            m_pfEglDestroyImageKHR(m_eglDisplay, nativeSurface->eglImage);
+            glDeleteTextures(1,&nativeSurface->texture);
+            nativeSurface->eglImage = 0;
+            nativeSurface->texture = 0;
+        }
+    }
+}
index 12f304e..73ad262 100644 (file)
@@ -22,8 +22,7 @@
 #include "config.h"
 #include "Shader.h"
 #include "ShaderProgramGLES.h"
-#include "TextureBinders/WaylandCopyGLES.h"
-#include "TextureBinders/WaylandEglImage.h"
+#include "TextureBinders/WaylandGLESTexture.h"
 #ifdef WITH_WAYLAND_FBDEV
 #include "WindowSystems/WaylandFbdevWindowSystem.h"
 #endif // WITH_WAYLAND_FBDEV
@@ -90,15 +89,7 @@ bool WaylandGLESRenderer::start(int width, int height, const char* displayname)
 
     eglDisplayhandle = m_pGraphicSystem->getEGLDisplay();
 
-#ifdef WITH_FORCE_COPY
-    m_binder = new WaylandCopyGLES(eglDisplayhandle, nativeDisplayHandle);
-#else // WITH_FORCE_COPY
-#ifdef EGL_NATIVE_PIXMAP_KHR
-    m_binder = new WaylandEglImage(eglDisplayhandle, nativeDisplayHandle);
-#else // EGL_NATIVE_PIXMAP_KHR
-    m_binder = new WaylandCopyGLES(eglDisplayhandle, nativeDisplayHandle);
-#endif // EGL_NATIVE_PIXMAP_KHR
-#endif // WITH_FORCE_COPY
+    m_binder = new WaylandGLESTexture(eglDisplayhandle, nativeDisplayHandle);
     if (m_binder && nativeDisplayHandle && eglDisplayhandle)
     {
         m_pGraphicSystem->setTextureBinder(m_binder);