summaryrefslogtreecommitdiff
path: root/src/gui/opengl/qopenglframebufferobject.cpp
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2011-09-07 10:31:03 +0200
committerPaul Olav Tvete <paul.tvete@nokia.com>2011-09-08 11:07:56 +0200
commit1b1831500142c995137f5e4b1bc03d21aa08e1e1 (patch)
tree5fcd21ee23c37fbe3466fde353d0bcfd09a051e2 /src/gui/opengl/qopenglframebufferobject.cpp
parent68974d8e647febb80a47d9cf6ce9452f3ce4fa21 (diff)
downloadqtbase-1b1831500142c995137f5e4b1bc03d21aa08e1e1.tar.gz
Improved and made public the QOpenGLPaintDevice API.
The new API is more flexible, allowing the use of QOpenGLPaintDevice with any QOpenGLContext, and putting more responsibility on the user for ensuring the correct FBO is current (the user knows best anyhow). Task-number: QTBUG-21263 Change-Id: I50b954125f552baef52fbb3fe2ed907a11ad519c Reviewed-on: http://codereview.qt-project.org/4325 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Paul Olav Tvete <paul.tvete@nokia.com>
Diffstat (limited to 'src/gui/opengl/qopenglframebufferobject.cpp')
-rw-r--r--src/gui/opengl/qopenglframebufferobject.cpp117
1 files changed, 1 insertions, 116 deletions
diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp
index 51d6f7ee32..4512904a15 100644
--- a/src/gui/opengl/qopenglframebufferobject.cpp
+++ b/src/gui/opengl/qopenglframebufferobject.cpp
@@ -47,7 +47,6 @@
#include <private/qopenglcontext_p.h>
#include <private/qopenglextensions_p.h>
#include <private/qfont_p.h>
-#include <private/qopenglpaintengine_p.h>
#include <qwindow.h>
#include <qlibrary.h>
@@ -314,41 +313,6 @@ bool QOpenGLFramebufferObjectFormat::operator!=(const QOpenGLFramebufferObjectFo
return !(*this == other);
}
-void QOpenGLFBOGLPaintDevice::setFBO(QOpenGLFramebufferObject* f,
- QOpenGLFramebufferObject::Attachment attachment)
-{
- fbo = f;
- m_thisFBO = fbo->d_func()->fbo(); // This shouldn't be needed
-
- // The context that the fbo was created in may not have depth
- // and stencil buffers, but the fbo itself might.
- fboFormat = QOpenGLContext::currentContext()->format();
- if (attachment == QOpenGLFramebufferObject::CombinedDepthStencil) {
- fboFormat.setDepthBufferSize(24);
- fboFormat.setStencilBufferSize(8);
- } else if (attachment == QOpenGLFramebufferObject::Depth) {
- fboFormat.setDepthBufferSize(24);
- fboFormat.setStencilBufferSize(0);
- } else {
- fboFormat.setDepthBufferSize(0);
- fboFormat.setStencilBufferSize(0);
- }
-
- GLenum format = f->format().internalTextureFormat();
- reqAlpha = (format != GL_RGB
-#ifndef QT_OPENGL_ES
- && format != GL_RGB5 && format != GL_RGB8
-#endif
- );
-}
-
-QOpenGLContextGroup *QOpenGLFBOGLPaintDevice::group() const
-{
- QOpenGLSharedResourceGuard *fbo_guard =
- fbo->d_func()->fbo_guard;
- return fbo_guard ? fbo_guard->group() : 0;
-}
-
bool QOpenGLFramebufferObjectPrivate::checkFramebufferStatus() const
{
QOpenGLContext *ctx = QOpenGLContext::currentContext();
@@ -414,7 +378,7 @@ namespace
}
}
-void QOpenGLFramebufferObjectPrivate::init(QOpenGLFramebufferObject *q, const QSize &sz,
+void QOpenGLFramebufferObjectPrivate::init(QOpenGLFramebufferObject *, const QSize &sz,
QOpenGLFramebufferObject::Attachment attachment,
GLenum texture_target, GLenum internal_format,
GLint samples, bool mipmap)
@@ -646,8 +610,6 @@ void QOpenGLFramebufferObjectPrivate::init(QOpenGLFramebufferObject *q, const QS
format.setAttachment(fbo_attachment);
format.setInternalTextureFormat(internal_format);
format.setMipmap(mipmap);
-
- glDevice.setFBO(q, attachment);
}
/*!
@@ -704,12 +666,6 @@ void QOpenGLFramebufferObjectPrivate::init(QOpenGLFramebufferObject *q, const QS
the constructors that take a QOpenGLFramebufferObject parameter, and set the
QOpenGLFramebufferObject::samples() property to a non-zero value.
- When painting to a QOpenGLFramebufferObject using QPainter, the state of
- the current GL context will be altered by the paint engine to reflect
- its needs. Applications should not rely upon the GL state being reset
- to its original conditions, particularly the current shader program,
- GL viewport, texture units, and drawing modes.
-
For multisample framebuffer objects a color render buffer is created,
otherwise a texture with the specified texture target is created.
The color render buffer or texture will have the specified internal
@@ -875,8 +831,6 @@ QOpenGLFramebufferObject::~QOpenGLFramebufferObject()
{
Q_D(QOpenGLFramebufferObject);
- delete d->engine;
-
if (d->texture_guard)
d->texture_guard->free();
if (d->color_buffer_guard)
@@ -1103,23 +1057,6 @@ QImage QOpenGLFramebufferObject::toImage() const
return image;
}
-Q_GLOBAL_STATIC(QOpenGLEngineThreadStorage<QOpenGL2PaintEngineEx>, qt_buffer_2_engine)
-
-/*! \reimp */
-QPaintEngine *QOpenGLFramebufferObject::paintEngine() const
-{
- Q_D(const QOpenGLFramebufferObject);
- if (d->engine)
- return d->engine;
-
- QPaintEngine *engine = qt_buffer_2_engine()->engine();
- if (engine->isActive() && engine->paintDevice() != this) {
- d->engine = new QOpenGL2PaintEngineEx;
- return d->engine;
- }
- return engine;
-}
-
/*!
\fn bool QOpenGLFramebufferObject::bindDefault()
\internal
@@ -1158,53 +1095,6 @@ bool QOpenGLFramebufferObject::hasOpenGLFramebufferObjects()
return QOpenGLFunctions(QOpenGLContext::currentContext()).hasOpenGLFeature(QOpenGLFunctions::Framebuffers);
}
-/*! \reimp */
-int QOpenGLFramebufferObject::metric(PaintDeviceMetric metric) const
-{
- Q_D(const QOpenGLFramebufferObject);
-
- float dpmx = qt_defaultDpiX()*100./2.54;
- float dpmy = qt_defaultDpiY()*100./2.54;
- int w = d->size.width();
- int h = d->size.height();
- switch (metric) {
- case PdmWidth:
- return w;
-
- case PdmHeight:
- return h;
-
- case PdmWidthMM:
- return qRound(w * 1000 / dpmx);
-
- case PdmHeightMM:
- return qRound(h * 1000 / dpmy);
-
- case PdmNumColors:
- return 0;
-
- case PdmDepth:
- return 32;//d->depth;
-
- case PdmDpiX:
- return qRound(dpmx * 0.0254);
-
- case PdmDpiY:
- return qRound(dpmy * 0.0254);
-
- case PdmPhysicalDpiX:
- return qRound(dpmx * 0.0254);
-
- case PdmPhysicalDpiY:
- return qRound(dpmy * 0.0254);
-
- default:
- qWarning("QOpenGLFramebufferObject::metric(), Unhandled metric type: %d.\n", metric);
- break;
- }
- return 0;
-}
-
/*!
\fn GLuint QOpenGLFramebufferObject::handle() const
@@ -1220,11 +1110,6 @@ GLuint QOpenGLFramebufferObject::handle() const
return d->fbo();
}
-/*! \fn int QOpenGLFramebufferObject::devType() const
- \internal
-*/
-
-
/*!
Returns the status of the depth and stencil buffers attached to
this framebuffer object.