From 36ee7835d6570b5eb90a11877afa5d9a78284395 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 16 Jun 2022 15:18:04 +0200 Subject: [PATCH] Return a const& from Image{View,Data}::size(), instead of a value. Allows creating a StridedArrayView slice on the sizes to feed them to various algorithms, instead of first having to copy the sizes out to a freshly allocated array. --- doc/changelog.dox | 4 ++++ src/Magnum/Image.h | 4 ++-- src/Magnum/ImageView.h | 4 ++-- src/Magnum/Trade/ImageData.h | 4 ++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/doc/changelog.dox b/doc/changelog.dox index 76f5a0784..712da2115 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -329,6 +329,10 @@ See also: - @ref MeshIndexType was enlarged to 32 bits and can now wrap implementation-specific values similar to @ref PixelFormat, @ref CompressedPixelFormat, @ref VertexFormat and @ref MeshPrimitive +- @ref Image::size(), @ref ImageView::size() as well as + @ref Trade::ImageData::size() now return a @cpp const& @ce instead of a + value to allow creating a @relativeref{Corrade,Containers::StridedArrayView} + slice onto this member. @subsubsection changelog-latest-changes-debugtools DebugTools library diff --git a/src/Magnum/Image.h b/src/Magnum/Image.h index a60ed3fae..158a9a074 100644 --- a/src/Magnum/Image.h +++ b/src/Magnum/Image.h @@ -364,7 +364,7 @@ template class Image { UnsignedInt pixelSize() const { return _pixelSize; } /** @brief Image size in pixels */ - VectorTypeFor size() const { return _size; } + const VectorTypeFor& size() const { return _size; } /** * @brief Image data properties @@ -470,7 +470,7 @@ template class Image { PixelFormat _format; UnsignedInt _formatExtra; UnsignedInt _pixelSize; - Math::Vector _size; + VectorTypeFor _size; Containers::Array _data; }; diff --git a/src/Magnum/ImageView.h b/src/Magnum/ImageView.h index 14546b6ff..65ac7082b 100644 --- a/src/Magnum/ImageView.h +++ b/src/Magnum/ImageView.h @@ -410,7 +410,7 @@ template class ImageView { UnsignedInt pixelSize() const { return _pixelSize; } /** @brief Image size in pixels */ - constexpr VectorTypeFor size() const { return _size; } + constexpr const VectorTypeFor& size() const { return _size; } /** * @brief Image data properties @@ -484,7 +484,7 @@ template class ImageView { PixelFormat _format; UnsignedInt _formatExtra; UnsignedInt _pixelSize; - Math::Vector _size; + VectorTypeFor _size; Containers::ArrayView _data; }; diff --git a/src/Magnum/Trade/ImageData.h b/src/Magnum/Trade/ImageData.h index 1bd127bcc..f9a265fd8 100644 --- a/src/Magnum/Trade/ImageData.h +++ b/src/Magnum/Trade/ImageData.h @@ -524,7 +524,7 @@ template class ImageData { UnsignedInt pixelSize() const; /** @brief Image size in pixels */ - VectorTypeFor size() const { return _size; } + const VectorTypeFor& size() const { return _size; } /** * @brief Uncompressed image data properties @@ -693,7 +693,7 @@ template class ImageData { }; UnsignedInt _formatExtra; UnsignedInt _pixelSize; - Math::Vector _size; + VectorTypeFor _size; Containers::Array _data; const void* _importerState; };