Skip to content

Commit

Permalink
egl: force each implementation to include egl
Browse files Browse the repository at this point in the history
Final part in the egl refactor.

This allows for each implementation to pick its native types based on defines.
For example, a Wayland implementation would include <wayland-egl.h> and
<EGL/egl.h> which would change the native types, but without affecting the
other back-ends.

Now,we can realistically build a binary that will support X, Wayland,
KMS, and fbdev, chosen at runtime based on the environment we start under. We
just need to write those back-ends ;)
  • Loading branch information
Cory Fields committed Oct 17, 2012
1 parent 7b34703 commit 6cb41b9
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 31 deletions.
12 changes: 7 additions & 5 deletions xbmc/windowing/egl/EGLNativeType.h
Expand Up @@ -20,10 +20,12 @@
*
*/

#include <EGL/egl.h>
#include "guilib/Resolution.h"
#include "EGLQuirks.h"

typedef void* XBNativeDisplayType;
typedef void* XBNativeWindowType;

/*!
This class provides extra functionality on top of EGL in order to facilitate
the implementation-dependent functionality relating to creating, maintaining,
Expand Down Expand Up @@ -99,10 +101,10 @@ class CEGLNativeType
virtual bool CreateNativeWindow() = 0;

/*! \brief Returns the current Native Display */
virtual bool GetNativeDisplay(EGLNativeDisplayType **nativeDisplay) const = 0;
virtual bool GetNativeDisplay(XBNativeDisplayType **nativeDisplay) const = 0;

/*! \brief Returns the current Native Window */
virtual bool GetNativeWindow(EGLNativeWindowType **nativeWindow) const = 0;
virtual bool GetNativeWindow(XBNativeWindowType **nativeWindow) const = 0;

/*! \brief Destroy the Native Window
Expand Down Expand Up @@ -142,6 +144,6 @@ class CEGLNativeType
virtual bool ShowWindow(bool show) = 0;

protected:
EGLNativeDisplayType m_nativeDisplay;
EGLNativeWindowType m_nativeWindow;
XBNativeDisplayType m_nativeDisplay;
XBNativeWindowType m_nativeWindow;
};
17 changes: 11 additions & 6 deletions xbmc/windowing/egl/EGLNativeTypeAmlogic.cpp
Expand Up @@ -17,6 +17,7 @@
* <http://www.gnu.org/licenses/>.
*
*/
#include <EGL/egl.h>
#include "EGLNativeTypeAmlogic.h"
#include <stdlib.h>
#include <linux/fb.h>
Expand Down Expand Up @@ -64,9 +65,13 @@ bool CEGLNativeTypeAmlogic::CreateNativeDisplay()
bool CEGLNativeTypeAmlogic::CreateNativeWindow()
{
#if defined(_FBDEV_WINDOW_H_)
m_nativeWindow = new fbdev_window;
m_nativeWindow->width = 1280;
m_nativeWindow->height = 720;
fbdev_window *nativeWindow = new fbdev_window;
if (!nativeWindow)
return false;

nativeWindow->width = 1280;
nativeWindow->height = 720;
m_nativeWindow = nativeWindow;
return true;
#else
return false;
Expand All @@ -75,13 +80,13 @@ bool CEGLNativeTypeAmlogic::CreateNativeWindow()

bool CEGLNativeTypeAmlogic::GetNativeDisplay(EGLNativeDisplayType **nativeDisplay) const
{
*nativeDisplay = (EGLNativeDisplayType*) &m_nativeDisplay;
*nativeDisplay = (XBNativeDisplayType*) &m_nativeDisplay;
return true;
}

bool CEGLNativeTypeAmlogic::GetNativeWindow(EGLNativeWindowType **nativeWindow) const
bool CEGLNativeTypeAmlogic::GetNativeWindow(XBNativeWindowType **nativeWindow) const
{
*nativeWindow = (EGLNativeWindowType*) &m_nativeWindow;
*nativeWindow = (XBNativeWindowType*) &m_nativeWindow;
return true;
}

Expand Down
4 changes: 2 additions & 2 deletions xbmc/windowing/egl/EGLNativeTypeAmlogic.h
Expand Up @@ -34,8 +34,8 @@ class CEGLNativeTypeAmlogic : public CEGLNativeType

virtual bool CreateNativeDisplay();
virtual bool CreateNativeWindow();
virtual bool GetNativeDisplay(EGLNativeDisplayType **nativeDisplay) const;
virtual bool GetNativeWindow(EGLNativeWindowType **nativeWindow) const;
virtual bool GetNativeDisplay(XBNativeDisplayType **nativeDisplay) const;
virtual bool GetNativeWindow(XBNativeWindowType **nativeWindow) const;

virtual bool DestroyNativeWindow();
virtual bool DestroyNativeDisplay();
Expand Down
17 changes: 9 additions & 8 deletions xbmc/windowing/egl/EGLNativeTypeAndroid.cpp
Expand Up @@ -18,6 +18,7 @@
*
*/
#include "system.h"
#include <EGL/egl.h>
#include "EGLNativeTypeAndroid.h"
#include "utils/log.h"
#include "guilib/gui3d.h"
Expand Down Expand Up @@ -65,15 +66,15 @@ bool CEGLNativeTypeAndroid::CreateNativeWindow()
#endif
}

