diff --git a/doc/changelog.dox b/doc/changelog.dox index 198b85344..3d0831756 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -489,6 +489,12 @@ See also: is deprecated for doing too many things at once and being too tied to one particular STL container, use @ref MeshTools::generateFlatNormals(const Containers::StridedArrayView1D&) instead +- Templated versions of @ref Image::data(), @ref ImageView::data(), + @ref CompressedImage::data(), @ref CompressedImageView::data() and + @ref Trade::ImageData::data() that returned a raw pointer are deprecated, + use the non-templated version together with + @ref Corrade::Containers::arrayCast() instead for properly bounds-checked + type conversion @subsection changelog-latest-compatibility Potential compatibility breakages, removed APIs diff --git a/src/Magnum/Image.h b/src/Magnum/Image.h index c5324a80c..b4b8aad20 100644 --- a/src/Magnum/Image.h +++ b/src/Magnum/Image.h @@ -364,15 +364,27 @@ template class Image { Containers::ArrayView data() const & { return _data; } Containers::ArrayView data() const && = delete; /**< @overload */ - /** @overload */ - template T* data() { + #ifdef MAGNUM_BUILD_DEPRECATED + /** + * @brief Image data in a particular type + * @deprecated Use non-templated @ref data() together with + * @ref Corrade::Containers::arrayCast() instead for properly + * bounds-checked type conversion. + */ + template CORRADE_DEPRECATED("use data() together with Containers::arrayCast() instead") T* data() { return reinterpret_cast(_data.data()); } - /** @overload */ - template const T* data() const { + /** + * @brief Image data in a particular type + * @deprecated Use non-templated @ref data() together with + * @ref Corrade::Containers::arrayCast() instead for properly + * bounds-checked type conversion. + */ + template CORRADE_DEPRECATED("use data() together with Containers::arrayCast() instead") const T* data() const { return reinterpret_cast(_data.data()); } + #endif /** * @brief View on pixel data @@ -580,15 +592,27 @@ template class CompressedImage { /** @overload */ Containers::ArrayView data() const { return _data; } - /** @overload */ - template T* data() { + #ifdef MAGNUM_BUILD_DEPRECATED + /** + * @brief Image data in a particular type + * @deprecated Use non-templated @ref data() together with + * @ref Corrade::Containers::arrayCast() instead for properly + * bounds-checked type conversion. + */ + template CORRADE_DEPRECATED("use data() together with Containers::arrayCast() instead") T* data() { return reinterpret_cast(_data.data()); } - /** @overload */ - template const T* data() const { + /** + * @brief Image data in a particular type + * @deprecated Use non-templated @ref data() together with + * @ref Corrade::Containers::arrayCast() instead for properly + * bounds-checked type conversion. + */ + template CORRADE_DEPRECATED("use data() together with Containers::arrayCast() instead") const T* data() const { return reinterpret_cast(_data.data()); } + #endif /** * @brief Release data storage diff --git a/src/Magnum/ImageView.h b/src/Magnum/ImageView.h index 1e76af1bc..da8e0292f 100644 --- a/src/Magnum/ImageView.h +++ b/src/Magnum/ImageView.h @@ -373,10 +373,17 @@ template class ImageView { */ Containers::ArrayView data() const { return _data; } - /** @overload */ - template const T* data() const { + #ifdef MAGNUM_BUILD_DEPRECATED + /** + * @brief Image data in a particular type + * @deprecated Use non-templated @ref data() together with + * @ref Corrade::Containers::arrayCast() instead for properly + * bounds-checked type conversion. + */ + template CORRADE_DEPRECATED("use data() together with Containers::arrayCast() instead") const T* data() const { return reinterpret_cast(_data.data()); } + #endif /** * @brief Set image data @@ -612,10 +619,17 @@ template class CompressedImageView { /** @brief Image data */ Containers::ArrayView data() const { return _data; } - /** @overload */ - template const T* data() const { + #ifdef MAGNUM_BUILD_DEPRECATED + /** + * @brief Image data in a particular type + * @deprecated Use non-templated @ref data() together with + * @ref Corrade::Containers::arrayCast() instead for properly + * bounds-checked type conversion. + */ + template CORRADE_DEPRECATED("use data() together with Containers::arrayCast() instead") const T* data() const { return reinterpret_cast(_data.data()); } + #endif /** * @brief Set image data diff --git a/src/Magnum/Trade/ImageData.h b/src/Magnum/Trade/ImageData.h index 3452d84bd..0ed1d224c 100644 --- a/src/Magnum/Trade/ImageData.h +++ b/src/Magnum/Trade/ImageData.h @@ -340,15 +340,27 @@ template class ImageData { Containers::ArrayView data() const & { return _data; } Containers::ArrayView data() const && = delete; /**< @overload */ - /** @overload */ - template T* data() { + #ifdef MAGNUM_BUILD_DEPRECATED + /** + * @brief Image data in a particular type + * @deprecated Use non-templated @ref data() together with + * @ref Corrade::Containers::arrayCast() instead for properly + * bounds-checked type conversion. + */ + template CORRADE_DEPRECATED("use data() together with Containers::arrayCast() instead") T* data() { return reinterpret_cast(_data.data()); } - /** @overload */ - template const T* data() const { + /** + * @brief Image data in a particular type + * @deprecated Use non-templated @ref data() together with + * @ref Corrade::Containers::arrayCast() instead for properly + * bounds-checked type conversion. + */ + template CORRADE_DEPRECATED("use data() together with Containers::arrayCast() instead") const T* data() const { return reinterpret_cast(_data.data()); } + #endif /** * @brief View on pixel data