From a808c3c7fbc9a6ed848ebc5b8276c24107f2101d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 23 Jul 2015 14:42:47 +0200 Subject: [PATCH] Compressed image support, part 2: renamed ImageReference to ImageView. With pixel pack/unpack support it will be possible to create views onto sub-images, renamed the class to reflect that. The old Magnum/ImageReference.h and ImageReference types are now aliases to ImageView.h and ImageView types, are marked as deprecated and will be removed in future release. --- src/Magnum/AbstractImage.h | 2 +- src/Magnum/AbstractTexture.cpp | 24 ++-- src/Magnum/AbstractTexture.h | 14 +- src/Magnum/BufferImage.h | 2 +- src/Magnum/CMakeLists.txt | 7 +- src/Magnum/ColorFormat.h | 4 +- src/Magnum/CubeMapTexture.cpp | 4 +- src/Magnum/CubeMapTexture.h | 8 +- src/Magnum/CubeMapTextureArray.h | 4 +- src/Magnum/Image.h | 14 +- src/Magnum/ImageReference.h | 119 ++++------------ src/Magnum/ImageView.h | 134 ++++++++++++++++++ src/Magnum/Magnum.h | 19 ++- src/Magnum/RectangleTexture.h | 4 +- src/Magnum/Test/CMakeLists.txt | 2 +- src/Magnum/Test/CubeMapTextureArrayGLTest.cpp | 14 +- src/Magnum/Test/CubeMapTextureGLTest.cpp | 26 ++-- src/Magnum/Test/ImageTest.cpp | 8 +- ...ageReferenceTest.cpp => ImageViewTest.cpp} | 22 +-- src/Magnum/Test/RectangleTextureGLTest.cpp | 12 +- src/Magnum/Test/TextureArrayGLTest.cpp | 28 ++-- src/Magnum/Test/TextureGLTest.cpp | 42 +++--- src/Magnum/Text/DistanceFieldGlyphCache.cpp | 6 +- src/Magnum/Text/DistanceFieldGlyphCache.h | 4 +- src/Magnum/Text/GlyphCache.cpp | 2 +- src/Magnum/Text/GlyphCache.h | 2 +- src/Magnum/Texture.h | 8 +- src/Magnum/TextureArray.h | 6 +- src/Magnum/Trade/AbstractImageConverter.cpp | 12 +- src/Magnum/Trade/AbstractImageConverter.h | 12 +- src/Magnum/Trade/ImageData.h | 14 +- .../Trade/Test/AbstractImageConverterTest.cpp | 6 +- src/Magnum/Trade/Test/ImageDataTest.cpp | 8 +- .../Test/TgaImageConverterTest.cpp | 6 +- .../TgaImageConverter/TgaImageConverter.cpp | 2 +- .../TgaImageConverter/TgaImageConverter.h | 2 +- 36 files changed, 342 insertions(+), 261 deletions(-) create mode 100644 src/Magnum/ImageView.h rename src/Magnum/Test/{ImageReferenceTest.cpp => ImageViewTest.cpp} (77%) diff --git a/src/Magnum/AbstractImage.h b/src/Magnum/AbstractImage.h index 70cda0581..a9b99be8b 100644 --- a/src/Magnum/AbstractImage.h +++ b/src/Magnum/AbstractImage.h @@ -45,7 +45,7 @@ namespace Implementation { /** @brief Non-templated base for one-, two- or three-dimensional images -See @ref Image, @ref ImageReference, @ref BufferImage and @ref Trade::ImageData +See @ref Image, @ref ImageView, @ref BufferImage and @ref Trade::ImageData documentation for more information. @todo Where to put glClampColor() and glPixelStore() encapsulation? It is needed in AbstractFramebuffer::read(), Texture::setImage() etc (i.e. all diff --git a/src/Magnum/AbstractTexture.cpp b/src/Magnum/AbstractTexture.cpp index 20bddde41..7389315f0 100644 --- a/src/Magnum/AbstractTexture.cpp +++ b/src/Magnum/AbstractTexture.cpp @@ -1015,7 +1015,7 @@ void AbstractTexture::storageImplementationFallback(const GLsizei levels, const for(GLsizei level = 0; level != levels; ++level) DataHelper<1>::setImage(*this, level, internalFormat, - ImageReference1D{format, type, Math::max(Math::Vector<1, GLsizei>(1), size >> level)}); + ImageView1D{format, type, Math::max(Math::Vector<1, GLsizei>(1), size >> level)}); } void AbstractTexture::storageImplementationDefault(GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size) { @@ -1047,7 +1047,7 @@ void AbstractTexture::storageImplementationFallback(const GLsizei levels, const { for(GLsizei level = 0; level != levels; ++level) DataHelper<2>::setImage(*this, level, internalFormat, - ImageReference2D{format, type, Math::max(Vector2i(1), size >> level)}); + ImageView2D{format, type, Math::max(Vector2i(1), size >> level)}); /* Cube map additionally needs to specify all faces */ } else if(_target == GL_TEXTURE_CUBE_MAP) { @@ -1059,7 +1059,7 @@ void AbstractTexture::storageImplementationFallback(const GLsizei levels, const GL_TEXTURE_CUBE_MAP_POSITIVE_Z, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z}) DataHelper<2>::setImage(*this, face, level, internalFormat, - ImageReference2D{format, type, Math::max(Vector2i(1), size >> level)}); + ImageView2D{format, type, Math::max(Vector2i(1), size >> level)}); } #ifndef MAGNUM_TARGET_GLES @@ -1067,7 +1067,7 @@ void AbstractTexture::storageImplementationFallback(const GLsizei levels, const } else if(_target == GL_TEXTURE_1D_ARRAY) { for(GLsizei level = 0; level != levels; ++level) DataHelper<2>::setImage(*this, level, internalFormat, - ImageReference2D{format, type, Vector2i{Math::max(1, size.x() >> level), size.y()}}); + ImageView2D{format, type, Vector2i{Math::max(1, size.x() >> level), size.y()}}); #endif /* No other targets are available */ @@ -1115,7 +1115,7 @@ void AbstractTexture::storageImplementationFallback(GLsizei levels, TextureForma #endif for(GLsizei level = 0; level != levels; ++level) DataHelper<3>::setImage(*this, level, internalFormat, - ImageReference3D{format, type, Math::max(Vector3i(1), size >> level)}); + ImageView3D{format, type, Math::max(Vector3i(1), size >> level)}); #ifndef MAGNUM_TARGET_GLES2 /* Array texture is not scaled in "layer" dimension */ @@ -1126,7 +1126,7 @@ void AbstractTexture::storageImplementationFallback(GLsizei levels, TextureForma #endif for(GLsizei level = 0; level != levels; ++level) DataHelper<3>::setImage(*this, level, internalFormat, - ImageReference3D{format, type, Vector3i{Math::max(Vector2i{1}, size.xy() >> level), size.z()}}); + ImageView3D{format, type, Vector3i{Math::max(Vector2i{1}, size.xy() >> level), size.z()}}); #endif /* No other targets are available */ @@ -1439,7 +1439,7 @@ void AbstractTexture::DataHelper<3>::setStorageMultisample(AbstractTexture& text #endif #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::DataHelper<1>::setImage(AbstractTexture& texture, const GLint level, const TextureFormat internalFormat, const ImageReference1D& image) { +void AbstractTexture::DataHelper<1>::setImage(AbstractTexture& texture, const GLint level, const TextureFormat internalFormat, const ImageView1D& image) { Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); texture.bindInternal(); glTexImage1D(texture._target, level, GLint(internalFormat), image.size()[0], 0, GLenum(image.format()), GLenum(image.type()), image.data()); @@ -1451,7 +1451,7 @@ void AbstractTexture::DataHelper<1>::setImage(AbstractTexture& texture, const GL glTexImage1D(texture._target, level, GLint(internalFormat), image.size()[0], 0, GLenum(image.format()), GLenum(image.type()), nullptr); } -void AbstractTexture::DataHelper<1>::setSubImage(AbstractTexture& texture, const GLint level, const Math::Vector<1, GLint>& offset, const ImageReference1D& image) { +void AbstractTexture::DataHelper<1>::setSubImage(AbstractTexture& texture, const GLint level, const Math::Vector<1, GLint>& offset, const ImageView1D& image) { Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); (texture.*Context::current()->state().texture->subImage1DImplementation)(level, offset, image.size(), image.format(), image.type(), image.data()); } @@ -1462,7 +1462,7 @@ void AbstractTexture::DataHelper<1>::setSubImage(AbstractTexture& texture, const } #endif -void AbstractTexture::DataHelper<2>::setImage(AbstractTexture& texture, const GLenum target, const GLint level, const TextureFormat internalFormat, const ImageReference2D& image) { +void AbstractTexture::DataHelper<2>::setImage(AbstractTexture& texture, const GLenum target, const GLint level, const TextureFormat internalFormat, const ImageView2D& image) { #ifndef MAGNUM_TARGET_GLES2 Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); #endif @@ -1478,7 +1478,7 @@ void AbstractTexture::DataHelper<2>::setImage(AbstractTexture& texture, const GL } #endif -void AbstractTexture::DataHelper<2>::setSubImage(AbstractTexture& texture, const GLint level, const Vector2i& offset, const ImageReference2D& image) { +void AbstractTexture::DataHelper<2>::setSubImage(AbstractTexture& texture, const GLint level, const Vector2i& offset, const ImageView2D& image) { #ifndef MAGNUM_TARGET_GLES2 Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); #endif @@ -1493,7 +1493,7 @@ void AbstractTexture::DataHelper<2>::setSubImage(AbstractTexture& texture, const #endif #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) -void AbstractTexture::DataHelper<3>::setImage(AbstractTexture& texture, const GLint level, const TextureFormat internalFormat, const ImageReference3D& image) { +void AbstractTexture::DataHelper<3>::setImage(AbstractTexture& texture, const GLint level, const TextureFormat internalFormat, const ImageView3D& image) { #ifndef MAGNUM_TARGET_GLES2 Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); #endif @@ -1520,7 +1520,7 @@ void AbstractTexture::DataHelper<3>::setImage(AbstractTexture& texture, const GL #endif #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) -void AbstractTexture::DataHelper<3>::setSubImage(AbstractTexture& texture, const GLint level, const Vector3i& offset, const ImageReference3D& image) { +void AbstractTexture::DataHelper<3>::setSubImage(AbstractTexture& texture, const GLint level, const Vector3i& offset, const ImageView3D& image) { #ifndef MAGNUM_TARGET_GLES2 Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); #endif diff --git a/src/Magnum/AbstractTexture.h b/src/Magnum/AbstractTexture.h index d16965794..31a401579 100644 --- a/src/Magnum/AbstractTexture.h +++ b/src/Magnum/AbstractTexture.h @@ -575,10 +575,10 @@ template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<1> { static void setStorage(AbstractTexture& texture, GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size); - static void setImage(AbstractTexture& texture, GLint level, TextureFormat internalFormat, const ImageReference1D& image); + static void setImage(AbstractTexture& texture, GLint level, TextureFormat internalFormat, const ImageView1D& image); static void setImage(AbstractTexture& texture, GLint level, TextureFormat internalFormat, BufferImage1D& image); - static void setSubImage(AbstractTexture& texture, GLint level, const Math::Vector<1, GLint>& offset, const ImageReference1D& image); + static void setSubImage(AbstractTexture& texture, GLint level, const Math::Vector<1, GLint>& offset, const ImageView1D& image); static void setSubImage(AbstractTexture& texture, GLint level, const Math::Vector<1, GLint>& offset, BufferImage1D& image); static void invalidateSubImage(AbstractTexture& texture, GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLint>& size); @@ -597,10 +597,10 @@ template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<2> { static void setStorageMultisample(AbstractTexture& texture, GLsizei samples, TextureFormat internalFormat, const Vector2i& size, GLboolean fixedSampleLocations); #endif - static void setImage(AbstractTexture& texture, GLint level, TextureFormat internalFormat, const ImageReference2D& image) { + static void setImage(AbstractTexture& texture, GLint level, TextureFormat internalFormat, const ImageView2D& image) { setImage(texture, texture._target, level, internalFormat, image); } - static void setImage(AbstractTexture& texture, GLenum target, GLint level, TextureFormat internalFormat, const ImageReference2D& image); + static void setImage(AbstractTexture& texture, GLenum target, GLint level, TextureFormat internalFormat, const ImageView2D& image); #ifndef MAGNUM_TARGET_GLES2 static void setImage(AbstractTexture& texture, GLint level, TextureFormat internalFormat, BufferImage2D& image) { setImage(texture, texture._target, level, internalFormat, image); @@ -608,7 +608,7 @@ template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<2> { static void setImage(AbstractTexture& texture, GLenum target, GLint level, TextureFormat internalFormat, BufferImage2D& image); #endif - static void setSubImage(AbstractTexture& texture, GLint level, const Vector2i& offset, const ImageReference2D& image); + static void setSubImage(AbstractTexture& texture, GLint level, const Vector2i& offset, const ImageView2D& image); #ifndef MAGNUM_TARGET_GLES2 static void setSubImage(AbstractTexture& texture, GLint level, const Vector2i& offset, BufferImage2D& image); #endif @@ -629,12 +629,12 @@ template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<3> { static void setStorageMultisample(AbstractTexture& texture, GLsizei samples, TextureFormat internalFormat, const Vector3i& size, GLboolean fixedSampleLocations); #endif - static void setImage(AbstractTexture& texture, GLint level, TextureFormat internalFormat, const ImageReference3D& image); + static void setImage(AbstractTexture& texture, GLint level, TextureFormat internalFormat, const ImageView3D& image); #ifndef MAGNUM_TARGET_GLES2 static void setImage(AbstractTexture& texture, GLint level, TextureFormat internalFormat, BufferImage3D& image); #endif - static void setSubImage(AbstractTexture& texture, GLint level, const Vector3i& offset, const ImageReference3D& image); + static void setSubImage(AbstractTexture& texture, GLint level, const Vector3i& offset, const ImageView3D& image); #ifndef MAGNUM_TARGET_GLES2 static void setSubImage(AbstractTexture& texture, GLint level, const Vector3i& offset, BufferImage3D& image); #endif diff --git a/src/Magnum/BufferImage.h b/src/Magnum/BufferImage.h index cd8a3853d..31728a2f7 100644 --- a/src/Magnum/BufferImage.h +++ b/src/Magnum/BufferImage.h @@ -43,7 +43,7 @@ namespace Magnum { @brief Buffer image Stores image data in GPU memory. Interchangeable with @ref Image, -@ref ImageReference or @ref Trade::ImageData. +@ref ImageView or @ref Trade::ImageData. @see @ref BufferImage1D, @ref BufferImage2D, @ref BufferImage3D, @ref Buffer @requires_gles30 Pixel buffer objects are not available in OpenGL ES 2.0. @requires_webgl20 Pixel buffer objects are not available in WebGL 1.0. diff --git a/src/Magnum/CMakeLists.txt b/src/Magnum/CMakeLists.txt index 5543a2d12..5e9825a97 100644 --- a/src/Magnum/CMakeLists.txt +++ b/src/Magnum/CMakeLists.txt @@ -95,7 +95,7 @@ set(Magnum_HEADERS Extensions.h Framebuffer.h Image.h - ImageReference.h + ImageView.h Magnum.h Mesh.h MeshView.h @@ -129,6 +129,11 @@ set(Magnum_PRIVATE_HEADERS Implementation/State.h Implementation/TextureState.h) +# Deprecated stuff +if(BUILD_DEPRECATED) + list(APPEND Magnum_HEADERS ImageReference.h) +endif() + # Desktop-only stuff if(NOT TARGET_GLES) list(APPEND Magnum_SRCS RectangleTexture.cpp) diff --git a/src/Magnum/ColorFormat.h b/src/Magnum/ColorFormat.h index 509147a32..216d30b90 100644 --- a/src/Magnum/ColorFormat.h +++ b/src/Magnum/ColorFormat.h @@ -50,7 +50,7 @@ In most cases you may want to use @ref ColorFormat::Red (for grayscale images), See documentation of these values for possible limitations when using OpenGL ES 2.0 or WebGL. -@see @ref Image, @ref ImageReference, @ref BufferImage, @ref Trade::ImageData +@see @ref Image, @ref ImageView, @ref BufferImage, @ref Trade::ImageData */ enum class ColorFormat: GLenum { #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) @@ -310,7 +310,7 @@ In most cases you may want to use @ref ColorType::UnsignedByte along with See documentation of these values for possible limitations when using OpenGL ES 2.0 or WebGL. -@see @ref Image, @ref ImageReference, @ref BufferImage, @ref Trade::ImageData +@see @ref Image, @ref ImageView, @ref BufferImage, @ref Trade::ImageData */ enum class ColorType: GLenum { /** Each component unsigned byte. */ diff --git a/src/Magnum/CubeMapTexture.cpp b/src/Magnum/CubeMapTexture.cpp index f8f64de0e..41c7b7bef 100644 --- a/src/Magnum/CubeMapTexture.cpp +++ b/src/Magnum/CubeMapTexture.cpp @@ -124,7 +124,7 @@ BufferImage3D CubeMapTexture::subImage(const Int level, const Range3Di& range, B return std::move(image); } -CubeMapTexture& CubeMapTexture::setSubImage(const Int level, const Vector3i& offset, const ImageReference3D& image) { +CubeMapTexture& CubeMapTexture::setSubImage(const Int level, const Vector3i& offset, const ImageView3D& image) { Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); glTextureSubImage3D(_id, level, offset.x(), offset.y(), offset.z(), image.size().x(), image.size().y(), image.size().z(), GLenum(image.format()), GLenum(image.type()), image.data()); return *this; @@ -137,7 +137,7 @@ CubeMapTexture& CubeMapTexture::setSubImage(const Int level, const Vector3i& off } #endif -CubeMapTexture& CubeMapTexture::setSubImage(const Coordinate coordinate, const Int level, const Vector2i& offset, const ImageReference2D& image) { +CubeMapTexture& CubeMapTexture::setSubImage(const Coordinate coordinate, const Int level, const Vector2i& offset, const ImageView2D& image) { #ifndef MAGNUM_TARGET_GLES2 Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); #endif diff --git a/src/Magnum/CubeMapTexture.h b/src/Magnum/CubeMapTexture.h index 60b9b243a..e2dee33da 100644 --- a/src/Magnum/CubeMapTexture.h +++ b/src/Magnum/CubeMapTexture.h @@ -588,7 +588,7 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { * @deprecated_gl Prefer to use @ref setStorage() and @ref setSubImage() * instead. */ - CubeMapTexture& setImage(Coordinate coordinate, Int level, TextureFormat internalFormat, const ImageReference2D& image) { + CubeMapTexture& setImage(Coordinate coordinate, Int level, TextureFormat internalFormat, const ImageView2D& image) { DataHelper<2>::setImage(*this, GLenum(coordinate), level, internalFormat, image); return *this; } @@ -625,7 +625,7 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { * @brief Set image subdata * @param level Mip level * @param offset Offset where to put data in the texture - * @param image @ref Image3D, @ref ImageReference3D or + * @param image @ref Image3D, @ref ImageView3D or * @ref Trade::ImageData3D * @return Reference to self (for method chaining) * @@ -634,7 +634,7 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { * @requires_gl In OpenGL ES and WebGL you need to set image for each * face separately. */ - CubeMapTexture& setSubImage(Int level, const Vector3i& offset, const ImageReference3D& image); + CubeMapTexture& setSubImage(Int level, const Vector3i& offset, const ImageView3D& image); /** @overload * @requires_gl45 Extension @extension{ARB,direct_state_access} @@ -659,7 +659,7 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { * * See @ref Texture::setSubImage() for more information. */ - CubeMapTexture& setSubImage(Coordinate coordinate, Int level, const Vector2i& offset, const ImageReference2D& image); + CubeMapTexture& setSubImage(Coordinate coordinate, Int level, const Vector2i& offset, const ImageView2D& image); #ifndef MAGNUM_TARGET_GLES2 /** @overload diff --git a/src/Magnum/CubeMapTextureArray.h b/src/Magnum/CubeMapTextureArray.h index dfbc88ae8..58a4d2182 100644 --- a/src/Magnum/CubeMapTextureArray.h +++ b/src/Magnum/CubeMapTextureArray.h @@ -472,7 +472,7 @@ class MAGNUM_EXPORT CubeMapTextureArray: public AbstractTexture { * @deprecated_gl Prefer to use @ref setStorage() and @ref setSubImage() * instead. */ - CubeMapTextureArray& setImage(Int level, TextureFormat internalFormat, const ImageReference3D& image) { + CubeMapTextureArray& setImage(Int level, TextureFormat internalFormat, const ImageView3D& image) { DataHelper<3>::setImage(*this, level, internalFormat, image); return *this; } @@ -503,7 +503,7 @@ class MAGNUM_EXPORT CubeMapTextureArray: public AbstractTexture { * * See @ref Texture::setSubImage() for more information. */ - CubeMapTextureArray& setSubImage(Int level, const Vector3i& offset, const ImageReference3D& image) { + CubeMapTextureArray& setSubImage(Int level, const Vector3i& offset, const ImageView3D& image) { DataHelper<3>::setSubImage(*this, level, offset, image); return *this; } diff --git a/src/Magnum/Image.h b/src/Magnum/Image.h index c65f8ac71..6f2fda56e 100644 --- a/src/Magnum/Image.h +++ b/src/Magnum/Image.h @@ -29,14 +29,14 @@ * @brief Class @ref Magnum::Image, typedef @ref Magnum::Image1D, @ref Magnum::Image2D, @ref Magnum::Image3D */ -#include "Magnum/ImageReference.h" +#include "Magnum/ImageView.h" namespace Magnum { /** @brief Image -Stores image data on client memory. Interchangeable with @ref ImageReference, +Stores image data on client memory. Interchangeable with @ref ImageView, @ref BufferImage or @ref Trade::ImageData. @see @ref Image1D, @ref Image2D, @ref Image3D */ @@ -83,8 +83,8 @@ template class Image: public AbstractImage { /** @brief Destructor */ ~Image() { delete[] _data; } - /** @brief Conversion to reference */ - /*implicit*/ operator ImageReference() + /** @brief Conversion to view */ + /*implicit*/ operator ImageView() #ifndef CORRADE_GCC47_COMPATIBILITY const &; #else @@ -93,7 +93,7 @@ template class Image: public AbstractImage { #ifndef CORRADE_GCC47_COMPATIBILITY /** @overload */ - /*implicit*/ operator ImageReference() const && = delete; + /*implicit*/ operator ImageView() const && = delete; #endif /** @brief Format of pixel data */ @@ -186,14 +186,14 @@ template inline Image& Image::op return *this; } -template inline Image::operator ImageReference() +template inline Image::operator ImageView() #ifndef CORRADE_GCC47_COMPATIBILITY const & #else const #endif { - return ImageReference{_format, _type, _size, _data}; + return ImageView{_format, _type, _size, _data}; } template inline char* Image::release() { diff --git a/src/Magnum/ImageReference.h b/src/Magnum/ImageReference.h index c0d8286d4..de80107f8 100644 --- a/src/Magnum/ImageReference.h +++ b/src/Magnum/ImageReference.h @@ -26,109 +26,40 @@ */ /** @file - * @brief Class @ref Magnum::ImageReference, typedef @ref Magnum::ImageReference1D, @ref Magnum::ImageReference2D, @ref Magnum::ImageReference3D + * @deprecated Use @ref Magnum/ImageView.h instead. */ -#include "Magnum/Math/Vector3.h" -#include "Magnum/AbstractImage.h" -#include "Magnum/DimensionTraits.h" +#include "Magnum/configure.h" -namespace Magnum { - -/** -@brief Image reference - -Adds information about dimensions, color components and component type to some -data in memory. - -Unlike @ref Image, this class doesn't delete the data on destruction, so it is -targeted for wrapping data which are either stored in stack/constant memory -(and shouldn't be deleted) or they are managed by someone else and have the -same properties for each frame, such as video stream. Thus it is not possible -to change image properties, only data pointer. - -Interchangeable with @ref Image, @ref BufferImage or @ref Trade::ImageData. -@see @ref ImageReference1D, @ref ImageReference2D, @ref ImageReference3D -*/ -template class ImageReference: public AbstractImage { - public: - enum: UnsignedInt { - Dimensions = dimensions /**< Image dimension count */ - }; - - /** - * @brief Constructor - * @param format Format of pixel data - * @param type Data type of pixel data - * @param size Image size - * @param data Image data - */ - constexpr explicit ImageReference(ColorFormat format, ColorType type, const VectorTypeFor& size, const void* data): _format{format}, _type{type}, _size{size}, _data{reinterpret_cast(data)} {} - - /** - * @brief Constructor - * @param format Format of pixel data - * @param type Data type of pixel data - * @param size Image size - * - * Data pointer is set to `nullptr`, call @ref setData() to fill the - * image with data. - */ - constexpr explicit ImageReference(ColorFormat format, ColorType type, const VectorTypeFor& size): _format{format}, _type{type}, _size{size}, _data{nullptr} {} - - /** @brief Format of pixel data */ - ColorFormat format() const { return _format; } - - /** @brief Data type of pixel data */ - ColorType type() const { return _type; } - - /** @brief Pixel size (in bytes) */ - std::size_t pixelSize() const { return Implementation::imagePixelSize(_format, _type); } +#ifdef MAGNUM_BUILD_DEPRECATED +#include "Magnum/ImageView.h" +CORRADE_DEPRECATED_FILE("use Magnum/ImageView.h instead") - /** @brief Image size */ - constexpr VectorTypeFor size() const { return _size; } - - /** @copydoc Image::dataSize() */ - std::size_t dataSize(const VectorTypeFor& size) const { - return Implementation::imageDataSize(*this, _format, _type, size); - } - - /** @brief Pointer to raw data */ - constexpr const char* data() const { return _data; } - - /** @overload */ - template const T* data() const { - return reinterpret_cast(_data); - } - - /** - * @brief Set image data - * @param data Image data - * - * Dimensions, color compnents and data type remains the same as - * passed in constructor. The data are not copied nor deleted on - * destruction. - */ - void setData(const void* data) { - _data = reinterpret_cast(data); - } +namespace Magnum { - private: - ColorFormat _format; - ColorType _type; - Math::Vector _size; - const char* _data; -}; +/** @copybrief ImageView + * @deprecated Use @ref ImageView instead. + */ +template using CORRADE_DEPRECATED("use ImageView instead") ImageReference = ImageView; -/** @brief One-dimensional image wrapper */ -typedef ImageReference<1> ImageReference1D; +/** @copybrief ImageView1D + * @deprecated Use @ref ImageView1D instead. + */ +typedef CORRADE_DEPRECATED("use ImageView1D instead") ImageView1D ImageReference1D; -/** @brief Two-dimensional image wrapper */ -typedef ImageReference<2> ImageReference2D; +/** @copybrief ImageView2D + * @deprecated Use @ref ImageView2D instead. + */ +typedef CORRADE_DEPRECATED("use ImageView2D instead") ImageView2D ImageReference2D; -/** @brief Three-dimensional image wrapper */ -typedef ImageReference<3> ImageReference3D; +/** @copybrief ImageView3D + * @deprecated Use @ref ImageView3D instead. + */ +typedef CORRADE_DEPRECATED("use ImageView3D instead") ImageView3D ImageReference3D; } +#else +#error use Magnum/ImageView.h instead +#endif #endif diff --git a/src/Magnum/ImageView.h b/src/Magnum/ImageView.h new file mode 100644 index 000000000..6c51d22b5 --- /dev/null +++ b/src/Magnum/ImageView.h @@ -0,0 +1,134 @@ +#ifndef Magnum_ImageView_h +#define Magnum_ImageView_h +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +/** @file + * @brief Class @ref Magnum::ImageView, typedef @ref Magnum::ImageView1D, @ref Magnum::ImageView2D, @ref Magnum::ImageView3D + */ + +#include "Magnum/Math/Vector3.h" +#include "Magnum/AbstractImage.h" +#include "Magnum/DimensionTraits.h" + +namespace Magnum { + +/** +@brief Image view + +Adds information about dimensions, color components and component type to some +data in memory. + +Unlike @ref Image, this class doesn't delete the data on destruction, so it is +targeted for wrapping data which are either stored in stack/constant memory +(and shouldn't be deleted) or they are managed by someone else and have the +same properties for each frame, such as video stream. Thus it is not possible +to change image properties, only data pointer. + +Interchangeable with @ref Image, @ref BufferImage or @ref Trade::ImageData. +@see @ref ImageView1D, @ref ImageView2D, @ref ImageView3D +*/ +template class ImageView: public AbstractImage { + public: + enum: UnsignedInt { + Dimensions = dimensions /**< Image dimension count */ + }; + + /** + * @brief Constructor + * @param format Format of pixel data + * @param type Data type of pixel data + * @param size Image size + * @param data Image data + */ + constexpr explicit ImageView(ColorFormat format, ColorType type, const VectorTypeFor& size, const void* data): _format{format}, _type{type}, _size{size}, _data{reinterpret_cast(data)} {} + + /** + * @brief Constructor + * @param format Format of pixel data + * @param type Data type of pixel data + * @param size Image size + * + * Data pointer is set to `nullptr`, call @ref setData() to fill the + * image with data. + */ + constexpr explicit ImageView(ColorFormat format, ColorType type, const VectorTypeFor& size): _format{format}, _type{type}, _size{size}, _data{nullptr} {} + + /** @brief Format of pixel data */ + ColorFormat format() const { return _format; } + + /** @brief Data type of pixel data */ + ColorType type() const { return _type; } + + /** @brief Pixel size (in bytes) */ + std::size_t pixelSize() const { return Implementation::imagePixelSize(_format, _type); } + + /** @brief Image size */ + constexpr VectorTypeFor size() const { return _size; } + + /** @copydoc Image::dataSize() */ + std::size_t dataSize(const VectorTypeFor& size) const { + return Implementation::imageDataSize(*this, _format, _type, size); + } + + /** @brief Pointer to raw data */ + constexpr const char* data() const { return _data; } + + /** @overload */ + template const T* data() const { + return reinterpret_cast(_data); + } + + /** + * @brief Set image data + * @param data Image data + * + * Dimensions, color compnents and data type remains the same as + * passed in constructor. The data are not copied nor deleted on + * destruction. + */ + void setData(const void* data) { + _data = reinterpret_cast(data); + } + + private: + ColorFormat _format; + ColorType _type; + Math::Vector _size; + const char* _data; +}; + +/** @brief One-dimensional image view */ +typedef ImageView<1> ImageView1D; + +/** @brief Two-dimensional image view */ +typedef ImageView<2> ImageView2D; + +/** @brief Three-dimensional image view */ +typedef ImageView<3> ImageView3D; + +} + +#endif diff --git a/src/Magnum/Magnum.h b/src/Magnum/Magnum.h index 0b22f642a..3f354ab43 100644 --- a/src/Magnum/Magnum.h +++ b/src/Magnum/Magnum.h @@ -34,6 +34,10 @@ #include "Magnum/Types.h" #include "Magnum/Math/Math.h" +#ifdef MAGNUM_BUILD_DEPRECATED +#include +#endif + #ifndef DOXYGEN_GENERATING_OUTPUT typedef unsigned int GLenum; /* Needed for *Format and *Type enums */ #endif @@ -475,10 +479,17 @@ typedef Image<1> Image1D; typedef Image<2> Image2D; typedef Image<3> Image3D; -template class ImageReference; -typedef ImageReference<1> ImageReference1D; -typedef ImageReference<2> ImageReference2D; -typedef ImageReference<3> ImageReference3D; +template class ImageView; +typedef ImageView<1> ImageView1D; +typedef ImageView<2> ImageView2D; +typedef ImageView<3> ImageView3D; + +#ifdef MAGNUM_BUILD_DEPRECATED +template using CORRADE_DEPRECATED("use ImageView instead") ImageReference = ImageView; +typedef CORRADE_DEPRECATED("use ImageView1D instead") ImageView1D ImageReference1D; +typedef CORRADE_DEPRECATED("use ImageView2D instead") ImageView2D ImageReference2D; +typedef CORRADE_DEPRECATED("use ImageView3D instead") ImageView3D ImageReference3D; +#endif enum class MeshPrimitive: GLenum; diff --git a/src/Magnum/RectangleTexture.h b/src/Magnum/RectangleTexture.h index fceba142d..25b74b33c 100644 --- a/src/Magnum/RectangleTexture.h +++ b/src/Magnum/RectangleTexture.h @@ -363,7 +363,7 @@ class MAGNUM_EXPORT RectangleTexture: public AbstractTexture { * @deprecated_gl Prefer to use @ref setStorage() and @ref setSubImage() * instead. */ - RectangleTexture& setImage(TextureFormat internalFormat, const ImageReference2D& image) { + RectangleTexture& setImage(TextureFormat internalFormat, const ImageView2D& image) { DataHelper<2>::setImage(*this, 0, internalFormat, image); return *this; } @@ -391,7 +391,7 @@ class MAGNUM_EXPORT RectangleTexture: public AbstractTexture { * * See @ref Texture::setSubImage() for more information. */ - RectangleTexture& setSubImage(const Vector2i& offset, const ImageReference2D& image) { + RectangleTexture& setSubImage(const Vector2i& offset, const ImageView2D& image) { DataHelper<2>::setSubImage(*this, 0, offset, image); return *this; } diff --git a/src/Magnum/Test/CMakeLists.txt b/src/Magnum/Test/CMakeLists.txt index 9492f8039..82f146533 100644 --- a/src/Magnum/Test/CMakeLists.txt +++ b/src/Magnum/Test/CMakeLists.txt @@ -33,7 +33,7 @@ corrade_add_test(DebugOutputTest DebugOutputTest.cpp LIBRARIES Magnum) corrade_add_test(DefaultFramebufferTest DefaultFramebufferTest.cpp LIBRARIES Magnum) corrade_add_test(FramebufferTest FramebufferTest.cpp LIBRARIES Magnum) corrade_add_test(ImageTest ImageTest.cpp LIBRARIES Magnum) -corrade_add_test(ImageReferenceTest ImageReferenceTest.cpp LIBRARIES Magnum) +corrade_add_test(ImageViewTest ImageViewTest.cpp LIBRARIES Magnum) corrade_add_test(MeshTest MeshTest.cpp LIBRARIES Magnum) corrade_add_test(RendererTest RendererTest.cpp LIBRARIES Magnum) corrade_add_test(ResourceManagerTest ResourceManagerTest.cpp LIBRARIES Magnum) diff --git a/src/Magnum/Test/CubeMapTextureArrayGLTest.cpp b/src/Magnum/Test/CubeMapTextureArrayGLTest.cpp index 7be43da79..c8a1fbae3 100644 --- a/src/Magnum/Test/CubeMapTextureArrayGLTest.cpp +++ b/src/Magnum/Test/CubeMapTextureArrayGLTest.cpp @@ -362,7 +362,7 @@ void CubeMapTextureArrayGLTest::image() { CubeMapTextureArray texture; texture.setImage(0, TextureFormat::RGBA8, - ImageReference3D(ColorFormat::RGBA, ColorType::UnsignedByte, {2, 2, 6}, Data)); + ImageView3D(ColorFormat::RGBA, ColorType::UnsignedByte, {2, 2, 6}, Data)); MAGNUM_VERIFY_NO_ERROR(); @@ -467,9 +467,9 @@ void CubeMapTextureArrayGLTest::subImage() { CubeMapTextureArray texture; texture.setImage(0, TextureFormat::RGBA8, - ImageReference3D(ColorFormat::RGBA, ColorType::UnsignedByte, {4, 4, 6}, Zero)); + ImageView3D(ColorFormat::RGBA, ColorType::UnsignedByte, {4, 4, 6}, Zero)); texture.setSubImage(0, Vector3i(1), - ImageReference3D(ColorFormat::RGBA, ColorType::UnsignedByte, {2, 2, 4}, SubData)); + ImageView3D(ColorFormat::RGBA, ColorType::UnsignedByte, {2, 2, 4}, SubData)); MAGNUM_VERIFY_NO_ERROR(); @@ -497,7 +497,7 @@ void CubeMapTextureArrayGLTest::subImageBuffer() { CubeMapTextureArray texture; texture.setImage(0, TextureFormat::RGBA8, - ImageReference3D(ColorFormat::RGBA, ColorType::UnsignedByte, {4, 4, 6}, Zero)); + ImageView3D(ColorFormat::RGBA, ColorType::UnsignedByte, {4, 4, 6}, Zero)); texture.setSubImage(0, Vector3i(1), BufferImage3D(ColorFormat::RGBA, ColorType::UnsignedByte, {2, 2, 4}, SubData, BufferUsage::StaticDraw)); @@ -524,7 +524,7 @@ void CubeMapTextureArrayGLTest::subImageQuery() { CubeMapTextureArray texture; texture.setStorage(1, TextureFormat::RGBA8, {4, 4, 6}) - .setSubImage(0, {}, ImageReference3D{ColorFormat::RGBA, ColorType::UnsignedByte, {4, 4, 6}, SubDataComplete}); + .setSubImage(0, {}, ImageView3D{ColorFormat::RGBA, ColorType::UnsignedByte, {4, 4, 6}, SubDataComplete}); MAGNUM_VERIFY_NO_ERROR(); @@ -546,7 +546,7 @@ void CubeMapTextureArrayGLTest::subImageQueryBuffer() { CubeMapTextureArray texture; texture.setStorage(1, TextureFormat::RGBA8, {4, 4, 6}) - .setSubImage(0, {}, ImageReference3D{ColorFormat::RGBA, ColorType::UnsignedByte, {4, 4, 6}, SubDataComplete}); + .setSubImage(0, {}, ImageView3D{ColorFormat::RGBA, ColorType::UnsignedByte, {4, 4, 6}, SubDataComplete}); MAGNUM_VERIFY_NO_ERROR(); @@ -573,7 +573,7 @@ void CubeMapTextureArrayGLTest::generateMipmap() { CubeMapTextureArray texture; texture.setImage(0, TextureFormat::RGBA8, - ImageReference3D(ColorFormat::RGBA, ColorType::UnsignedByte, {32, 32, 24})); + ImageView3D(ColorFormat::RGBA, ColorType::UnsignedByte, {32, 32, 24})); CORRADE_COMPARE(texture.imageSize(0), Vector3i(32, 32, 24)); CORRADE_COMPARE(texture.imageSize(1), Vector3i(0)); diff --git a/src/Magnum/Test/CubeMapTextureGLTest.cpp b/src/Magnum/Test/CubeMapTextureGLTest.cpp index a6dbcc452..b92bd3a6f 100644 --- a/src/Magnum/Test/CubeMapTextureGLTest.cpp +++ b/src/Magnum/Test/CubeMapTextureGLTest.cpp @@ -393,7 +393,7 @@ void CubeMapTextureGLTest::imageFull() { CubeMapTexture texture; texture.setStorage(1, TextureFormat::RGBA8, Vector2i{2, 2}) - .setSubImage(0, {}, ImageReference3D{ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i{2, 2, 6}, DataFull}); + .setSubImage(0, {}, ImageView3D{ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i{2, 2, 6}, DataFull}); MAGNUM_VERIFY_NO_ERROR(); @@ -437,7 +437,7 @@ namespace { void CubeMapTextureGLTest::image() { CubeMapTexture texture; texture.setImage(CubeMapTexture::Coordinate::PositiveX, 0, TextureFormat::RGBA8, - ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data)); + ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data)); MAGNUM_VERIFY_NO_ERROR(); @@ -488,9 +488,9 @@ namespace { void CubeMapTextureGLTest::subImage() { CubeMapTexture texture; texture.setImage(CubeMapTexture::Coordinate::PositiveX, 0, TextureFormat::RGBA8, - ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), Zero)); + ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), Zero)); texture.setSubImage(CubeMapTexture::Coordinate::PositiveX, 0, Vector2i(1), - ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data)); + ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data)); MAGNUM_VERIFY_NO_ERROR(); @@ -511,7 +511,7 @@ void CubeMapTextureGLTest::subImage() { void CubeMapTextureGLTest::subImageBuffer() { CubeMapTexture texture; texture.setImage(CubeMapTexture::Coordinate::PositiveX, 0, TextureFormat::RGBA8, - ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), Zero)); + ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), Zero)); texture.setSubImage(CubeMapTexture::Coordinate::PositiveX, 0, Vector2i(1), BufferImage2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data, BufferUsage::StaticDraw)); @@ -540,7 +540,7 @@ void CubeMapTextureGLTest::subImageQuery() { CubeMapTexture texture; texture.setStorage(1, TextureFormat::RGBA8, Vector2i{4}) - .setSubImage(0, {}, ImageReference3D{ColorFormat::RGBA, ColorType::UnsignedByte, {4, 4, 1}, SubDataComplete}); + .setSubImage(0, {}, ImageView3D{ColorFormat::RGBA, ColorType::UnsignedByte, {4, 4, 1}, SubDataComplete}); MAGNUM_VERIFY_NO_ERROR(); @@ -563,7 +563,7 @@ void CubeMapTextureGLTest::subImageQueryBuffer() { CubeMapTexture texture; texture.setStorage(1, TextureFormat::RGBA8, Vector2i{4}) - .setSubImage(0, {}, ImageReference3D{ColorFormat::RGBA, ColorType::UnsignedByte, {4, 4, 1}, SubDataComplete}); + .setSubImage(0, {}, ImageView3D{ColorFormat::RGBA, ColorType::UnsignedByte, {4, 4, 1}, SubDataComplete}); MAGNUM_VERIFY_NO_ERROR(); @@ -580,17 +580,17 @@ void CubeMapTextureGLTest::subImageQueryBuffer() { void CubeMapTextureGLTest::generateMipmap() { CubeMapTexture texture; texture.setImage(CubeMapTexture::Coordinate::PositiveX, 0, TextureFormat::RGBA8, - ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(32))); + ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(32))); texture.setImage(CubeMapTexture::Coordinate::PositiveY, 0, TextureFormat::RGBA8, - ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(32))); + ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(32))); texture.setImage(CubeMapTexture::Coordinate::PositiveZ, 0, TextureFormat::RGBA8, - ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(32))); + ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(32))); texture.setImage(CubeMapTexture::Coordinate::NegativeX, 0, TextureFormat::RGBA8, - ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(32))); + ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(32))); texture.setImage(CubeMapTexture::Coordinate::NegativeY, 0, TextureFormat::RGBA8, - ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(32))); + ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(32))); texture.setImage(CubeMapTexture::Coordinate::NegativeZ, 0, TextureFormat::RGBA8, - ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(32))); + ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(32))); /** @todo How to test this on ES? */ #ifndef MAGNUM_TARGET_GLES diff --git a/src/Magnum/Test/ImageTest.cpp b/src/Magnum/Test/ImageTest.cpp index c6c6e1aa1..56eab6fdb 100644 --- a/src/Magnum/Test/ImageTest.cpp +++ b/src/Magnum/Test/ImageTest.cpp @@ -108,20 +108,20 @@ void ImageTest::setData() { void ImageTest::toReference() { auto data = new char[3]; const Image2D a(ColorFormat::Red, ColorType::UnsignedByte, {1, 3}, data); - ImageReference2D b = a; + ImageView2D b = a; CORRADE_COMPARE(b.format(), ColorFormat::Red); CORRADE_COMPARE(b.type(), ColorType::UnsignedByte); CORRADE_COMPARE(b.size(), Vector2i(1, 3)); CORRADE_COMPARE(b.data(), data); - CORRADE_VERIFY((std::is_convertible::value)); + CORRADE_VERIFY((std::is_convertible::value)); { #ifdef CORRADE_GCC47_COMPATIBILITY CORRADE_EXPECT_FAIL("Rvalue references for *this are not supported in GCC < 4.8.1."); #endif - CORRADE_VERIFY(!(std::is_convertible::value)); - CORRADE_VERIFY(!(std::is_convertible::value)); + CORRADE_VERIFY(!(std::is_convertible::value)); + CORRADE_VERIFY(!(std::is_convertible::value)); } } diff --git a/src/Magnum/Test/ImageReferenceTest.cpp b/src/Magnum/Test/ImageViewTest.cpp similarity index 77% rename from src/Magnum/Test/ImageReferenceTest.cpp rename to src/Magnum/Test/ImageViewTest.cpp index 841617559..621e99e94 100644 --- a/src/Magnum/Test/ImageReferenceTest.cpp +++ b/src/Magnum/Test/ImageViewTest.cpp @@ -26,25 +26,25 @@ #include #include "Magnum/ColorFormat.h" -#include "Magnum/ImageReference.h" +#include "Magnum/ImageView.h" namespace Magnum { namespace Test { -struct ImageReferenceTest: TestSuite::Tester { - explicit ImageReferenceTest(); +struct ImageViewTest: TestSuite::Tester { + explicit ImageViewTest(); void construct(); void setData(); }; -ImageReferenceTest::ImageReferenceTest() { - addTests({&ImageReferenceTest::construct, - &ImageReferenceTest::setData}); +ImageViewTest::ImageViewTest() { + addTests({&ImageViewTest::construct, + &ImageViewTest::setData}); } -void ImageReferenceTest::construct() { +void ImageViewTest::construct() { const char data[3] = {}; - ImageReference2D a(ColorFormat::Red, ColorType::UnsignedByte, {1, 3}, data); + ImageView2D a(ColorFormat::Red, ColorType::UnsignedByte, {1, 3}, data); CORRADE_COMPARE(a.format(), ColorFormat::Red); CORRADE_COMPARE(a.type(), ColorType::UnsignedByte); @@ -52,9 +52,9 @@ void ImageReferenceTest::construct() { CORRADE_COMPARE(a.data(), data); } -void ImageReferenceTest::setData() { +void ImageViewTest::setData() { const char data[3] = {}; - ImageReference2D a(ColorFormat::Red, ColorType::UnsignedByte, {1, 3}, data); + ImageView2D a(ColorFormat::Red, ColorType::UnsignedByte, {1, 3}, data); const char data2[8] = {}; a.setData(data2); @@ -66,4 +66,4 @@ void ImageReferenceTest::setData() { }} -CORRADE_TEST_MAIN(Magnum::Test::ImageReferenceTest) +CORRADE_TEST_MAIN(Magnum::Test::ImageViewTest) diff --git a/src/Magnum/Test/RectangleTextureGLTest.cpp b/src/Magnum/Test/RectangleTextureGLTest.cpp index e215a012d..3d2c1e2f4 100644 --- a/src/Magnum/Test/RectangleTextureGLTest.cpp +++ b/src/Magnum/Test/RectangleTextureGLTest.cpp @@ -253,7 +253,7 @@ void RectangleTextureGLTest::image() { RectangleTexture texture; texture.setImage(TextureFormat::RGBA8, - ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data)); + ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data)); MAGNUM_VERIFY_NO_ERROR(); @@ -303,9 +303,9 @@ void RectangleTextureGLTest::subImage() { RectangleTexture texture; texture.setImage(TextureFormat::RGBA8, - ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), Zero)); + ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), Zero)); texture.setSubImage(Vector2i(1), - ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data)); + ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data)); MAGNUM_VERIFY_NO_ERROR(); @@ -325,7 +325,7 @@ void RectangleTextureGLTest::subImageBuffer() { RectangleTexture texture; texture.setImage(TextureFormat::RGBA8, - ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), Zero)); + ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), Zero)); texture.setSubImage(Vector2i(1), BufferImage2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data, BufferUsage::StaticDraw)); @@ -348,7 +348,7 @@ void RectangleTextureGLTest::subImageQuery() { RectangleTexture texture; texture.setStorage(TextureFormat::RGBA8, Vector2i{4}) - .setSubImage({}, ImageReference2D{ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i{4}, SubDataComplete}); + .setSubImage({}, ImageView2D{ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i{4}, SubDataComplete}); MAGNUM_VERIFY_NO_ERROR(); @@ -370,7 +370,7 @@ void RectangleTextureGLTest::subImageQueryBuffer() { RectangleTexture texture; texture.setStorage(TextureFormat::RGBA8, Vector2i{4}) - .setSubImage({}, ImageReference2D{ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i{4}, SubDataComplete}); + .setSubImage({}, ImageView2D{ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i{4}, SubDataComplete}); MAGNUM_VERIFY_NO_ERROR(); diff --git a/src/Magnum/Test/TextureArrayGLTest.cpp b/src/Magnum/Test/TextureArrayGLTest.cpp index b6df42004..4cfb788a1 100644 --- a/src/Magnum/Test/TextureArrayGLTest.cpp +++ b/src/Magnum/Test/TextureArrayGLTest.cpp @@ -651,7 +651,7 @@ void TextureArrayGLTest::image1D() { Texture1DArray texture; texture.setImage(0, TextureFormat::RGBA8, - ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data1D)); + ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data1D)); MAGNUM_VERIFY_NO_ERROR(); @@ -704,7 +704,7 @@ void TextureArrayGLTest::image2D() { Texture2DArray texture; texture.setImage(0, TextureFormat::RGBA8, - ImageReference3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(2), Data2D)); + ImageView3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(2), Data2D)); MAGNUM_VERIFY_NO_ERROR(); @@ -766,9 +766,9 @@ void TextureArrayGLTest::subImage1D() { Texture1DArray texture; texture.setImage(0, TextureFormat::RGBA8, - ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), Zero1D)); + ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), Zero1D)); texture.setSubImage(0, Vector2i(1), - ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), SubData1D)); + ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), SubData1D)); MAGNUM_VERIFY_NO_ERROR(); @@ -788,7 +788,7 @@ void TextureArrayGLTest::subImage1DBuffer() { Texture1DArray texture; texture.setImage(0, TextureFormat::RGBA8, - ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), Zero1D)); + ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), Zero1D)); texture.setSubImage(0, Vector2i(1), BufferImage2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), SubData1D, BufferUsage::StaticDraw)); @@ -811,7 +811,7 @@ void TextureArrayGLTest::subImage1DQuery() { Texture1DArray texture; texture.setStorage(1, TextureFormat::RGBA8, Vector2i{4}) - .setSubImage(0, {}, ImageReference2D{ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i{4}, SubData1DComplete}); + .setSubImage(0, {}, ImageView2D{ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i{4}, SubData1DComplete}); MAGNUM_VERIFY_NO_ERROR(); @@ -832,7 +832,7 @@ void TextureArrayGLTest::subImage1DQueryBuffer() { Texture1DArray texture; texture.setStorage(1, TextureFormat::RGBA8, Vector2i{4}) - .setSubImage(0, {}, ImageReference2D{ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i{4}, SubData1DComplete}); + .setSubImage(0, {}, ImageView2D{ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i{4}, SubData1DComplete}); MAGNUM_VERIFY_NO_ERROR(); @@ -887,9 +887,9 @@ void TextureArrayGLTest::subImage2D() { Texture2DArray texture; texture.setImage(0, TextureFormat::RGBA8, - ImageReference3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(4), Zero2D)); + ImageView3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(4), Zero2D)); texture.setSubImage(0, Vector3i(1), - ImageReference3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(2), SubData2D)); + ImageView3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(2), SubData2D)); MAGNUM_VERIFY_NO_ERROR(); @@ -913,7 +913,7 @@ void TextureArrayGLTest::subImage2DBuffer() { Texture2DArray texture; texture.setImage(0, TextureFormat::RGBA8, - ImageReference3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(4), Zero2D)); + ImageView3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(4), Zero2D)); texture.setSubImage(0, Vector3i(1), BufferImage3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(2), SubData2D, BufferUsage::StaticDraw)); @@ -940,7 +940,7 @@ void TextureArrayGLTest::subImage2DQuery() { Texture2DArray texture; texture.setStorage(1, TextureFormat::RGBA8, Vector3i{4}) - .setSubImage(0, {}, ImageReference3D{ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i{4}, SubData2DComplete}); + .setSubImage(0, {}, ImageView3D{ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i{4}, SubData2DComplete}); MAGNUM_VERIFY_NO_ERROR(); @@ -961,7 +961,7 @@ void TextureArrayGLTest::subImage2DQueryBuffer() { Texture2DArray texture; texture.setStorage(1, TextureFormat::RGBA8, Vector3i{4}) - .setSubImage(0, {}, ImageReference3D{ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i{4}, SubData2DComplete}); + .setSubImage(0, {}, ImageView3D{ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i{4}, SubData2DComplete}); MAGNUM_VERIFY_NO_ERROR(); @@ -982,7 +982,7 @@ void TextureArrayGLTest::generateMipmap1D() { Texture1DArray texture; texture.setImage(0, TextureFormat::RGBA8, - ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(32))); + ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(32))); CORRADE_COMPARE(texture.imageSize(0), Vector2i(32)); CORRADE_COMPARE(texture.imageSize(1), Vector2i( 0)); @@ -1012,7 +1012,7 @@ void TextureArrayGLTest::generateMipmap2D() { Texture2DArray texture; texture.setImage(0, TextureFormat::RGBA8, - ImageReference3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(32))); + ImageView3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(32))); /** @todo How to test this on ES? */ #ifndef MAGNUM_TARGET_GLES diff --git a/src/Magnum/Test/TextureGLTest.cpp b/src/Magnum/Test/TextureGLTest.cpp index b39c08ee9..82d64a9b1 100644 --- a/src/Magnum/Test/TextureGLTest.cpp +++ b/src/Magnum/Test/TextureGLTest.cpp @@ -883,7 +883,7 @@ namespace { void TextureGLTest::image1D() { Texture1D texture; texture.setImage(0, TextureFormat::RGBA8, - ImageReference1D(ColorFormat::RGBA, ColorType::UnsignedByte, 2, Data1D)); + ImageView1D(ColorFormat::RGBA, ColorType::UnsignedByte, 2, Data1D)); MAGNUM_VERIFY_NO_ERROR(); @@ -924,7 +924,7 @@ namespace { void TextureGLTest::image2D() { Texture2D texture; texture.setImage(0, TextureFormat::RGBA8, - ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data2D)); + ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data2D)); MAGNUM_VERIFY_NO_ERROR(); @@ -981,7 +981,7 @@ void TextureGLTest::image3D() { Texture3D texture; texture.setImage(0, TextureFormat::RGBA8, - ImageReference3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(2), Data3D)); + ImageView3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(2), Data3D)); MAGNUM_VERIFY_NO_ERROR(); @@ -1030,9 +1030,9 @@ namespace { void TextureGLTest::subImage1D() { Texture1D texture; texture.setImage(0, TextureFormat::RGBA8, - ImageReference1D(ColorFormat::RGBA, ColorType::UnsignedByte, 4, Zero1D)); + ImageView1D(ColorFormat::RGBA, ColorType::UnsignedByte, 4, Zero1D)); texture.setSubImage(0, 1, - ImageReference1D(ColorFormat::RGBA, ColorType::UnsignedByte, 2, Data1D)); + ImageView1D(ColorFormat::RGBA, ColorType::UnsignedByte, 2, Data1D)); MAGNUM_VERIFY_NO_ERROR(); @@ -1049,7 +1049,7 @@ void TextureGLTest::subImage1D() { void TextureGLTest::subImage1DBuffer() { Texture1D texture; texture.setImage(0, TextureFormat::RGBA8, - ImageReference1D(ColorFormat::RGBA, ColorType::UnsignedByte, 4, Zero1D)); + ImageView1D(ColorFormat::RGBA, ColorType::UnsignedByte, 4, Zero1D)); texture.setSubImage(0, 1, BufferImage1D(ColorFormat::RGBA, ColorType::UnsignedByte, 2, Data1D, BufferUsage::StaticDraw)); @@ -1070,7 +1070,7 @@ void TextureGLTest::subImage1DQuery() { Texture1D texture; texture.setStorage(1, TextureFormat::RGBA8, 4) - .setSubImage(0, {}, ImageReference1D{ColorFormat::RGBA, ColorType::UnsignedByte, 4, SubData1DComplete}); + .setSubImage(0, {}, ImageView1D{ColorFormat::RGBA, ColorType::UnsignedByte, 4, SubData1DComplete}); MAGNUM_VERIFY_NO_ERROR(); @@ -1089,7 +1089,7 @@ void TextureGLTest::subImage1DQueryBuffer() { Texture1D texture; texture.setStorage(1, TextureFormat::RGBA8, 4) - .setSubImage(0, {}, ImageReference1D{ColorFormat::RGBA, ColorType::UnsignedByte, 4, SubData1DComplete}); + .setSubImage(0, {}, ImageView1D{ColorFormat::RGBA, ColorType::UnsignedByte, 4, SubData1DComplete}); MAGNUM_VERIFY_NO_ERROR(); @@ -1116,9 +1116,9 @@ namespace { void TextureGLTest::subImage2D() { Texture2D texture; texture.setImage(0, TextureFormat::RGBA8, - ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), Zero2D)); + ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), Zero2D)); texture.setSubImage(0, Vector2i(1), - ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data2D)); + ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data2D)); MAGNUM_VERIFY_NO_ERROR(); @@ -1139,7 +1139,7 @@ void TextureGLTest::subImage2D() { void TextureGLTest::subImage2DBuffer() { Texture2D texture; texture.setImage(0, TextureFormat::RGBA8, - ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), Zero2D)); + ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), Zero2D)); texture.setSubImage(0, Vector2i(1), BufferImage2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data2D, BufferUsage::StaticDraw)); @@ -1165,7 +1165,7 @@ void TextureGLTest::subImage2DQuery() { Texture2D texture; texture.setStorage(1, TextureFormat::RGBA8, Vector2i{4}) - .setSubImage(0, {}, ImageReference2D{ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i{4}, SubData2DComplete}); + .setSubImage(0, {}, ImageView2D{ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i{4}, SubData2DComplete}); MAGNUM_VERIFY_NO_ERROR(); @@ -1184,7 +1184,7 @@ void TextureGLTest::subImage2DQueryBuffer() { Texture2D texture; texture.setStorage(1, TextureFormat::RGBA8, Vector2i{4}) - .setSubImage(0, {}, ImageReference2D{ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i{4}, SubData2DComplete}); + .setSubImage(0, {}, ImageView2D{ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i{4}, SubData2DComplete}); MAGNUM_VERIFY_NO_ERROR(); @@ -1231,9 +1231,9 @@ void TextureGLTest::subImage3D() { Texture3D texture; texture.setImage(0, TextureFormat::RGBA8, - ImageReference3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(4), Zero3D)); + ImageView3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(4), Zero3D)); texture.setSubImage(0, Vector3i(1), - ImageReference3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(2), Data3D)); + ImageView3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(2), Data3D)); MAGNUM_VERIFY_NO_ERROR(); @@ -1254,7 +1254,7 @@ void TextureGLTest::subImage3D() { void TextureGLTest::subImage3DBuffer() { Texture3D texture; texture.setImage(0, TextureFormat::RGBA8, - ImageReference3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(4), Zero3D)); + ImageView3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(4), Zero3D)); texture.setSubImage(0, Vector3i(1), BufferImage3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(2), Data3D, BufferUsage::StaticDraw)); @@ -1280,7 +1280,7 @@ void TextureGLTest::subImage3DQuery() { Texture3D texture; texture.setStorage(1, TextureFormat::RGBA8, Vector3i{4}) - .setSubImage(0, {}, ImageReference3D{ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i{4}, SubData3DComplete}); + .setSubImage(0, {}, ImageView3D{ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i{4}, SubData3DComplete}); MAGNUM_VERIFY_NO_ERROR(); @@ -1299,7 +1299,7 @@ void TextureGLTest::subImage3DQueryBuffer() { Texture3D texture; texture.setStorage(1, TextureFormat::RGBA8, Vector3i{4}) - .setSubImage(0, {}, ImageReference3D{ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i{4}, SubData3DComplete}); + .setSubImage(0, {}, ImageView3D{ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i{4}, SubData3DComplete}); MAGNUM_VERIFY_NO_ERROR(); @@ -1318,7 +1318,7 @@ void TextureGLTest::generateMipmap1D() { Texture1D texture; texture.setImage(0, TextureFormat::RGBA8, - ImageReference1D(ColorFormat::RGBA, ColorType::UnsignedByte, 32)); + ImageView1D(ColorFormat::RGBA, ColorType::UnsignedByte, 32)); CORRADE_COMPARE(texture.imageSize(0), 32); CORRADE_COMPARE(texture.imageSize(1), 0); @@ -1346,7 +1346,7 @@ void TextureGLTest::generateMipmap2D() { Texture2D texture; texture.setImage(0, TextureFormat::RGBA8, - ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(32))); + ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(32))); /** @todo How to test this on ES? */ #ifndef MAGNUM_TARGET_GLES @@ -1382,7 +1382,7 @@ void TextureGLTest::generateMipmap3D() { Texture3D texture; texture.setImage(0, TextureFormat::RGBA8, - ImageReference3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(32))); + ImageView3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(32))); /** @todo How to test this on ES? */ #ifndef MAGNUM_TARGET_GLES diff --git a/src/Magnum/Text/DistanceFieldGlyphCache.cpp b/src/Magnum/Text/DistanceFieldGlyphCache.cpp index 47ab788af..f780ea656 100644 --- a/src/Magnum/Text/DistanceFieldGlyphCache.cpp +++ b/src/Magnum/Text/DistanceFieldGlyphCache.cpp @@ -30,7 +30,7 @@ #endif #include "Magnum/Context.h" #include "Magnum/Extensions.h" -#include "Magnum/ImageReference.h" +#include "Magnum/ImageView.h" #include "Magnum/TextureFormat.h" #include "Magnum/TextureTools/DistanceField.h" @@ -59,7 +59,7 @@ DistanceFieldGlyphCache::DistanceFieldGlyphCache(const Vector2i& originalSize, c #endif } -void DistanceFieldGlyphCache::setImage(const Vector2i& offset, const ImageReference2D& image) { +void DistanceFieldGlyphCache::setImage(const Vector2i& offset, const ImageView2D& image) { #if !(defined(MAGNUM_TARGET_GLES) && defined(MAGNUM_TARGET_GLES2)) const TextureFormat internalFormat = TextureFormat::R8; CORRADE_ASSERT(image.format() == ColorFormat::Red, @@ -90,7 +90,7 @@ void DistanceFieldGlyphCache::setImage(const Vector2i& offset, const ImageRefere TextureTools::distanceField(input, texture(), Range2Di::fromSize(offset*scale, image.size()*scale), radius, image.size()); } -void DistanceFieldGlyphCache::setDistanceFieldImage(const Vector2i& offset, const ImageReference2D& image) { +void DistanceFieldGlyphCache::setDistanceFieldImage(const Vector2i& offset, const ImageView2D& image) { #if !(defined(MAGNUM_TARGET_GLES) && defined(MAGNUM_TARGET_GLES2)) CORRADE_ASSERT(image.format() == ColorFormat::Red, "Text::DistanceFieldGlyphCache::setDistanceFieldImage(): expected" << ColorFormat::Red << "but got" << image.format(), ); diff --git a/src/Magnum/Text/DistanceFieldGlyphCache.h b/src/Magnum/Text/DistanceFieldGlyphCache.h index cefc3d6fb..580bc77d5 100644 --- a/src/Magnum/Text/DistanceFieldGlyphCache.h +++ b/src/Magnum/Text/DistanceFieldGlyphCache.h @@ -79,7 +79,7 @@ class MAGNUM_TEXT_EXPORT DistanceFieldGlyphCache: public GlyphCache { * Uploads image for one or more glyphs to given offset in original * cache texture. The texture is then converted to distance field. */ - void setImage(const Vector2i& offset, const ImageReference2D& image) override; + void setImage(const Vector2i& offset, const ImageView2D& image) override; /** * @brief Set distance field cache image @@ -87,7 +87,7 @@ class MAGNUM_TEXT_EXPORT DistanceFieldGlyphCache: public GlyphCache { * Uploads already computed distance field image to given offset in * distance field texture. */ - void setDistanceFieldImage(const Vector2i& offset, const ImageReference2D& image); + void setDistanceFieldImage(const Vector2i& offset, const ImageView2D& image); private: const Vector2 scale; diff --git a/src/Magnum/Text/GlyphCache.cpp b/src/Magnum/Text/GlyphCache.cpp index 9c9788baa..5ef9a4fcd 100644 --- a/src/Magnum/Text/GlyphCache.cpp +++ b/src/Magnum/Text/GlyphCache.cpp @@ -92,7 +92,7 @@ void GlyphCache::insert(const UnsignedInt glyph, const Vector2i& position, const else CORRADE_INTERNAL_ASSERT_OUTPUT(glyphs.insert({glyph, glyphData}).second); } -void GlyphCache::setImage(const Vector2i& offset, const ImageReference2D& image) { +void GlyphCache::setImage(const Vector2i& offset, const ImageView2D& image) { /** @todo some internalformat/format checking also here (if querying internal format is not slow) */ _texture.setSubImage(0, offset, image); } diff --git a/src/Magnum/Text/GlyphCache.h b/src/Magnum/Text/GlyphCache.h index 9472d8a87..08848d83e 100644 --- a/src/Magnum/Text/GlyphCache.h +++ b/src/Magnum/Text/GlyphCache.h @@ -185,7 +185,7 @@ class MAGNUM_TEXT_EXPORT GlyphCache { * Uploads image for one or more glyphs to given offset in cache * texture. */ - virtual void setImage(const Vector2i& offset, const ImageReference2D& image); + virtual void setImage(const Vector2i& offset, const ImageView2D& image); private: void MAGNUM_LOCAL initialize(TextureFormat internalFormat, const Vector2i& size); diff --git a/src/Magnum/Texture.h b/src/Magnum/Texture.h index 1f5c00c11..e05536faa 100644 --- a/src/Magnum/Texture.h +++ b/src/Magnum/Texture.h @@ -754,7 +754,7 @@ template class Texture: public AbstractTexture { * @brief Set image data * @param level Mip level * @param internalFormat Internal format - * @param image @ref Image, @ref ImageReference or + * @param image @ref Image, @ref ImageView or * @ref Trade::ImageData of the same dimension count * @return Reference to self (for method chaining) * @@ -768,7 +768,7 @@ template class Texture: public AbstractTexture { * @deprecated_gl Prefer to use @ref setStorage() and @ref setSubImage() * instead. */ - Texture& setImage(Int level, TextureFormat internalFormat, const ImageReference& image) { + Texture& setImage(Int level, TextureFormat internalFormat, const ImageView& image) { DataHelper::setImage(*this, level, internalFormat, image); return *this; } @@ -804,7 +804,7 @@ template class Texture: public AbstractTexture { * @brief Set image subdata * @param level Mip level * @param offset Offset where to put data in the texture - * @param image @ref Image, @ref ImageReference or + * @param image @ref Image, @ref ImageView or * @ref Trade::ImageData of the same dimension count * @return Reference to self (for method chaining) * @@ -825,7 +825,7 @@ template class Texture: public AbstractTexture { * able to use @ref setStorage() as it uses implicit @ref ColorType * value. */ - Texture& setSubImage(Int level, const VectorTypeFor& offset, const ImageReference& image) { + Texture& setSubImage(Int level, const VectorTypeFor& offset, const ImageView& image) { DataHelper::setSubImage(*this, level, offset, image); return *this; } diff --git a/src/Magnum/TextureArray.h b/src/Magnum/TextureArray.h index 7c626505c..74ac5af2b 100644 --- a/src/Magnum/TextureArray.h +++ b/src/Magnum/TextureArray.h @@ -490,7 +490,7 @@ template class TextureArray: public AbstractTexture { * @deprecated_gl Prefer to use @ref setStorage() and @ref setSubImage() * instead. */ - TextureArray& setImage(Int level, TextureFormat internalFormat, const ImageReference& image) { + TextureArray& setImage(Int level, TextureFormat internalFormat, const ImageView& image) { DataHelper::setImage(*this, level, internalFormat, image); return *this; } @@ -516,7 +516,7 @@ template class TextureArray: public AbstractTexture { * @brief Set image subdata * @param level Mip level * @param offset Offset where to put data in the texture - * @param image @ref Image, @ref ImageReference or + * @param image @ref Image, @ref ImageView or * @ref Trade::ImageData of the same dimension count * @return Reference to self (for method chaining) * @@ -531,7 +531,7 @@ template class TextureArray: public AbstractTexture { * eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and * @fn_gl{TexSubImage2D}/@fn_gl{TexSubImage3D} */ - TextureArray& setSubImage(Int level, const VectorTypeFor& offset, const ImageReference& image) { + TextureArray& setSubImage(Int level, const VectorTypeFor& offset, const ImageView& image) { DataHelper::setSubImage(*this, level, offset, image); return *this; } diff --git a/src/Magnum/Trade/AbstractImageConverter.cpp b/src/Magnum/Trade/AbstractImageConverter.cpp index 1c5539ea8..1a0899b8f 100644 --- a/src/Magnum/Trade/AbstractImageConverter.cpp +++ b/src/Magnum/Trade/AbstractImageConverter.cpp @@ -37,35 +37,35 @@ AbstractImageConverter::AbstractImageConverter() = default; AbstractImageConverter::AbstractImageConverter(PluginManager::AbstractManager& manager, std::string plugin): AbstractPlugin(manager, std::move(plugin)) {} -std::optional AbstractImageConverter::exportToImage(const ImageReference2D& image) const { +std::optional AbstractImageConverter::exportToImage(const ImageView2D& image) const { CORRADE_ASSERT(features() & Feature::ConvertImage, "Trade::AbstractImageConverter::exportToImage(): feature not supported", {}); return doExportToImage(image); } -std::optional AbstractImageConverter::doExportToImage(const ImageReference2D&) const { +std::optional AbstractImageConverter::doExportToImage(const ImageView2D&) const { CORRADE_ASSERT(false, "Trade::AbstractImageConverter::exportToImage(): feature advertised but not implemented", {}); return std::nullopt; } -Containers::Array AbstractImageConverter::exportToData(const ImageReference2D& image) const { +Containers::Array AbstractImageConverter::exportToData(const ImageView2D& image) const { CORRADE_ASSERT(features() & Feature::ConvertData, "Trade::AbstractImageConverter::exportToData(): feature not supported", nullptr); return doExportToData(image); } -Containers::Array AbstractImageConverter::doExportToData(const ImageReference2D&) const { +Containers::Array AbstractImageConverter::doExportToData(const ImageView2D&) const { CORRADE_ASSERT(false, "Trade::AbstractImageConverter::exportToData(): feature advertised but not implemented", nullptr); return nullptr; } -bool AbstractImageConverter::exportToFile(const ImageReference2D& image, const std::string& filename) const { +bool AbstractImageConverter::exportToFile(const ImageView2D& image, const std::string& filename) const { return doExportToFile(image, filename); } -bool AbstractImageConverter::doExportToFile(const ImageReference2D& image, const std::string& filename) const { +bool AbstractImageConverter::doExportToFile(const ImageView2D& image, const std::string& filename) const { CORRADE_ASSERT(features() & Feature::ConvertData, "Trade::AbstractImageConverter::exportToFile(): not implemented", false); const auto data = doExportToData(image); diff --git a/src/Magnum/Trade/AbstractImageConverter.h b/src/Magnum/Trade/AbstractImageConverter.h index e92567e5d..d5b42a06d 100644 --- a/src/Magnum/Trade/AbstractImageConverter.h +++ b/src/Magnum/Trade/AbstractImageConverter.h @@ -98,7 +98,7 @@ class MAGNUM_EXPORT AbstractImageConverter: public PluginManager::AbstractPlugin * converted image on success, `std::nullopt` otherwise. * @see @ref features(), @ref exportToData(), @ref exportToFile() */ - std::optional exportToImage(const ImageReference2D& image) const; + std::optional exportToImage(const ImageView2D& image) const; /** * @brief Export image to raw data @@ -107,7 +107,7 @@ class MAGNUM_EXPORT AbstractImageConverter: public PluginManager::AbstractPlugin * data on success, zero-sized array otherwise. * @see @ref features(), @ref exportToImage(), @ref exportToFile() */ - Containers::Array exportToData(const ImageReference2D& image) const; + Containers::Array exportToData(const ImageView2D& image) const; /** * @brief Export image to file @@ -115,7 +115,7 @@ class MAGNUM_EXPORT AbstractImageConverter: public PluginManager::AbstractPlugin * Returns `true` on success, `false` otherwise. * @see @ref features(), @ref exportToImage(), @ref exportToData() */ - bool exportToFile(const ImageReference2D& image, const std::string& filename) const; + bool exportToFile(const ImageView2D& image, const std::string& filename) const; #ifndef DOXYGEN_GENERATING_OUTPUT private: @@ -126,10 +126,10 @@ class MAGNUM_EXPORT AbstractImageConverter: public PluginManager::AbstractPlugin virtual Features doFeatures() const = 0; /** @brief Implementation of @ref exportToImage() */ - virtual std::optional doExportToImage(const ImageReference2D& image) const; + virtual std::optional doExportToImage(const ImageView2D& image) const; /** @brief Implementation of @ref exportToData() */ - virtual Containers::Array doExportToData(const ImageReference2D& image) const; + virtual Containers::Array doExportToData(const ImageView2D& image) const; /** * @brief Implementation of @ref exportToFile() @@ -137,7 +137,7 @@ class MAGNUM_EXPORT AbstractImageConverter: public PluginManager::AbstractPlugin * If @ref Feature::ConvertData is supported, default implementation * calls @ref doExportToData() and saves the result to given file. */ - virtual bool doExportToFile(const ImageReference2D& image, const std::string& filename) const; + virtual bool doExportToFile(const ImageView2D& image, const std::string& filename) const; }; CORRADE_ENUMSET_OPERATORS(AbstractImageConverter::Features) diff --git a/src/Magnum/Trade/ImageData.h b/src/Magnum/Trade/ImageData.h index f09848d47..26be30561 100644 --- a/src/Magnum/Trade/ImageData.h +++ b/src/Magnum/Trade/ImageData.h @@ -29,7 +29,7 @@ * @brief Class @ref Magnum::Trade::ImageData, typedef @ref Magnum::Trade::ImageData1D, @ref Magnum::Trade::ImageData2D, @ref Magnum::Trade::ImageData3D */ -#include "Magnum/ImageReference.h" +#include "Magnum/ImageView.h" namespace Magnum { namespace Trade { @@ -37,7 +37,7 @@ namespace Magnum { namespace Trade { @brief Image data Access to image data provided by @ref AbstractImporter subclasses. -Interchangeable with @ref Image, @ref ImageReference or @ref BufferImage. +Interchangeable with @ref Image, @ref ImageView or @ref BufferImage. @see @ref ImageData1D, @ref ImageData2D, @ref ImageData3D */ template class ImageData: public AbstractImage { @@ -73,8 +73,8 @@ template class ImageData: public AbstractImage { /** @brief Destructor */ ~ImageData() { delete[] _data; } - /** @brief Conversion to reference */ - /*implicit*/ operator ImageReference() + /** @brief Conversion to view */ + /*implicit*/ operator ImageView() #ifndef CORRADE_GCC47_COMPATIBILITY const &; #else @@ -83,7 +83,7 @@ template class ImageData: public AbstractImage { #ifndef CORRADE_GCC47_COMPATIBILITY /** @overload */ - /*implicit*/ operator ImageReference() const && = delete; + /*implicit*/ operator ImageView() const && = delete; #endif /** @brief Format of pixel data */ @@ -157,14 +157,14 @@ template inline ImageData& ImageData inline ImageData::operator ImageReference() +template inline ImageData::operator ImageView() #ifndef CORRADE_GCC47_COMPATIBILITY const & #else const #endif { - return ImageReference(_format, _type, _size, _data); + return ImageView(_format, _type, _size, _data); } template inline char* ImageData::release() { diff --git a/src/Magnum/Trade/Test/AbstractImageConverterTest.cpp b/src/Magnum/Trade/Test/AbstractImageConverterTest.cpp index 45d6f40dc..6d2428bdd 100644 --- a/src/Magnum/Trade/Test/AbstractImageConverterTest.cpp +++ b/src/Magnum/Trade/Test/AbstractImageConverterTest.cpp @@ -29,7 +29,7 @@ #include #include "Magnum/ColorFormat.h" -#include "Magnum/ImageReference.h" +#include "Magnum/ImageView.h" #include "Magnum/Trade/AbstractImageConverter.h" #include "configure.h" @@ -52,7 +52,7 @@ void AbstractImageConverterTest::exportToFile() { private: Features doFeatures() const override { return Feature::ConvertData; } - Containers::Array doExportToData(const ImageReference2D& image) const override { + Containers::Array doExportToData(const ImageView2D& image) const override { return Containers::Array::from(char(image.size().x()), char(image.size().y())); }; }; @@ -62,7 +62,7 @@ void AbstractImageConverterTest::exportToFile() { /* doExportToFile() should call doExportToData() */ DataExporter exporter; - ImageReference2D image(ColorFormat::RGBA, ColorType::UnsignedByte, {0xfe, 0xed}, nullptr); + ImageView2D image(ColorFormat::RGBA, ColorType::UnsignedByte, {0xfe, 0xed}, nullptr); CORRADE_VERIFY(exporter.exportToFile(image, Utility::Directory::join(TRADE_TEST_OUTPUT_DIR, "image.out"))); CORRADE_COMPARE_AS(Utility::Directory::join(TRADE_TEST_OUTPUT_DIR, "image.out"), "\xFE\xED", TestSuite::Compare::FileToString); diff --git a/src/Magnum/Trade/Test/ImageDataTest.cpp b/src/Magnum/Trade/Test/ImageDataTest.cpp index 6d0f1a02c..ffc1a446d 100644 --- a/src/Magnum/Trade/Test/ImageDataTest.cpp +++ b/src/Magnum/Trade/Test/ImageDataTest.cpp @@ -95,20 +95,20 @@ void ImageDataTest::constructMove() { void ImageDataTest::toReference() { auto data = new char[3]; const Trade::ImageData2D a(ColorFormat::Red, ColorType::UnsignedByte, {1, 3}, data); - ImageReference2D b = a; + ImageView2D b = a; CORRADE_COMPARE(b.format(), ColorFormat::Red); CORRADE_COMPARE(b.type(), ColorType::UnsignedByte); CORRADE_COMPARE(b.size(), Vector2i(1, 3)); CORRADE_COMPARE(b.data(), data); - CORRADE_VERIFY((std::is_convertible::value)); + CORRADE_VERIFY((std::is_convertible::value)); { #ifdef CORRADE_GCC47_COMPATIBILITY CORRADE_EXPECT_FAIL("Rvalue references for *this are not supported in GCC < 4.8.1."); #endif - CORRADE_VERIFY(!(std::is_convertible::value)); - CORRADE_VERIFY(!(std::is_convertible::value)); + CORRADE_VERIFY(!(std::is_convertible::value)); + CORRADE_VERIFY(!(std::is_convertible::value)); } } diff --git a/src/MagnumPlugins/TgaImageConverter/Test/TgaImageConverterTest.cpp b/src/MagnumPlugins/TgaImageConverter/Test/TgaImageConverterTest.cpp index f97e2eb87..03bc46262 100644 --- a/src/MagnumPlugins/TgaImageConverter/Test/TgaImageConverterTest.cpp +++ b/src/MagnumPlugins/TgaImageConverter/Test/TgaImageConverterTest.cpp @@ -56,7 +56,7 @@ namespace { 5, 6, 7, 6, 7, 8 }; - const ImageReference2D original(ColorFormat::RGB, ColorType::UnsignedByte, {2, 3}, originalData); + const ImageView2D original(ColorFormat::RGB, ColorType::UnsignedByte, {2, 3}, originalData); } TgaImageConverterTest::TgaImageConverterTest() { @@ -67,7 +67,7 @@ TgaImageConverterTest::TgaImageConverterTest() { } void TgaImageConverterTest::wrongFormat() { - ImageReference2D image(ColorFormat::RG, ColorType::UnsignedByte, {}, nullptr); + ImageView2D image(ColorFormat::RG, ColorType::UnsignedByte, {}, nullptr); std::ostringstream out; Error::setOutput(&out); @@ -78,7 +78,7 @@ void TgaImageConverterTest::wrongFormat() { } void TgaImageConverterTest::wrongType() { - ImageReference2D image(ColorFormat::Red, ColorType::Float, {}, nullptr); + ImageView2D image(ColorFormat::Red, ColorType::Float, {}, nullptr); std::ostringstream out; Error::setOutput(&out); diff --git a/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.cpp b/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.cpp index 43b06a92e..46746b758 100644 --- a/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.cpp +++ b/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.cpp @@ -45,7 +45,7 @@ TgaImageConverter::TgaImageConverter(PluginManager::AbstractManager& manager, st auto TgaImageConverter::doFeatures() const -> Features { return Feature::ConvertData; } -Containers::Array TgaImageConverter::doExportToData(const ImageReference2D& image) const { +Containers::Array TgaImageConverter::doExportToData(const ImageView2D& image) const { if(image.format() != ColorFormat::RGB && image.format() != ColorFormat::RGBA #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) diff --git a/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.h b/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.h index a83ade087..d674660e8 100644 --- a/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.h +++ b/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.h @@ -73,7 +73,7 @@ class MAGNUM_TGAIMAGECONVERTER_EXPORT TgaImageConverter: public AbstractImageCon private: Features MAGNUM_TGAIMAGECONVERTER_LOCAL doFeatures() const override; - Containers::Array MAGNUM_TGAIMAGECONVERTER_LOCAL doExportToData(const ImageReference2D& image) const override; + Containers::Array MAGNUM_TGAIMAGECONVERTER_LOCAL doExportToData(const ImageView2D& image) const override; }; }}