Browse Source

GL: properly move BufferImage::dataSize().

Discovered with PVS-Studio, many thanks to @alexesDev for collecting the
report.
pull/280/head
Vladimír Vondruš 8 years ago
parent
commit
471a6d0c28
  1. 3
      src/Magnum/GL/BufferImage.h
  2. 8
      src/Magnum/GL/Test/BufferImageGLTest.cpp

3
src/Magnum/GL/BufferImage.h

@ -764,7 +764,7 @@ typedef CompressedBufferImage<2> CompressedBufferImage2D;
/** @brief Three-dimensional compressed buffer image */
typedef CompressedBufferImage<3> CompressedBufferImage3D;
template<UnsignedInt dimensions> inline BufferImage<dimensions>::BufferImage(BufferImage<dimensions>&& other) noexcept: _storage{std::move(other._storage)}, _format{std::move(other._format)}, _type{std::move(other._type)}, _size{std::move(other._size)}, _buffer{std::move(other._buffer)} {
template<UnsignedInt dimensions> inline BufferImage<dimensions>::BufferImage(BufferImage<dimensions>&& other) noexcept: _storage{std::move(other._storage)}, _format{std::move(other._format)}, _type{std::move(other._type)}, _size{std::move(other._size)}, _buffer{std::move(other._buffer)}, _dataSize{std::move(other._dataSize)} {
other._size = {};
}
@ -780,6 +780,7 @@ template<UnsignedInt dimensions> inline BufferImage<dimensions>& BufferImage<dim
swap(_type, other._type);
swap(_size, other._size);
swap(_buffer, other._buffer);
swap(_dataSize, other._dataSize);
return *this;
}

8
src/Magnum/GL/Test/BufferImageGLTest.cpp

@ -107,6 +107,7 @@ void BufferImageGLTest::construct() {
CORRADE_COMPARE(a.format(), GL::PixelFormat::Red);
CORRADE_COMPARE(a.type(), PixelType::UnsignedByte);
CORRADE_COMPARE(a.size(), Vector2i(1, 3));
CORRADE_COMPARE(a.dataSize(), 3);
/** @todo How to verify the contents in ES? */
#ifndef MAGNUM_TARGET_GLES
@ -130,6 +131,7 @@ void BufferImageGLTest::constructGeneric() {
CORRADE_COMPARE(a.format(), GL::PixelFormat::Red);
CORRADE_COMPARE(a.type(), PixelType::UnsignedByte);
CORRADE_COMPARE(a.size(), Vector2i(1, 3));
CORRADE_COMPARE(a.dataSize(), 3);
/** @todo How to verify the contents in ES? */
#ifndef MAGNUM_TARGET_GLES
@ -217,6 +219,7 @@ void BufferImageGLTest::constructBuffer() {
CORRADE_COMPARE(a.format(), GL::PixelFormat::Red);
CORRADE_COMPARE(a.type(), PixelType::UnsignedByte);
CORRADE_COMPARE(a.size(), Vector2i(1, 3));
CORRADE_COMPARE(a.dataSize(), 3);
/** @todo How to verify the contents in ES? */
#ifndef MAGNUM_TARGET_GLES
@ -246,6 +249,7 @@ void BufferImageGLTest::constructBufferGeneric() {
CORRADE_COMPARE(a.format(), GL::PixelFormat::Red);
CORRADE_COMPARE(a.type(), PixelType::UnsignedByte);
CORRADE_COMPARE(a.size(), Vector2i(1, 3));
CORRADE_COMPARE(a.dataSize(), 3);
/** @todo How to verify the contents in ES? */
#ifndef MAGNUM_TARGET_GLES
@ -369,6 +373,7 @@ void BufferImageGLTest::constructMove() {
CORRADE_COMPARE(b.format(), GL::PixelFormat::Red);
CORRADE_COMPARE(b.type(), PixelType::UnsignedByte);
CORRADE_COMPARE(b.size(), Vector2i(4, 1));
CORRADE_COMPARE(b.dataSize(), 4);
CORRADE_COMPARE(b.buffer().id(), id);
const unsigned short data2[2*4] = { 1, 2, 3, 4, 5, 6, 7, 8 };
@ -387,6 +392,7 @@ void BufferImageGLTest::constructMove() {
CORRADE_COMPARE(c.format(), GL::PixelFormat::Red);
CORRADE_COMPARE(c.type(), PixelType::UnsignedByte);
CORRADE_COMPARE(c.size(), Vector2i(4, 1));
CORRADE_COMPARE(c.dataSize(), 4);
CORRADE_COMPARE(c.buffer().id(), id);
}
@ -480,6 +486,7 @@ void BufferImageGLTest::setData() {
CORRADE_COMPARE(a.format(), GL::PixelFormat::RGBA);
CORRADE_COMPARE(a.type(), PixelType::UnsignedShort);
CORRADE_COMPARE(a.size(), Vector2i(1, 2));
CORRADE_COMPARE(a.dataSize(), 16);
/** @todo How to verify the contents in ES? */
#ifndef MAGNUM_TARGET_GLES
@ -507,6 +514,7 @@ void BufferImageGLTest::setDataGeneric() {
CORRADE_COMPARE(a.format(), GL::PixelFormat::RGBA);
CORRADE_COMPARE(a.type(), PixelType::UnsignedShort);
CORRADE_COMPARE(a.size(), Vector2i(1, 2));
CORRADE_COMPARE(a.dataSize(), 16);
/** @todo How to verify the contents in ES? */
#ifndef MAGNUM_TARGET_GLES

Loading…
Cancel
Save