summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp128
-rw-r--r--src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.h19
-rw-r--r--src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.cpp8
-rw-r--r--src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.h4
4 files changed, 11 insertions, 148 deletions
diff --git a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp
index cb453d7..6696672 100644
--- a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp
+++ b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp
@@ -60,17 +60,20 @@ PvrEglScreen::PvrEglScreen(int displayId)
ttyfd = -1;
doGraphicsMode = true;
oldKdMode = KD_TEXT;
- if (QWSServer::instance())
- holder = new PvrEglSurfaceHolder();
- else
- holder = 0;
+
+ // Make sure that the EGL layer is initialized and the drivers loaded.
+ EGLDisplay dpy = eglGetDisplay((EGLNativeDisplayType)EGL_DEFAULT_DISPLAY);
+ if (!eglInitialize(dpy, 0, 0))
+ qWarning("Could not initialize EGL display - are the drivers loaded?");
+
+ // Make sure that screen 0 is initialized.
+ pvrQwsScreenWindow(0);
}
PvrEglScreen::~PvrEglScreen()
{
if (fd >= 0)
::close(fd);
- delete holder;
}
bool PvrEglScreen::initDevice()
@@ -194,7 +197,7 @@ QWSWindowSurface* PvrEglScreen::createSurface(QWidget *widget) const
QWSWindowSurface* PvrEglScreen::createSurface(const QString &key) const
{
if (key == QLatin1String("PvrEgl"))
- return new PvrEglWindowSurface(holder);
+ return new PvrEglWindowSurface();
return QScreen::createSurface(key);
}
@@ -275,116 +278,3 @@ bool PvrEglScreenSurfaceFunctions::createNativeWindow(QWidget *widget, EGLNative
*native = (EGLNativeWindowType)(nsurface->nativeDrawable());
return true;
}
-
-// The PowerVR engine on the device needs to allocate about 2Mb of
-// contiguous physical memory to manage drawing into a surface.
-//
-// The problem is that once Qtopia begins its startup sequence,
-// it allocates enough memory to severely fragment the physical
-// address space on the device. This leaves the PowerVR engine
-// unable to allocate the necessary contiguous physical memory
-// when an EGL surface is created.
-//
-// A solution to this is to pre-allocate a dummy surface early
-// in the startup sequence before memory becomes fragmented,
-// reserving it for any future EGL applications to use.
-//
-// However, the PowerVR engine has problems managing multiple
-// surfaces concurrently, and so real EGL applications end up
-// with unacceptably slow frame rates unless the dummy surface
-// is destroyed while the real EGL applications are running.
-//
-// In summary, we need to try to ensure that there is always at
-// least one EGL surface active at any given time to reserve the
-// memory but destroy the temporary surface when a real surface
-// is using the device. That is the purpose of PvrEglSurfaceHolder.
-
-PvrEglSurfaceHolder::PvrEglSurfaceHolder(QObject *parent)
- : QObject(parent)
-{
- numRealSurfaces = 0;
-
- PvrQwsRect rect;
- rect.x = 0;
- rect.y = 0;
- rect.width = 16;
- rect.height = 16;
- tempSurface = pvrQwsCreateWindow(0, -1, &rect);
-
- dpy = EGL_NO_DISPLAY;
- config = 0;
- surface = EGL_NO_SURFACE;
-
- dpy = eglGetDisplay((EGLNativeDisplayType)EGL_DEFAULT_DISPLAY);
- if (!eglInitialize(dpy, 0, 0)) {
- qWarning("Could not initialize EGL display - are the drivers loaded?");
- dpy = EGL_NO_DISPLAY;
- return;
- }
-
- EGLint attribList[16];
- int temp = 0;
- attribList[temp++] = EGL_LEVEL; // Framebuffer level 0
- attribList[temp++] = 0;
- attribList[temp++] = EGL_SURFACE_TYPE;
- attribList[temp++] = EGL_WINDOW_BIT;
- attribList[temp++] = EGL_NONE;
-
- EGLint numConfigs = 0;
- if (!eglChooseConfig(dpy, attribList, &config, 1, &numConfigs) || numConfigs != 1) {
- qWarning("Could not find a matching a EGL configuration");
- eglTerminate(dpy);
- dpy = EGL_NO_DISPLAY;
- return;
- }
-
- surface = eglCreateWindowSurface
- (dpy, config, (EGLNativeWindowType)(-1), NULL);
- if (surface == EGL_NO_SURFACE)
- qWarning("Could not create the temporary EGL surface");
-}
-
-PvrEglSurfaceHolder::~PvrEglSurfaceHolder()
-{
- if (surface != EGL_NO_SURFACE)
- eglDestroySurface(dpy, surface);
- if (dpy != EGL_NO_DISPLAY)
- eglTerminate(dpy);
- if (tempSurface)
- pvrQwsDestroyDrawable(tempSurface);
-}
-
-// Add a real EGL surface to the system.
-void PvrEglSurfaceHolder::addSurface()
-{
- ++numRealSurfaces;
- if (numRealSurfaces == 1) {
- // Destroy the temporary surface while some other application
- // is making use of the EGL sub-system for 3D rendering.
- if (surface != EGL_NO_SURFACE) {
- eglDestroySurface(dpy, surface);
- surface = EGL_NO_SURFACE;
- }
- }
-}
-
-// Remove an actual EGL surface from the system.
-void PvrEglSurfaceHolder::removeSurface()
-{
- if (numRealSurfaces > 0) {
- --numRealSurfaces;
- if (numRealSurfaces == 0) {
- // The last real EGL surface has been destroyed, so re-create
- // the temporary surface. There is a race condition here in
- // that Qtopia could allocate a lot of memory just after
- // the real EGL surface is destroyed but before we could
- // create the temporary surface again.
- if (surface == EGL_NO_SURFACE && dpy != EGL_NO_DISPLAY) {
- surface = eglCreateWindowSurface
- (dpy, config, (EGLNativeWindowType)(-1), NULL);
- if (surface == EGL_NO_SURFACE)
- qWarning("Could not re-create the temporary EGL surface");
- }
- }
- }
-}
diff --git a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.h b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.h
index 1c79f8e..8bf42c7 100644
--- a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.h
+++ b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.h
@@ -59,24 +59,6 @@ private:
int displayId;
};
-class PvrEglSurfaceHolder : public QObject
-{
- Q_OBJECT
-public:
- PvrEglSurfaceHolder(QObject *parent=0);
- ~PvrEglSurfaceHolder();
-
- void addSurface();
- void removeSurface();
-
-private:
- int numRealSurfaces;
- PvrQwsDrawable *tempSurface;
- EGLDisplay dpy;
- EGLConfig config;
- EGLSurface surface;
-};
-
class PvrEglScreen : public QGLScreen
{
public:
@@ -105,7 +87,6 @@ private:
int fd;
int ttyfd, oldKdMode;
- PvrEglSurfaceHolder *holder;
QString ttyDevice;
bool doGraphicsMode;
};
diff --git a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.cpp b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.cpp
index 09c0ace..2c5ac21 100644
--- a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.cpp
+++ b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.cpp
@@ -53,7 +53,6 @@ PvrEglWindowSurface::PvrEglWindowSurface
this->widget = widget;
this->screen = screen;
- this->holder = 0;
this->pdevice = 0;
QPoint pos = offset(widget);
@@ -78,7 +77,7 @@ PvrEglWindowSurface::PvrEglWindowSurface
drawable = pvrQwsCreateWindow(screenNum, (long)widget, &pvrRect);
}
-PvrEglWindowSurface::PvrEglWindowSurface(PvrEglSurfaceHolder *holder)
+PvrEglWindowSurface::PvrEglWindowSurface()
: QWSGLWindowSurface()
{
setSurfaceFlags(QWSWindowSurface::Opaque);
@@ -86,9 +85,6 @@ PvrEglWindowSurface::PvrEglWindowSurface(PvrEglSurfaceHolder *holder)
widget = 0;
screen = 0;
pdevice = 0;
-
- this->holder = holder;
- holder->addSurface();
}
PvrEglWindowSurface::~PvrEglWindowSurface()
@@ -100,8 +96,6 @@ PvrEglWindowSurface::~PvrEglWindowSurface()
if (drawable && pvrQwsReleaseWindow(drawable))
pvrQwsDestroyDrawable(drawable);
- if (holder)
- holder->removeSurface();
delete pdevice;
}
diff --git a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.h b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.h
index 0da3653..58a5fb2 100644
--- a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.h
+++ b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.h
@@ -46,13 +46,12 @@
#include "pvrqwsdrawable.h"
class QScreen;
-class PvrEglSurfaceHolder;
class PvrEglWindowSurface : public QWSGLWindowSurface
{
public:
PvrEglWindowSurface(QWidget *widget, QScreen *screen, int screenNum);
- PvrEglWindowSurface(PvrEglSurfaceHolder *holder);
+ PvrEglWindowSurface();
~PvrEglWindowSurface();
QString key() const { return QLatin1String("PvrEgl"); }
@@ -78,7 +77,6 @@ private:
QWidget *widget;
PvrQwsDrawable *drawable;
QScreen *screen;
- PvrEglSurfaceHolder *holder;
QPaintDevice *pdevice;
};