diff --git a/doc/changelog-old.dox b/doc/changelog-old.dox index e415e1b15..0ffb7baeb 100644 --- a/doc/changelog-old.dox +++ b/doc/changelog-old.dox @@ -51,7 +51,7 @@ Released 2018-05-01, tagged as @subsection changelog-2018-04-new New features - New @ref PixelFormat / @ref CompressedPixelFormat enums containing generic - API-independent pixel formats, together with @ref pixelSize(), + API-independent pixel formats, together with @cpp pixelSize() @ce, @ref pixelFormatWrap() / @ref pixelFormatUnwrap(), @ref compressedPixelFormatWrap() / @ref compressedPixelFormatUnwrap() and @ref isPixelFormatImplementationSpecific() / @ref isCompressedPixelFormatImplementationSpecific() utilities now used by @@ -252,12 +252,12 @@ Released 2018-05-01, tagged as but marked as deprecated. Use either the generic values or @ref GL::PixelFormat (together with @ref GL::PixelType) and @ref GL::CompressedPixelFormat instead. -- `PixelStorage::pixelSize()` was deprecated, use @ref GL::pixelSize() or - @ref Magnum::pixelSize() instead +- `PixelStorage::pixelSize()` was deprecated, use @cpp GL::pixelSize() @ce + or @cpp Magnum::pixelSize() @ce instead - `PixelStorage::dataProperties(GL::PixelFormat, GL::PixelSize, const Vector3i&)` was deprecated for being too GL-specific, use @ref PixelStorage::dataProperties(std::size_t, const Vector3i&) const - together with @ref GL::pixelSize() instead + together with @cpp GL::pixelSize() @ce instead - `Image*::type()` functions are deprecated as these are too GL-specific. The second format specifier is now available through @ref Image::formatExtra(), @ref ImageView::formatExtra() and @ref Trade::ImageData::formatExtra() diff --git a/doc/changelog.dox b/doc/changelog.dox index 712da2115..6fa651105 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -769,6 +769,12 @@ See also: the canvas and status elements from the JS `Module`. See @ref platforms-html5-apps and [mosra/magnum#481](https://github.com/mosra/magnum/pull/481) for details. +- @cpp pixelSize() @ce, @cpp GL::pixelSize() @ce, @cpp compressedBlockSize() @ce + and @cpp compressedBlockDataSize() @ce is deprecated in favor of + @ref pixelFormatSize(), @ref GL::pixelFormatSize(), + @ref compressedPixelFormatBlockSize() and + @ref compressedPixelFormatBlockDataSize() for consistency with similar APIs + for @ref VertexFormat and other format enums - Templated variants of @ref DebugTools::bufferData() and @ref DebugTools::bufferSubData() are deprecated in favor of the non-templated API together with @relativeref{Corrade,Containers::arrayCast()}. @@ -1001,6 +1007,11 @@ See also: is included in affected headers for implicit conversions from/to a @ref std::string, but in some cases you may be forced to change the code that uses those APIs. +- @ref Image, @ref ImageView and @ref Trade::ImageData now look for a + @cpp pixelFormatSize() @ce API via ADL instead of @cpp pixelSize() @ce. In + case you were passing a custom pixel format enum to the image classes, you + have provide a size query function with the new name to make your code + compile again. - @ref GL::TextureFormat::SR8 and @ref GL::TextureFormat::SRG8 were present on ES2 builds by mistake --- the @gl_extension{EXT,texture_sRGB_R8} and @gl_extension{EXT,texture_sRGB_RG8} extensions require OpenGL ES 3.0 at @@ -1921,9 +1932,9 @@ Released 2019-10-24, tagged as @ref PixelFormat::RGB8Srgb and @ref PixelFormat::RGBA8Srgb sRGB pixel formats as well as their conversion to corresponding GL/Vulkan formats in @ref GL::pixelFormat() and @ref Vk::vkFormat(Magnum::PixelFormat) -- New @ref compressedBlockSize() and @ref compressedBlockDataSize() utilities - for querying parameters of @ref CompressedPixelFormat entries, similar to - what @ref pixelSize() is for @ref PixelFormat +- New @cpp compressedBlockSize() @ce and @cpp compressedBlockDataSize() @ce + utilities for querying parameters of @ref CompressedPixelFormat entries, + similar to what @cpp pixelSize() @ce is for @ref PixelFormat @subsubsection changelog-2019-10-new-audio Audio library diff --git a/src/Magnum/GL/AbstractTexture.cpp b/src/Magnum/GL/AbstractTexture.cpp index d36f726dc..14304a7a3 100644 --- a/src/Magnum/GL/AbstractTexture.cpp +++ b/src/Magnum/GL/AbstractTexture.cpp @@ -1564,7 +1564,7 @@ void AbstractTexture::imageImplementationSvga3DSliceBySlice(const GLenum target, DSA cleanness is not worth it. */ /** @todo this will break when we support uploading from buffer offset (i.e. data != nullptr) */ if(target == GL_TEXTURE_1D_ARRAY && data && size.y() > 1) - subImageImplementationSvga3DSliceBySlice<&AbstractTexture::subImage2DImplementationDefault>(level, {0, 1}, {size.x(), size.y() - 1}, format, type, static_cast(data) + std::get<1>(storage.dataProperties(pixelSize(format, type), {size, 1})).x(), storage); + subImageImplementationSvga3DSliceBySlice<&AbstractTexture::subImage2DImplementationDefault>(level, {0, 1}, {size.x(), size.y() - 1}, format, type, static_cast(data) + std::get<1>(storage.dataProperties(pixelFormatSize(format, type), {size, 1})).x(), storage); } #endif @@ -1579,7 +1579,7 @@ template(storage.dataProperties(pixelSize(format, type), {size, 1})).x(); + const std::size_t stride = std::get<1>(storage.dataProperties(pixelFormatSize(format, type), {size, 1})).x(); for(Int i = 0; i != size.y(); ++i) (this->*original)(level, {offset.x(), offset.y() + i}, {size.x(), 1}, format, type, static_cast(data) + stride*i, storage); @@ -1637,7 +1637,7 @@ void AbstractTexture::imageImplementationSvga3DSliceBySlice(GLint level, Texture #endif ) && data && size.z() > 1) { - subImageImplementationSvga3DSliceBySlice<&AbstractTexture::subImage3DImplementationDefault>(level, {0, 0, 1}, {size.xy(), size.z() - 1}, format, type, static_cast(data) + std::get<1>(storage.dataProperties(pixelSize(format, type), size)).xy().product(), storage); + subImageImplementationSvga3DSliceBySlice<&AbstractTexture::subImage3DImplementationDefault>(level, {0, 0, 1}, {size.xy(), size.z() - 1}, format, type, static_cast(data) + std::get<1>(storage.dataProperties(pixelFormatSize(format, type), size)).xy().product(), storage); } } #endif @@ -1664,7 +1664,7 @@ template(storage.dataProperties(pixelSize(format, type), size)).xy().product(); + const std::size_t stride = std::get<1>(storage.dataProperties(pixelFormatSize(format, type), size)).xy().product(); for(Int i = 0; i != size.z(); ++i) (this->*original)(level, {offset.xy(), offset.z() + i}, {size.xy(), 1}, format, type, static_cast(data) + stride*i, storage); diff --git a/src/Magnum/GL/BufferImage.cpp b/src/Magnum/GL/BufferImage.cpp index 1ef416985..b26c98cd6 100644 --- a/src/Magnum/GL/BufferImage.cpp +++ b/src/Magnum/GL/BufferImage.cpp @@ -64,7 +64,7 @@ template BufferImage& BufferImage UnsignedInt BufferImage::pixelSize() const { return GL::pixelSize(_format, _type); } +template UnsignedInt BufferImage::pixelSize() const { return pixelFormatSize(_format, _type); } template std::pair, VectorTypeFor> BufferImage::dataProperties() const { return Magnum::Implementation::imageDataProperties(*this); diff --git a/src/Magnum/GL/BufferImage.h b/src/Magnum/GL/BufferImage.h index 6c4da9e1e..2d56146e0 100644 --- a/src/Magnum/GL/BufferImage.h +++ b/src/Magnum/GL/BufferImage.h @@ -61,9 +61,10 @@ and @link GL::PixelType @endlink: It's also possible to pass the generic @ref Magnum::PixelFormat to it, however the @ref format() and @ref type() queries will always return the GL-specific value. On construction, the image internally calculates pixel size -corresponding to given pixel format using either @ref GL::pixelSize() or -@ref Magnum::pixelSize(). This value is needed to check that the passed data -are large enough and also required by most of image manipulation operations. +corresponding to given pixel format using either @ref GL::pixelFormatSize() or +@ref Magnum::pixelFormatSize(). This value is needed to check that the passed +data are large enough and also required by most of image manipulation +operations. Besides creating and owning the buffer, you can also pass existing buffer to it, for example to use buffer storage and other advanced functionality. The @@ -275,7 +276,7 @@ template class BufferImage { /** * @brief Size of a pixel in bytes * - * @see @ref Magnum::pixelSize(), @ref GL::pixelSize() + * @see @ref Magnum::pixelFormatSize(), @ref GL::pixelFormatSize() */ UnsignedInt pixelSize() const; diff --git a/src/Magnum/GL/CubeMapTexture.cpp b/src/Magnum/GL/CubeMapTexture.cpp index d5db53505..af1dbfefb 100644 --- a/src/Magnum/GL/CubeMapTexture.cpp +++ b/src/Magnum/GL/CubeMapTexture.cpp @@ -640,14 +640,14 @@ void CubeMapTexture::getImageImplementationDSA(const GLint level, const Vector3i } void CubeMapTexture::getImageImplementationDSAAmdSliceBySlice(const GLint level, const Vector3i& size, const PixelFormat format, const PixelType type, std::size_t, GLvoid* const data, const PixelStorage& storage) { - auto dataProperties = storage.dataProperties(pixelSize(format, type), size); + auto dataProperties = storage.dataProperties(pixelFormatSize(format, type), size); const std::size_t stride = dataProperties.second.xy().product(); for(Int i = 0; i != size.z(); ++i) glGetTextureSubImage(_id, level, 0, 0, i, size.x(), size.y(), 1, GLenum(format), GLenum(type), stride, static_cast(data) + dataProperties.first.sum() + stride*i); } void CubeMapTexture::getImageImplementationSliceBySlice(const GLint level, const Vector3i& size, const PixelFormat format, const PixelType type, std::size_t, GLvoid* const data, const PixelStorage& storage) { - auto dataProperties = storage.dataProperties(pixelSize(format, type), size); + auto dataProperties = storage.dataProperties(pixelFormatSize(format, type), size); const std::size_t stride = dataProperties.second.xy().product(); for(Int i = 0; i != size.z(); ++i) getImageImplementationDefault(CubeMapCoordinate(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i), level, size.xy(), format, type, stride, static_cast(data) + stride*i); @@ -699,14 +699,14 @@ void CubeMapTexture::subImageImplementationDSA(const GLint level, const Vector3i } void CubeMapTexture::subImageImplementationDSASliceBySlice(const GLint level, const Vector3i& offset, const Vector3i& size, const PixelFormat format, const PixelType type, const GLvoid* const data, const PixelStorage& storage) { - const std::size_t stride = std::get<1>(storage.dataProperties(pixelSize(format, type), size)).xy().product(); + const std::size_t stride = std::get<1>(storage.dataProperties(pixelFormatSize(format, type), size)).xy().product(); for(Int i = 0; i != size.z(); ++i) subImageImplementationDSA(level, {offset.xy(), offset.z() + i}, {size.xy(), 1}, format, type, static_cast(data) + stride*i, storage); } #endif void CubeMapTexture::subImageImplementationSliceBySlice(const GLint level, const Vector3i& offset, const Vector3i& size, const PixelFormat format, const PixelType type, const GLvoid* const data, const PixelStorage& storage) { - const std::size_t stride = std::get<1>(storage.dataProperties(pixelSize(format, type), size)).xy().product(); + const std::size_t stride = std::get<1>(storage.dataProperties(pixelFormatSize(format, type), size)).xy().product(); for(Int i = 0; i != size.z(); ++i) subImageImplementationDefault(CubeMapCoordinate(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i), level, offset.xy(), size.xy(), format, type, static_cast(data) + stride*i); } diff --git a/src/Magnum/GL/PixelFormat.cpp b/src/Magnum/GL/PixelFormat.cpp index 93acfef5c..9da456ec9 100644 --- a/src/Magnum/GL/PixelFormat.cpp +++ b/src/Magnum/GL/PixelFormat.cpp @@ -122,7 +122,7 @@ TextureFormat textureFormat(const Magnum::PixelFormat format) { return out; } -UnsignedInt pixelSize(const PixelFormat format, const PixelType type) { +UnsignedInt pixelFormatSize(const PixelFormat format, const PixelType type) { std::size_t size = 0; #ifdef CORRADE_TARGET_GCC #pragma GCC diagnostic push @@ -252,7 +252,7 @@ UnsignedInt pixelSize(const PixelFormat format, const PixelType type) { /* Handled above */ case PixelFormat::DepthStencil: - CORRADE_ASSERT_UNREACHABLE("GL::pixelSize(): invalid" << type << "specified for" << format, 0); + CORRADE_ASSERT_UNREACHABLE("GL::pixelFormatSize(): invalid" << type << "specified for" << format, 0); } #ifdef CORRADE_TARGET_GCC #pragma GCC diagnostic pop diff --git a/src/Magnum/GL/PixelFormat.h b/src/Magnum/GL/PixelFormat.h index e557837d0..6495e1531 100644 --- a/src/Magnum/GL/PixelFormat.h +++ b/src/Magnum/GL/PixelFormat.h @@ -26,7 +26,7 @@ */ /** @file - * @brief Enum @ref Magnum::GL::PixelFormat, @ref Magnum::GL::PixelType, @ref Magnum::GL::CompressedPixelFormat, function @ref Magnum::GL::hasPixelFormat(), @ref Magnum::GL::pixelFormat(), @ref Magnum::GL::pixelType(), @ref Magnum::GL::pixelSize(), @ref Magnum::GL::hasCompressedPixelFormat(), @ref Magnum::GL::compressedPixelFormat() + * @brief Enum @ref Magnum::GL::PixelFormat, @ref Magnum::GL::PixelType, @ref Magnum::GL::CompressedPixelFormat, function @ref Magnum::GL::hasPixelFormat(), @ref Magnum::GL::pixelFormat(), @ref Magnum::GL::pixelType(), @ref Magnum::GL::pixelFormatSize(), @ref Magnum::GL::hasCompressedPixelFormat(), @ref Magnum::GL::compressedPixelFormat() */ #include @@ -676,7 +676,7 @@ to query availability of given format. MAGNUM_GL_EXPORT PixelFormat pixelFormat(Magnum::PixelFormat format); /** -@brief Convert a generic pixel type to OpenGL pixel type +@brief Convert a generic pixel format to OpenGL pixel type In case @ref isPixelFormatImplementationSpecific() returns @cpp false @ce for @p format, maps it to a corresponding OpenGL pixel type. In case @@ -694,9 +694,19 @@ MAGNUM_GL_EXPORT PixelType pixelType(Magnum::PixelFormat format, UnsignedInt ext /** @brief Size of a pixel for given format/type combination in bytes -@see @ref Magnum::pixelSize(), @ref PixelStorage::dataProperties() +@see @ref Magnum::pixelFormatSize(), @ref PixelStorage::dataProperties() */ -MAGNUM_GL_EXPORT UnsignedInt pixelSize(PixelFormat format, PixelType type); +MAGNUM_GL_EXPORT UnsignedInt pixelFormatSize(PixelFormat format, PixelType type); + +#ifdef MAGNUM_BUILD_DEPRECATED +/** + * @brief @copybrief pixelFormatSize() + * @m_deprecated_since_latest Use @ref pixelFormatSize() instead. + */ +CORRADE_DEPRECATED("use pixelFormatSize() instead") inline UnsignedInt pixelSize(PixelFormat format, PixelType type) { + return pixelFormatSize(format, type); +} +#endif /** @debugoperatorenum{PixelFormat} */ MAGNUM_GL_EXPORT Debug& operator<<(Debug& debug, PixelFormat value); diff --git a/src/Magnum/GL/Test/PixelFormatTest.cpp b/src/Magnum/GL/Test/PixelFormatTest.cpp index fa5a7848f..e2a35dff6 100644 --- a/src/Magnum/GL/Test/PixelFormatTest.cpp +++ b/src/Magnum/GL/Test/PixelFormatTest.cpp @@ -337,17 +337,17 @@ void PixelFormatTest::mapTextureFormatInvalid() { void PixelFormatTest::size() { #ifndef MAGNUM_TARGET_GLES - CORRADE_COMPARE(pixelSize(PixelFormat::RGB, PixelType::UnsignedByte332), 1); + CORRADE_COMPARE(pixelFormatSize(PixelFormat::RGB, PixelType::UnsignedByte332), 1); #endif #ifndef MAGNUM_TARGET_WEBGL - CORRADE_COMPARE(pixelSize(PixelFormat::StencilIndex, PixelType::UnsignedByte), 1); + CORRADE_COMPARE(pixelFormatSize(PixelFormat::StencilIndex, PixelType::UnsignedByte), 1); #endif - CORRADE_COMPARE(pixelSize(PixelFormat::DepthComponent, PixelType::UnsignedShort), 2); - CORRADE_COMPARE(pixelSize(PixelFormat::RGBA, PixelType::UnsignedShort4444), 2); - CORRADE_COMPARE(pixelSize(PixelFormat::DepthStencil, PixelType::UnsignedInt248), 4); - CORRADE_COMPARE(pixelSize(PixelFormat::RGBA, PixelType::UnsignedInt), 4*4); + CORRADE_COMPARE(pixelFormatSize(PixelFormat::DepthComponent, PixelType::UnsignedShort), 2); + CORRADE_COMPARE(pixelFormatSize(PixelFormat::RGBA, PixelType::UnsignedShort4444), 2); + CORRADE_COMPARE(pixelFormatSize(PixelFormat::DepthStencil, PixelType::UnsignedInt248), 4); + CORRADE_COMPARE(pixelFormatSize(PixelFormat::RGBA, PixelType::UnsignedInt), 4*4); #ifndef MAGNUM_TARGET_GLES2 - CORRADE_COMPARE(pixelSize(PixelFormat::DepthStencil, PixelType::Float32UnsignedInt248Rev), 8); + CORRADE_COMPARE(pixelFormatSize(PixelFormat::DepthStencil, PixelType::Float32UnsignedInt248Rev), 8); #endif } @@ -358,8 +358,8 @@ void PixelFormatTest::sizeInvalid() { std::ostringstream out; Error redirectError{&out}; - pixelSize(PixelFormat::DepthStencil, PixelType::Float); - CORRADE_COMPARE(out.str(), "GL::pixelSize(): invalid GL::PixelType::Float specified for GL::PixelFormat::DepthStencil\n"); + pixelFormatSize(PixelFormat::DepthStencil, PixelType::Float); + CORRADE_COMPARE(out.str(), "GL::pixelFormatSize(): invalid GL::PixelType::Float specified for GL::PixelFormat::DepthStencil\n"); } void PixelFormatTest::mapCompressedFormatTextureFormat() { diff --git a/src/Magnum/Image.cpp b/src/Magnum/Image.cpp index 96ad66978..23d2a6476 100644 --- a/src/Magnum/Image.cpp +++ b/src/Magnum/Image.cpp @@ -31,7 +31,7 @@ namespace Magnum { -template Image::Image(const PixelStorage storage, const PixelFormat format, const VectorTypeFor& size, Containers::Array&& data) noexcept: Image{storage, format, {}, Magnum::pixelSize(format), size, std::move(data)} {} +template Image::Image(const PixelStorage storage, const PixelFormat format, const VectorTypeFor& size, Containers::Array&& data) noexcept: Image{storage, format, {}, pixelFormatSize(format), size, std::move(data)} {} template Image::Image(const PixelStorage storage, const UnsignedInt format, const UnsignedInt formatExtra, const UnsignedInt pixelSize, const VectorTypeFor& size, Containers::Array&& data) noexcept: Image{storage, pixelFormatWrap(format), formatExtra, pixelSize, size, std::move(data)} {} @@ -39,7 +39,7 @@ template Image::Image(const PixelStorage sto CORRADE_ASSERT(Implementation::imageDataSize(*this) <= _data.size(), "Image: data too small, got" << _data.size() << "but expected at least" << Implementation::imageDataSize(*this) << "bytes", ); } -template Image::Image(const PixelStorage storage, const PixelFormat format) noexcept: Image{storage, format, {}, Magnum::pixelSize(format)} {} +template Image::Image(const PixelStorage storage, const PixelFormat format) noexcept: Image{storage, format, {}, pixelFormatSize(format)} {} template Image::Image(const PixelStorage storage, const UnsignedInt format, const UnsignedInt formatExtra, const UnsignedInt pixelSize) noexcept: Image{storage, pixelFormatWrap(format), formatExtra, pixelSize} {} diff --git a/src/Magnum/Image.h b/src/Magnum/Image.h index 158a9a074..9b5d86d82 100644 --- a/src/Magnum/Image.h +++ b/src/Magnum/Image.h @@ -67,8 +67,8 @@ with storing image size and one of the generic @ref PixelFormat values: @snippet Magnum.cpp Image-usage On construction, the image internally calculates pixel size corresponding to -given pixel format using @ref pixelSize(). This value is needed to check that -the passed data array is large enough and is also required by most image +given pixel format using @ref pixelFormatSize(). This value is needed to check +that the passed data array is large enough and is also required by most image manipulation operations. It's also possible to create just an image placeholder, storing only the image @@ -173,7 +173,7 @@ template class Image { * * Unlike with @ref Image(PixelStorage, PixelFormat, const VectorTypeFor&, Containers::Array&&), * where pixel size is calculated automatically using - * @ref pixelSize(PixelFormat), this allows you to specify an + * @ref pixelFormatSize(), this allows you to specify an * implementation-specific pixel format and pixel size directly. Uses * @ref pixelFormatWrap() internally to wrap @p format in * @ref PixelFormat. @@ -198,10 +198,10 @@ template class Image { * @param pixelSize Size of a pixel in given format, in bytes * * Unlike with @ref Image(PixelStorage, PixelFormat), where pixel size - * is calculated automatically using @ref pixelSize(PixelFormat), this + * is calculated automatically using @ref pixelFormatSize(), this * allows you to specify an implementation-specific pixel format and - * pixel size directly. Uses @ref pixelFormatWrap() internally to - * wrap @p format in @ref PixelFormat. + * pixel size directly. Uses @ref pixelFormatWrap() internally to wrap + * @p format in @ref PixelFormat. */ explicit Image(PixelStorage storage, UnsignedInt format, UnsignedInt formatExtra, UnsignedInt pixelSize) noexcept; @@ -220,8 +220,8 @@ template class Image { * @param size Image size * @param data Image data * - * Uses ADL to find a corresponding @cpp pixelSize(T, U) @ce overload, - * then calls @ref Image(PixelStorage, UnsignedInt, UnsignedInt, UnsignedInt, const VectorTypeFor&, Containers::Array&&) + * Uses ADL to find a corresponding @cpp pixelFormatSize(T, U) @ce + * overload, then calls @ref Image(PixelStorage, UnsignedInt, UnsignedInt, UnsignedInt, const VectorTypeFor&, Containers::Array&&) * with calculated pixel size. */ template explicit Image(PixelStorage storage, T format, U formatExtra, const VectorTypeFor& size, Containers::Array&& data) noexcept; @@ -233,8 +233,8 @@ template class Image { * @param size Image size * @param data Image data * - * Uses ADL to find a corresponding @cpp pixelSize(T) @ce overload, - * then calls @ref Image(PixelStorage, UnsignedInt, UnsignedInt, UnsignedInt, const VectorTypeFor&, Containers::Array&&) + * Uses ADL to find a corresponding @cpp pixelFormatSize(T) @ce + * overload, then calls @ref Image(PixelStorage, UnsignedInt, UnsignedInt, UnsignedInt, const VectorTypeFor&, Containers::Array&&) * with calculated pixel size and @p formatExtra set to @cpp 0 @ce. */ template explicit Image(PixelStorage storage, T format, const VectorTypeFor& size, Containers::Array&& data) noexcept; @@ -268,8 +268,8 @@ template class Image { * @param format Format of pixel data * @param formatExtra Additional pixel format specifier * - * Uses ADL to find a corresponding @cpp pixelSize(T, U) @ce overload, - * then calls @ref Image(PixelStorage, UnsignedInt, UnsignedInt, UnsignedInt) + * Uses ADL to find a corresponding @cpp pixelFormatSize(T, U) @ce + * overload, then calls @ref Image(PixelStorage, UnsignedInt, UnsignedInt, UnsignedInt) * with calculated pixel size. */ template /*implicit*/ Image(PixelStorage storage, T format, U formatExtra) noexcept; @@ -289,8 +289,8 @@ template class Image { * @param storage Storage of pixel data * @param format Format of pixel data * - * Uses ADL to find a corresponding @cpp pixelSize(T) @ce overload, - * then calls @ref Image(PixelStorage, UnsignedInt, UnsignedInt, UnsignedInt) + * Uses ADL to find a corresponding @cpp pixelFormatSize(T) @ce + * overload, then calls @ref Image(PixelStorage, UnsignedInt, UnsignedInt, UnsignedInt) * with calculated pixel size and @p formatExtra set to @cpp 0 @ce. */ template /*implicit*/ Image(PixelStorage storage, T format) noexcept; @@ -359,7 +359,7 @@ template class Image { /** * @brief Size of a pixel in bytes * - * @see @ref pixelSize(PixelFormat) + * @see @ref pixelFormatSize() */ UnsignedInt pixelSize() const { return _pixelSize; } @@ -708,22 +708,22 @@ typedef CompressedImage<2> CompressedImage2D; /** @brief Three-dimensional compressed image */ typedef CompressedImage<3> CompressedImage3D; -template template inline Image::Image(const PixelStorage storage, const T format, const U formatExtra, const VectorTypeFor& size, Containers::Array&& data) noexcept: Image{storage, UnsignedInt(format), UnsignedInt(formatExtra), Implementation::pixelSizeAdl(format, formatExtra), size, std::move(data)} { +template template inline Image::Image(const PixelStorage storage, const T format, const U formatExtra, const VectorTypeFor& size, Containers::Array&& data) noexcept: Image{storage, UnsignedInt(format), UnsignedInt(formatExtra), Implementation::pixelFormatSizeAdl(format, formatExtra), size, std::move(data)} { static_assert(sizeof(T) <= 4 && sizeof(U) <= 4, "format types larger than 32bits are not supported"); } -template template inline Image::Image(const PixelStorage storage, const T format, const VectorTypeFor& size, Containers::Array&& data) noexcept: Image{storage, UnsignedInt(format), {}, Implementation::pixelSizeAdl(format), size, std::move(data)} { +template template inline Image::Image(const PixelStorage storage, const T format, const VectorTypeFor& size, Containers::Array&& data) noexcept: Image{storage, UnsignedInt(format), {}, Implementation::pixelFormatSizeAdl(format), size, std::move(data)} { static_assert(sizeof(T) <= 4, "format types larger than 32bits are not supported"); } -template template inline Image::Image(const PixelStorage storage, const T format, const U formatExtra) noexcept: Image{storage, UnsignedInt(format), UnsignedInt(formatExtra), Implementation::pixelSizeAdl(format, formatExtra)} { +template template inline Image::Image(const PixelStorage storage, const T format, const U formatExtra) noexcept: Image{storage, UnsignedInt(format), UnsignedInt(formatExtra), Implementation::pixelFormatSizeAdl(format, formatExtra)} { static_assert(sizeof(T) <= 4 && sizeof(U) <= 4, "format types larger than 32bits are not supported"); } -template template inline Image::Image(const PixelStorage storage, const T format) noexcept: Image{storage, UnsignedInt(format), {}, Implementation::pixelSizeAdl(format)} { +template template inline Image::Image(const PixelStorage storage, const T format) noexcept: Image{storage, UnsignedInt(format), {}, Implementation::pixelFormatSizeAdl(format)} { static_assert(sizeof(T) <= 4, "format types larger than 32bits are not supported"); } diff --git a/src/Magnum/ImageView.cpp b/src/Magnum/ImageView.cpp index db3a77b03..9bbb53786 100644 --- a/src/Magnum/ImageView.cpp +++ b/src/Magnum/ImageView.cpp @@ -30,7 +30,7 @@ namespace Magnum { -template ImageView::ImageView(const PixelStorage storage, const PixelFormat format, const VectorTypeFor& size, const Containers::ArrayView data) noexcept: ImageView{storage, format, {}, Magnum::pixelSize(format), size, data} {} +template ImageView::ImageView(const PixelStorage storage, const PixelFormat format, const VectorTypeFor& size, const Containers::ArrayView data) noexcept: ImageView{storage, format, {}, pixelFormatSize(format), size, data} {} template ImageView::ImageView(const PixelStorage storage, const UnsignedInt format, const UnsignedInt formatExtra, const UnsignedInt pixelSize, const VectorTypeFor& size, const Containers::ArrayView data) noexcept: ImageView{storage, pixelFormatWrap(format), formatExtra, pixelSize, size, data} {} @@ -46,7 +46,7 @@ template ImageView::ImageView(co #endif } -template ImageView::ImageView(const PixelStorage storage, const PixelFormat format, const VectorTypeFor& size) noexcept: ImageView{storage, format, {}, Magnum::pixelSize(format), size} {} +template ImageView::ImageView(const PixelStorage storage, const PixelFormat format, const VectorTypeFor& size) noexcept: ImageView{storage, format, {}, pixelFormatSize(format), size} {} template ImageView::ImageView(const PixelStorage storage, const UnsignedInt format, const UnsignedInt formatExtra, const UnsignedInt pixelSize, const VectorTypeFor& size) noexcept: ImageView{storage, pixelFormatWrap(format), formatExtra, pixelSize, size} {} diff --git a/src/Magnum/ImageView.h b/src/Magnum/ImageView.h index 65ac7082b..f644e557b 100644 --- a/src/Magnum/ImageView.h +++ b/src/Magnum/ImageView.h @@ -72,9 +72,9 @@ describe its layout, with pixel format being one of the values from the generic @snippet Magnum.cpp ImageView-usage On construction, the image view internally calculates pixel size corresponding -to given pixel format using @ref pixelSize(). This value is needed to check -that the passed data array is large enough and is also required by most image -manipulation operations. +to given pixel format using @ref pixelFormatSize(). This value is needed to +check that the passed data array is large enough and is also required by most +image manipulation operations. It's also possible to create an empty view and assign the memory later. That is useful for example in case of multi-buffered video streaming, where each frame @@ -114,9 +114,9 @@ the @ref GL::PixelFormat and @ref GL::PixelType pair: @snippet Magnum.cpp ImageView-usage-gl -In such cases, pixel size is calculated using either @cpp pixelSize(T, U) @ce -or @cpp pixelSize(T) @ce that is found using -[ADL](https://en.wikipedia.org/wiki/Argument-dependent_name_lookup), with +In such cases, pixel size is calculated using either +@cpp pixelFormatSize(T, U) @ce or @cpp pixelFormatSize(T) @ce that is found +using [ADL](https://en.wikipedia.org/wiki/Argument-dependent_name_lookup), with @cpp T @ce and @cpp U @ce corresponding to types of passed arguments. The implementation-specific format is wrapped in @ref PixelFormat using @ref pixelFormatWrap() and @ref format() returns the wrapped value. In order to @@ -127,11 +127,11 @@ value is stored verbatim in @ref formatExtra(): @snippet Magnum.cpp ImageView-usage-gl-extract -As a final fallback, types for which the @cpp pixelSize() @ce overload is not -available can be specified directly together with pixel size. In particular, -pixel size of @cpp 0 @ce will cause the image to be treated as fully opaque -data, disabling all slicing operations. The following shows a image view using -Metal-specific format identifier: +As a final fallback, types for which the @cpp pixelFormatSize() @ce overload is +not available can be specified directly together with pixel size. In +particular, pixel size of @cpp 0 @ce will cause the image to be treated as +fully opaque data, disabling all slicing operations. The following shows a +image view using Metal-specific format identifier: @snippet Magnum.cpp ImageView-usage-metal @@ -220,7 +220,7 @@ template class ImageView { * * Unlike with @ref ImageView(PixelStorage, PixelFormat, const VectorTypeFor&, Containers::ArrayView), * where pixel size is calculated automatically using - * @ref pixelSize(PixelFormat), this allows you to specify an + * @ref pixelFormatSize(), this allows you to specify an * implementation-specific pixel format and pixel size directly. Uses * @ref pixelFormatWrap() internally to wrap @p format in * @ref PixelFormat. @@ -247,7 +247,7 @@ template class ImageView { * * Unlike with @ref ImageView(PixelStorage, PixelFormat, const VectorTypeFor&), * where pixel size is calculated automatically using - * @ref pixelSize(PixelFormat), this allows you to specify an + * @ref pixelFormatSize(), this allows you to specify an * implementation-specific pixel format and pixel size directly. Uses * @ref pixelFormatWrap() internally to wrap @p format in * @ref PixelFormat. @@ -272,8 +272,8 @@ template class ImageView { * @param size Image size * @param data Image data * - * Uses ADL to find a corresponding @cpp pixelSize(T, U) @ce overload, - * then calls @ref ImageView(PixelStorage, UnsignedInt, UnsignedInt, UnsignedInt, const VectorTypeFor&, Containers::ArrayView) + * Uses ADL to find a corresponding @cpp pixelFormatSize(T, U) @ce + * overload, then calls @ref ImageView(PixelStorage, UnsignedInt, UnsignedInt, UnsignedInt, const VectorTypeFor&, Containers::ArrayView) * with calculated pixel size. */ template explicit ImageView(PixelStorage storage, U format, V formatExtra, const VectorTypeFor& size, Containers::ArrayView data) noexcept; @@ -285,8 +285,8 @@ template class ImageView { * @param size Image size * @param data Image data * - * Uses ADL to find a corresponding @cpp pixelSize(T) @ce overload, - * then calls @ref ImageView(PixelStorage, UnsignedInt, UnsignedInt, UnsignedInt, const VectorTypeFor&, Containers::ArrayView) + * Uses ADL to find a corresponding @cpp pixelFormatSize(T) @ce + * overload, then calls @ref ImageView(PixelStorage, UnsignedInt, UnsignedInt, UnsignedInt, const VectorTypeFor&, Containers::ArrayView) * with calculated pixel size and @p formatExtra set to @cpp 0 @ce. */ template explicit ImageView(PixelStorage storage, U format, const VectorTypeFor& size, Containers::ArrayView data) noexcept; @@ -321,8 +321,8 @@ template class ImageView { * @param formatExtra Additional pixel format specifier * @param size Image size * - * Uses ADL to find a corresponding @cpp pixelSize(T, U) @ce overload, - * then calls @ref ImageView(PixelStorage, UnsignedInt, UnsignedInt, UnsignedInt, const VectorTypeFor&) + * Uses ADL to find a corresponding @cpp pixelFormatSize(T, U) @ce + * overload, then calls @ref ImageView(PixelStorage, UnsignedInt, UnsignedInt, UnsignedInt, const VectorTypeFor&) * with calculated pixel size. * * Data pointer is set to @cpp nullptr @ce, call @ref setData() to @@ -336,8 +336,8 @@ template class ImageView { * @param format Format of pixel data * @param size Image size * - * Uses ADL to find a corresponding @cpp pixelSize(T) @ce overload, - * then calls @ref ImageView(PixelStorage, UnsignedInt, UnsignedInt, UnsignedInt, const VectorTypeFor&) + * Uses ADL to find a corresponding @cpp pixelFormatSize(T) @ce + * overload, then calls @ref ImageView(PixelStorage, UnsignedInt, UnsignedInt, UnsignedInt, const VectorTypeFor&) * with calculated pixel size and @p formatExtra set to @cpp 0 @ce. * * Data pointer is set to @cpp nullptr @ce, call @ref setData() to @@ -405,7 +405,7 @@ template class ImageView { /** * @brief Size of a pixel in bytes * - * @see @ref pixelSize(PixelFormat) + * @see @ref pixelFormatSize() */ UnsignedInt pixelSize() const { return _pixelSize; } @@ -899,22 +899,22 @@ typedef BasicMutableCompressedImageView<2> MutableCompressedImageView2D; */ typedef BasicMutableCompressedImageView<3> MutableCompressedImageView3D; -template template inline ImageView::ImageView(const PixelStorage storage, const U format, const V formatExtra, const VectorTypeFor& size, const Containers::ArrayView data) noexcept: ImageView{storage, UnsignedInt(format), UnsignedInt(formatExtra), Implementation::pixelSizeAdl(format, formatExtra), size, data} { +template template inline ImageView::ImageView(const PixelStorage storage, const U format, const V formatExtra, const VectorTypeFor& size, const Containers::ArrayView data) noexcept: ImageView{storage, UnsignedInt(format), UnsignedInt(formatExtra), Implementation::pixelFormatSizeAdl(format, formatExtra), size, data} { static_assert(sizeof(T) <= 4 && sizeof(U) <= 4, "format types larger than 32bits are not supported"); } -template template inline ImageView::ImageView(const PixelStorage storage, const U format, const VectorTypeFor& size, const Containers::ArrayView data) noexcept: ImageView{storage, UnsignedInt(format), {}, Implementation::pixelSizeAdl(format), size, data} { +template template inline ImageView::ImageView(const PixelStorage storage, const U format, const VectorTypeFor& size, const Containers::ArrayView data) noexcept: ImageView{storage, UnsignedInt(format), {}, Implementation::pixelFormatSizeAdl(format), size, data} { static_assert(sizeof(U) <= 4, "format types larger than 32bits are not supported"); } -template template inline ImageView::ImageView(const PixelStorage storage, const U format, const V formatExtra, const VectorTypeFor& size) noexcept: ImageView{storage, UnsignedInt(format), UnsignedInt(formatExtra), Implementation::pixelSizeAdl(format, formatExtra), size} { +template template inline ImageView::ImageView(const PixelStorage storage, const U format, const V formatExtra, const VectorTypeFor& size) noexcept: ImageView{storage, UnsignedInt(format), UnsignedInt(formatExtra), Implementation::pixelFormatSizeAdl(format, formatExtra), size} { static_assert(sizeof(U) <= 4 && sizeof(U) <= 4, "format types larger than 32bits are not supported"); } -template template inline ImageView::ImageView(const PixelStorage storage, const U format, const VectorTypeFor& size) noexcept: ImageView{storage, UnsignedInt(format), {}, Implementation::pixelSizeAdl(format), size} { +template template inline ImageView::ImageView(const PixelStorage storage, const U format, const VectorTypeFor& size) noexcept: ImageView{storage, UnsignedInt(format), {}, Implementation::pixelFormatSizeAdl(format), size} { static_assert(sizeof(U) <= 4, "format types larger than 32bits are not supported"); } diff --git a/src/Magnum/PixelFormat.cpp b/src/Magnum/PixelFormat.cpp index 1f0a4ca10..d4ae29d6f 100644 --- a/src/Magnum/PixelFormat.cpp +++ b/src/Magnum/PixelFormat.cpp @@ -34,9 +34,9 @@ namespace Magnum { -UnsignedInt pixelSize(const PixelFormat format) { +UnsignedInt pixelFormatSize(const PixelFormat format) { CORRADE_ASSERT(!isPixelFormatImplementationSpecific(format), - "pixelSize(): can't determine size of an implementation-specific format" << reinterpret_cast(pixelFormatUnwrap(format)), {}); + "pixelFormatSize(): can't determine size of an implementation-specific format" << reinterpret_cast(pixelFormatUnwrap(format)), {}); #ifdef CORRADE_TARGET_GCC #pragma GCC diagnostic push @@ -115,7 +115,7 @@ UnsignedInt pixelSize(const PixelFormat format) { #pragma GCC diagnostic pop #endif - CORRADE_ASSERT_UNREACHABLE("pixelSize(): invalid format" << format, {}); + CORRADE_ASSERT_UNREACHABLE("pixelFormatSize(): invalid format" << format, {}); } namespace { @@ -176,12 +176,12 @@ constexpr UnsignedShort CompressedBlockData[] { } -Vector3i compressedBlockSize(const CompressedPixelFormat format) { +Vector3i compressedPixelFormatBlockSize(const CompressedPixelFormat format) { CORRADE_ASSERT(!(UnsignedInt(format) & (1 << 31)), - "compressedBlockSize(): can't determine size of an implementation-specific format" << reinterpret_cast(compressedPixelFormatUnwrap(format)), {}); + "compressedPixelFormatBlockSize(): can't determine size of an implementation-specific format" << reinterpret_cast(compressedPixelFormatUnwrap(format)), {}); CORRADE_ASSERT(UnsignedInt(format) - 1 < Containers::arraySize(CompressedBlockData), - "compressedBlockSize(): invalid format" << format, {}); + "compressedPixelFormatBlockSize(): invalid format" << format, {}); const UnsignedInt data = CompressedBlockData[UnsignedInt(format) - 1]; return { (Int(data >> 12) & 0xf) + 1, @@ -190,12 +190,18 @@ Vector3i compressedBlockSize(const CompressedPixelFormat format) { }; } -UnsignedInt compressedBlockDataSize(const CompressedPixelFormat format) { +#ifdef MAGNUM_BUILD_DEPRECATED +Vector3i compressedBlockSize(const CompressedPixelFormat format) { + return compressedPixelFormatBlockSize(format); +} +#endif + +UnsignedInt compressedPixelFormatBlockDataSize(const CompressedPixelFormat format) { CORRADE_ASSERT(!(UnsignedInt(format) & (1 << 31)), - "compressedBlockDataSize(): can't determine size of an implementation-specific format" << reinterpret_cast(compressedPixelFormatUnwrap(format)), {}); + "compressedPixelFormatBlockDataSize(): can't determine size of an implementation-specific format" << reinterpret_cast(compressedPixelFormatUnwrap(format)), {}); CORRADE_ASSERT(UnsignedInt(format) - 1 < Containers::arraySize(CompressedBlockData), - "compressedBlockDataSize(): invalid format" << format, {}); + "compressedPixelFormatBlockDataSize(): invalid format" << format, {}); return (CompressedBlockData[UnsignedInt(format) - 1] & 0xf) + 1; } diff --git a/src/Magnum/PixelFormat.h b/src/Magnum/PixelFormat.h index da59c8ae1..d455bbd77 100644 --- a/src/Magnum/PixelFormat.h +++ b/src/Magnum/PixelFormat.h @@ -26,7 +26,7 @@ */ /** @file - * @brief Enum @ref Magnum::PixelFormat, @ref Magnum::CompressedPixelFormat, function @ref Magnum::pixelSize(), @ref Magnum::isPixelFormatImplementationSpecific(), @ref Magnum::pixelFormatWrap(), @ref Magnum::pixelFormatUnwrap(), @ref Magnum::isCompressedPixelFormatImplementationSpecific(), @ref Magnum::compressedPixelFormatWrap(), @ref Magnum::compressedPixelFormatUnwrap() + * @brief Enum @ref Magnum::PixelFormat, @ref Magnum::CompressedPixelFormat, function @ref Magnum::pixelFormatSize(), @ref Magnum::isPixelFormatImplementationSpecific(), @ref Magnum::pixelFormatWrap(), @ref Magnum::pixelFormatUnwrap(), @ref Magnum::compressedPixelFormatBlockSize(), @ref Magnum::compressedPixelFormatBlockDataSize(), @ref Magnum::isCompressedPixelFormatImplementationSpecific(), @ref Magnum::compressedPixelFormatWrap(), @ref Magnum::compressedPixelFormatUnwrap() */ #include @@ -35,6 +35,10 @@ #include "Magnum/Magnum.h" #include "Magnum/visibility.h" +#ifdef MAGNUM_BUILD_DEPRECATED +#include +#endif + namespace Magnum { /** @@ -61,8 +65,8 @@ For D3D, corresponds to @m_class{m-doc-external} [DXGI_FORMAT](https://docs.micr and import is provided by the @ref Trade::DdsImporter "DdsImporter" plugin; for Metal, corresponds to @m_class{m-doc-external} [MTLPixelFormat](https://developer.apple.com/documentation/metal/mtlpixelformat?language=objc). See documentation of each value for more information about the mapping. -@see @ref pixelSize(), @ref CompressedPixelFormat, @ref Image, @ref ImageView, - @ref VertexFormat +@see @ref pixelFormatSize(), @ref CompressedPixelFormat, @ref Image, + @ref ImageView, @ref VertexFormat */ enum class PixelFormat: UnsignedInt { /* Zero reserved for an invalid format (but not being a named value) */ @@ -768,12 +772,23 @@ enum class PixelFormat: UnsignedInt { }; /** -@brief Size of a pixel +@brief Pixel format size +@m_since_latest Expects that the pixel format is *not* implementation-specific. -@see @ref isPixelFormatImplementationSpecific(), @ref GL::pixelSize() +@see @ref isPixelFormatImplementationSpecific(), @ref GL::pixelFormatSize() */ -MAGNUM_EXPORT UnsignedInt pixelSize(PixelFormat format); +MAGNUM_EXPORT UnsignedInt pixelFormatSize(PixelFormat format); + +#ifdef MAGNUM_BUILD_DEPRECATED +/** + * @brief @copybrief pixelFormatSize() + * @m_deprecated_since_latest Use @ref pixelFormatSize() instead. + */ +MAGNUM_EXPORT CORRADE_DEPRECATED("use pixelFormatSize() instead") inline UnsignedInt pixelSize(PixelFormat format) { + return pixelFormatSize(format); +} +#endif /** @debugoperatorenum{PixelFormat} */ MAGNUM_EXPORT Debug& operator<<(Debug& debug, PixelFormat value); @@ -844,8 +859,9 @@ For D3D, corresponds to @m_class{m-doc-external} [DXGI_FORMAT](https://docs.micr and import is provided by the @ref Trade::DdsImporter "DdsImporter" plugin; for Metal, corresponds to @m_class{m-doc-external} [MTLPixelFormat](https://developer.apple.com/documentation/metal/mtlpixelformat?language=objc). See documentation of each value for more information about the mapping. -@see @ref compressedBlockSize(), @ref compressedBlockDataSize(), - @ref PixelFormat, @ref CompressedImage, @ref CompressedImageView +@see @ref compressedPixelFormatBlockSize(), + @ref compressedPixelFormatBlockDataSize(), @ref PixelFormat, + @ref CompressedImage, @ref CompressedImageView */ enum class CompressedPixelFormat: UnsignedInt { /* Zero reserved for an invalid format (but not being a named value) */ @@ -2322,26 +2338,46 @@ enum class CompressedPixelFormat: UnsignedInt { }; /** -@brief Compressed block size -@m_since{2019,10} +@brief Compressed pixel format block size +@m_since_latest For 2D formats the Z dimension is always 1. Expects that the pixel format is * *not* implementation-specific. -@see @ref compressedBlockDataSize(), +@see @ref compressedPixelFormatBlockDataSize(), @ref isCompressedPixelFormatImplementationSpecific() */ -MAGNUM_EXPORT Vector3i compressedBlockSize(CompressedPixelFormat format); +MAGNUM_EXPORT Vector3i compressedPixelFormatBlockSize(CompressedPixelFormat format); + +#ifdef MAGNUM_BUILD_DEPRECATED +/** + * @brief @copybrief compressedPixelFormatBlockSize() + * @m_deprecated_since_latest Use @ref compressedPixelFormatBlockSize() + * instead. + */ +MAGNUM_EXPORT CORRADE_DEPRECATED("use compressedPixelFormatBlockSize() instead") Vector3i compressedBlockSize(CompressedPixelFormat format); +#endif /** -@brief Compressed block data size -@m_since{2019,10} +@brief Compressed pixel format block data size +@m_since_latest Byte size of each compressed block. Expects that the pixel format is *not* implementation-specific. -@see @ref compressedBlockSize(), +@see @ref compressedPixelFormatBlockSize(), @ref isCompressedPixelFormatImplementationSpecific() */ -MAGNUM_EXPORT UnsignedInt compressedBlockDataSize(CompressedPixelFormat format); +MAGNUM_EXPORT UnsignedInt compressedPixelFormatBlockDataSize(CompressedPixelFormat format); + +#ifdef MAGNUM_BUILD_DEPRECATED +/** + * @brief @copybrief compressedPixelFormatBlockDataSize() + * @m_deprecated_since_latest Use @ref compressedPixelFormatBlockDataSize() + * instead. + */ +CORRADE_DEPRECATED("use compressedPixelFormatBlockDataSize() instead") inline UnsignedInt compressedBlockDataSize(CompressedPixelFormat format) { + return compressedPixelFormatBlockDataSize(format); +} +#endif /** @debugoperatorenum{CompressedPixelFormat} */ MAGNUM_EXPORT Debug& operator<<(Debug& debug, CompressedPixelFormat value); diff --git a/src/Magnum/PixelStorage.h b/src/Magnum/PixelStorage.h index da757efe1..b877c924c 100644 --- a/src/Magnum/PixelStorage.h +++ b/src/Magnum/PixelStorage.h @@ -128,7 +128,7 @@ class MAGNUM_EXPORT PixelStorage { * and given @p pixelSize. The offset reflects the @ref skip() * parameter. Sum of the byte offset vector gives the byte offset of * first pixel in the data array. - * @see @ref GL::pixelSize() + * @see @ref pixelFormatSize(), @ref GL::pixelFormatSize() */ std::pair, Math::Vector3> dataProperties(std::size_t pixelSize, const Vector3i& size) const; @@ -185,7 +185,7 @@ class MAGNUM_EXPORT CompressedPixelStorage: public PixelStorage { * If set to @cpp 0 @ce for given dimension, size information from * particular compressed format is used. Default is @cpp 0 @ce in all * dimensions. - * @see @ref Magnum::compressedBlockSize() + * @see @ref Magnum::compressedPixelFormatBlockSize() */ CompressedPixelStorage& setCompressedBlockSize(const Vector3i& size) { _blockSize = size; @@ -200,7 +200,7 @@ class MAGNUM_EXPORT CompressedPixelStorage: public PixelStorage { * * If set to @cpp 0 @ce, size information from particular compressed * format is used. Default is @cpp 0 @ce in all dimensions. - * @see @ref Magnum::compressedBlockDataSize() + * @see @ref Magnum::compressedPixelFormatBlockDataSize() */ CompressedPixelStorage& setCompressedBlockDataSize(Int size) { _blockDataSize = size; @@ -249,12 +249,12 @@ constexpr PixelStorage::PixelStorage() noexcept: _rowLength{0}, _imageHeight{0}, namespace Implementation { /* Used in templated image[view] constructors */ - template inline UnsignedInt pixelSizeAdl(T format) { - return pixelSize(format); + template inline UnsignedInt pixelFormatSizeAdl(T format) { + return pixelFormatSize(format); } - template inline UnsignedInt pixelSizeAdl(T format, U formatExtra) { - return pixelSize(format, formatExtra); + template inline UnsignedInt pixelFormatSizeAdl(T format, U formatExtra) { + return pixelFormatSize(format, formatExtra); } /* Used in image query functions */ diff --git a/src/Magnum/Test/ImageTest.cpp b/src/Magnum/Test/ImageTest.cpp index 4829f72d9..f98ebb3bb 100644 --- a/src/Magnum/Test/ImageTest.cpp +++ b/src/Magnum/Test/ImageTest.cpp @@ -146,8 +146,8 @@ namespace GL { enum class PixelType { UnsignedShort = 1337 }; /* Clang -Wmissing-prototypes warns otherwise, even though this is in an anonymous namespace */ - UnsignedInt pixelSize(PixelFormat, PixelType); - UnsignedInt pixelSize(PixelFormat format, PixelType type) { + UnsignedInt pixelFormatSize(PixelFormat, PixelType); + UnsignedInt pixelFormatSize(PixelFormat format, PixelType type) { CORRADE_INTERNAL_ASSERT(format == PixelFormat::RGB); CORRADE_INTERNAL_ASSERT(type == PixelType::UnsignedShort); #ifdef CORRADE_NO_ASSERT @@ -164,8 +164,8 @@ namespace Vk { enum class PixelFormat { R32G32B32F = 42 }; /* Clang -Wmissing-prototypes warns otherwise, even though this is in an anonymous namespace */ - UnsignedInt pixelSize(PixelFormat); - UnsignedInt pixelSize(PixelFormat format) { + UnsignedInt pixelFormatSize(PixelFormat); + UnsignedInt pixelFormatSize(PixelFormat format) { CORRADE_INTERNAL_ASSERT(format == PixelFormat::R32G32B32F); #ifdef CORRADE_NO_ASSERT static_cast(format); diff --git a/src/Magnum/Test/ImageViewTest.cpp b/src/Magnum/Test/ImageViewTest.cpp index 1fb37da62..a26d55580 100644 --- a/src/Magnum/Test/ImageViewTest.cpp +++ b/src/Magnum/Test/ImageViewTest.cpp @@ -140,8 +140,8 @@ namespace GL { enum class PixelType { UnsignedShort = 1337 }; /* Clang -Wmissing-prototypes warns otherwise, even though this is in an anonymous namespace */ - UnsignedInt pixelSize(PixelFormat, PixelType); - UnsignedInt pixelSize(PixelFormat format, PixelType type) { + UnsignedInt pixelFormatSize(PixelFormat, PixelType); + UnsignedInt pixelFormatSize(PixelFormat format, PixelType type) { CORRADE_INTERNAL_ASSERT(format == PixelFormat::RGB); CORRADE_INTERNAL_ASSERT(type == PixelType::UnsignedShort); #ifdef CORRADE_NO_ASSERT @@ -158,8 +158,8 @@ namespace Vk { enum class PixelFormat { R32G32B32F = 42 }; /* Clang -Wmissing-prototypes warns otherwise, even though this is in an anonymous namespace */ - UnsignedInt pixelSize(PixelFormat); - UnsignedInt pixelSize(PixelFormat format) { + UnsignedInt pixelFormatSize(PixelFormat); + UnsignedInt pixelFormatSize(PixelFormat format) { CORRADE_INTERNAL_ASSERT(format == PixelFormat::R32G32B32F); #ifdef CORRADE_NO_ASSERT static_cast(format); diff --git a/src/Magnum/Test/PixelFormatTest.cpp b/src/Magnum/Test/PixelFormatTest.cpp index a0f32cb8d..be5f55ccf 100644 --- a/src/Magnum/Test/PixelFormatTest.cpp +++ b/src/Magnum/Test/PixelFormatTest.cpp @@ -172,8 +172,8 @@ void PixelFormatTest::compressedMapping() { CORRADE_COMPARE(Utility::ConfigurationValue::toString(CompressedPixelFormat::format, {}), #format); \ CORRADE_COMPARE(nextHandled, i); \ CORRADE_COMPARE(firstUnhandled, 0xffff); \ - CORRADE_COMPARE(Magnum::compressedBlockSize(CompressedPixelFormat::format), (Vector3i{width, height, depth})); \ - CORRADE_COMPARE(compressedBlockDataSize(CompressedPixelFormat::format), size/8); \ + CORRADE_COMPARE(compressedPixelFormatBlockSize(CompressedPixelFormat::format), (Vector3i{width, height, depth})); \ + CORRADE_COMPARE(compressedPixelFormatBlockDataSize(CompressedPixelFormat::format), size/8); \ CORRADE_COMPARE(size % 8, 0); \ CORRADE_COMPARE_AS(width, 16, TestSuite::Compare::LessOrEqual); \ CORRADE_COMPARE_AS(height, 16, TestSuite::Compare::LessOrEqual); \ @@ -198,14 +198,14 @@ void PixelFormatTest::compressedMapping() { } void PixelFormatTest::size() { - CORRADE_COMPARE(pixelSize(PixelFormat::R8I), 1); - CORRADE_COMPARE(pixelSize(PixelFormat::R16UI), 2); - CORRADE_COMPARE(pixelSize(PixelFormat::RGB8Unorm), 3); - CORRADE_COMPARE(pixelSize(PixelFormat::RGBA8Snorm), 4); - CORRADE_COMPARE(pixelSize(PixelFormat::RGB16I), 6); - CORRADE_COMPARE(pixelSize(PixelFormat::RGBA16F), 8); - CORRADE_COMPARE(pixelSize(PixelFormat::RGB32UI), 12); - CORRADE_COMPARE(pixelSize(PixelFormat::RGBA32F), 16); + CORRADE_COMPARE(pixelFormatSize(PixelFormat::R8I), 1); + CORRADE_COMPARE(pixelFormatSize(PixelFormat::R16UI), 2); + CORRADE_COMPARE(pixelFormatSize(PixelFormat::RGB8Unorm), 3); + CORRADE_COMPARE(pixelFormatSize(PixelFormat::RGBA8Snorm), 4); + CORRADE_COMPARE(pixelFormatSize(PixelFormat::RGB16I), 6); + CORRADE_COMPARE(pixelFormatSize(PixelFormat::RGBA16F), 8); + CORRADE_COMPARE(pixelFormatSize(PixelFormat::RGB32UI), 12); + CORRADE_COMPARE(pixelFormatSize(PixelFormat::RGBA32F), 16); } void PixelFormatTest::sizeInvalid() { @@ -216,12 +216,12 @@ void PixelFormatTest::sizeInvalid() { std::ostringstream out; Error redirectError{&out}; - pixelSize(PixelFormat{}); - pixelSize(PixelFormat(0xdead)); + pixelFormatSize(PixelFormat{}); + pixelFormatSize(PixelFormat(0xdead)); CORRADE_COMPARE(out.str(), - "pixelSize(): invalid format PixelFormat(0x0)\n" - "pixelSize(): invalid format PixelFormat(0xdead)\n"); + "pixelFormatSize(): invalid format PixelFormat(0x0)\n" + "pixelFormatSize(): invalid format PixelFormat(0xdead)\n"); } void PixelFormatTest::sizeImplementationSpecific() { @@ -232,20 +232,20 @@ void PixelFormatTest::sizeImplementationSpecific() { std::ostringstream out; Error redirectError{&out}; - pixelSize(pixelFormatWrap(0xdead)); + pixelFormatSize(pixelFormatWrap(0xdead)); - CORRADE_COMPARE(out.str(), "pixelSize(): can't determine size of an implementation-specific format 0xdead\n"); + CORRADE_COMPARE(out.str(), "pixelFormatSize(): can't determine size of an implementation-specific format 0xdead\n"); } void PixelFormatTest::compressedBlockSize() { - CORRADE_COMPARE(Magnum::compressedBlockSize(CompressedPixelFormat::Etc2RGB8A1Srgb), (Vector3i{4, 4, 1})); - CORRADE_COMPARE(compressedBlockDataSize(CompressedPixelFormat::Etc2RGB8A1Srgb), 8); - CORRADE_COMPARE(Magnum::compressedBlockSize(CompressedPixelFormat::Astc5x4RGBAUnorm), (Vector3i{5, 4, 1})); - CORRADE_COMPARE(compressedBlockDataSize(CompressedPixelFormat::Astc5x4RGBAUnorm), 16); - CORRADE_COMPARE(Magnum::compressedBlockSize(CompressedPixelFormat::Astc12x10RGBAUnorm), (Vector3i{12, 10, 1})); - CORRADE_COMPARE(compressedBlockDataSize(CompressedPixelFormat::Astc12x10RGBAUnorm), 16); - CORRADE_COMPARE(Magnum::compressedBlockSize(CompressedPixelFormat::PvrtcRGBA2bppUnorm), (Vector3i{8, 4, 1})); - CORRADE_COMPARE(compressedBlockDataSize(CompressedPixelFormat::PvrtcRGBA2bppUnorm), 8); + CORRADE_COMPARE(compressedPixelFormatBlockSize(CompressedPixelFormat::Etc2RGB8A1Srgb), (Vector3i{4, 4, 1})); + CORRADE_COMPARE(compressedPixelFormatBlockDataSize(CompressedPixelFormat::Etc2RGB8A1Srgb), 8); + CORRADE_COMPARE(compressedPixelFormatBlockSize(CompressedPixelFormat::Astc5x4RGBAUnorm), (Vector3i{5, 4, 1})); + CORRADE_COMPARE(compressedPixelFormatBlockDataSize(CompressedPixelFormat::Astc5x4RGBAUnorm), 16); + CORRADE_COMPARE(compressedPixelFormatBlockSize(CompressedPixelFormat::Astc12x10RGBAUnorm), (Vector3i{12, 10, 1})); + CORRADE_COMPARE(compressedPixelFormatBlockDataSize(CompressedPixelFormat::Astc12x10RGBAUnorm), 16); + CORRADE_COMPARE(compressedPixelFormatBlockSize(CompressedPixelFormat::PvrtcRGBA2bppUnorm), (Vector3i{8, 4, 1})); + CORRADE_COMPARE(compressedPixelFormatBlockDataSize(CompressedPixelFormat::PvrtcRGBA2bppUnorm), 8); /* The rest tested in compressedMapping() */ } @@ -258,16 +258,16 @@ void PixelFormatTest::compressedBlockSizeInvalid() { std::ostringstream out; Error redirectError{&out}; - Magnum::compressedBlockSize(CompressedPixelFormat{}); - Magnum::compressedBlockSize(CompressedPixelFormat(0xdead)); - compressedBlockDataSize(CompressedPixelFormat{}); - compressedBlockDataSize(CompressedPixelFormat(0xdead)); + compressedPixelFormatBlockSize(CompressedPixelFormat{}); + compressedPixelFormatBlockSize(CompressedPixelFormat(0xdead)); + compressedPixelFormatBlockDataSize(CompressedPixelFormat{}); + compressedPixelFormatBlockDataSize(CompressedPixelFormat(0xdead)); CORRADE_COMPARE(out.str(), - "compressedBlockSize(): invalid format CompressedPixelFormat(0x0)\n" - "compressedBlockSize(): invalid format CompressedPixelFormat(0xdead)\n" - "compressedBlockDataSize(): invalid format CompressedPixelFormat(0x0)\n" - "compressedBlockDataSize(): invalid format CompressedPixelFormat(0xdead)\n"); + "compressedPixelFormatBlockSize(): invalid format CompressedPixelFormat(0x0)\n" + "compressedPixelFormatBlockSize(): invalid format CompressedPixelFormat(0xdead)\n" + "compressedPixelFormatBlockDataSize(): invalid format CompressedPixelFormat(0x0)\n" + "compressedPixelFormatBlockDataSize(): invalid format CompressedPixelFormat(0xdead)\n"); } void PixelFormatTest::compressedBlockSizeImplementationSpecific() { @@ -278,12 +278,12 @@ void PixelFormatTest::compressedBlockSizeImplementationSpecific() { std::ostringstream out; Error redirectError{&out}; - Magnum::compressedBlockSize(compressedPixelFormatWrap(0xdead)); - compressedBlockDataSize(compressedPixelFormatWrap(0xdead)); + compressedPixelFormatBlockSize(compressedPixelFormatWrap(0xdead)); + compressedPixelFormatBlockDataSize(compressedPixelFormatWrap(0xdead)); CORRADE_COMPARE(out.str(), - "compressedBlockSize(): can't determine size of an implementation-specific format 0xdead\n" - "compressedBlockDataSize(): can't determine size of an implementation-specific format 0xdead\n"); + "compressedPixelFormatBlockSize(): can't determine size of an implementation-specific format 0xdead\n" + "compressedPixelFormatBlockDataSize(): can't determine size of an implementation-specific format 0xdead\n"); } void PixelFormatTest::isImplementationSpecific() { diff --git a/src/Magnum/Test/PixelStorageTest.cpp b/src/Magnum/Test/PixelStorageTest.cpp index f8d1c9cae..5309d3499 100644 --- a/src/Magnum/Test/PixelStorageTest.cpp +++ b/src/Magnum/Test/PixelStorageTest.cpp @@ -109,15 +109,15 @@ void PixelStorageTest::dataProperties() { PixelStorage storage; storage.setAlignment(1); - CORRADE_COMPARE(storage.dataProperties(pixelSize(PixelFormat::RGBA8Unorm), Vector3i{0}), + CORRADE_COMPARE(storage.dataProperties(pixelFormatSize(PixelFormat::RGBA8Unorm), Vector3i{0}), (std::pair{{}, {0, 0, 0}})); - CORRADE_COMPARE(storage.dataProperties(pixelSize(PixelFormat::RGBA8Unorm), Vector3i{1}), + CORRADE_COMPARE(storage.dataProperties(pixelFormatSize(PixelFormat::RGBA8Unorm), Vector3i{1}), (std::pair{{}, {4, 1, 1}})); - CORRADE_COMPARE(storage.dataProperties(pixelSize(PixelFormat::R8Unorm), {8, 2, 1}), + CORRADE_COMPARE(storage.dataProperties(pixelFormatSize(PixelFormat::R8Unorm), {8, 2, 1}), (std::pair{{}, {8, 2, 1}})); - CORRADE_COMPARE(storage.dataProperties(pixelSize(PixelFormat::R8Unorm), {2, 4, 1}), + CORRADE_COMPARE(storage.dataProperties(pixelFormatSize(PixelFormat::R8Unorm), {2, 4, 1}), (std::pair{{}, {2, 4, 1}})); - CORRADE_COMPARE(storage.dataProperties(pixelSize(PixelFormat::R8Unorm), {2, 4, 6}), + CORRADE_COMPARE(storage.dataProperties(pixelFormatSize(PixelFormat::R8Unorm), {2, 4, 6}), (std::pair{{}, {2, 4, 6}})); } @@ -126,15 +126,15 @@ void PixelStorageTest::dataPropertiesAlignment() { storage.setAlignment(8) .setSkip({3, 2, 1}); - CORRADE_COMPARE(storage.dataProperties(pixelSize(PixelFormat::RGBA8Unorm), Vector3i{0}), + CORRADE_COMPARE(storage.dataProperties(pixelFormatSize(PixelFormat::RGBA8Unorm), Vector3i{0}), (std::pair{{3*4, 0, 0}, {0, 0, 0}})); - CORRADE_COMPARE(storage.dataProperties(pixelSize(PixelFormat::RGBA8Unorm), Vector3i{1}), + CORRADE_COMPARE(storage.dataProperties(pixelFormatSize(PixelFormat::RGBA8Unorm), Vector3i{1}), (std::pair{{12, 16, 8}, {8, 1, 1}})); - CORRADE_COMPARE(storage.dataProperties(pixelSize(PixelFormat::R8Unorm), {8, 2, 1}), + CORRADE_COMPARE(storage.dataProperties(pixelFormatSize(PixelFormat::R8Unorm), {8, 2, 1}), (std::pair{{3, 16, 16}, {8, 2, 1}})); - CORRADE_COMPARE(storage.dataProperties(pixelSize(PixelFormat::R8Unorm), {2, 4, 1}), + CORRADE_COMPARE(storage.dataProperties(pixelFormatSize(PixelFormat::R8Unorm), {2, 4, 1}), (std::pair{{3, 16, 32}, {8, 4, 1}})); - CORRADE_COMPARE(storage.dataProperties(pixelSize(PixelFormat::R8Unorm), {2, 4, 6}), + CORRADE_COMPARE(storage.dataProperties(pixelFormatSize(PixelFormat::R8Unorm), {2, 4, 6}), (std::pair{{3, 16, 32}, {8, 4, 6}})); } @@ -144,15 +144,15 @@ void PixelStorageTest::dataPropertiesRowLength() { .setRowLength(15) .setSkip({3, 7, 0}); - CORRADE_COMPARE(storage.dataProperties(pixelSize(PixelFormat::RGBA8Unorm), Vector3i{0}), + CORRADE_COMPARE(storage.dataProperties(pixelFormatSize(PixelFormat::RGBA8Unorm), Vector3i{0}), (std::pair{{3*4, 7*15*4, 0}, {0, 0, 0}})); - CORRADE_COMPARE(storage.dataProperties(pixelSize(PixelFormat::RGBA8Unorm), Vector3i{1}), + CORRADE_COMPARE(storage.dataProperties(pixelFormatSize(PixelFormat::RGBA8Unorm), Vector3i{1}), (std::pair{{3*4, 7*15*4, 0}, {60, 1, 1}})); - CORRADE_COMPARE(storage.dataProperties(pixelSize(PixelFormat::R8Unorm), {4, 2, 1}), + CORRADE_COMPARE(storage.dataProperties(pixelFormatSize(PixelFormat::R8Unorm), {4, 2, 1}), (std::pair{{3, 7*16, 0}, {16, 2, 1}})); - CORRADE_COMPARE(storage.dataProperties(pixelSize(PixelFormat::R8Unorm), {2, 4, 1}), + CORRADE_COMPARE(storage.dataProperties(pixelFormatSize(PixelFormat::R8Unorm), {2, 4, 1}), (std::pair{{3, 7*16, 0}, {16, 4, 1}})); - CORRADE_COMPARE(storage.dataProperties(pixelSize(PixelFormat::R8Unorm), {2, 4, 6}), + CORRADE_COMPARE(storage.dataProperties(pixelFormatSize(PixelFormat::R8Unorm), {2, 4, 6}), (std::pair{{3, 7*16, 0}, {16, 4, 6}})); } @@ -162,15 +162,15 @@ void PixelStorageTest::dataPropertiesImageHeight() { .setImageHeight(128) .setSkip({3, 7, 2}); - CORRADE_COMPARE(storage.dataProperties(pixelSize(PixelFormat::RGBA8Unorm), Vector3i{0}), + CORRADE_COMPARE(storage.dataProperties(pixelFormatSize(PixelFormat::RGBA8Unorm), Vector3i{0}), (std::pair{{3*4, 0, 0}, {0, 0, 0}})); - CORRADE_COMPARE(storage.dataProperties(pixelSize(PixelFormat::RGBA8Unorm), Vector3i{1}), + CORRADE_COMPARE(storage.dataProperties(pixelFormatSize(PixelFormat::RGBA8Unorm), Vector3i{1}), (std::pair{{3*4, 7*1*4, 2*128*1*4}, {4, 128, 1}})); - CORRADE_COMPARE(storage.dataProperties(pixelSize(PixelFormat::R8Unorm), {4, 2, 1}), + CORRADE_COMPARE(storage.dataProperties(pixelFormatSize(PixelFormat::R8Unorm), {4, 2, 1}), (std::pair{{3, 7*1*4, 2*128*4}, {4, 128, 1}})); - CORRADE_COMPARE(storage.dataProperties(pixelSize(PixelFormat::R8Unorm), {2, 4, 1}), + CORRADE_COMPARE(storage.dataProperties(pixelFormatSize(PixelFormat::R8Unorm), {2, 4, 1}), (std::pair{{3, 7*1*2, 2*128*2}, {2, 128, 1}})); - CORRADE_COMPARE(storage.dataProperties(pixelSize(PixelFormat::R8Unorm), {2, 4, 6}), + CORRADE_COMPARE(storage.dataProperties(pixelFormatSize(PixelFormat::R8Unorm), {2, 4, 6}), (std::pair{{3, 7*1*2, 2*128*2}, {2, 128, 6}})); } diff --git a/src/Magnum/Trade/ImageData.cpp b/src/Magnum/Trade/ImageData.cpp index e8a9faf5b..c07a91c96 100644 --- a/src/Magnum/Trade/ImageData.cpp +++ b/src/Magnum/Trade/ImageData.cpp @@ -33,7 +33,7 @@ namespace Magnum { namespace Trade { -template ImageData::ImageData(const PixelStorage storage, const PixelFormat format, const VectorTypeFor& size, Containers::Array&& data, const void* const importerState) noexcept: ImageData{storage, format, {}, Magnum::pixelSize(format), size, std::move(data), importerState} {} +template ImageData::ImageData(const PixelStorage storage, const PixelFormat format, const VectorTypeFor& size, Containers::Array&& data, const void* const importerState) noexcept: ImageData{storage, format, {}, pixelFormatSize(format), size, std::move(data), importerState} {} template ImageData::ImageData(const PixelStorage storage, const PixelFormat format, const VectorTypeFor& size, const DataFlags dataFlags, const Containers::ArrayView data, const void* const importerState) noexcept: ImageData{storage, format, size, Containers::Array{const_cast(static_cast(data.data())), data.size(), Implementation::nonOwnedArrayDeleter}, importerState} { CORRADE_ASSERT(!(dataFlags & DataFlag::Owned), diff --git a/src/Magnum/Trade/ImageData.h b/src/Magnum/Trade/ImageData.h index f9a265fd8..71ac0a8d9 100644 --- a/src/Magnum/Trade/ImageData.h +++ b/src/Magnum/Trade/ImageData.h @@ -186,7 +186,7 @@ template class ImageData { * * Unlike with @ref ImageData(PixelStorage, PixelFormat, const VectorTypeFor&, Containers::Array&&, const void*), * where pixel size is calculated automatically using - * @ref pixelSize(PixelFormat), this allows you to specify an + * @ref pixelFormatSize(), this allows you to specify an * implementation-specific pixel format and pixel size directly. Uses * @ref pixelFormatWrap() internally to wrap @p format in * @ref Magnum::PixelFormat "PixelFormat". @@ -243,8 +243,8 @@ template class ImageData { * @param data Image data * @param importerState Importer-specific state * - * Uses ADL to find a corresponding @cpp pixelSize(T, U) @ce overload, - * then calls @ref ImageData(PixelStorage, UnsignedInt, UnsignedInt, UnsignedInt, const VectorTypeFor&, Containers::Array&&, const void*) + * Uses ADL to find a corresponding @cpp pixelFormatSize(T, U) @ce + * overload, then calls @ref ImageData(PixelStorage, UnsignedInt, UnsignedInt, UnsignedInt, const VectorTypeFor&, Containers::Array&&, const void*) * with calculated pixel size. */ template explicit ImageData(PixelStorage storage, T format, U formatExtra, const VectorTypeFor& size, Containers::Array&& data, const void* importerState = nullptr) noexcept; @@ -276,8 +276,8 @@ template class ImageData { * @param data Image data * @param importerState Importer-specific state * - * Uses ADL to find a corresponding @cpp pixelSize(T) @ce overload, - * then calls @ref ImageData(PixelStorage, UnsignedInt, UnsignedInt, UnsignedInt, const VectorTypeFor&, Containers::Array&&, const void*) + * Uses ADL to find a corresponding @cpp pixelFormatSize(T) @ce + * overload, then calls @ref ImageData(PixelStorage, UnsignedInt, UnsignedInt, UnsignedInt, const VectorTypeFor&, Containers::Array&&, const void*) * with calculated pixel size and @p formatExtra set to @cpp 0 @ce. */ template explicit ImageData(PixelStorage storage, T format, const VectorTypeFor& size, Containers::Array&& data, const void* importerState = nullptr) noexcept; @@ -519,7 +519,7 @@ template class ImageData { * @brief Size of a pixel in bytes * * The image is expected to be uncompressed. - * @see @ref isCompressed(), @ref Magnum::pixelSize() + * @see @ref isCompressed(), @ref pixelFormatSize() */ UnsignedInt pixelSize() const; @@ -707,22 +707,22 @@ typedef ImageData<2> ImageData2D; /** @brief Three-dimensional image data */ typedef ImageData<3> ImageData3D; -template template ImageData::ImageData(const PixelStorage storage, const T format, const U formatExtra, const VectorTypeFor& size, Containers::Array&& data, const void* const importerState) noexcept: ImageData{storage, UnsignedInt(format), UnsignedInt(formatExtra), Magnum::Implementation::pixelSizeAdl(format, formatExtra), size, std::move(data), importerState} { +template template ImageData::ImageData(const PixelStorage storage, const T format, const U formatExtra, const VectorTypeFor& size, Containers::Array&& data, const void* const importerState) noexcept: ImageData{storage, UnsignedInt(format), UnsignedInt(formatExtra), Magnum::Implementation::pixelFormatSizeAdl(format, formatExtra), size, std::move(data), importerState} { static_assert(sizeof(T) <= 4 && sizeof(U) <= 4, "format types larger than 32bits are not supported"); } -template template ImageData::ImageData(const PixelStorage storage, const T format, const U formatExtra, const VectorTypeFor& size, const DataFlags dataFlags, const Containers::ArrayView data, const void* const importerState) noexcept: ImageData{storage, UnsignedInt(format), UnsignedInt(formatExtra), Magnum::Implementation::pixelSizeAdl(format, formatExtra), size, dataFlags, data, importerState} { +template template ImageData::ImageData(const PixelStorage storage, const T format, const U formatExtra, const VectorTypeFor& size, const DataFlags dataFlags, const Containers::ArrayView data, const void* const importerState) noexcept: ImageData{storage, UnsignedInt(format), UnsignedInt(formatExtra), Magnum::Implementation::pixelFormatSizeAdl(format, formatExtra), size, dataFlags, data, importerState} { static_assert(sizeof(T) <= 4 && sizeof(U) <= 4, "format types larger than 32bits are not supported"); } -template template ImageData::ImageData(const PixelStorage storage, const T format, const VectorTypeFor& size, Containers::Array&& data, const void* const importerState) noexcept: ImageData{storage, UnsignedInt(format), {}, Magnum::Implementation::pixelSizeAdl(format), size, std::move(data), importerState} { +template template ImageData::ImageData(const PixelStorage storage, const T format, const VectorTypeFor& size, Containers::Array&& data, const void* const importerState) noexcept: ImageData{storage, UnsignedInt(format), {}, Magnum::Implementation::pixelFormatSizeAdl(format), size, std::move(data), importerState} { static_assert(sizeof(T) <= 4, "format types larger than 32bits are not supported"); } -template template ImageData::ImageData(const PixelStorage storage, const T format, const VectorTypeFor& size, const DataFlags dataFlags, const Containers::ArrayView data, const void* const importerState) noexcept: ImageData{storage, UnsignedInt(format), {}, Magnum::Implementation::pixelSizeAdl(format), size, dataFlags, data, importerState} { +template template ImageData::ImageData(const PixelStorage storage, const T format, const VectorTypeFor& size, const DataFlags dataFlags, const Containers::ArrayView data, const void* const importerState) noexcept: ImageData{storage, UnsignedInt(format), {}, Magnum::Implementation::pixelFormatSizeAdl(format), size, dataFlags, data, importerState} { static_assert(sizeof(T) <= 4, "format types larger than 32bits are not supported"); } diff --git a/src/Magnum/Trade/Test/ImageDataTest.cpp b/src/Magnum/Trade/Test/ImageDataTest.cpp index 21f6316ea..f7d11bdac 100644 --- a/src/Magnum/Trade/Test/ImageDataTest.cpp +++ b/src/Magnum/Trade/Test/ImageDataTest.cpp @@ -168,8 +168,8 @@ namespace GL { enum class PixelType { UnsignedShort = 1337 }; /* Clang -Wmissing-prototypes warns otherwise, even though this is in an anonymous namespace */ - UnsignedInt pixelSize(PixelFormat, PixelType); - UnsignedInt pixelSize(PixelFormat format, PixelType type) { + UnsignedInt pixelFormatSize(PixelFormat, PixelType); + UnsignedInt pixelFormatSize(PixelFormat format, PixelType type) { CORRADE_INTERNAL_ASSERT(format == PixelFormat::RGB); CORRADE_INTERNAL_ASSERT(type == PixelType::UnsignedShort); #ifdef CORRADE_NO_ASSERT @@ -186,8 +186,8 @@ namespace Vk { enum class PixelFormat { R32G32B32F = 42 }; /* Clang -Wmissing-prototypes warns otherwise, even though this is in an anonymous namespace */ - UnsignedInt pixelSize(PixelFormat); - UnsignedInt pixelSize(PixelFormat format) { + UnsignedInt pixelFormatSize(PixelFormat); + UnsignedInt pixelFormatSize(PixelFormat format) { CORRADE_INTERNAL_ASSERT(format == PixelFormat::R32G32B32F); #ifdef CORRADE_NO_ASSERT static_cast(format); diff --git a/src/Magnum/Trade/imageconverter.cpp b/src/Magnum/Trade/imageconverter.cpp index cbd824880..d21064171 100644 --- a/src/Magnum/Trade/imageconverter.cpp +++ b/src/Magnum/Trade/imageconverter.cpp @@ -478,7 +478,7 @@ no -C / --converter is specified, AnyImageConverter is used.)") Error{} << "Invalid raw pixel format" << args.value("importer"); return 4; } - const UnsignedInt pixelSize = Magnum::pixelSize(format); + const UnsignedInt pixelSize = pixelFormatSize(format); /* Read the file or map it if requested */ Containers::Array data;