summaryrefslogtreecommitdiffstats
path: root/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp
diff options
context:
space:
mode:
authorRhys Weatherley <rhys.weatherley@nokia.com>2009-10-15 00:50:57 (GMT)
committerRhys Weatherley <rhys.weatherley@nokia.com>2009-10-15 00:50:57 (GMT)
commit4f2fecbdb852028bd191fa63aa66527107672dc7 (patch)
treef708eff7418f8781fcc27a2fed3d827c207537b6 /src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp
parent93eb7c1378d97978fbe415f532e341de0138f4fe (diff)
downloadQt-4f2fecbdb852028bd191fa63aa66527107672dc7.zip
Qt-4f2fecbdb852028bd191fa63aa66527107672dc7.tar.gz
Qt-4f2fecbdb852028bd191fa63aa66527107672dc7.tar.bz2
Remove the surface holder from the PowerVR screen driver
The PvrEglSurfaceHolder is a hold-over from Qtopia that isn't needed any more and was never very stable anyway. Reviewed-by: trustme Back port of f613b0170d0fe806378779472315d0bbdc1aada9
Diffstat (limited to 'src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp')
-rw-r--r--src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp128
1 files changed, 9 insertions, 119 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");
- }
- }
- }
-}