From 16720126954a14b8c16cff68973d29b21c0e030e Mon Sep 17 00:00:00 2001 From: Marek Pikarski Date: Tue, 1 Oct 2013 09:34:46 +0200 Subject: [PATCH] PlatformSurfaces: Added DirectFB/EGL platform surfaces Added support for DirectFB/EGL surfaces as used on the DirectFB platform. Signed-off-by: Marek Pikarski --- .../include/PlatformSurfaces/DFBPlatformSurface.h | 110 +++++++++++++++++++++ .../PlatformSurfaces/EglDFBPlatformSurface.h | 47 +++++++++ 2 files changed, 157 insertions(+) create mode 100644 LayerManagerPlugins/Renderers/Graphic/include/PlatformSurfaces/DFBPlatformSurface.h create mode 100644 LayerManagerPlugins/Renderers/Graphic/include/PlatformSurfaces/EglDFBPlatformSurface.h diff --git a/LayerManagerPlugins/Renderers/Graphic/include/PlatformSurfaces/DFBPlatformSurface.h b/LayerManagerPlugins/Renderers/Graphic/include/PlatformSurfaces/DFBPlatformSurface.h new file mode 100644 index 0000000..cf1420d --- /dev/null +++ b/LayerManagerPlugins/Renderers/Graphic/include/PlatformSurfaces/DFBPlatformSurface.h @@ -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. + * + ****************************************************************************/ + +#ifndef _DFBPLATFORMSURFACE_H_ +#define _DFBPLATFORMSURFACE_H_ + +#include "config.h" +#include "Log.h" + +#include "PlatformSurface.h" +#include "Surface.h" + +#include + +typedef int DFBDisplay; +typedef DFBWindowID DFBWindow; + +class DFBPlatformSurface: public PlatformSurface { +public: + DFBPlatformSurface(Surface* surface, IDirectFBDisplayLayer *layer) + : PlatformSurface(surface) + , isMapped(false) + , dfb_window_id(0) + , dfb_window(NULL) + , dfb_surface_id(0) + , dfb_surface(NULL) + , texture(0) + , m_isReadyForRendering(false) + { + if (surface->hasNativeContent()) { + if (layer->GetWindow( layer, (DFBWindowID)surface->getNativeContent(), &dfb_window )) { + LOG_ERROR( "DFBPlatformSurface", __FUNCTION__ << ": failed to get IDirectFBWindow by id " << surface->getNativeContent() ); + } + else { + LOG_DEBUG( "DFBPlatformSurface", __FUNCTION__ << ": resolved window id " << surface->getNativeContent() << " to window " << dfb_window ); + + dfb_window_id = surface->getNativeContent(); + + if (dfb_window->GetSurface( dfb_window, &dfb_surface )) { + LOG_ERROR( "DFBPlatformSurface", __FUNCTION__ << ": failed to get IDirectFBSurface from window " << dfb_window << " with id " << dfb_window_id ); + } + else { + LOG_DEBUG( "DFBPlatformSurface", __FUNCTION__ << ": retrieved surface " << dfb_surface << " from window" ); + + if (dfb_surface->GetID( dfb_surface, &dfb_surface_id )) { + LOG_ERROR( "DFBPlatformSurface", __FUNCTION__ << ": failed to get ID from surface " << dfb_surface ); + } + else { + LOG_DEBUG( "DFBPlatformSurface", __FUNCTION__ << ": resolved surface " << dfb_surface << " to ID " << dfb_surface_id ); + } + } + } + } + } + + ~DFBPlatformSurface() + { + if (dfb_surface) + dfb_surface->Release( dfb_surface ); + + if (dfb_window) + dfb_window->Release( dfb_window ); + } + + bool enableRendering() + { + m_isReadyForRendering = true; + return m_isReadyForRendering; + } + + bool disableRendering() + { + m_isReadyForRendering = false; + return m_isReadyForRendering; + } + + bool isReadyForRendering() + { + return m_isReadyForRendering; + } + + // TODO: private/protected + bool isMapped; + DFBWindowID dfb_window_id; + IDirectFBWindow *dfb_window; + DFBSurfaceID dfb_surface_id; + IDirectFBSurface *dfb_surface; + uint texture; + bool m_isReadyForRendering; +}; + +#endif + diff --git a/LayerManagerPlugins/Renderers/Graphic/include/PlatformSurfaces/EglDFBPlatformSurface.h b/LayerManagerPlugins/Renderers/Graphic/include/PlatformSurfaces/EglDFBPlatformSurface.h new file mode 100644 index 0000000..422c591 --- /dev/null +++ b/LayerManagerPlugins/Renderers/Graphic/include/PlatformSurfaces/EglDFBPlatformSurface.h @@ -0,0 +1,47 @@ +/*************************************************************************** + * + * 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 _EGLDFBPLATFORMSURFACE_H_ +#define _EGLDFBPLATFORMSURFACE_H_ + +#include "Surface.h" +#include "GLES2/gl2.h" +#include "EGL/egl.h" +#include "EGL/eglext.h" +#include "DFBPlatformSurface.h" + +class EglDFBPlatformSurface: public DFBPlatformSurface { +public: + EglDFBPlatformSurface(Surface* surface, IDirectFBDisplayLayer *layer) + : DFBPlatformSurface(surface, layer) + , eglImage(0) + { + } + + ~EglDFBPlatformSurface() + { + } + + // TODO: private/protected + EGLImageKHR eglImage; +}; + + +#endif -- 2.7.4