From 4b47f69f02e3ac33ff0bc31e9be32d99d28c45ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 23 Feb 2018 11:45:44 +0100 Subject: [PATCH] Removed long-deprecated Image* constructors and functions taking void*. Use constructors and functions taking Array/ArrayView instead. --- src/Magnum/BufferImage.h | 39 ---------------------- src/Magnum/Image.h | 23 ------------- src/Magnum/ImageView.h | 51 ---------------------------- src/Magnum/PixelStorage.h | 7 ---- src/Magnum/Test/ImageViewTest.cpp | 55 ------------------------------- src/Magnum/Trade/ImageData.h | 12 ------- 6 files changed, 187 deletions(-) diff --git a/src/Magnum/BufferImage.h b/src/Magnum/BufferImage.h index 0780df336..00de0407d 100644 --- a/src/Magnum/BufferImage.h +++ b/src/Magnum/BufferImage.h @@ -93,23 +93,6 @@ template class BufferImage { */ explicit BufferImage(PixelFormat format, PixelType type, const VectorTypeFor& size, Buffer&& buffer, std::size_t dataSize) noexcept: BufferImage{{}, format, type, size, std::move(buffer), dataSize} {} - #ifdef MAGNUM_BUILD_DEPRECATED - /** @brief @copybrief BufferImage(PixelFormat, PixelType, const VectorTypeFor&, Containers::ArrayView, BufferUsage) - * @deprecated Use @ref BufferImage(PixelFormat, PixelType, const VectorTypeFor&, Containers::ArrayView, BufferUsage) - * instead. - */ - explicit CORRADE_DEPRECATED("use BufferImage(PixelFormat, PixelType, const VectorTypeFor&, Containers::ArrayView, BufferUsage) instead") BufferImage(PixelFormat format, PixelType type, const VectorTypeFor& size, const void* data, BufferUsage usage): BufferImage{{}, format, type, size, {data, Implementation::imageDataSizeFor(format, type, size)}, usage} {} - - #ifndef DOXYGEN_GENERATING_OUTPUT - /* To avoid decay of sized arrays and nullptr to const void* and - unwanted use of deprecated function */ - template explicit BufferImage(PixelFormat format, PixelType type, const VectorTypeFor& size, const T(&data)[dataSize], BufferUsage usage): BufferImage{{}, format, type, size, Containers::ArrayView{data}, usage} {} - /* To avoid ambiguous overload when passing Containers::Array[View] */ - template explicit BufferImage(PixelFormat format, PixelType type, const VectorTypeFor& size, const Containers::Array& data, BufferUsage usage): BufferImage{{}, format, type, size, Containers::ArrayView{data}, usage} {} - template explicit BufferImage(PixelFormat format, PixelType type, const VectorTypeFor& size, const Containers::ArrayView& data, BufferUsage usage): BufferImage{{}, format, type, size, Containers::ArrayView{data}, usage} {} - #endif - #endif - /** * @brief Constructor * @param storage Storage of pixel data @@ -218,28 +201,6 @@ template class BufferImage { setData({}, format, type, size, data, usage); } - #ifdef MAGNUM_BUILD_DEPRECATED - /** @brief @copybrief setData(PixelFormat, PixelType, const VectorTypeFor&, Containers::ArrayView, BufferUsage) - * @deprecated Use @ref setData(PixelFormat, PixelType, const VectorTypeFor&, Containers::ArrayView, BufferUsage) - * instead. - */ - void CORRADE_DEPRECATED("use setData(PixelFormat, PixelType, const VectorTypeFor&, Containers::ArrayView, BufferUsage) instead") setData(PixelFormat format, PixelType type, const VectorTypeFor& size, const void* data, BufferUsage usage) { - setData({}, format, type, size, {data, Implementation::imageDataSizeFor(format, type, size)}, usage); - } - - #ifndef DOXYGEN_GENERATING_OUTPUT - /* To avoid decay of sized char arrays and nullptr to const void* and - unwanted use of deprecated function */ - template void setData(PixelFormat format, PixelType type, const VectorTypeFor& size, const T(&data)[dataSize], BufferUsage usage) { - setData({}, format, type, size, Containers::ArrayView{data}, usage); - } - /* To avoid ambiguous overload when passing Containers::Array */ - template void setData(PixelFormat format, PixelType type, const VectorTypeFor& size, const Containers::Array& data, BufferUsage usage) { - setData({}, format, type, size, Containers::ArrayView(data), usage); - } - #endif - #endif - /** * @brief Release the image buffer * diff --git a/src/Magnum/Image.h b/src/Magnum/Image.h index 40195f69c..bf8342f3d 100644 --- a/src/Magnum/Image.h +++ b/src/Magnum/Image.h @@ -66,19 +66,6 @@ template class Image { */ explicit Image(PixelFormat format, PixelType type, const VectorTypeFor& size, Containers::Array&& data) noexcept: Image{{}, format, type, size, std::move(data)} {} - #ifdef MAGNUM_BUILD_DEPRECATED - /** @brief @copybrief Image(PixelFormat, PixelType, const VectorTypeFor&, Containers::Array&&) - * @deprecated Use @ref Image(PixelFormat, PixelType, const VectorTypeFor&, Containers::Array&&) - * instead. - */ - explicit CORRADE_DEPRECATED("use Image(PixelFormat, PixelType, const VectorTypeFor&, Containers::Array&&) instead") Image(PixelFormat format, PixelType type, const VectorTypeFor& size, void* data) noexcept: Image{{}, format, type, size, Containers::Array{reinterpret_cast(data), Implementation::imageDataSizeFor(format, type, size)}} {} - #ifndef DOXYGEN_GENERATING_OUTPUT - /* To avoid decay of nullptr to const void* and unwanted use of - deprecated function */ - explicit Image(PixelFormat format, PixelType type, const VectorTypeFor& size, std::nullptr_t) noexcept: Image{{}, format, type, size, nullptr} {} - #endif - #endif - /** * @brief Constructor * @param storage Storage of pixel data @@ -199,16 +186,6 @@ template class Image { setData({}, format, type, size, std::move(data)); } - #ifdef MAGNUM_BUILD_DEPRECATED - /** @brief @copybrief setData(PixelFormat, PixelType, const VectorTypeFor&, Containers::Array&&) - * @deprecated Use @ref setData(PixelFormat, PixelType, const VectorTypeFor&, Containers::Array&&) - * instead. - */ - void CORRADE_DEPRECATED("use setData(PixelFormat, PixelType, const VectorTypeFor&, Containers::ArrayView) instead") setData(PixelFormat format, PixelType type, const VectorTypeFor& size, void* data) { - setData({}, format, type, size, Containers::Array{reinterpret_cast(data), Implementation::imageDataSizeFor(format, type, size)}); - } - #endif - /** * @brief Release data storage * diff --git a/src/Magnum/ImageView.h b/src/Magnum/ImageView.h index a8ce59b4d..4a4466509 100644 --- a/src/Magnum/ImageView.h +++ b/src/Magnum/ImageView.h @@ -35,10 +35,6 @@ #include "Magnum/PixelStorage.h" #include "Magnum/Math/Vector4.h" -#ifdef MAGNUM_BUILD_DEPRECATED -#include -#endif - namespace Magnum { /** @@ -83,24 +79,6 @@ template class ImageView { */ explicit ImageView(PixelFormat format, PixelType type, const VectorTypeFor& size, Containers::ArrayView data) noexcept: ImageView{{}, format, type, size, data} {} - #ifdef MAGNUM_BUILD_DEPRECATED - /** @brief @copybrief ImageView(PixelFormat, PixelType, const VectorTypeFor&, Containers::ArrayView) - * @deprecated Use @ref ImageView(PixelFormat, PixelType, const VectorTypeFor&, Containers::ArrayView) instead. - */ - explicit CORRADE_DEPRECATED("use ImageView(PixelFormat, PixelType, const VectorTypeFor&, Containers::ArrayView) instead") ImageView(PixelFormat format, PixelType type, const VectorTypeFor& size, const void* data) noexcept: ImageView{{}, format, type, size, {reinterpret_cast(data), Implementation::imageDataSizeFor(format, type, size)}} {} - - #ifndef DOXYGEN_GENERATING_OUTPUT - /* To avoid ambiguous overload when passing ArrayView to the - constructor */ - template explicit ImageView(PixelFormat format, PixelType type, const VectorTypeFor& size, Containers::ArrayView data): ImageView{{}, format, type, size, Containers::ArrayView{data}} {} - template explicit ImageView(PixelFormat format, PixelType type, const VectorTypeFor& size, const Containers::Array& data): ImageView{{}, format, type, size, Containers::ArrayView(data)} {} - /* To avoid decay of sized arrays and nullptr to const void* and - unwanted use of deprecated function */ - template explicit ImageView(PixelFormat format, PixelType type, const VectorTypeFor& size, const T(&data)[dataSize]): ImageView{{}, format, type, size, Containers::ArrayView{data}} {} - explicit ImageView(PixelFormat format, PixelType type, const VectorTypeFor& size, std::nullptr_t): ImageView{{}, format, type, size, Containers::ArrayView{nullptr}} {} - #endif - #endif - /** * @brief Constructor * @param storage Storage of pixel data @@ -167,35 +145,6 @@ template class ImageView { _data = {reinterpret_cast(data.data()), data.size()}; } - #ifdef MAGNUM_BUILD_DEPRECATED - /** @brief @copybrief setData(Containers::ArrayView) - * @deprecated Use @ref setData(Containers::ArrayView) - * instead. - */ - void CORRADE_DEPRECATED("use setData(Containers::ArrayView) instead") setData(const void* data) { - setData({reinterpret_cast(data), Implementation::imageDataSize(*this)}); - } - - #ifndef DOXYGEN_GENERATING_OUTPUT - /* To avoid ambiguous overload when passing ArrayView to the - function */ - template void setData(Containers::ArrayView data) { - setData(Containers::ArrayView{data}); - } - template void setData(const Containers::Array& data) { - setData(Containers::ArrayView(data)); - } - /* To avoid decay of sized arrays and nullptr to const void* and - unwanted use of deprecated function */ - template void setData(const T(&data)[size]) { - setData(Containers::ArrayView{data}); - } - void setData(std::nullptr_t) { - setData(Containers::ArrayView{nullptr}); - } - #endif - #endif - private: PixelStorage _storage; PixelFormat _format; diff --git a/src/Magnum/PixelStorage.h b/src/Magnum/PixelStorage.h index 2d61ea8b7..3256394fd 100644 --- a/src/Magnum/PixelStorage.h +++ b/src/Magnum/PixelStorage.h @@ -440,13 +440,6 @@ namespace Implementation { return imageDataSizeFor(image, image.size()); } - #ifdef MAGNUM_BUILD_DEPRECATED - /* Uses default pixel storage */ - template std::size_t imageDataSizeFor(PixelFormat format, PixelType type, const Math::Vector& size) { - return std::get<1>(PixelStorage{}.dataProperties(format, type, Vector3i::pad(size, 1))).product(); - } - #endif - #ifndef MAGNUM_TARGET_GLES template std::pair compressedImageDataOffsetSizeFor(const T& image, const Math::Vector& size) { CORRADE_INTERNAL_ASSERT(image.storage().compressedBlockSize().product() && image.storage().compressedBlockDataSize()); diff --git a/src/Magnum/Test/ImageViewTest.cpp b/src/Magnum/Test/ImageViewTest.cpp index bec0b2d6d..366acf304 100644 --- a/src/Magnum/Test/ImageViewTest.cpp +++ b/src/Magnum/Test/ImageViewTest.cpp @@ -36,16 +36,8 @@ struct ImageViewTest: TestSuite::Tester { void construct(); void constructNullptr(); void constructCompressed(); - #ifdef MAGNUM_BUILD_DEPRECATED - void constructDeprecatedArrayView(); - void constructDeprecatedArray(); - #endif void setData(); - #ifdef MAGNUM_BUILD_DEPRECATED - void setDataDeprecatedArrayView(); - void setDataDeprecatedArray(); - #endif void setDataCompressed(); }; @@ -53,16 +45,8 @@ ImageViewTest::ImageViewTest() { addTests({&ImageViewTest::construct, &ImageViewTest::constructNullptr, &ImageViewTest::constructCompressed, - #ifdef MAGNUM_BUILD_DEPRECATED - &ImageViewTest::constructDeprecatedArrayView, - &ImageViewTest::constructDeprecatedArray, - #endif &ImageViewTest::setData, - #ifdef MAGNUM_BUILD_DEPRECATED - &ImageViewTest::setDataDeprecatedArrayView, - &ImageViewTest::setDataDeprecatedArray, - #endif &ImageViewTest::setDataCompressed}); } @@ -101,26 +85,6 @@ void ImageViewTest::constructCompressed() { CORRADE_COMPARE(a.data(), data); } -#ifdef MAGNUM_BUILD_DEPRECATED -void ImageViewTest::constructDeprecatedArrayView() { - char data[12]{}; - Containers::ArrayView view{data}; - ImageView2D a{PixelFormat::RGB, PixelType::UnsignedByte, {1, 3}, view}; - CORRADE_COMPARE(a.data(), data); - - Containers::ArrayView cview{data}; - ImageView2D b{PixelFormat::RGB, PixelType::UnsignedByte, {1, 3}, cview}; - CORRADE_COMPARE(b.data(), data); -} - -void ImageViewTest::constructDeprecatedArray() { - Containers::Array data{12}; - ImageView2D a{PixelFormat::RGB, PixelType::UnsignedByte, {1, 3}, data}; - - CORRADE_COMPARE(a.data(), data); -} -#endif - void ImageViewTest::setData() { const char data[3*3]{}; ImageView2D a{PixelStorage{}.setAlignment(1), @@ -135,25 +99,6 @@ void ImageViewTest::setData() { CORRADE_COMPARE(a.data(), data2); } -#ifdef MAGNUM_BUILD_DEPRECATED -void ImageViewTest::setDataDeprecatedArrayView() { - ImageView2D a{PixelFormat::RGB, PixelType::UnsignedByte, {1, 3}, nullptr}; - - const char data[12]{}; - Containers::ArrayView view{data}; - a.setData(view); - CORRADE_COMPARE(a.data(), data); -} - -void ImageViewTest::setDataDeprecatedArray() { - ImageView2D a{PixelFormat::RGB, PixelType::UnsignedByte, {1, 3}, nullptr}; - - Containers::Array data{12}; - a.setData(data); - CORRADE_COMPARE(a.data(), data); -} -#endif - void ImageViewTest::setDataCompressed() { const char data[8]{}; CompressedImageView2D a{ diff --git a/src/Magnum/Trade/ImageData.h b/src/Magnum/Trade/ImageData.h index 7a70ad2e3..dbc05444a 100644 --- a/src/Magnum/Trade/ImageData.h +++ b/src/Magnum/Trade/ImageData.h @@ -75,18 +75,6 @@ template class ImageData { */ explicit ImageData(PixelFormat format, PixelType type, const VectorTypeFor& size, Containers::Array&& data, const void* importerState = nullptr) noexcept: ImageData{{}, format, type, size, std::move(data), importerState} {} - #ifdef MAGNUM_BUILD_DEPRECATED - /** @brief @copybrief ImageData(PixelFormat, PixelType, const VectorTypeFor&, Containers::Array&&, const void*) - * @deprecated Use @ref ImageData(PixelFormat, PixelType, const VectorTypeFor&, Containers::Array&&, const void*) instead. - */ - explicit CORRADE_DEPRECATED("use ImageData(PixelFormat, PixelType, const VectorTypeFor&, Containers::Array&&) instead") ImageData(PixelFormat format, PixelType type, const VectorTypeFor& size, void* data) noexcept: ImageData{format, type, size, Containers::Array{reinterpret_cast(data), Magnum::Implementation::imageDataSizeFor(format, type, size)}} {} - #ifndef DOXYGEN_GENERATING_OUTPUT - /* To avoid decay of nullptr to const void* and unwanted use of - deprecated function */ - explicit ImageData(PixelFormat format, PixelType type, const VectorTypeFor& size, std::nullptr_t) noexcept: ImageData{{}, format, type, size, nullptr} {} - #endif - #endif - #ifndef MAGNUM_TARGET_GLES /** * @brief Construct compressed image data