summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Pikarski <mass@directfb.org>2013-10-01 09:30:20 +0200
committerTimo Lotterbach <timo.lotterbach@bmw-carit.de>2013-10-01 16:19:00 +0200
commite196b8cf6344497075f75dac38f1218c6d5a4a78 (patch)
tree8022ada3b7de6d4b5f10a0f708b2c289503989c1
parent56a68d816bf6d20ff9652d1d2ca492fdb48aaef5 (diff)
downloadlayer_management-e196b8cf6344497075f75dac38f1218c6d5a4a78.tar.gz
TextureBinders: Added binders for DirectFB/EGL images
Added support for EGL/Surface data as used with DirectFB. Signed-off-by: Marek Pikarski <mass@directfb.org>
-rw-r--r--LayerManagerPlugins/Renderers/Graphic/include/TextureBinders/DFBEglImage.h50
-rw-r--r--LayerManagerPlugins/Renderers/Graphic/include/TextureBinders/DFBImage.h43
-rw-r--r--LayerManagerPlugins/Renderers/Graphic/src/TextureBinders/DFBEglImage.cpp110
-rw-r--r--LayerManagerPlugins/Renderers/Graphic/src/TextureBinders/DFBImage.cpp58
4 files changed, 261 insertions, 0 deletions
diff --git a/LayerManagerPlugins/Renderers/Graphic/include/TextureBinders/DFBEglImage.h b/LayerManagerPlugins/Renderers/Graphic/include/TextureBinders/DFBEglImage.h
new file mode 100644
index 0000000..f6f5e23
--- /dev/null
+++ b/LayerManagerPlugins/Renderers/Graphic/include/TextureBinders/DFBEglImage.h
@@ -0,0 +1,50 @@
+/***************************************************************************
+ *
+ * Copyright (c) 2013 DirectFB integrated media GmbH
+ * Copyright (c) 2013 Renesas Solutions Corp.
+ *
+ *
+ * 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 _DFBEGLIMAGE_H_
+#define _DFBEGLIMAGE_H_
+
+#include "TextureBinders/ITextureBinder.h"
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+#include "PlatformSurfaces/DFBPlatformSurface.h"
+
+class DFBEglImage: public ITextureBinder {
+public:
+ virtual PlatformSurface* createPlatformSurface(Surface* surface);
+
+ DFBEglImage(EGLDisplay eglDisplay, IDirectFBDisplayLayer *layer);
+ bool bindSurfaceTexture(Surface* surface);
+ bool unbindSurfaceTexture(Surface* surface);
+ void createClientBuffer(Surface* surface);
+ void destroyClientBuffer(Surface* surface);
+
+private:
+ PFNEGLCREATEIMAGEKHRPROC m_pfEglCreateImageKHR;
+ PFNEGLDESTROYIMAGEKHRPROC m_pfEglDestroyImageKHR;
+ PFNGLEGLIMAGETARGETTEXTURE2DOESPROC m_pfGLEglImageTargetTexture2DOES;
+ EGLDisplay m_eglDisplay;
+ IDirectFBDisplayLayer* m_layer;
+};
+
+#endif
+
diff --git a/LayerManagerPlugins/Renderers/Graphic/include/TextureBinders/DFBImage.h b/LayerManagerPlugins/Renderers/Graphic/include/TextureBinders/DFBImage.h
new file mode 100644
index 0000000..48b0332
--- /dev/null
+++ b/LayerManagerPlugins/Renderers/Graphic/include/TextureBinders/DFBImage.h
@@ -0,0 +1,43 @@
+/***************************************************************************
+ *
+ * Copyright (c) 2013 DirectFB integrated media GmbH
+ * Copyright (c) 2013 Renesas Solutions Corp.
+ *
+ *
+ * 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 _DFBIMAGE_H_
+#define _DFBIMAGE_H_
+
+#include "TextureBinders/ITextureBinder.h"
+#include "PlatformSurfaces/DFBPlatformSurface.h"
+
+class DFBImage: public ITextureBinder {
+public:
+ virtual PlatformSurface* createPlatformSurface(Surface* surface);
+
+ DFBImage(DFBDisplay dfbDisplay, IDirectFBDisplayLayer *layer);
+ bool bindSurfaceTexture(Surface* surface);
+ bool unbindSurfaceTexture(Surface* surface);
+ void createClientBuffer(Surface* surface);
+ void destroyClientBuffer(Surface* surface);
+
+private:
+ DFBDisplay m_dfbDisplay;
+ IDirectFBDisplayLayer* m_layer;
+};
+
+#endif
+
diff --git a/LayerManagerPlugins/Renderers/Graphic/src/TextureBinders/DFBEglImage.cpp b/LayerManagerPlugins/Renderers/Graphic/src/TextureBinders/DFBEglImage.cpp
new file mode 100644
index 0000000..b07b04e
--- /dev/null
+++ b/LayerManagerPlugins/Renderers/Graphic/src/TextureBinders/DFBEglImage.cpp
@@ -0,0 +1,110 @@
+/***************************************************************************
+ *
+ * Copyright (c) 2013 DirectFB integrated media GmbH
+ * Copyright (c) 2013 Renesas Solutions Corp.
+ *
+ *
+ * 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/DFBEglImage.h"
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+#include <GLES2/gl2ext.h>
+#include "PlatformSurfaces/EglDFBPlatformSurface.h"
+
+#include <EGL/egldfbext.h>
+
+DFBEglImage::DFBEglImage(EGLDisplay eglDisplay, IDirectFBDisplayLayer* layer)
+: m_eglDisplay(eglDisplay)
+, m_layer(layer)
+{
+ m_pfGLEglImageTargetTexture2DOES = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)eglGetProcAddress("glEGLImageTargetTexture2DOES");
+ m_pfEglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC)eglGetProcAddress("eglCreateImageKHR");
+ m_pfEglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC)eglGetProcAddress("eglDestroyImageKHR");
+
+ if (!m_pfEglCreateImageKHR || !m_pfEglDestroyImageKHR || !m_pfGLEglImageTargetTexture2DOES)
+ LOG_ERROR( "DFBEglImage", __FUNCTION__ << ": query EGL extensions failed" );
+}
+
+bool DFBEglImage::bindSurfaceTexture(Surface* surface)
+{
+ EglDFBPlatformSurface* nativeSurface = (EglDFBPlatformSurface*)surface->platform;
+
+ if (nativeSurface && nativeSurface->isReadyForRendering()) {
+ glBindTexture(GL_TEXTURE_2D, nativeSurface->texture);
+ return true;
+ }
+
+ return false;
+}
+
+bool DFBEglImage::unbindSurfaceTexture(Surface* surface)
+{
+ (void)surface; // TODO: remove, only prevents warning
+
+ // TODO
+ return true;
+}
+
+void DFBEglImage::createClientBuffer(Surface* surface)
+{
+ EglDFBPlatformSurface* nativeSurface = (EglDFBPlatformSurface*)surface->platform;
+
+ if (NULL!=nativeSurface) {
+ EGLImageKHR eglImage = 0;
+
+ if (nativeSurface->eglImage) {
+ m_pfEglDestroyImageKHR(m_eglDisplay, nativeSurface->eglImage);
+ glDeleteTextures(1,&nativeSurface->texture);
+ nativeSurface->eglImage = 0;
+ nativeSurface->texture = 0;
+ }
+
+ eglImage = m_pfEglCreateImageKHR(m_eglDisplay,
+ EGL_NO_CONTEXT,
+ EGL_IMAGE_IDIRECTFBSURFACE_DIRECTFB,
+ (EGLClientBuffer)nativeSurface->dfb_surface,
+ NULL);
+ if (!eglImage) {
+ LOG_WARNING( "DFBEglImage", __FUNCTION__ << ": could not allocate EGL Image for surface " << surface << " with id " << surface->getNativeContent());
+ }
+ else {
+ nativeSurface->eglImage = eglImage;
+ glGenTextures(1,&nativeSurface->texture);
+ 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);
+ }
+ }
+}
+
+PlatformSurface* DFBEglImage::createPlatformSurface(Surface* surface)
+{
+ return new EglDFBPlatformSurface(surface, m_layer);
+}
+
+void DFBEglImage::destroyClientBuffer(Surface* surface)
+{
+ EglDFBPlatformSurface* nativeSurface = (EglDFBPlatformSurface*)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/DFBImage.cpp b/LayerManagerPlugins/Renderers/Graphic/src/TextureBinders/DFBImage.cpp
new file mode 100644
index 0000000..be2425b
--- /dev/null
+++ b/LayerManagerPlugins/Renderers/Graphic/src/TextureBinders/DFBImage.cpp
@@ -0,0 +1,58 @@
+/***************************************************************************
+ *
+ * Copyright (c) 2013 DirectFB integrated media GmbH
+ * Copyright (c) 2013 Renesas Solutions Corp.
+ *
+ *
+ * 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/DFBImage.h"
+#include "PlatformSurfaces/EglDFBPlatformSurface.h"
+
+DFBImage::DFBImage(DFBDisplay dfbDisplay, IDirectFBDisplayLayer* layer)
+: m_dfbDisplay(dfbDisplay)
+, m_layer(layer)
+{
+}
+
+bool DFBImage::bindSurfaceTexture(Surface* surface)
+{
+ (void)surface;
+
+ return true;
+}
+
+bool DFBImage::unbindSurfaceTexture(Surface* surface)
+{
+ (void)surface;
+
+ return true;
+}
+
+void DFBImage::createClientBuffer(Surface* surface)
+{
+ (void)surface;
+}
+
+PlatformSurface* DFBImage::createPlatformSurface(Surface* surface)
+{
+ return new DFBPlatformSurface(surface, m_layer);
+}
+
+void DFBImage::destroyClientBuffer(Surface* surface)
+{
+ (void)surface;
+}
+