diff options
author | Rhys Weatherley <rhys.weatherley@nokia.com> | 2009-09-08 03:00:43 (GMT) |
---|---|---|
committer | Rhys Weatherley <rhys.weatherley@nokia.com> | 2009-09-08 03:00:43 (GMT) |
commit | 2ed2632acec45ce4979ce21a0fe93d286a16613c (patch) | |
tree | 58e5a824f874fffcf533e04dae1845ace2667cd0 | |
parent | 79ad2c1d4f5205245c929be1c0db2c678d185038 (diff) | |
download | Qt-2ed2632acec45ce4979ce21a0fe93d286a16613c.zip Qt-2ed2632acec45ce4979ce21a0fe93d286a16613c.tar.gz Qt-2ed2632acec45ce4979ce21a0fe93d286a16613c.tar.bz2 |
Add operator== and != to QGLFramebufferObjectFormat
Reviewed-by: Sarah Smith
-rw-r--r-- | src/opengl/qglframebufferobject.cpp | 28 | ||||
-rw-r--r-- | src/opengl/qglframebufferobject.h | 3 | ||||
-rw-r--r-- | src/opengl/qpixmapdata_gl.cpp | 7 | ||||
-rw-r--r-- | tests/auto/qgl/tst_qgl.cpp | 49 |
4 files changed, 81 insertions, 6 deletions
diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp index 452f155..9990586 100644 --- a/src/opengl/qglframebufferobject.cpp +++ b/src/opengl/qglframebufferobject.cpp @@ -100,6 +100,13 @@ public: internal_format(other->internal_format) { } + bool equals(const QGLFramebufferObjectFormatPrivate *other) + { + return samples == other->samples && + attachment == other->attachment && + target == other->target && + internal_format == other->internal_format; + } QAtomicInt ref; int samples; @@ -311,6 +318,27 @@ void QGLFramebufferObjectFormat::setInternalTextureFormat(QMacCompatGLenum inter } #endif +/*! + Returns true if all the options of this framebuffer object format + are the same as \a other; otherwise returns false. +*/ +bool QGLFramebufferObjectFormat::operator==(const QGLFramebufferObjectFormat& other) const +{ + if (d == other.d) + return true; + else + return d->equals(other.d); +} + +/*! + Returns false if all the options of this framebuffer object format + are the same as \a other; otherwise returns true. +*/ +bool QGLFramebufferObjectFormat::operator!=(const QGLFramebufferObjectFormat& other) const +{ + return !(*this == other); +} + class QGLFramebufferObjectPrivate { public: diff --git a/src/opengl/qglframebufferobject.h b/src/opengl/qglframebufferobject.h index 6c1c0be..2778ec5 100644 --- a/src/opengl/qglframebufferobject.h +++ b/src/opengl/qglframebufferobject.h @@ -159,6 +159,9 @@ public: void setInternalTextureFormat(QMacCompatGLenum internalTextureFormat); #endif + bool operator==(const QGLFramebufferObjectFormat& other) const; + bool operator!=(const QGLFramebufferObjectFormat& other) const; + private: QGLFramebufferObjectFormatPrivate *d; diff --git a/src/opengl/qpixmapdata_gl.cpp b/src/opengl/qpixmapdata_gl.cpp index d63d2ad..a394716 100644 --- a/src/opengl/qpixmapdata_gl.cpp +++ b/src/opengl/qpixmapdata_gl.cpp @@ -80,12 +80,7 @@ QGLFramebufferObject *QGLFramebufferObjectPool::acquire(const QSize &requestSize for (int i = 0; !chosen && i < m_fbos.size(); ++i) { QGLFramebufferObject *fbo = m_fbos.at(i); - QGLFramebufferObjectFormat format = fbo->format(); - if (format.samples() == requestFormat.samples() - && format.attachment() == requestFormat.attachment() - && format.textureTarget() == requestFormat.textureTarget() - && format.internalTextureFormat() == requestFormat.internalTextureFormat()) - { + if (fbo->format() == requestFormat) { // choose the fbo with a matching format and the closest size if (!candidate || areaDiff(requestSize, candidate) > areaDiff(requestSize, fbo)) candidate = fbo; diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index 650c1ca..43f4227 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -1432,6 +1432,55 @@ void tst_QGL::fboFormat() QVERIFY(format1.attachment() == QGLFramebufferObject::CombinedDepthStencil); QCOMPARE(int(format1.textureTarget()), int(GL_TEXTURE_3D)); QCOMPARE(int(format1.internalTextureFormat()), int(GL_RGB16)); + + // operator== and operator!= for QGLFramebufferObjectFormat. + QGLFramebufferObjectFormat format1c; + QGLFramebufferObjectFormat format2c; + + QVERIFY(format1c == format2c); + QVERIFY(!(format1c != format2c)); + format1c.setSamples(8); + QVERIFY(!(format1c == format2c)); + QVERIFY(format1c != format2c); + format2c.setSamples(8); + QVERIFY(format1c == format2c); + QVERIFY(!(format1c != format2c)); + + format1c.setAttachment(QGLFramebufferObject::CombinedDepthStencil); + QVERIFY(!(format1c == format2c)); + QVERIFY(format1c != format2c); + format2c.setAttachment(QGLFramebufferObject::CombinedDepthStencil); + QVERIFY(format1c == format2c); + QVERIFY(!(format1c != format2c)); + + format1c.setTextureTarget(GL_TEXTURE_3D); + QVERIFY(!(format1c == format2c)); + QVERIFY(format1c != format2c); + format2c.setTextureTarget(GL_TEXTURE_3D); + QVERIFY(format1c == format2c); + QVERIFY(!(format1c != format2c)); + + format1c.setInternalTextureFormat(GL_RGB16); + QVERIFY(!(format1c == format2c)); + QVERIFY(format1c != format2c); + format2c.setInternalTextureFormat(GL_RGB16); + QVERIFY(format1c == format2c); + QVERIFY(!(format1c != format2c)); + + QGLFramebufferObjectFormat format3c(format1c); + QGLFramebufferObjectFormat format4c; + QVERIFY(format1c == format3c); + QVERIFY(!(format1c != format3c)); + format3c.setInternalTextureFormat(DEFAULT_FORMAT); + QVERIFY(!(format1c == format3c)); + QVERIFY(format1c != format3c); + + format4c = format1c; + QVERIFY(format1c == format4c); + QVERIFY(!(format1c != format4c)); + format4c.setInternalTextureFormat(DEFAULT_FORMAT); + QVERIFY(!(format1c == format4c)); + QVERIFY(format1c != format4c); } QTEST_MAIN(tst_QGL) |