Changeset 561 for trunk/src/opengl/qglpixelbuffer_egl.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/opengl/qglpixelbuffer_egl.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtOpenGL module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 48 48 #include <private/qgl_p.h> 49 49 50 #ifdef QT_OPENGL_ES_1_CL 51 #include "qgl_cl_p.h" 52 #endif 53 50 54 QT_BEGIN_NAMESPACE 51 55 … … 60 64 // Create the EGL context. 61 65 ctx = new QEglContext(); 62 ctx->setApi(QEgl Context::OpenGL);66 ctx->setApi(QEgl::OpenGL); 63 67 64 68 // Open the EGL display. … … 69 73 } 70 74 75 // Find the shared context. 76 QEglContext *shareContext = 0; 77 if (shareWidget && shareWidget->d_func()->glcx) 78 shareContext = shareWidget->d_func()->glcx->d_func()->eglContext; 79 71 80 // Choose an appropriate configuration. We use the best format 72 81 // we can find, even if it is greater than the requested format. 73 82 // We try for a pbuffer that is capable of texture rendering if possible. 74 QEglProperties configProps; 75 qt_egl_set_format(configProps, QInternal::Pbuffer, f); 76 configProps.setRenderableType(ctx->api()); 77 bool ok = false; 78 #if QGL_RENDER_TEXTURE 79 textureFormat = EGL_TEXTURE_RGBA; 80 configProps.setValue(EGL_BIND_TO_TEXTURE_RGBA, EGL_TRUE); 81 ok = ctx->chooseConfig(configProps, QEglContext::BestPixelFormat); 82 if (!ok) { 83 // Try again with RGB texture rendering. 84 textureFormat = EGL_TEXTURE_RGB; 85 configProps.removeValue(EGL_BIND_TO_TEXTURE_RGBA); 86 configProps.setValue(EGL_BIND_TO_TEXTURE_RGB, EGL_TRUE); 87 ok = ctx->chooseConfig(configProps, QEglContext::BestPixelFormat); 83 textureFormat = EGL_NONE; 84 if (shareContext) { 85 // Use the same configuration as the widget we are sharing with. 86 ctx->setConfig(shareContext->config()); 87 #if QGL_RENDER_TEXTURE 88 EGLint value = EGL_FALSE; 89 if (ctx->configAttrib(EGL_BIND_TO_TEXTURE_RGBA, &value) && value) 90 textureFormat = EGL_TEXTURE_RGBA; 91 else if (ctx->configAttrib(EGL_BIND_TO_TEXTURE_RGB, &value) && value) 92 textureFormat = EGL_TEXTURE_RGB; 93 #endif 94 } else { 95 QEglProperties configProps; 96 qt_egl_set_format(configProps, QInternal::Pbuffer, f); 97 configProps.setRenderableType(ctx->api()); 98 bool ok = false; 99 #if QGL_RENDER_TEXTURE 100 textureFormat = EGL_TEXTURE_RGBA; 101 configProps.setValue(EGL_BIND_TO_TEXTURE_RGBA, EGL_TRUE); 102 ok = ctx->chooseConfig(configProps, QEgl::BestPixelFormat); 88 103 if (!ok) { 89 // One last try for a pbuffer with no texture rendering. 90 configProps.removeValue(EGL_BIND_TO_TEXTURE_RGB); 91 textureFormat = EGL_NONE; 104 // Try again with RGB texture rendering. 105 textureFormat = EGL_TEXTURE_RGB; 106 configProps.removeValue(EGL_BIND_TO_TEXTURE_RGBA); 107 configProps.setValue(EGL_BIND_TO_TEXTURE_RGB, EGL_TRUE); 108 ok = ctx->chooseConfig(configProps, QEgl::BestPixelFormat); 109 if (!ok) { 110 // One last try for a pbuffer with no texture rendering. 111 configProps.removeValue(EGL_BIND_TO_TEXTURE_RGB); 112 textureFormat = EGL_NONE; 113 } 92 114 } 93 } 94 #else 95 textureFormat = EGL_NONE; 96 #endif 97 if (!ok) { 98 if (!ctx->chooseConfig(configProps, QEglContext::BestPixelFormat)) { 99 delete ctx; 100 ctx = 0; 101 return false; 115 #endif 116 if (!ok) { 117 if (!ctx->chooseConfig(configProps, QEgl::BestPixelFormat)) { 118 delete ctx; 119 ctx = 0; 120 return false; 121 } 102 122 } 103 123 } … … 132 152 return false; 133 153 } 134 ctx->setSurface(pbuf);135 154 136 155 // Create a new context for the configuration. 137 QEglContext *shareContext = 0;138 if (shareWidget && shareWidget->d_func()->glcx)139 shareContext = shareWidget->d_func()->glcx->d_func()->eglContext;140 156 if (!ctx->createContext(shareContext)) { 141 157 delete ctx; … … 149 165 bool QGLPixelBufferPrivate::cleanup() 150 166 { 151 eglDestroySurface(QEglContext::defaultDisplay(0), pbuf);167 // No need to destroy "pbuf" here - it is done in QGLContext::reset(). 152 168 return true; 153 169 } … … 160 176 return false; 161 177 glBindTexture(GL_TEXTURE_2D, texture_id); 162 return eglBindTexImage(d->ctx->display(), d-> ctx->surface(), EGL_BACK_BUFFER);178 return eglBindTexImage(d->ctx->display(), d->pbuf, EGL_BACK_BUFFER); 163 179 #else 164 180 Q_UNUSED(texture_id); … … 173 189 if (d->invalid || d->textureFormat == EGL_NONE || !d->ctx) 174 190 return; 175 eglReleaseTexImage(d->ctx->display(), d-> ctx->surface(), EGL_BACK_BUFFER);191 eglReleaseTexImage(d->ctx->display(), d->pbuf, EGL_BACK_BUFFER); 176 192 #endif 177 193 } … … 189 205 else 190 206 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, d->req_size.width(), d->req_size.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); 191 glTexParameter i(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);192 glTexParameter i(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);207 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 208 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 193 209 return texture; 194 210 #else … … 200 216 { 201 217 // See if we have at least 1 configuration that matches the default format. 202 QEglContext ctx;203 if ( !ctx.openDisplay(0))218 EGLDisplay dpy = QEglContext::defaultDisplay(0); 219 if (dpy == EGL_NO_DISPLAY) 204 220 return false; 205 221 QEglProperties configProps; 206 222 qt_egl_set_format(configProps, QInternal::Pbuffer, QGLFormat::defaultFormat()); 207 configProps.setRenderableType(QEglContext::OpenGL); 208 return ctx.chooseConfig(configProps); 223 configProps.setRenderableType(QEgl::OpenGL); 224 do { 225 EGLConfig cfg = 0; 226 EGLint matching = 0; 227 if (eglChooseConfig(dpy, configProps.properties(), 228 &cfg, 1, &matching) && matching > 0) 229 return true; 230 } while (configProps.reduceConfiguration()); 231 return false; 209 232 } 210 233
Note:
See TracChangeset
for help on using the changeset viewer.