From ac90cd8a4517841448aa367ae0fcef210475719d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 14 Dec 2012 22:03:02 +0100 Subject: [PATCH] Removed TypeTraits::imageType() and related function in *Image* classes. It is now ambiguous whether data passed as `std::int8_t` are of Type::Byte, Type::ByteInteger or whatnot. The user now must explicitly specify both format and type. --- src/BufferedImage.h | 18 ------------------ src/Image.h | 27 --------------------------- src/ImageWrapper.h | 14 -------------- src/Trade/ImageData.h | 14 -------------- src/TypeTraits.h | 29 +++-------------------------- 5 files changed, 3 insertions(+), 99 deletions(-) diff --git a/src/BufferedImage.h b/src/BufferedImage.h index b87756e09..9cbe3a119 100644 --- a/src/BufferedImage.h +++ b/src/BufferedImage.h @@ -25,7 +25,6 @@ #include "AbstractImage.h" #include "Buffer.h" #include "DimensionTraits.h" -#include "TypeTraits.h" namespace Magnum { @@ -74,23 +73,6 @@ template class MAGNUM_EXPORT BufferedImage: public Abst /** @brief %Image buffer */ inline Buffer* buffer() { return &_buffer; } - /** - * @brief Set image data - * @param size %Image size - * @param format Format of pixel data. Data type is - * detected from passed data array. - * @param data %Image data - * @param usage %Image buffer usage - * - * Updates the image buffer with given data. The data are not deleted - * after filling the buffer. - * - * @see setData(const Math::Vector&, Format, Type, const GLvoid*, Buffer::Usage) - */ - template inline void setData(const typename DimensionTraits::VectorType& size, Format format, const T* data, Buffer::Usage usage) { - setData(size, format, TypeTraits::imageType(), data, usage); - } - /** * @brief Set image data * @param size %Image size diff --git a/src/Image.h b/src/Image.h index a28ac8863..e447c2c9f 100644 --- a/src/Image.h +++ b/src/Image.h @@ -22,7 +22,6 @@ #include "Math/Vector3.h" #include "AbstractImage.h" #include "DimensionTraits.h" -#include "TypeTraits.h" namespace Magnum { @@ -37,18 +36,6 @@ template class Image: public AbstractImage { public: const static std::uint8_t Dimensions = dimensions; /**< @brief %Image dimension count */ - /** - * @brief Constructor - * @param size %Image size - * @param format Format of pixel data. Data type is - * detected from passed data array. - * @param data %Image data with proper size - * - * Note that the image data are not copied on construction, but they - * are deleted on class destruction. - */ - template inline Image(const typename DimensionTraits::VectorType& size, Format format, T* data): AbstractImage(format, TypeTraits::imageType()), _size(size), _data(data) {} - /** * @brief Constructor * @param size %Image size @@ -81,20 +68,6 @@ template class Image: public AbstractImage { inline void* data() { return _data; } inline const void* data() const { return _data; } /**< @overload */ - /** - * @brief Set image data - * @param size %Image size - * @param format Format of pixel data. Data type is - * detected from passed data array. - * @param data %Image data - * - * Deletes previous data and replaces them with new. Note that the - * data are not copied, but they are deleted on destruction. - */ - template inline void setData(const typename DimensionTraits::VectorType& size, Format format, T* data) { - setData(size, format, TypeTraits::imageType(), data); - } - /** * @brief Set image data * @param size %Image size diff --git a/src/ImageWrapper.h b/src/ImageWrapper.h index 59b4e3508..f02b79667 100644 --- a/src/ImageWrapper.h +++ b/src/ImageWrapper.h @@ -22,7 +22,6 @@ #include "Math/Vector3.h" #include "AbstractImage.h" #include "DimensionTraits.h" -#include "TypeTraits.h" namespace Magnum { @@ -44,19 +43,6 @@ Interchangeable with Image, BufferedImage or Trade::ImageData. template class ImageWrapper: public AbstractImage { public: const static std::uint8_t Dimensions = dimensions; /**< @brief %Image dimension count */ - - /** - * @brief Constructor - * @param size %Image size - * @param format Format of pixel data. Data type is - * detected from passed data array. - * @param data %Image data with proper size - * - * Note that the image data are not copied on construction, but they - * are deleted on class destruction. - */ - template inline ImageWrapper(const typename DimensionTraits::VectorType& size, Format format, T* data): AbstractImage(format, TypeTraits::imageType()), _size(size), _data(data) {} - /** * @brief Constructor * @param size %Image size diff --git a/src/Trade/ImageData.h b/src/Trade/ImageData.h index eaa9e052b..b1d250ab7 100644 --- a/src/Trade/ImageData.h +++ b/src/Trade/ImageData.h @@ -22,7 +22,6 @@ #include "Math/Vector3.h" #include "AbstractImage.h" #include "DimensionTraits.h" -#include "TypeTraits.h" namespace Magnum { namespace Trade { @@ -37,19 +36,6 @@ template class ImageData: public AbstractImage { public: const static std::uint8_t Dimensions = dimensions; /**< @brief %Image dimension count */ - /** - * @brief Constructor - * @param name %Image name - * @param size %Image size - * @param format Format of pixel data. Data type is - * detected from passed data array. - * @param data %Image data - * - * Note that the image data are not copied on construction, but they - * are deleted on class destruction. - */ - template inline ImageData(const std::string& name, const typename DimensionTraits::VectorType& size, Format format, T* data): AbstractImage(format, TypeTraits::imageType()), _name(name), _size(size), _data(reinterpret_cast(data)) {} - /** * @brief Constructor * @param name %Image name diff --git a/src/TypeTraits.h b/src/TypeTraits.h index d1f1f4cae..be2d5fc81 100644 --- a/src/TypeTraits.h +++ b/src/TypeTraits.h @@ -22,7 +22,9 @@ #include #include "Math/MathTypeTraits.h" -#include "AbstractImage.h" +#include "Magnum.h" + +#include "magnumVisibility.h" namespace Magnum { @@ -68,15 +70,6 @@ template struct TypeTraits: Math::MathTypeTraits { */ inline constexpr static Type indexType(); - /** - * @brief OpenGL type ID for pixel data - * - * Implemented only in types which can be used for image data, like - * GLubyte. This function is not present for types unusable for image data, - * like GLdouble and Matrix3. - */ - inline constexpr static AbstractImage::Type imageType(); - /** * @brief Size of plain OpenGL type * @@ -182,7 +175,6 @@ template<> struct TypeTraits: Math::MathTypeTraits { /* Can not be used for attributes */ inline constexpr static Type type() { return Type::UnsignedByte; } inline constexpr static Type indexType() { return Type::UnsignedByte; } - inline constexpr static AbstractImage::Type imageType() { return AbstractImage::Type::UnsignedByte; } inline constexpr static std::size_t size() { return sizeof(GLubyte); } inline constexpr static std::size_t count() { return 1; } }; @@ -191,9 +183,6 @@ template<> struct TypeTraits: Math::MathTypeTraits { /* Can not be used for attributes */ inline constexpr static Type type() { return Type::Byte; } /* Can not be used for indices */ - #ifndef MAGNUM_TARGET_GLES2 - inline constexpr static AbstractImage::Type imageType() { return AbstractImage::Type::Byte; } - #endif inline constexpr static std::size_t size() { return sizeof(GLbyte); } inline constexpr static std::size_t count() { return 1; } }; @@ -202,7 +191,6 @@ template<> struct TypeTraits: Math::MathTypeTraits { /* Can not be used for attributes */ inline constexpr static Type type() { return Type::UnsignedShort; } inline constexpr static Type indexType() { return Type::UnsignedShort; } - inline constexpr static AbstractImage::Type imageType() { return AbstractImage::Type::UnsignedShort; } inline constexpr static std::size_t size() { return sizeof(GLushort); } inline constexpr static std::size_t count() { return 1; } }; @@ -211,9 +199,6 @@ template<> struct TypeTraits: Math::MathTypeTraits { /* Can not be used for attributes */ inline constexpr static Type type() { return Type::Short; } /* Can not be used for indices */ - #ifndef MAGNUM_TARGET_GLES2 - inline constexpr static AbstractImage::Type imageType() { return AbstractImage::Type::Short; } - #endif inline constexpr static std::size_t size() { return sizeof(GLshort); } inline constexpr static std::size_t count() { return 1; } }; @@ -222,7 +207,6 @@ template<> struct TypeTraits: Math::MathTypeTraits { typedef GLuint AttributeType; inline constexpr static Type type() { return Type::UnsignedInt; } inline constexpr static Type indexType() { return Type::UnsignedInt; } - inline constexpr static AbstractImage::Type imageType() { return AbstractImage::Type::UnsignedInt; } inline constexpr static std::size_t size() { return sizeof(GLuint); } inline constexpr static std::size_t count() { return 1; } }; @@ -231,9 +215,6 @@ template<> struct TypeTraits: Math::MathTypeTraits { typedef GLint AttributeType; inline constexpr static Type type() { return Type::Int; } /* Can not be used for indices */ - #ifndef MAGNUM_TARGET_GLES2 - inline constexpr static AbstractImage::Type imageType() { return AbstractImage::Type::Int; } - #endif inline constexpr static std::size_t size() { return sizeof(GLint); } inline constexpr static std::size_t count() { return 1; } }; @@ -242,7 +223,6 @@ template<> struct TypeTraits: Math::MathTypeTraits { typedef GLfloat AttributeType; inline constexpr static Type type() { return Type::Float; } /* Can not be used for indices */ - inline constexpr static AbstractImage::Type imageType() { return AbstractImage::Type::Float; } inline constexpr static std::size_t size() { return sizeof(GLfloat); } inline constexpr static std::size_t count() { return 1; } }; @@ -252,7 +232,6 @@ template<> struct TypeTraits: Math::MathTypeTraits { typedef GLdouble AttributeType; inline constexpr static Type type() { return Type::Double; } /* Can not be used for indices */ - /* Can not be used for images */ inline constexpr static std::size_t size() { return sizeof(GLdouble); } inline constexpr static std::size_t count() { return 1; } }; @@ -264,7 +243,6 @@ namespace Implementation { inline constexpr static Type type() { return TypeTraits::type(); } /* Might be used for attributes, see below */ /* Can not be used for indices */ - /* Can not be used for images */ inline constexpr static std::size_t size() { return sizeof(T); } inline constexpr static std::size_t count() { return vectorSize; } }; @@ -311,7 +289,6 @@ namespace Implementation { inline constexpr static Type type() { return TypeTraits::type(); } /* Might be used for attributes, see below */ /* Can not be used for indices */ - /* Can not be used for images */ inline constexpr static std::size_t size() { return sizeof(T); } inline constexpr static std::size_t count() { return rows; } inline constexpr static std::size_t vectors() { return cols; }