diff options
Diffstat (limited to 'src/opengl')
-rw-r--r-- | src/opengl/qgl.cpp | 237 | ||||
-rw-r--r-- | src/opengl/qgl.h | 1 | ||||
-rw-r--r-- | src/opengl/qgl_p.h | 56 | ||||
-rw-r--r-- | src/opengl/qgl_x11.cpp | 2 | ||||
-rw-r--r-- | src/opengl/qglframebufferobject.h | 1 | ||||
-rw-r--r-- | src/opengl/qglpaintdevice.cpp | 66 | ||||
-rw-r--r-- | src/opengl/qglpaintdevice_p.h | 100 | ||||
-rw-r--r-- | src/opengl/qglpixelbuffer.cpp | 1 | ||||
-rw-r--r-- | src/opengl/qpaintengine_opengl.cpp | 4 |
9 files changed, 38 insertions, 430 deletions
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 8ad9860..a0b2d3a 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -4851,243 +4851,6 @@ Q_OPENGL_EXPORT const QString qt_gl_library_name() } #endif -#if 0 -void QGLDrawable::setDevice(QPaintDevice *pdev) -{ - wasBound = false; - widget = 0; - buffer = 0; - fbo = 0; -#ifdef Q_WS_QWS - wsurf = 0; -#endif - -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - if (pdev->devType() == QInternal::Pixmap) { - QPixmapData *data = static_cast<QPixmap *>(pdev)->pixmapData(); - Q_ASSERT(data->classId() == QPixmapData::OpenGLClass); - pixmapData = static_cast<QGLPixmapData *>(data); - - fbo = pixmapData->fbo(); - } -#else - Q_ASSERT(pdev->devType() != QInternal::Pixmap); -#endif - - if (pdev->devType() == QInternal::Widget) - widget = static_cast<QGLWidget *>(pdev); - else if (pdev->devType() == QInternal::Pbuffer) - buffer = static_cast<QGLPixelBuffer *>(pdev); - else if (pdev->devType() == QInternal::FramebufferObject) - fbo = static_cast<QGLFramebufferObject *>(pdev); -#ifdef Q_WS_QWS - else if (pdev->devType() == QInternal::UnknownDevice) - wsurf = static_cast<QWSGLPaintDevice*>(pdev)->windowSurface(); -#elif !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - else if (pdev->devType() == QInternal::UnknownDevice) - wsurf = static_cast<QGLWindowSurface *>(pdev); -#endif -} - -void QGLDrawable::swapBuffers() -{ - if (widget) { - if (widget->autoBufferSwap()) - widget->swapBuffers(); -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - } else if (pixmapData) { - pixmapData->swapBuffers(); -#endif - } else { - glFlush(); - } -} - -void QGLDrawable::makeCurrent() -{ - previous_fbo = 0; -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - if (!pixmapData && !fbo) { -#else - if (!fbo) { -#endif - QGLContext *ctx = context(); - previous_fbo = ctx->d_ptr->current_fbo; - ctx->d_ptr->current_fbo = 0; - if (previous_fbo) - glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0); - } - - if (widget) - widget->makeCurrent(); -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - else if (pixmapData) - pixmapData->makeCurrent(); -#endif - else if (buffer) - buffer->makeCurrent(); -#if defined(Q_WS_QWS) || (!defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)) - else if (wsurf) - wsurf->context()->makeCurrent(); -#endif - else if (fbo) { - wasBound = fbo->isBound(); - if (!wasBound) - fbo->bind(); - } -} - -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) -QGLPixmapData *QGLDrawable::copyOnBegin() const -{ - if (!pixmapData || pixmapData->isUninitialized()) - return 0; - return pixmapData; -} -#endif - -void QGLDrawable::doneCurrent() -{ -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - if (pixmapData) { - pixmapData->doneCurrent(); - return; - } -#endif - - if (previous_fbo) { - QGLContext *ctx = context(); - ctx->d_ptr->current_fbo = previous_fbo; - glBindFramebuffer(GL_FRAMEBUFFER_EXT, previous_fbo); - } - - if (fbo && !wasBound) - fbo->release(); -} - -QSize QGLDrawable::size() const -{ - if (widget) { - return QSize(widget->d_func()->glcx->device()->width(), - widget->d_func()->glcx->device()->height()); -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - } else if (pixmapData) { - return pixmapData->size(); -#endif - } else if (buffer) { - return buffer->size(); - } else if (fbo) { - return fbo->size(); - } -#ifdef Q_WS_QWS - else if (wsurf) - return wsurf->window()->frameSize(); -#elif !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - else if (wsurf) - return QSize(wsurf->width(), wsurf->height()); -#endif - return QSize(); -} - -QGLFormat QGLDrawable::format() const -{ - if (widget) - return widget->format(); - else if (buffer) - return buffer->format(); -#if defined(Q_WS_QWS) || (!defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)) - else if (wsurf) - return wsurf->context()->format(); -#endif - else if (fbo && QGLContext::currentContext()) { - QGLFormat fmt = QGLContext::currentContext()->format(); - fmt.setStencil(fbo->attachment() == QGLFramebufferObject::CombinedDepthStencil); - fmt.setDepth(fbo->attachment() != QGLFramebufferObject::NoAttachment); - return fmt; - } - - return QGLFormat(); -} - -GLuint QGLDrawable::bindTexture(const QImage &image, GLenum target, GLint format, - QGLContext::BindOptions options) -{ - QGLTexture *texture = 0; - options |= QGLContext::MemoryManagedBindOption; - if (widget) - texture = widget->d_func()->glcx->d_func()->bindTexture(image, target, format, options); - else if (buffer) - texture = buffer->d_func()->qctx->d_func()->bindTexture(image, target, format, options); - else if (fbo && QGLContext::currentContext()) - texture = const_cast<QGLContext *>(QGLContext::currentContext())->d_func()->bindTexture(image, target, format, options); -#if defined(Q_WS_QWS) || (!defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)) - else if (wsurf) - texture = wsurf->context()->d_func()->bindTexture(image, target, format, options); -#endif - return texture->id; -} - -GLuint QGLDrawable::bindTexture(const QPixmap &pixmap, GLenum target, GLint format, - QGLContext::BindOptions options) -{ - QGLTexture *texture = 0; - if (widget) - texture = widget->d_func()->glcx->d_func()->bindTexture(pixmap, target, format, options); - else if (buffer) - texture = buffer->d_func()->qctx->d_func()->bindTexture(pixmap, target, format, options); - else if (fbo && QGLContext::currentContext()) - texture = const_cast<QGLContext *>(QGLContext::currentContext())->d_func()->bindTexture(pixmap, target, format, options); -#if defined(Q_WS_QWS) || (!defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)) - else if (wsurf) - texture = wsurf->context()->d_func()->bindTexture(pixmap, target, format, options); -#endif - return texture->id; -} - -QColor QGLDrawable::backgroundColor() const -{ - if (widget) - return widget->palette().brush(widget->backgroundRole()).color(); -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - else if (pixmapData) - return pixmapData->fillColor(); -#endif - return QApplication::palette().brush(QPalette::Background).color(); -} - -bool QGLDrawable::hasTransparentBackground() const -{ - return widget && widget->testAttribute(Qt::WA_TranslucentBackground); -} - -QGLContext *QGLDrawable::context() const -{ - if (widget) - return widget->d_func()->glcx; - else if (buffer) - return buffer->d_func()->qctx; - else if (fbo) - return const_cast<QGLContext *>(QGLContext::currentContext()); -#if defined(Q_WS_QWS) || (!defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)) - else if (wsurf) - return wsurf->context(); -#endif - return 0; -} - -bool QGLDrawable::autoFillBackground() const -{ - if (widget) - return widget->autoFillBackground(); -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - else if (pixmapData) - return pixmapData->needsFill(); -#endif - else - return false; -} -#endif - bool QGLShareRegister::checkSharing(const QGLContext *context1, const QGLContext *context2) { bool sharing = (context1 && context2 && context1->d_ptr->group == context2->d_ptr->group); return sharing; diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h index ce50c58..151c7c4 100644 --- a/src/opengl/qgl.h +++ b/src/opengl/qgl.h @@ -385,7 +385,6 @@ private: friend class QGLPixelBuffer; friend class QGLPixelBufferPrivate; friend class QGLWidget; -// friend class QGLDrawable; friend class QGLWidgetPrivate; friend class QGLGlyphCache; friend class QOpenGLPaintEngine; diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index e86b843..b10d5da 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -191,7 +191,7 @@ public: bool renderCxPm(QPixmap *pixmap); void cleanupColormaps(); - QGLContext *glcx; // ### Keep for compatability with QGLDrawable (if that gets left in) + QGLContext *glcx; QGLWidgetGLPaintDevice glDevice; bool autoSwap; @@ -341,60 +341,6 @@ Q_SIGNALS: void aboutToDestroyContext(const QGLContext *context); }; -#if 0 -class QGLPixelBuffer; -class QGLFramebufferObject; -class QWSGLWindowSurface; -class QGLWindowSurface; -class QGLPixmapData; -class QGLDrawable { -public: - QGLDrawable() : widget(0), buffer(0), fbo(0) -#if defined(Q_WS_QWS) || (!defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)) - , wsurf(0) -#endif -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - , pixmapData(0) -#endif - {} - void setDevice(QPaintDevice *pdev); - void swapBuffers(); - void makeCurrent(); - void doneCurrent(); - QSize size() const; - QGLFormat format() const; - GLuint bindTexture(const QImage &image, GLenum target = GL_TEXTURE_2D, GLint format = GL_RGBA, - QGLContext::BindOptions = QGLContext::InternalBindOption); - GLuint bindTexture(const QPixmap &pixmap, GLenum target = GL_TEXTURE_2D, GLint format = GL_RGBA, - QGLContext::BindOptions = QGLContext::InternalBindOption); - QColor backgroundColor() const; - QGLContext *context() const; - bool autoFillBackground() const; - bool hasTransparentBackground() const; - -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - QGLPixmapData *copyOnBegin() const; -#endif - -private: - bool wasBound; - QGLWidget *widget; - QGLPixelBuffer *buffer; - QGLFramebufferObject *fbo; -#ifdef Q_WS_QWS - QWSGLWindowSurface *wsurf; -#elif !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - QGLWindowSurface *wsurf; -#endif - -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - QGLPixmapData *pixmapData; -#endif - int previous_fbo; -}; - -#endif - // GL extension definitions class QGLExtensions { public: diff --git a/src/opengl/qgl_x11.cpp b/src/opengl/qgl_x11.cpp index fc29264..a7376b2 100644 --- a/src/opengl/qgl_x11.cpp +++ b/src/opengl/qgl_x11.cpp @@ -41,7 +41,6 @@ #include "qgl.h" #include "qgl_p.h" -#include "qglpaintdevice_p.h" #include "qmap.h" #include "qapplication.h" @@ -1308,7 +1307,6 @@ void QGLWidget::setContext(QGLContext *context, d->glcx->doneCurrent(); QGLContext* oldcx = d->glcx; d->glcx = context; -// d->glDevice.setContext(context); // ### Do this for all platforms if (parentWidget()) { // force creation of delay-created widgets diff --git a/src/opengl/qglframebufferobject.h b/src/opengl/qglframebufferobject.h index 29b1f97..6efbb73 100644 --- a/src/opengl/qglframebufferobject.h +++ b/src/opengl/qglframebufferobject.h @@ -130,7 +130,6 @@ protected: private: Q_DISABLE_COPY(QGLFramebufferObject) QScopedPointer<QGLFramebufferObjectPrivate> d_ptr; -// friend class QGLDrawable; friend class QGLPaintDevice; friend class QGLFBOGLPaintDevice; }; diff --git a/src/opengl/qglpaintdevice.cpp b/src/opengl/qglpaintdevice.cpp index 15ea217..a89b884 100644 --- a/src/opengl/qglpaintdevice.cpp +++ b/src/opengl/qglpaintdevice.cpp @@ -9,8 +9,8 @@ ** No Commercial Usage ** This file contains pre-release code and may not be distributed. ** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. +** contained in the Technology Preview License Agreement accompanying +** this package. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser @@ -21,20 +21,20 @@ ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this ** package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -46,6 +46,8 @@ #include <private/qwindowsurface_gl_p.h> #include <private/qpixmapdata_gl_p.h> +QT_BEGIN_NAMESPACE + QGLPaintDevice::QGLPaintDevice() : m_thisFBO(0) { @@ -94,33 +96,16 @@ void QGLPaintDevice::endPaint() } } -//QColor QGLPaintDevice::backgroundColor() const -//{ -// return QApplication::palette().brush(QPalette::Background).color(); -//} - -//bool QGLPaintDevice::autoFillBackground() const -//{ -// return false; -//} - -//bool QGLPaintDevice::hasTransparentBackground() const -//{ -// return false; -//} - QGLFormat QGLPaintDevice::format() const { return context()->format(); } -//QSize QGLPaintDevice::size() const -//{ -// return QSize(); -//} +////////////////// QGLWidgetGLPaintDevice ////////////////// + QGLWidgetGLPaintDevice::QGLWidgetGLPaintDevice() { } @@ -130,21 +115,6 @@ QPaintEngine* QGLWidgetGLPaintDevice::paintEngine() const return glWidget->paintEngine(); } -//QColor QGLWidgetGLPaintDevice::backgroundColor() const -//{ -// return glWidget->palette().brush(glWidget->backgroundRole()).color(); -//} - -//bool QGLWidgetGLPaintDevice::autoFillBackground() const -//{ -// return glWidget->autoFillBackground(); -//} - -//bool QGLWidgetGLPaintDevice::hasTransparentBackground() const -//{ -// return glWidget->testAttribute(Qt::WA_TranslucentBackground); -//} - void QGLWidgetGLPaintDevice::setWidget(QGLWidget* w) { glWidget = w; @@ -214,4 +184,4 @@ QGLPaintDevice* QGLPaintDevice::getDevice(QPaintDevice* pd) return glpd; } - +QT_END_NAMESPACE diff --git a/src/opengl/qglpaintdevice_p.h b/src/opengl/qglpaintdevice_p.h index a175b8c..32a1275 100644 --- a/src/opengl/qglpaintdevice_p.h +++ b/src/opengl/qglpaintdevice_p.h @@ -9,8 +9,8 @@ ** No Commercial Usage ** This file contains pre-release code and may not be distributed. ** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. +** contained in the Technology Preview License Agreement accompanying +** this package. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser @@ -21,20 +21,20 @@ ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this ** package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -53,9 +53,13 @@ // We mean it. // + #include <qpaintdevice.h> #include <qgl.h> + +QT_BEGIN_NAMESPACE + class QGLPaintDevice : public QPaintDevice { public: @@ -68,12 +72,6 @@ public: virtual void ensureActiveTarget(); virtual void endPaint(); -// virtual void clearOnBegin() const; -// virtual QColor clearColor() const; -// virtual QColor backgroundColor() const; -// virtual bool autoFillBackground() const; -// virtual bool hasTransparentBackground() const; - virtual QGLContext* context() const = 0; QGLFormat format() const; virtual QSize size() const = 0; @@ -82,12 +80,8 @@ public: static QGLPaintDevice* getDevice(QPaintDevice*); protected: - // Inline? -// void setContext(QGLContext* c); GLuint m_previousFBO; GLuint m_thisFBO; -private: -// QGLContext* m_context; }; @@ -100,11 +94,6 @@ public: virtual QPaintEngine* paintEngine() const; -// virtual void clearOnBegin() const; -// virtual QColor clearColor() const; -// virtual bool autoFillBackground() const; -// virtual bool hasTransparentBackground() const; - // QGLWidgets need to do swapBufers in endPaint: virtual void beginPaint(); virtual void endPaint(); @@ -118,59 +107,6 @@ private: QGLWidget *glWidget; }; - - -/* -Replaces: - -class QGLPixelBuffer; -class QGLFramebufferObject; -class QWSGLWindowSurface; -class QGLWindowSurface; -class QGLPixmapData; -class QGLDrawable { -public: - QGLDrawable() : widget(0), buffer(0), fbo(0) -#if defined(Q_WS_QWS) || (!defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)) - , wsurf(0) -#endif -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - , pixmapData(0) -#endif - {} - void setDevice(QPaintDevice *pdev); - void swapBuffers(); - void makeCurrent(); - void doneCurrent(); - QSize size() const; - QGLFormat format() const; - GLuint bindTexture(const QImage &image, GLenum target = GL_TEXTURE_2D, GLint format = GL_RGBA); - GLuint bindTexture(const QPixmap &pixmap, GLenum target = GL_TEXTURE_2D, GLint format = GL_RGBA); - QColor backgroundColor() const; - QGLContext *context() const; - bool autoFillBackground() const; - bool hasTransparentBackground() const; - -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - QGLPixmapData *copyOnBegin() const; -#endif - -private: - bool wasBound; - QGLWidget *widget; - QGLPixelBuffer *buffer; - QGLFramebufferObject *fbo; -#ifdef Q_WS_QWS - QWSGLWindowSurface *wsurf; -#elif !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - QGLWindowSurface *wsurf; -#endif - -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - QGLPixmapData *pixmapData; -#endif - int previous_fbo; -}; -*/ +QT_END_NAMESPACE #endif // QGLPAINTDEVICE_P_H diff --git a/src/opengl/qglpixelbuffer.cpp b/src/opengl/qglpixelbuffer.cpp index 45ab3bc..b6a919c 100644 --- a/src/opengl/qglpixelbuffer.cpp +++ b/src/opengl/qglpixelbuffer.cpp @@ -114,7 +114,6 @@ void QGLPBufferGLPaintDevice::endPaint() { void QGLPBufferGLPaintDevice::setPBuffer(QGLPixelBuffer* pb) { pbuf = pb; -// setContext(pb->d_func()->qctx); } void QGLPixelBufferPrivate::common_init(const QSize &size, const QGLFormat &format, QGLWidget *shareWidget) diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp index 36a0081..34fff10 100644 --- a/src/opengl/qpaintengine_opengl.cpp +++ b/src/opengl/qpaintengine_opengl.cpp @@ -287,7 +287,6 @@ public Q_SLOTS: } private: -// QGLDrawable drawable; QGLPaintDevice* device; QGLFramebufferObject *offscreen; @@ -436,7 +435,7 @@ inline void QGLOffscreen::release() DEBUG_ONCE_STR("QGLOffscreen: releasing offscreen"); if (drawable_fbo) - device->context()->makeCurrent(); //### + device->ensureActiveTarget(); //### else offscreen->release(); @@ -765,7 +764,6 @@ public: GLubyte pen_color[4]; GLubyte brush_color[4]; QTransform::TransformationType txop; -// QGLDrawable drawable; QGLPaintDevice* device; QGLOffscreen offscreen; |