bool CEGLNativeTypeAndroid::GetNativeDisplay(EGLNativeDisplayType **nativeDisplay) const
bool CEGLNativeTypeAndroid::GetNativeDisplay(XBNativeDisplayType **nativeDisplay) const
{
*nativeDisplay = (EGLNativeDisplayType*) &m_nativeDisplay;
*nativeDisplay = (XBNativeDisplayType*) &m_nativeDisplay;
return true;
}

bool CEGLNativeTypeAndroid::GetNativeWindow(EGLNativeWindowType **nativeWindow) const
bool CEGLNativeTypeAndroid::GetNativeWindow(XBNativeWindowType **nativeWindow) const
{
*nativeWindow = (EGLNativeWindowType*) &m_nativeWindow;
*nativeWindow = (XBNativeWindowType*) &m_nativeWindow;
return true;
}

Expand All @@ -90,10 +91,10 @@ bool CEGLNativeTypeAndroid::DestroyNativeWindow()
bool CEGLNativeTypeAndroid::GetNativeResolution(RESOLUTION_INFO *res) const
{
#if defined(TARGET_ANDROID)
ANativeWindow_acquire(m_nativeWindow);
res->iWidth = ANativeWindow_getWidth(m_nativeWindow);
res->iHeight= ANativeWindow_getHeight(m_nativeWindow);
ANativeWindow_release(m_nativeWindow);
ANativeWindow_acquire((EGLNativeWindowType)m_nativeWindow);
res->iWidth = ANativeWindow_getWidth((EGLNativeWindowType)m_nativeWindow);
res->iHeight= ANativeWindow_getHeight((EGLNativeWindowType)m_nativeWindow);
ANativeWindow_release((EGLNativeWindowType)m_nativeWindow);

res->fRefreshRate = 60;
res->dwFlags= D3DPRESENTFLAG_PROGRESSIVE;
Expand Down
4 changes: 2 additions & 2 deletions xbmc/windowing/egl/EGLNativeTypeAndroid.h
Expand Up @@ -34,8 +34,8 @@ class CEGLNativeTypeAndroid : public CEGLNativeType

virtual bool CreateNativeDisplay();
virtual bool CreateNativeWindow();
virtual bool GetNativeDisplay(EGLNativeDisplayType **nativeDisplay) const;
virtual bool GetNativeWindow(EGLNativeWindowType **nativeWindow) const;
virtual bool GetNativeDisplay(XBNativeDisplayType **nativeDisplay) const;
virtual bool GetNativeWindow(XBNativeWindowType **nativeWindow) const;

virtual bool DestroyNativeWindow();
virtual bool DestroyNativeDisplay();
Expand Down
9 changes: 5 additions & 4 deletions xbmc/windowing/egl/EGLNativeTypeRaspberryPI.cpp
Expand Up @@ -19,6 +19,7 @@
*/
#include "system.h"

#include <EGL/egl.h>
#include "EGLNativeTypeRaspberryPI.h"
#include "utils/log.h"
#include "guilib/gui3d.h"
Expand Down Expand Up @@ -133,16 +134,16 @@ bool CEGLNativeTypeRaspberryPI::CreateNativeWindow()
#endif
}

