diff --git a/src/Magnum/GL/BufferImage.h b/src/Magnum/GL/BufferImage.h index 992c4d4b9..6bef0b395 100644 --- a/src/Magnum/GL/BufferImage.h +++ b/src/Magnum/GL/BufferImage.h @@ -272,32 +272,6 @@ template class BufferImage { /** @brief Move assignment */ BufferImage& operator=(BufferImage&& other) noexcept; - /** @brief Storage of pixel data */ - PixelStorage storage() const { return _storage; } - - /** @brief Format of pixel data */ - PixelFormat format() const { return _format; } - - /** @brief Data type of pixel data */ - PixelType type() const { return _type; } - - /** - * @brief Size of a pixel in bytes - * - * @see @ref Magnum::pixelFormatSize(), @ref GL::pixelFormatSize() - */ - UnsignedInt pixelSize() const { return _pixelSize; } - - /** @brief Image size in pixels */ - VectorTypeFor size() const { return _size; } - - /** - * @brief Image data properties - * - * See @ref PixelStorage::dataProperties() for more information. - */ - std::pair, VectorTypeFor> dataProperties() const; - /** @brief Currently allocated data size */ std::size_t dataSize() const { return _dataSize; } @@ -359,6 +333,32 @@ template class BufferImage { setData({}, format, size, data, usage); } + /** @brief Storage of pixel data */ + PixelStorage storage() const { return _storage; } + + /** @brief Format of pixel data */ + PixelFormat format() const { return _format; } + + /** @brief Data type of pixel data */ + PixelType type() const { return _type; } + + /** + * @brief Size of a pixel in bytes + * + * @see @ref Magnum::pixelFormatSize(), @ref GL::pixelFormatSize() + */ + UnsignedInt pixelSize() const { return _pixelSize; } + + /** @brief Image size in pixels */ + VectorTypeFor size() const { return _size; } + + /** + * @brief Image data properties + * + * See @ref PixelStorage::dataProperties() for more information. + */ + std::pair, VectorTypeFor> dataProperties() const; + /** * @brief Release the image buffer * @@ -618,46 +618,6 @@ template class CompressedBufferImage { /** @brief Move assignment */ CompressedBufferImage& operator=(CompressedBufferImage&& other) noexcept; - /** @brief Storage of compressed pixel data */ - CompressedPixelStorage storage() const { return _storage; } - - /** @brief Format of compressed pixel data */ - CompressedPixelFormat format() const { return _format; } - - /** - * @brief Size of a compressed block in pixels - * @m_since_latest - * - * Note that the blocks can be 3D even for 2D images and 2D or 3D even - * for 1D images, in which case only the first slice in the extra - * dimensions is used. - * @see @ref blockDataSize(), @ref compressedPixelFormatBlockSize() - */ - Vector3i blockSize() const { return Vector3i{_blockSize}; } - - /** - * @brief Size of a compressed block in bytes - * @m_since_latest - * - * @see @ref blockSize(), @ref compressedPixelFormatBlockDataSize() - */ - UnsignedInt blockDataSize() const { return _blockDataSize; } - - /** @brief Image size */ - VectorTypeFor size() const { return _size; } - - /** - * @brief Compressed image data properties - * - * See @ref CompressedPixelStorage::dataProperties() for more - * information. - * @requires_gl42 Extension @gl_extension{ARB,compressed_texture_pixel_storage} - * for non-default @ref CompressedPixelStorage - * @requires_gl Non-default @ref CompressedPixelStorage is not - * available in OpenGL ES and WebGL. - */ - std::pair, VectorTypeFor> dataProperties() const; - /** * @brief Image buffer * @@ -729,6 +689,46 @@ template class CompressedBufferImage { setData({}, format, size, data, usage); } + /** @brief Storage of compressed pixel data */ + CompressedPixelStorage storage() const { return _storage; } + + /** @brief Format of compressed pixel data */ + CompressedPixelFormat format() const { return _format; } + + /** + * @brief Size of a compressed block in pixels + * @m_since_latest + * + * Note that the blocks can be 3D even for 2D images and 2D or 3D even + * for 1D images, in which case only the first slice in the extra + * dimensions is used. + * @see @ref blockDataSize(), @ref compressedPixelFormatBlockSize() + */ + Vector3i blockSize() const { return Vector3i{_blockSize}; } + + /** + * @brief Size of a compressed block in bytes + * @m_since_latest + * + * @see @ref blockSize(), @ref compressedPixelFormatBlockDataSize() + */ + UnsignedInt blockDataSize() const { return _blockDataSize; } + + /** @brief Image size */ + VectorTypeFor size() const { return _size; } + + /** + * @brief Compressed image data properties + * + * See @ref CompressedPixelStorage::dataProperties() for more + * information. + * @requires_gl42 Extension @gl_extension{ARB,compressed_texture_pixel_storage} + * for non-default @ref CompressedPixelStorage + * @requires_gl Non-default @ref CompressedPixelStorage is not + * available in OpenGL ES and WebGL. + */ + std::pair, VectorTypeFor> dataProperties() const; + /** * @brief Release the image buffer * diff --git a/src/Magnum/Image.h b/src/Magnum/Image.h index f43742786..d9dcfc39d 100644 --- a/src/Magnum/Image.h +++ b/src/Magnum/Image.h @@ -391,6 +391,33 @@ template class Image { */ ImageFlags flags() const { return _flags; } + /** + * @brief Raw image data + * + * @see @ref release(), @ref pixels() + */ + Containers::ArrayView data() & { return _data; } + + /** @overload */ + Containers::ArrayView data() const & { return _data; } + + /** + * @brief Raw image data from a r-value + * @m_since{2019,10} + * + * Unlike @ref data(), which returns a view, this is equivalent to + * @ref release() to avoid a dangling view when the temporary instance + * goes out of scope. + * @todoc stupid doxygen can't link to & overloads ffs + */ + Containers::Array data() && { return release(); } + + /** @overload + * @m_since{2019,10} + * @todo what to do here?! + */ + Containers::Array data() const && = delete; + /** @brief Storage of pixel data */ PixelStorage storage() const { return _storage; } @@ -435,33 +462,6 @@ template class Image { */ std::pair, VectorTypeFor> dataProperties() const; - /** - * @brief Raw image data - * - * @see @ref release(), @ref pixels() - */ - Containers::ArrayView data() & { return _data; } - - /** @overload */ - Containers::ArrayView data() const & { return _data; } - - /** - * @brief Raw image data from a r-value - * @m_since{2019,10} - * - * Unlike @ref data(), which returns a view, this is equivalent to - * @ref release() to avoid a dangling view when the temporary instance - * goes out of scope. - * @todoc stupid doxygen can't link to & overloads ffs - */ - Containers::Array data() && { return release(); } - - /** @overload - * @m_since{2019,10} - * @todo what to do here?! - */ - Containers::Array data() const && = delete; - /** * @brief Pixel data * @m_since{2019,10} @@ -730,6 +730,33 @@ template class CompressedImage { */ ImageFlags flags() const { return _flags; } + /** + * @brief Raw image data + * + * @see @ref release() + */ + Containers::ArrayView data() & { return _data; } + + /** @overload */ + Containers::ArrayView data() const & { return _data; } + + /** + * @brief Raw image data from a r-value + * @m_since{2019,10} + * + * Unlike @ref data(), which returns a view, this is equivalent to + * @ref release() to avoid a dangling view when the temporary instance + * goes out of scope. + * @todoc stupid doxygen can't link to & overloads ffs + */ + Containers::Array data() && { return release(); } + + /** @overload + * @m_since{2019,10} + * @todo what to do here?! + */ + Containers::Array data() const && = delete; + /** @brief Storage of compressed pixel data */ CompressedPixelStorage storage() const { return _storage; } @@ -777,33 +804,6 @@ template class CompressedImage { */ std::pair, VectorTypeFor> dataProperties() const; - /** - * @brief Raw image data - * - * @see @ref release() - */ - Containers::ArrayView data() & { return _data; } - - /** @overload */ - Containers::ArrayView data() const & { return _data; } - - /** - * @brief Raw image data from a r-value - * @m_since{2019,10} - * - * Unlike @ref data(), which returns a view, this is equivalent to - * @ref release() to avoid a dangling view when the temporary instance - * goes out of scope. - * @todoc stupid doxygen can't link to & overloads ffs - */ - Containers::Array data() && { return release(); } - - /** @overload - * @m_since{2019,10} - * @todo what to do here?! - */ - Containers::Array data() const && = delete; - /** * @brief Release data storage * diff --git a/src/Magnum/ImageView.h b/src/Magnum/ImageView.h index 8a509152d..523fb21f0 100644 --- a/src/Magnum/ImageView.h +++ b/src/Magnum/ImageView.h @@ -446,6 +446,21 @@ template class ImageView { */ ImageFlags flags() const { return _flags; } + /** + * @brief Raw image data + * + * @see @ref pixels() + */ + Containers::ArrayView data() const { return _data; } + + /** + * @brief Set image data + * + * The data array is expected to be of proper size for parameters + * specified in the constructor. + */ + void setData(Containers::ArrayView data); + /** @brief Storage of pixel data */ PixelStorage storage() const { return _storage; } @@ -490,21 +505,6 @@ template class ImageView { */ std::pair, VectorTypeFor> dataProperties() const; - /** - * @brief Raw image data - * - * @see @ref pixels() - */ - Containers::ArrayView data() const { return _data; } - - /** - * @brief Set image data - * - * The data array is expected to be of proper size for parameters - * specified in the constructor. - */ - void setData(Containers::ArrayView data); - /** * @brief Pixel data * @m_since{2019,10} @@ -972,6 +972,17 @@ template class CompressedImageView { */ ImageFlags flags() const { return _flags; } + /** @brief Raw image data */ + Containers::ArrayView data() const { return _data; } + + /** + * @brief Set image data + * + * The data array is expected to be of proper size for parameters + * specified in the constructor. + */ + void setData(Containers::ArrayView data); + /** @brief Storage of compressed pixel data */ CompressedPixelStorage storage() const { return _storage; } @@ -1019,17 +1030,6 @@ template class CompressedImageView { */ std::pair, VectorTypeFor> dataProperties() const; - /** @brief Raw image data */ - Containers::ArrayView data() const { return _data; } - - /** - * @brief Set image data - * - * The data array is expected to be of proper size for parameters - * specified in the constructor. - */ - void setData(Containers::ArrayView data); - private: /* Needed for mutable->const conversion */ template friend class CompressedImageView; diff --git a/src/Magnum/Trade/ImageData.h b/src/Magnum/Trade/ImageData.h index d6a0e6297..76f9beb49 100644 --- a/src/Magnum/Trade/ImageData.h +++ b/src/Magnum/Trade/ImageData.h @@ -734,15 +734,6 @@ template class ImageData { /** @brief Move assignment */ ImageData& operator=(ImageData&& other) noexcept; - /** - * @brief Data flags - * @m_since{2020,06} - */ - DataFlags dataFlags() const { return _dataFlags; } - - /** @brief Whether the image is compressed */ - bool isCompressed() const { return _compressed; } - /** * @brief Conversion to a view * @@ -781,12 +772,57 @@ template class ImageData { */ /*implicit*/ operator BasicMutableCompressedImageView(); + /** + * @brief Data flags + * @m_since{2020,06} + */ + DataFlags dataFlags() const { return _dataFlags; } + /** * @brief Layout flags * @m_since_latest */ ImageFlags flags() const { return _flags; } + /** + * @brief Raw image data + * + * @see @ref release(), @ref pixels() + */ + Containers::ArrayView data() const & { return _data; } + + /** + * @brief Image data from a r-value + * @m_since{2019,10} + * + * Unlike @ref data(), which returns a view, this is equivalent to + * @ref release() to avoid a dangling view when the temporary instance + * goes out of scope. Note that the returned array has a custom no-op + * deleter when the data are not owned by the image, and while the + * returned array type is mutable, the actual memory might be not. + * @todoc stupid doxygen can't link to & overloads ffs + */ + Containers::Array data() && { return release(); } + + /** @overload + * @m_since{2019,10} + * @todo what to do here?! + */ + Containers::Array data() const && = delete; + + /** + * @brief Mutable image data + * @m_since{2020,06} + * + * Like @ref data(), but returns a non-const view. Expects that the + * image is mutable. + * @see @ref dataFlags() + */ + Containers::ArrayView mutableData() &; + + /** @brief Whether the image is compressed */ + bool isCompressed() const { return _compressed; } + /** * @brief Storage of pixel data * @@ -899,42 +935,6 @@ template class ImageData { */ std::pair, VectorTypeFor> compressedDataProperties() const; - /** - * @brief Raw image data - * - * @see @ref release(), @ref pixels() - */ - Containers::ArrayView data() const & { return _data; } - - /** - * @brief Image data from a r-value - * @m_since{2019,10} - * - * Unlike @ref data(), which returns a view, this is equivalent to - * @ref release() to avoid a dangling view when the temporary instance - * goes out of scope. Note that the returned array has a custom no-op - * deleter when the data are not owned by the image, and while the - * returned array type is mutable, the actual memory might be not. - * @todoc stupid doxygen can't link to & overloads ffs - */ - Containers::Array data() && { return release(); } - - /** @overload - * @m_since{2019,10} - * @todo what to do here?! - */ - Containers::Array data() const && = delete; - - /** - * @brief Mutable image data - * @m_since{2020,06} - * - * Like @ref data(), but returns a non-const view. Expects that the - * image is mutable. - * @see @ref dataFlags() - */ - Containers::ArrayView mutableData() &; - /** * @brief Pixel data * @m_since{2019,10}