Browse Source

Removed long-deprecated Image* constructors and functions taking void*.

Use constructors and functions taking Array/ArrayView instead.
pull/231/head
Vladimír Vondruš 8 years ago
parent
commit
4b47f69f02
  1. 39
      src/Magnum/BufferImage.h
  2. 23
      src/Magnum/Image.h
  3. 51
      src/Magnum/ImageView.h
  4. 7
      src/Magnum/PixelStorage.h
  5. 55
      src/Magnum/Test/ImageViewTest.cpp
  6. 12
      src/Magnum/Trade/ImageData.h

39
src/Magnum/BufferImage.h

@ -93,23 +93,6 @@ template<UnsignedInt dimensions> class BufferImage {
*/
explicit BufferImage(PixelFormat format, PixelType type, const VectorTypeFor<dimensions, Int>& 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<dimensions, Int>&, Containers::ArrayView<const void>, BufferUsage)
* @deprecated Use @ref BufferImage(PixelFormat, PixelType, const VectorTypeFor<dimensions, Int>&, Containers::ArrayView<const void>, BufferUsage)
* instead.
*/
explicit CORRADE_DEPRECATED("use BufferImage(PixelFormat, PixelType, const VectorTypeFor&, Containers::ArrayView, BufferUsage) instead") BufferImage(PixelFormat format, PixelType type, const VectorTypeFor<dimensions, Int>& 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<class T, std::size_t dataSize> explicit BufferImage(PixelFormat format, PixelType type, const VectorTypeFor<dimensions, Int>& size, const T(&data)[dataSize], BufferUsage usage): BufferImage{{}, format, type, size, Containers::ArrayView<const void>{data}, usage} {}
/* To avoid ambiguous overload when passing Containers::Array[View] */
template<class T> explicit BufferImage(PixelFormat format, PixelType type, const VectorTypeFor<dimensions, Int>& size, const Containers::Array<T>& data, BufferUsage usage): BufferImage{{}, format, type, size, Containers::ArrayView<const void>{data}, usage} {}
template<class T> explicit BufferImage(PixelFormat format, PixelType type, const VectorTypeFor<dimensions, Int>& size, const Containers::ArrayView<T>& data, BufferUsage usage): BufferImage{{}, format, type, size, Containers::ArrayView<const void>{data}, usage} {}
#endif
#endif
/**
* @brief Constructor
* @param storage Storage of pixel data
@ -218,28 +201,6 @@ template<UnsignedInt dimensions> class BufferImage {
setData({}, format, type, size, data, usage);
}
#ifdef MAGNUM_BUILD_DEPRECATED
/** @brief @copybrief setData(PixelFormat, PixelType, const VectorTypeFor<dimensions, Int>&, Containers::ArrayView<const void>, BufferUsage)
* @deprecated Use @ref setData(PixelFormat, PixelType, const VectorTypeFor<dimensions, Int>&, Containers::ArrayView<const void>, BufferUsage)
* instead.
*/
void CORRADE_DEPRECATED("use setData(PixelFormat, PixelType, const VectorTypeFor&, Containers::ArrayView, BufferUsage) instead") setData(PixelFormat format, PixelType type, const VectorTypeFor<dimensions, Int>& 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<class T, std::size_t dataSize> void setData(PixelFormat format, PixelType type, const VectorTypeFor<dimensions, Int>& size, const T(&data)[dataSize], BufferUsage usage) {
setData({}, format, type, size, Containers::ArrayView<const void>{data}, usage);
}
/* To avoid ambiguous overload when passing Containers::Array */
template<class T> void setData(PixelFormat format, PixelType type, const VectorTypeFor<dimensions, Int>& size, const Containers::Array<T>& data, BufferUsage usage) {
setData({}, format, type, size, Containers::ArrayView<const void>(data), usage);
}
#endif
#endif
/**
* @brief Release the image buffer
*

23
src/Magnum/Image.h

@ -66,19 +66,6 @@ template<UnsignedInt dimensions> class Image {
*/
explicit Image(PixelFormat format, PixelType type, const VectorTypeFor<dimensions, Int>& size, Containers::Array<char>&& data) noexcept: Image{{}, format, type, size, std::move(data)} {}
#ifdef MAGNUM_BUILD_DEPRECATED
/** @brief @copybrief Image(PixelFormat, PixelType, const VectorTypeFor<dimensions, Int>&, Containers::Array<char>&&)
* @deprecated Use @ref Image(PixelFormat, PixelType, const VectorTypeFor<dimensions, Int>&, Containers::Array<char>&&)
* instead.
*/
explicit CORRADE_DEPRECATED("use Image(PixelFormat, PixelType, const VectorTypeFor&, Containers::Array&&) instead") Image(PixelFormat format, PixelType type, const VectorTypeFor<dimensions, Int>& size, void* data) noexcept: Image{{}, format, type, size, Containers::Array<char>{reinterpret_cast<char*>(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<dimensions, Int>& 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<UnsignedInt dimensions> class Image {
setData({}, format, type, size, std::move(data));
}
#ifdef MAGNUM_BUILD_DEPRECATED
/** @brief @copybrief setData(PixelFormat, PixelType, const VectorTypeFor<dimensions, Int>&, Containers::Array<char>&&)
* @deprecated Use @ref setData(PixelFormat, PixelType, const VectorTypeFor<dimensions, Int>&, Containers::Array<char>&&)
* instead.
*/
void CORRADE_DEPRECATED("use setData(PixelFormat, PixelType, const VectorTypeFor&, Containers::ArrayView) instead") setData(PixelFormat format, PixelType type, const VectorTypeFor<dimensions, Int>& size, void* data) {
setData({}, format, type, size, Containers::Array<char>{reinterpret_cast<char*>(data), Implementation::imageDataSizeFor(format, type, size)});
}
#endif
/**
* @brief Release data storage
*

51
src/Magnum/ImageView.h

@ -35,10 +35,6 @@
#include "Magnum/PixelStorage.h"
#include "Magnum/Math/Vector4.h"
#ifdef MAGNUM_BUILD_DEPRECATED
#include <Corrade/Containers/Array.h>
#endif
namespace Magnum {
/**
@ -83,24 +79,6 @@ template<UnsignedInt dimensions> class ImageView {
*/
explicit ImageView(PixelFormat format, PixelType type, const VectorTypeFor<dimensions, Int>& size, Containers::ArrayView<const void> data) noexcept: ImageView{{}, format, type, size, data} {}
#ifdef MAGNUM_BUILD_DEPRECATED
/** @brief @copybrief ImageView(PixelFormat, PixelType, const VectorTypeFor<dimensions, Int>&, Containers::ArrayView<const void>)
* @deprecated Use @ref ImageView(PixelFormat, PixelType, const VectorTypeFor<dimensions, Int>&, Containers::ArrayView<const void>) instead.
*/
explicit CORRADE_DEPRECATED("use ImageView(PixelFormat, PixelType, const VectorTypeFor&, Containers::ArrayView) instead") ImageView(PixelFormat format, PixelType type, const VectorTypeFor<dimensions, Int>& size, const void* data) noexcept: ImageView{{}, format, type, size, {reinterpret_cast<const char*>(data), Implementation::imageDataSizeFor(format, type, size)}} {}
#ifndef DOXYGEN_GENERATING_OUTPUT
/* To avoid ambiguous overload when passing ArrayView<T> to the
constructor */
template<class T> explicit ImageView(PixelFormat format, PixelType type, const VectorTypeFor<dimensions, Int>& size, Containers::ArrayView<T> data): ImageView{{}, format, type, size, Containers::ArrayView<const void>{data}} {}
template<class T> explicit ImageView(PixelFormat format, PixelType type, const VectorTypeFor<dimensions, Int>& size, const Containers::Array<T>& data): ImageView{{}, format, type, size, Containers::ArrayView<const void>(data)} {}
/* To avoid decay of sized arrays and nullptr to const void* and
unwanted use of deprecated function */
template<class T, std::size_t dataSize> explicit ImageView(PixelFormat format, PixelType type, const VectorTypeFor<dimensions, Int>& size, const T(&data)[dataSize]): ImageView{{}, format, type, size, Containers::ArrayView<const void>{data}} {}
explicit ImageView(PixelFormat format, PixelType type, const VectorTypeFor<dimensions, Int>& size, std::nullptr_t): ImageView{{}, format, type, size, Containers::ArrayView<const void>{nullptr}} {}
#endif
#endif
/**
* @brief Constructor
* @param storage Storage of pixel data
@ -167,35 +145,6 @@ template<UnsignedInt dimensions> class ImageView {
_data = {reinterpret_cast<const char*>(data.data()), data.size()};
}
#ifdef MAGNUM_BUILD_DEPRECATED
/** @brief @copybrief setData(Containers::ArrayView<const void>)
* @deprecated Use @ref setData(Containers::ArrayView<const void>)
* instead.
*/
void CORRADE_DEPRECATED("use setData(Containers::ArrayView) instead") setData(const void* data) {
setData({reinterpret_cast<const char*>(data), Implementation::imageDataSize(*this)});
}
#ifndef DOXYGEN_GENERATING_OUTPUT
/* To avoid ambiguous overload when passing ArrayView<T> to the
function */
template<class T> void setData(Containers::ArrayView<const T> data) {
setData(Containers::ArrayView<const void>{data});
}
template<class T> void setData(const Containers::Array<T>& data) {
setData(Containers::ArrayView<const void>(data));
}
/* To avoid decay of sized arrays and nullptr to const void* and
unwanted use of deprecated function */
template<class T, std::size_t size> void setData(const T(&data)[size]) {
setData(Containers::ArrayView<const void>{data});
}
void setData(std::nullptr_t) {
setData(Containers::ArrayView<const void>{nullptr});
}
#endif
#endif
private:
PixelStorage _storage;
PixelFormat _format;

7
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 dimensions> std::size_t imageDataSizeFor(PixelFormat format, PixelType type, const Math::Vector<dimensions, Int>& size) {
return std::get<1>(PixelStorage{}.dataProperties(format, type, Vector3i::pad(size, 1))).product();
}
#endif
#ifndef MAGNUM_TARGET_GLES
template<std::size_t dimensions, class T> std::pair<std::size_t, std::size_t> compressedImageDataOffsetSizeFor(const T& image, const Math::Vector<dimensions, Int>& size) {
CORRADE_INTERNAL_ASSERT(image.storage().compressedBlockSize().product() && image.storage().compressedBlockDataSize());

55
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<char> view{data};
ImageView2D a{PixelFormat::RGB, PixelType::UnsignedByte, {1, 3}, view};
CORRADE_COMPARE(a.data(), data);
Containers::ArrayView<const char> cview{data};
ImageView2D b{PixelFormat::RGB, PixelType::UnsignedByte, {1, 3}, cview};
CORRADE_COMPARE(b.data(), data);
}
void ImageViewTest::constructDeprecatedArray() {
Containers::Array<char> 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<const char> view{data};
a.setData(view);
CORRADE_COMPARE(a.data(), data);
}
void ImageViewTest::setDataDeprecatedArray() {
ImageView2D a{PixelFormat::RGB, PixelType::UnsignedByte, {1, 3}, nullptr};
Containers::Array<char> data{12};
a.setData(data);
CORRADE_COMPARE(a.data(), data);
}
#endif
void ImageViewTest::setDataCompressed() {
const char data[8]{};
CompressedImageView2D a{

12
src/Magnum/Trade/ImageData.h

@ -75,18 +75,6 @@ template<UnsignedInt dimensions> class ImageData {
*/
explicit ImageData(PixelFormat format, PixelType type, const VectorTypeFor<dimensions, Int>& size, Containers::Array<char>&& 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<dimensions, Int>&, Containers::Array<char>&&, const void*)
* @deprecated Use @ref ImageData(PixelFormat, PixelType, const VectorTypeFor<dimensions, Int>&, Containers::Array<char>&&, const void*) instead.
*/
explicit CORRADE_DEPRECATED("use ImageData(PixelFormat, PixelType, const VectorTypeFor&, Containers::Array&&) instead") ImageData(PixelFormat format, PixelType type, const VectorTypeFor<dimensions, Int>& size, void* data) noexcept: ImageData{format, type, size, Containers::Array<char>{reinterpret_cast<char*>(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<dimensions, Int>& size, std::nullptr_t) noexcept: ImageData{{}, format, type, size, nullptr} {}
#endif
#endif
#ifndef MAGNUM_TARGET_GLES
/**
* @brief Construct compressed image data

Loading…
Cancel
Save