bool CEGLNativeTypeRaspberryPI::GetNativeDisplay(EGLNativeDisplayType **nativeDisplay) const
bool CEGLNativeTypeRaspberryPI::GetNativeDisplay(XBNativeDisplayType **nativeDisplay) const
{
*nativeDisplay = (EGLNativeDisplayType*) &m_nativeDisplay;
*nativeDisplay = (XBNativeDisplayType*) &m_nativeDisplay;
return true;
}

bool CEGLNativeTypeRaspberryPI::GetNativeWindow(EGLNativeWindowType **nativeWindow) const
bool CEGLNativeTypeRaspberryPI::GetNativeWindow(XBNativeDisplayType **nativeWindow) const
{
*nativeWindow = (EGLNativeWindowType*) &m_nativeWindow;
DLOG("CEGLNativeTypeRaspberryPI::GetNativeWindow\n");
*nativeWindow = (XBNativeWindowType*) &m_nativeWindow;
return true;
}

Expand Down
7 changes: 5 additions & 2 deletions xbmc/windowing/egl/EGLNativeTypeRaspberryPI.h
Expand Up @@ -21,7 +21,10 @@
*/

#include "EGLNativeType.h"
#if defined(TARGET_RASPBERRY_PI)
#include <semaphore.h>
#include <bcm_host.h>
#endif

class DllBcmHost;
class CEGLNativeTypeRaspberryPI : public CEGLNativeType
Expand All @@ -37,8 +40,8 @@ class CEGLNativeTypeRaspberryPI : public CEGLNativeType

virtual bool CreateNativeDisplay();
virtual bool CreateNativeWindow();
virtual bool GetNativeDisplay(EGLNativeDisplayType **nativeDisplay) const;
virtual bool GetNativeWindow(EGLNativeWindowType **nativeWindow) const;
virtual bool GetNativeDisplay(XBNativeDisplayType **nativeDisplay) const;
virtual bool GetNativeWindow(XBNativeWindowType **nativeWindow) const;

virtual bool DestroyNativeWindow();
virtual bool DestroyNativeDisplay();
Expand Down
4 changes: 2 additions & 2 deletions xbmc/windowing/egl/EGLWrapper.cpp
Expand Up @@ -191,7 +191,7 @@ bool CEGLWrapper::InitDisplay(EGLDisplay *display)
//nativeDisplay can be (and usually is) NULL. Don't use if(nativeDisplay) as a test!
EGLint status;
EGLNativeDisplayType *nativeDisplay = NULL;
if (!m_nativeTypes->GetNativeDisplay(&nativeDisplay))
if (!m_nativeTypes->GetNativeDisplay((XBNativeDisplayType**)&nativeDisplay))
return false;

*display = eglGetDisplay(*nativeDisplay);
Expand Down Expand Up @@ -263,7 +263,7 @@ bool CEGLWrapper::CreateSurface(EGLDisplay display, EGLConfig config, EGLSurface
return false;

EGLNativeWindowType *nativeWindow=NULL;
if (!m_nativeTypes->GetNativeWindow(&nativeWindow))
if (!m_nativeTypes->GetNativeWindow((XBNativeWindowType**)&nativeWindow))
return false;

*surface = eglCreateWindowSurface(display, config, *nativeWindow, NULL);
Expand Down
1 change: 1 addition & 0 deletions xbmc/windowing/egl/EGLWrapper.h
Expand Up @@ -21,6 +21,7 @@
*/

#include "guilib/Resolution.h"
#include <EGL/egl.h>
class CEGLNativeType;
class CEGLWrapper
{
Expand Down

0 comments on commit 6cb41b9

Please sign in to comment.