Browse Source

De-inline Image headers, remove dependency on ImageView.

This means users have to add some more #includes on their side. Sorry
but it's for your own good :P
pull/362/head
Vladimír Vondruš 7 years ago
parent
commit
93789721b2
  1. 1
      doc/generated/primitives.cpp
  2. 1
      doc/generated/shaders.cpp
  3. 1
      doc/snippets/Magnum.cpp
  4. 1
      doc/snippets/MagnumDebugTools.cpp
  5. 1
      doc/snippets/MagnumGL.cpp
  6. 1
      doc/snippets/MagnumTrade.cpp
  7. 1
      doc/snippets/debugtools-compareimage.cpp
  8. 2
      src/Magnum/CMakeLists.txt
  9. 1
      src/Magnum/DebugTools/Screenshot.cpp
  10. 1
      src/Magnum/DebugTools/Test/ForceRendererGLTest.cpp
  11. 1
      src/Magnum/DebugTools/Test/ObjectRendererGLTest.cpp
  12. 1
      src/Magnum/DebugTools/Test/TextureImageGLTest.cpp
  13. 1
      src/Magnum/GL/AbstractTexture.cpp
  14. 39
      src/Magnum/GL/BufferImage.cpp
  15. 38
      src/Magnum/GL/BufferImage.h
  16. 1
      src/Magnum/GL/CubeMapTexture.cpp
  17. 1
      src/Magnum/GL/Test/AbstractShaderProgramGLTest.cpp
  18. 1
      src/Magnum/GL/Test/CubeMapTextureArrayGLTest.cpp
  19. 1
      src/Magnum/GL/Test/CubeMapTextureGLTest.cpp
  20. 1
      src/Magnum/GL/Test/FramebufferGLTest.cpp
  21. 1
      src/Magnum/GL/Test/PixelStorageGLTest.cpp
  22. 1
      src/Magnum/GL/Test/RectangleTextureGLTest.cpp
  23. 1
      src/Magnum/GL/Test/TextureArrayGLTest.cpp
  24. 1
      src/Magnum/GL/Test/TextureGLTest.cpp
  25. 68
      src/Magnum/Image.cpp
  26. 68
      src/Magnum/Image.h
  27. 10
      src/Magnum/ImageView.cpp
  28. 18
      src/Magnum/ImageView.h
  29. 16
      src/Magnum/Implementation/ImageProperties.h
  30. 1
      src/Magnum/MeshTools/Test/CompileGLTest.cpp
  31. 13
      src/Magnum/PixelStorage.h
  32. 1
      src/Magnum/Test/ImageTest.cpp
  33. 1
      src/Magnum/Text/AbstractGlyphCache.cpp
  34. 1
      src/Magnum/Text/Test/AbstractGlyphCacheTest.cpp
  35. 1
      src/Magnum/TextureTools/Test/DistanceFieldGLTest.cpp
  36. 1
      src/Magnum/TextureTools/distancefieldconverter.cpp
  37. 1
      src/Magnum/Trade/AbstractImageConverter.cpp
  38. 43
      src/Magnum/Trade/ImageData.cpp
  39. 43
      src/Magnum/Trade/ImageData.h
  40. 1
      src/Magnum/Trade/Test/AbstractImageConverterTest.cpp
  41. 1
      src/Magnum/Trade/Test/ImageDataTest.cpp
  42. 1
      src/MagnumPlugins/AnyImageConverter/Test/AnyImageConverterTest.cpp
  43. 1
      src/MagnumPlugins/MagnumFont/MagnumFont.cpp
  44. 1
      src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.cpp
  45. 2
      src/MagnumPlugins/TgaImageConverter/Test/TgaImageConverterTest.cpp
  46. 2
      src/MagnumPlugins/TgaImageConverter/TgaImageConverter.cpp

1
doc/generated/primitives.cpp

@ -40,6 +40,7 @@
#endif #endif
#include <Magnum/Image.h> #include <Magnum/Image.h>
#include <Magnum/ImageView.h>
#include <Magnum/PixelFormat.h> #include <Magnum/PixelFormat.h>
#include <Magnum/GL/Buffer.h> #include <Magnum/GL/Buffer.h>
#include <Magnum/GL/Framebuffer.h> #include <Magnum/GL/Framebuffer.h>

1
doc/generated/shaders.cpp

@ -39,6 +39,7 @@
#endif #endif
#include <Magnum/Image.h> #include <Magnum/Image.h>
#include <Magnum/ImageView.h>
#include <Magnum/PixelFormat.h> #include <Magnum/PixelFormat.h>
#include <Magnum/GL/Buffer.h> #include <Magnum/GL/Buffer.h>
#include <Magnum/GL/Framebuffer.h> #include <Magnum/GL/Framebuffer.h>

1
doc/snippets/Magnum.cpp

@ -27,6 +27,7 @@
#include "Magnum/Math/Color.h" #include "Magnum/Math/Color.h"
#include "Magnum/Image.h" #include "Magnum/Image.h"
#include "Magnum/ImageView.h"
#include "Magnum/PixelFormat.h" #include "Magnum/PixelFormat.h"
#ifdef MAGNUM_TARGET_GL #ifdef MAGNUM_TARGET_GL
#include "Magnum/ResourceManager.h" #include "Magnum/ResourceManager.h"

1
doc/snippets/MagnumDebugTools.cpp

@ -27,6 +27,7 @@
#include <Corrade/PluginManager/Manager.h> #include <Corrade/PluginManager/Manager.h>
#include "Magnum/Image.h" #include "Magnum/Image.h"
#include "Magnum/ImageView.h"
#include "Magnum/PixelFormat.h" #include "Magnum/PixelFormat.h"
#include "Magnum/DebugTools/CompareImage.h" #include "Magnum/DebugTools/CompareImage.h"
#include "Magnum/Math/Color.h" #include "Magnum/Math/Color.h"

1
doc/snippets/MagnumGL.cpp

@ -27,6 +27,7 @@
#include <Corrade/Containers/Reference.h> #include <Corrade/Containers/Reference.h>
#include "Magnum/Image.h" #include "Magnum/Image.h"
#include "Magnum/ImageView.h"
#include "Magnum/PixelFormat.h" #include "Magnum/PixelFormat.h"
#include "Magnum/GL/AbstractShaderProgram.h" #include "Magnum/GL/AbstractShaderProgram.h"
#include "Magnum/GL/Buffer.h" #include "Magnum/GL/Buffer.h"

1
doc/snippets/MagnumTrade.cpp

@ -28,6 +28,7 @@
#include <Corrade/Utility/Directory.h> #include <Corrade/Utility/Directory.h>
#include "Magnum/FileCallback.h" #include "Magnum/FileCallback.h"
#include "Magnum/ImageView.h"
#include "Magnum/PixelFormat.h" #include "Magnum/PixelFormat.h"
#include "Magnum/Animation/Player.h" #include "Magnum/Animation/Player.h"
#include "Magnum/MeshTools/Transform.h" #include "Magnum/MeshTools/Transform.h"

1
doc/snippets/debugtools-compareimage.cpp

@ -29,6 +29,7 @@
#include <Corrade/Utility/Directory.h> #include <Corrade/Utility/Directory.h>
#include "Magnum/Image.h" #include "Magnum/Image.h"
#include "Magnum/ImageView.h"
#include "Magnum/Trade/ImageData.h" #include "Magnum/Trade/ImageData.h"
#include "Magnum/Trade/AbstractImporter.h" #include "Magnum/Trade/AbstractImporter.h"
#include "Magnum/DebugTools/CompareImage.h" #include "Magnum/DebugTools/CompareImage.h"

2
src/Magnum/CMakeLists.txt

@ -64,7 +64,7 @@ set(Magnum_HEADERS
visibility.h) visibility.h)
set(Magnum_PRIVATE_HEADERS set(Magnum_PRIVATE_HEADERS
Implementation/ImagePixelView.h) Implementation/ImageProperties.h)
# Files shared between main library and math unit test library # Files shared between main library and math unit test library
set(MagnumMath_SRCS set(MagnumMath_SRCS

1
src/Magnum/DebugTools/Screenshot.cpp

@ -31,6 +31,7 @@
#include "Magnum/PixelFormat.h" #include "Magnum/PixelFormat.h"
#include "Magnum/Image.h" #include "Magnum/Image.h"
#include "Magnum/ImageView.h"
#include "Magnum/GL/AbstractFramebuffer.h" #include "Magnum/GL/AbstractFramebuffer.h"
#include "Magnum/GL/PixelFormat.h" #include "Magnum/GL/PixelFormat.h"
#include "Magnum/Trade/AbstractImageConverter.h" #include "Magnum/Trade/AbstractImageConverter.h"

1
src/Magnum/DebugTools/Test/ForceRendererGLTest.cpp

@ -28,6 +28,7 @@
#include <Corrade/Utility/Directory.h> #include <Corrade/Utility/Directory.h>
#include "Magnum/Image.h" #include "Magnum/Image.h"
#include "Magnum/ImageView.h"
#include "Magnum/PixelFormat.h" #include "Magnum/PixelFormat.h"
#include "Magnum/DebugTools/CompareImage.h" #include "Magnum/DebugTools/CompareImage.h"
#include "Magnum/DebugTools/ForceRenderer.h" #include "Magnum/DebugTools/ForceRenderer.h"

1
src/Magnum/DebugTools/Test/ObjectRendererGLTest.cpp

@ -28,6 +28,7 @@
#include <Corrade/Utility/Directory.h> #include <Corrade/Utility/Directory.h>
#include "Magnum/Image.h" #include "Magnum/Image.h"
#include "Magnum/ImageView.h"
#include "Magnum/PixelFormat.h" #include "Magnum/PixelFormat.h"
#include "Magnum/DebugTools/CompareImage.h" #include "Magnum/DebugTools/CompareImage.h"
#include "Magnum/DebugTools/ObjectRenderer.h" #include "Magnum/DebugTools/ObjectRenderer.h"

1
src/Magnum/DebugTools/Test/TextureImageGLTest.cpp

@ -26,6 +26,7 @@
#include <Corrade/TestSuite/Compare/Container.h> #include <Corrade/TestSuite/Compare/Container.h>
#include "Magnum/Image.h" #include "Magnum/Image.h"
#include "Magnum/ImageView.h"
#include "Magnum/PixelFormat.h" #include "Magnum/PixelFormat.h"
#include "Magnum/DebugTools/TextureImage.h" #include "Magnum/DebugTools/TextureImage.h"
#include "Magnum/GL/CubeMapTexture.h" #include "Magnum/GL/CubeMapTexture.h"

1
src/Magnum/GL/AbstractTexture.cpp

@ -30,6 +30,7 @@
#include "Magnum/Array.h" #include "Magnum/Array.h"
#include "Magnum/Image.h" #include "Magnum/Image.h"
#include "Magnum/ImageView.h"
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
#include "Magnum/GL/BufferImage.h" #include "Magnum/GL/BufferImage.h"
#endif #endif

39
src/Magnum/GL/BufferImage.cpp

@ -26,6 +26,7 @@
#include "BufferImage.h" #include "BufferImage.h"
#include "Magnum/GL/PixelFormat.h" #include "Magnum/GL/PixelFormat.h"
#include "Magnum/Implementation/ImageProperties.h"
namespace Magnum { namespace GL { namespace Magnum { namespace GL {
@ -48,8 +49,27 @@ template<UnsignedInt dimensions> BufferImage<dimensions>::BufferImage(const Pixe
template<UnsignedInt dimensions> BufferImage<dimensions>::BufferImage(NoCreateT) noexcept: _format{PixelFormat::RGBA}, _type{PixelType::UnsignedByte}, _buffer{NoCreate}, _dataSize{} {} template<UnsignedInt dimensions> BufferImage<dimensions>::BufferImage(NoCreateT) noexcept: _format{PixelFormat::RGBA}, _type{PixelType::UnsignedByte}, _buffer{NoCreate}, _dataSize{} {}
template<UnsignedInt dimensions> BufferImage<dimensions>::BufferImage(BufferImage<dimensions>&& other) noexcept: _storage{std::move(other._storage)}, _format{std::move(other._format)}, _type{std::move(other._type)}, _size{std::move(other._size)}, _buffer{std::move(other._buffer)}, _dataSize{std::move(other._dataSize)} {
other._size = {};
}
template<UnsignedInt dimensions> BufferImage<dimensions>& BufferImage<dimensions>::operator=(BufferImage<dimensions>&& other) noexcept {
using std::swap;
swap(_storage, other._storage);
swap(_format, other._format);
swap(_type, other._type);
swap(_size, other._size);
swap(_buffer, other._buffer);
swap(_dataSize, other._dataSize);
return *this;
}
template<UnsignedInt dimensions> UnsignedInt BufferImage<dimensions>::pixelSize() const { return GL::pixelSize(_format, _type); } template<UnsignedInt dimensions> UnsignedInt BufferImage<dimensions>::pixelSize() const { return GL::pixelSize(_format, _type); }
template<UnsignedInt dimensions> std::pair<VectorTypeFor<dimensions, std::size_t>, VectorTypeFor<dimensions, std::size_t>> BufferImage<dimensions>::dataProperties() const {
return Magnum::Implementation::imageDataProperties<dimensions>(*this);
}
template<UnsignedInt dimensions> void BufferImage<dimensions>::setData(const PixelStorage storage, const PixelFormat format, const PixelType type, const VectorTypeFor<dimensions, Int>& size, Containers::ArrayView<const void> const data, const BufferUsage usage) { template<UnsignedInt dimensions> void BufferImage<dimensions>::setData(const PixelStorage storage, const PixelFormat format, const PixelType type, const VectorTypeFor<dimensions, Int>& size, Containers::ArrayView<const void> const data, const BufferUsage usage) {
_storage = storage; _storage = storage;
_format = format; _format = format;
@ -84,6 +104,25 @@ template<UnsignedInt dimensions> CompressedBufferImage<dimensions>::CompressedBu
template<UnsignedInt dimensions> CompressedBufferImage<dimensions>::CompressedBufferImage(NoCreateT) noexcept: _format{}, _buffer{NoCreate}, _dataSize{} {} template<UnsignedInt dimensions> CompressedBufferImage<dimensions>::CompressedBufferImage(NoCreateT) noexcept: _format{}, _buffer{NoCreate}, _dataSize{} {}
template<UnsignedInt dimensions> CompressedBufferImage<dimensions>::CompressedBufferImage(CompressedBufferImage<dimensions>&& other) noexcept: _storage{std::move(other._storage)}, _format{std::move(other._format)}, _size{std::move(other._size)}, _buffer{std::move(other._buffer)}, _dataSize{std::move(other._dataSize)} {
other._size = {};
other._dataSize = {};
}
template<UnsignedInt dimensions> CompressedBufferImage<dimensions>& CompressedBufferImage<dimensions>::operator=(CompressedBufferImage<dimensions>&& other) noexcept {
using std::swap;
swap(_storage, other._storage);
swap(_format, other._format);
swap(_size, other._size);
swap(_buffer, other._buffer);
swap(_dataSize, other._dataSize);
return *this;
}
template<UnsignedInt dimensions> std::pair<VectorTypeFor<dimensions, std::size_t>, VectorTypeFor<dimensions, std::size_t>> CompressedBufferImage<dimensions>::dataProperties() const {
return Magnum::Implementation::compressedImageDataProperties<dimensions>(*this);
}
template<UnsignedInt dimensions> void CompressedBufferImage<dimensions>::setData(const CompressedPixelStorage storage, const CompressedPixelFormat format, const VectorTypeFor<dimensions, Int>& size, const Containers::ArrayView<const void> data, const BufferUsage usage) { template<UnsignedInt dimensions> void CompressedBufferImage<dimensions>::setData(const CompressedPixelStorage storage, const CompressedPixelFormat format, const VectorTypeFor<dimensions, Int>& size, const Containers::ArrayView<const void> data, const BufferUsage usage) {
_storage = storage; _storage = storage;
_format = format; _format = format;

38
src/Magnum/GL/BufferImage.h

@ -285,9 +285,7 @@ template<UnsignedInt dimensions> class BufferImage {
* *
* See @ref PixelStorage::dataProperties() for more information. * See @ref PixelStorage::dataProperties() for more information.
*/ */
std::pair<VectorTypeFor<dimensions, std::size_t>, VectorTypeFor<dimensions, std::size_t>> dataProperties() const { std::pair<VectorTypeFor<dimensions, std::size_t>, VectorTypeFor<dimensions, std::size_t>> dataProperties() const;
return Magnum::Implementation::imageDataProperties<dimensions>(*this);
}
/** @brief Currently allocated data size */ /** @brief Currently allocated data size */
std::size_t dataSize() const { return _dataSize; } std::size_t dataSize() const { return _dataSize; }
@ -597,9 +595,7 @@ template<UnsignedInt dimensions> class CompressedBufferImage {
* @requires_gl Compressed pixel storage is hardcoded in OpenGL ES and * @requires_gl Compressed pixel storage is hardcoded in OpenGL ES and
* WebGL. * WebGL.
*/ */
std::pair<VectorTypeFor<dimensions, std::size_t>, VectorTypeFor<dimensions, std::size_t>> dataProperties() const { std::pair<VectorTypeFor<dimensions, std::size_t>, VectorTypeFor<dimensions, std::size_t>> dataProperties() const;
return Magnum::Implementation::compressedImageDataProperties<dimensions>(*this);
}
/** /**
* @brief Image buffer * @brief Image buffer
@ -695,36 +691,6 @@ typedef CompressedBufferImage<2> CompressedBufferImage2D;
/** @brief Three-dimensional compressed buffer image */ /** @brief Three-dimensional compressed buffer image */
typedef CompressedBufferImage<3> CompressedBufferImage3D; typedef CompressedBufferImage<3> CompressedBufferImage3D;
template<UnsignedInt dimensions> inline BufferImage<dimensions>::BufferImage(BufferImage<dimensions>&& other) noexcept: _storage{std::move(other._storage)}, _format{std::move(other._format)}, _type{std::move(other._type)}, _size{std::move(other._size)}, _buffer{std::move(other._buffer)}, _dataSize{std::move(other._dataSize)} {
other._size = {};
}
template<UnsignedInt dimensions> inline CompressedBufferImage<dimensions>::CompressedBufferImage(CompressedBufferImage<dimensions>&& other) noexcept: _storage{std::move(other._storage)}, _format{std::move(other._format)}, _size{std::move(other._size)}, _buffer{std::move(other._buffer)}, _dataSize{std::move(other._dataSize)} {
other._size = {};
other._dataSize = {};
}
template<UnsignedInt dimensions> inline BufferImage<dimensions>& BufferImage<dimensions>::operator=(BufferImage<dimensions>&& other) noexcept {
using std::swap;
swap(_storage, other._storage);
swap(_format, other._format);
swap(_type, other._type);
swap(_size, other._size);
swap(_buffer, other._buffer);
swap(_dataSize, other._dataSize);
return *this;
}
template<UnsignedInt dimensions> inline CompressedBufferImage<dimensions>& CompressedBufferImage<dimensions>::operator=(CompressedBufferImage<dimensions>&& other) noexcept {
using std::swap;
swap(_storage, other._storage);
swap(_format, other._format);
swap(_size, other._size);
swap(_buffer, other._buffer);
swap(_dataSize, other._dataSize);
return *this;
}
}} }}
#else #else
#error this header is not available in OpenGL ES 2.0 build #error this header is not available in OpenGL ES 2.0 build

1
src/Magnum/GL/CubeMapTexture.cpp

@ -26,6 +26,7 @@
#include "CubeMapTexture.h" #include "CubeMapTexture.h"
#include "Magnum/Image.h" #include "Magnum/Image.h"
#include "Magnum/ImageView.h"
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
#include "Magnum/GL/BufferImage.h" #include "Magnum/GL/BufferImage.h"
#endif #endif

1
src/Magnum/GL/Test/AbstractShaderProgramGLTest.cpp

@ -30,6 +30,7 @@
#include <Corrade/Utility/Resource.h> #include <Corrade/Utility/Resource.h>
#include "Magnum/Image.h" #include "Magnum/Image.h"
#include "Magnum/ImageView.h"
#include "Magnum/GL/AbstractShaderProgram.h" #include "Magnum/GL/AbstractShaderProgram.h"
#include "Magnum/GL/Context.h" #include "Magnum/GL/Context.h"
#include "Magnum/GL/Extensions.h" #include "Magnum/GL/Extensions.h"

1
src/Magnum/GL/Test/CubeMapTextureArrayGLTest.cpp

@ -26,6 +26,7 @@
#include <Corrade/TestSuite/Compare/Container.h> #include <Corrade/TestSuite/Compare/Container.h>
#include "Magnum/Image.h" #include "Magnum/Image.h"
#include "Magnum/ImageView.h"
#include "Magnum/GL/BufferImage.h" #include "Magnum/GL/BufferImage.h"
#include "Magnum/GL/CubeMapTextureArray.h" #include "Magnum/GL/CubeMapTextureArray.h"
#include "Magnum/GL/Context.h" #include "Magnum/GL/Context.h"

1
src/Magnum/GL/Test/CubeMapTextureGLTest.cpp

@ -26,6 +26,7 @@
#include <Corrade/TestSuite/Compare/Container.h> #include <Corrade/TestSuite/Compare/Container.h>
#include "Magnum/Image.h" #include "Magnum/Image.h"
#include "Magnum/ImageView.h"
#include "Magnum/GL/Context.h" #include "Magnum/GL/Context.h"
#include "Magnum/GL/Extensions.h" #include "Magnum/GL/Extensions.h"
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2

1
src/Magnum/GL/Test/FramebufferGLTest.cpp

@ -27,6 +27,7 @@
#include <Corrade/Utility/DebugStl.h> #include <Corrade/Utility/DebugStl.h>
#include "Magnum/Image.h" #include "Magnum/Image.h"
#include "Magnum/ImageView.h"
#include "Magnum/GL/Context.h" #include "Magnum/GL/Context.h"
#include "Magnum/GL/CubeMapTexture.h" #include "Magnum/GL/CubeMapTexture.h"
#include "Magnum/GL/Extensions.h" #include "Magnum/GL/Extensions.h"

1
src/Magnum/GL/Test/PixelStorageGLTest.cpp

@ -26,6 +26,7 @@
#include <Corrade/TestSuite/Compare/Container.h> #include <Corrade/TestSuite/Compare/Container.h>
#include "Magnum/Image.h" #include "Magnum/Image.h"
#include "Magnum/ImageView.h"
#include "Magnum/GL/Context.h" #include "Magnum/GL/Context.h"
#include "Magnum/GL/Extensions.h" #include "Magnum/GL/Extensions.h"
#include "Magnum/GL/OpenGLTester.h" #include "Magnum/GL/OpenGLTester.h"

1
src/Magnum/GL/Test/RectangleTextureGLTest.cpp

@ -27,6 +27,7 @@
#include <Corrade/TestSuite/Compare/Container.h> #include <Corrade/TestSuite/Compare/Container.h>
#include "Magnum/Image.h" #include "Magnum/Image.h"
#include "Magnum/ImageView.h"
#include "Magnum/GL/Context.h" #include "Magnum/GL/Context.h"
#include "Magnum/GL/Extensions.h" #include "Magnum/GL/Extensions.h"
#include "Magnum/GL/BufferImage.h" #include "Magnum/GL/BufferImage.h"

1
src/Magnum/GL/Test/TextureArrayGLTest.cpp

@ -26,6 +26,7 @@
#include <Corrade/TestSuite/Compare/Container.h> #include <Corrade/TestSuite/Compare/Container.h>
#include "Magnum/Image.h" #include "Magnum/Image.h"
#include "Magnum/ImageView.h"
#include "Magnum/GL/Context.h" #include "Magnum/GL/Context.h"
#include "Magnum/GL/Extensions.h" #include "Magnum/GL/Extensions.h"
#include "Magnum/GL/BufferImage.h" #include "Magnum/GL/BufferImage.h"

1
src/Magnum/GL/Test/TextureGLTest.cpp

@ -26,6 +26,7 @@
#include <Corrade/TestSuite/Compare/Container.h> #include <Corrade/TestSuite/Compare/Container.h>
#include "Magnum/Image.h" #include "Magnum/Image.h"
#include "Magnum/ImageView.h"
#include "Magnum/GL/Context.h" #include "Magnum/GL/Context.h"
#include "Magnum/GL/Extensions.h" #include "Magnum/GL/Extensions.h"
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2

68
src/Magnum/Image.cpp

@ -25,8 +25,9 @@
#include "Image.h" #include "Image.h"
#include "Magnum/ImageView.h"
#include "Magnum/PixelFormat.h" #include "Magnum/PixelFormat.h"
#include "Magnum/Implementation/ImagePixelView.h" #include "Magnum/Implementation/ImageProperties.h"
namespace Magnum { namespace Magnum {
@ -44,6 +45,33 @@ template<UnsignedInt dimensions> Image<dimensions>::Image(const PixelStorage sto
template<UnsignedInt dimensions> Image<dimensions>::Image(const PixelStorage storage, const PixelFormat format, const UnsignedInt formatExtra, const UnsignedInt pixelSize) noexcept: _storage{storage}, _format{format}, _formatExtra{formatExtra}, _pixelSize{pixelSize}, _data{} {} template<UnsignedInt dimensions> Image<dimensions>::Image(const PixelStorage storage, const PixelFormat format, const UnsignedInt formatExtra, const UnsignedInt pixelSize) noexcept: _storage{storage}, _format{format}, _formatExtra{formatExtra}, _pixelSize{pixelSize}, _data{} {}
template<UnsignedInt dimensions> Image<dimensions>::Image(Image<dimensions>&& other) noexcept: _storage{std::move(other._storage)}, _format{std::move(other._format)}, _formatExtra{std::move(other._formatExtra)}, _pixelSize{std::move(other._pixelSize)}, _size{std::move(other._size)}, _data{std::move(other._data)} {
other._size = {};
}
template<UnsignedInt dimensions> Image<dimensions>& Image<dimensions>::operator=(Image<dimensions>&& other) noexcept {
using std::swap;
swap(_storage, other._storage);
swap(_format, other._format);
swap(_formatExtra, other._formatExtra);
swap(_pixelSize, other._pixelSize);
swap(_size, other._size);
swap(_data, other._data);
return *this;
}
template<UnsignedInt dimensions> Image<dimensions>::operator ImageView<dimensions, char>() {
return ImageView<dimensions, char>{_storage, _format, _formatExtra, _pixelSize, _size, _data};
}
template<UnsignedInt dimensions> Image<dimensions>::operator ImageView<dimensions, const char>() const {
return ImageView<dimensions, const char>{_storage, _format, _formatExtra, _pixelSize, _size, _data};
}
template<UnsignedInt dimensions> std::pair<VectorTypeFor<dimensions, std::size_t>, VectorTypeFor<dimensions, std::size_t>> Image<dimensions>::dataProperties() const {
return Implementation::imageDataProperties<dimensions>(*this);
}
template<UnsignedInt dimensions> Containers::StridedArrayView<dimensions + 1, char> Image<dimensions>::pixels() { template<UnsignedInt dimensions> Containers::StridedArrayView<dimensions + 1, char> Image<dimensions>::pixels() {
return Implementation::imagePixelView<dimensions, char>(*this); return Implementation::imagePixelView<dimensions, char>(*this);
} }
@ -52,12 +80,50 @@ template<UnsignedInt dimensions> Containers::StridedArrayView<dimensions + 1, co
return Implementation::imagePixelView<dimensions, const char>(*this); return Implementation::imagePixelView<dimensions, const char>(*this);
} }
template<UnsignedInt dimensions> Containers::Array<char> Image<dimensions>::release() {
Containers::Array<char> data{std::move(_data)};
_size = {};
return data;
}
template<UnsignedInt dimensions> CompressedImage<dimensions>::CompressedImage(const CompressedPixelStorage storage, const CompressedPixelFormat format, const VectorTypeFor<dimensions, Int>& size, Containers::Array<char>&& data) noexcept: _storage{storage}, _format{format}, _size{size}, _data{std::move(data)} {} template<UnsignedInt dimensions> CompressedImage<dimensions>::CompressedImage(const CompressedPixelStorage storage, const CompressedPixelFormat format, const VectorTypeFor<dimensions, Int>& size, Containers::Array<char>&& data) noexcept: _storage{storage}, _format{format}, _size{size}, _data{std::move(data)} {}
template<UnsignedInt dimensions> CompressedImage<dimensions>::CompressedImage(const CompressedPixelStorage storage, const UnsignedInt format, const VectorTypeFor<dimensions, Int>& size, Containers::Array<char>&& data) noexcept: CompressedImage{storage, compressedPixelFormatWrap(format), size, std::move(data)} {} template<UnsignedInt dimensions> CompressedImage<dimensions>::CompressedImage(const CompressedPixelStorage storage, const UnsignedInt format, const VectorTypeFor<dimensions, Int>& size, Containers::Array<char>&& data) noexcept: CompressedImage{storage, compressedPixelFormatWrap(format), size, std::move(data)} {}
template<UnsignedInt dimensions> CompressedImage<dimensions>::CompressedImage(const CompressedPixelStorage storage) noexcept: _storage{storage}, _format{} {} template<UnsignedInt dimensions> CompressedImage<dimensions>::CompressedImage(const CompressedPixelStorage storage) noexcept: _storage{storage}, _format{} {}
template<UnsignedInt dimensions> CompressedImage<dimensions>::CompressedImage(CompressedImage<dimensions>&& other) noexcept: _storage{std::move(other._storage)}, _format{std::move(other._format)}, _size{std::move(other._size)}, _data{std::move(other._data)}
{
other._size = {};
}
template<UnsignedInt dimensions> CompressedImage<dimensions>& CompressedImage<dimensions>::operator=(CompressedImage<dimensions>&& other) noexcept {
using std::swap;
swap(_storage, other._storage);
swap(_format, other._format);
swap(_size, other._size);
swap(_data, other._data);
return *this;
}
template<UnsignedInt dimensions> CompressedImage<dimensions>::operator CompressedImageView<dimensions, char>() {
return CompressedImageView<dimensions, char>{_storage, _format, _size, _data};
}
template<UnsignedInt dimensions> CompressedImage<dimensions>::operator CompressedImageView<dimensions, const char>() const {
return CompressedImageView<dimensions, const char>{_storage, _format, _size, _data};
}
template<UnsignedInt dimensions> std::pair<VectorTypeFor<dimensions, std::size_t>, VectorTypeFor<dimensions, std::size_t>> CompressedImage<dimensions>::dataProperties() const {
return Implementation::compressedImageDataProperties<dimensions>(*this);
}
template<UnsignedInt dimensions> Containers::Array<char> CompressedImage<dimensions>::release() {
Containers::Array<char> data{std::move(_data)};
_size = {};
return data;
}
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
template class MAGNUM_EXPORT Image<1>; template class MAGNUM_EXPORT Image<1>;
template class MAGNUM_EXPORT Image<2>; template class MAGNUM_EXPORT Image<2>;

68
src/Magnum/Image.h

@ -31,7 +31,8 @@
#include <Corrade/Containers/Array.h> #include <Corrade/Containers/Array.h>
#include "Magnum/ImageView.h" #include "Magnum/DimensionTraits.h"
#include "Magnum/PixelStorage.h"
namespace Magnum { namespace Magnum {
@ -350,9 +351,7 @@ template<UnsignedInt dimensions> class Image {
* *
* See @ref PixelStorage::dataProperties() for more information. * See @ref PixelStorage::dataProperties() for more information.
*/ */
std::pair<VectorTypeFor<dimensions, std::size_t>, VectorTypeFor<dimensions, std::size_t>> dataProperties() const { std::pair<VectorTypeFor<dimensions, std::size_t>, VectorTypeFor<dimensions, std::size_t>> dataProperties() const;
return Implementation::imageDataProperties<dimensions>(*this);
}
/** /**
* @brief Raw data * @brief Raw data
@ -597,9 +596,7 @@ template<UnsignedInt dimensions> class CompressedImage {
* See @ref CompressedPixelStorage::dataProperties() for more * See @ref CompressedPixelStorage::dataProperties() for more
* information. * information.
*/ */
std::pair<VectorTypeFor<dimensions, std::size_t>, VectorTypeFor<dimensions, std::size_t>> dataProperties() const { std::pair<VectorTypeFor<dimensions, std::size_t>, VectorTypeFor<dimensions, std::size_t>> dataProperties() const;
return Implementation::compressedImageDataProperties<dimensions>(*this);
}
/** /**
* @brief Raw data * @brief Raw data
@ -677,63 +674,6 @@ typedef CompressedImage<2> CompressedImage2D;
/** @brief Three-dimensional compressed image */ /** @brief Three-dimensional compressed image */
typedef CompressedImage<3> CompressedImage3D; typedef CompressedImage<3> CompressedImage3D;
template<UnsignedInt dimensions> inline Image<dimensions>::Image(Image<dimensions>&& other) noexcept: _storage{std::move(other._storage)}, _format{std::move(other._format)}, _formatExtra{std::move(other._formatExtra)}, _pixelSize{std::move(other._pixelSize)}, _size{std::move(other._size)}, _data{std::move(other._data)} {
other._size = {};
}
template<UnsignedInt dimensions> inline CompressedImage<dimensions>::CompressedImage(CompressedImage<dimensions>&& other) noexcept: _storage{std::move(other._storage)}, _format{std::move(other._format)}, _size{std::move(other._size)}, _data{std::move(other._data)}
{
other._size = {};
}
template<UnsignedInt dimensions> inline Image<dimensions>& Image<dimensions>::operator=(Image<dimensions>&& other) noexcept {
using std::swap;
swap(_storage, other._storage);
swap(_format, other._format);
swap(_formatExtra, other._formatExtra);
swap(_pixelSize, other._pixelSize);
swap(_size, other._size);
swap(_data, other._data);
return *this;
}
template<UnsignedInt dimensions> inline CompressedImage<dimensions>& CompressedImage<dimensions>::operator=(CompressedImage<dimensions>&& other) noexcept {
using std::swap;
swap(_storage, other._storage);
swap(_format, other._format);
swap(_size, other._size);
swap(_data, other._data);
return *this;
}
template<UnsignedInt dimensions> inline Image<dimensions>::operator ImageView<dimensions, char>() {
return ImageView<dimensions, char>{_storage, _format, _formatExtra, _pixelSize, _size, _data};
}
template<UnsignedInt dimensions> inline Image<dimensions>::operator ImageView<dimensions, const char>() const {
return ImageView<dimensions, const char>{_storage, _format, _formatExtra, _pixelSize, _size, _data};
}
template<UnsignedInt dimensions> inline CompressedImage<dimensions>::operator CompressedImageView<dimensions, char>() {
return CompressedImageView<dimensions, char>{_storage, _format, _size, _data};
}
template<UnsignedInt dimensions> inline CompressedImage<dimensions>::operator CompressedImageView<dimensions, const char>() const {
return CompressedImageView<dimensions, const char>{_storage, _format, _size, _data};
}
template<UnsignedInt dimensions> inline Containers::Array<char> Image<dimensions>::release() {
Containers::Array<char> data{std::move(_data)};
_size = {};
return data;
}
template<UnsignedInt dimensions> inline Containers::Array<char> CompressedImage<dimensions>::release() {
Containers::Array<char> data{std::move(_data)};
_size = {};
return data;
}
template<UnsignedInt dimensions> template<class T, class U> inline Image<dimensions>::Image(const PixelStorage storage, const T format, const U formatExtra, const VectorTypeFor<dimensions, Int>& size, Containers::Array<char>&& data) noexcept: Image{storage, UnsignedInt(format), UnsignedInt(formatExtra), Implementation::pixelSizeAdl(format, formatExtra), size, std::move(data)} { template<UnsignedInt dimensions> template<class T, class U> inline Image<dimensions>::Image(const PixelStorage storage, const T format, const U formatExtra, const VectorTypeFor<dimensions, Int>& size, Containers::Array<char>&& data) noexcept: Image{storage, UnsignedInt(format), UnsignedInt(formatExtra), Implementation::pixelSizeAdl(format, formatExtra), size, std::move(data)} {
static_assert(sizeof(T) <= 4 && sizeof(U) <= 4, static_assert(sizeof(T) <= 4 && sizeof(U) <= 4,
"format types larger than 32bits are not supported"); "format types larger than 32bits are not supported");

10
src/Magnum/ImageView.cpp

@ -26,7 +26,7 @@
#include "ImageView.h" #include "ImageView.h"
#include "Magnum/PixelFormat.h" #include "Magnum/PixelFormat.h"
#include "Magnum/Implementation/ImagePixelView.h" #include "Magnum/Implementation/ImageProperties.h"
namespace Magnum { namespace Magnum {
@ -44,6 +44,10 @@ template<UnsignedInt dimensions, class T> ImageView<dimensions, T>::ImageView(co
template<UnsignedInt dimensions, class T> ImageView<dimensions, T>::ImageView(const PixelStorage storage, const PixelFormat format, const UnsignedInt formatExtra, const UnsignedInt pixelSize, const VectorTypeFor<dimensions, Int>& size) noexcept: _storage{storage}, _format{format}, _formatExtra{formatExtra}, _pixelSize{pixelSize}, _size{size}, _data{nullptr} {} template<UnsignedInt dimensions, class T> ImageView<dimensions, T>::ImageView(const PixelStorage storage, const PixelFormat format, const UnsignedInt formatExtra, const UnsignedInt pixelSize, const VectorTypeFor<dimensions, Int>& size) noexcept: _storage{storage}, _format{format}, _formatExtra{formatExtra}, _pixelSize{pixelSize}, _size{size}, _data{nullptr} {}
template<UnsignedInt dimensions, class T> std::pair<VectorTypeFor<dimensions, std::size_t>, VectorTypeFor<dimensions, std::size_t>> ImageView<dimensions, T>::dataProperties() const {
return Implementation::imageDataProperties<dimensions>(*this);
}
template<UnsignedInt dimensions, class T> void ImageView<dimensions, T>::setData(const Containers::ArrayView<ErasedType> data) { template<UnsignedInt dimensions, class T> void ImageView<dimensions, T>::setData(const Containers::ArrayView<ErasedType> data) {
CORRADE_ASSERT(Implementation::imageDataSize(*this) <= data.size(), "ImageView::setData(): data too small, got" << data.size() << "but expected at least" << Implementation::imageDataSize(*this) << "bytes", ); CORRADE_ASSERT(Implementation::imageDataSize(*this) <= data.size(), "ImageView::setData(): data too small, got" << data.size() << "but expected at least" << Implementation::imageDataSize(*this) << "bytes", );
_data = {reinterpret_cast<Type*>(data.data()), data.size()}; _data = {reinterpret_cast<Type*>(data.data()), data.size()};
@ -61,6 +65,10 @@ template<UnsignedInt dimensions, class T> CompressedImageView<dimensions, T>::Co
template<UnsignedInt dimensions, class T> CompressedImageView<dimensions, T>::CompressedImageView(const CompressedPixelStorage storage, const UnsignedInt format, const VectorTypeFor<dimensions, Int>& size) noexcept: CompressedImageView{storage, compressedPixelFormatWrap(format), size} {} template<UnsignedInt dimensions, class T> CompressedImageView<dimensions, T>::CompressedImageView(const CompressedPixelStorage storage, const UnsignedInt format, const VectorTypeFor<dimensions, Int>& size) noexcept: CompressedImageView{storage, compressedPixelFormatWrap(format), size} {}
template<UnsignedInt dimensions, class T> std::pair<VectorTypeFor<dimensions, std::size_t>, VectorTypeFor<dimensions, std::size_t>> CompressedImageView<dimensions, T>::dataProperties() const {
return Implementation::compressedImageDataProperties<dimensions>(*this);
}
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
template class MAGNUM_EXPORT ImageView<1, const char>; template class MAGNUM_EXPORT ImageView<1, const char>;
template class MAGNUM_EXPORT ImageView<2, const char>; template class MAGNUM_EXPORT ImageView<2, const char>;

18
src/Magnum/ImageView.h

@ -400,9 +400,7 @@ template<UnsignedInt dimensions, class T> class ImageView {
* *
* See @ref PixelStorage::dataProperties() for more information. * See @ref PixelStorage::dataProperties() for more information.
*/ */
std::pair<VectorTypeFor<dimensions, std::size_t>, VectorTypeFor<dimensions, std::size_t>> dataProperties() const { std::pair<VectorTypeFor<dimensions, std::size_t>, VectorTypeFor<dimensions, std::size_t>> dataProperties() const;
return Implementation::imageDataProperties<dimensions>(*this);
}
/** /**
* @brief Image data * @brief Image data
@ -726,9 +724,7 @@ template<UnsignedInt dimensions, class T> class CompressedImageView {
* See @ref CompressedPixelStorage::dataProperties() for more * See @ref CompressedPixelStorage::dataProperties() for more
* information. * information.
*/ */
std::pair<VectorTypeFor<dimensions, std::size_t>, VectorTypeFor<dimensions, std::size_t>> dataProperties() const { std::pair<VectorTypeFor<dimensions, std::size_t>, VectorTypeFor<dimensions, std::size_t>> dataProperties() const;
return Implementation::compressedImageDataProperties<dimensions>(*this);
}
/** @brief Image data */ /** @brief Image data */
Containers::ArrayView<Type> data() const { return _data; } Containers::ArrayView<Type> data() const { return _data; }
@ -812,16 +808,6 @@ typedef CompressedImageView<2, char> MutableCompressedImageView2D;
*/ */
typedef CompressedImageView<3, char> MutableCompressedImageView3D; typedef CompressedImageView<3, char> MutableCompressedImageView3D;
namespace Implementation {
template<class T> inline UnsignedInt pixelSizeAdl(T format) {
return pixelSize(format);
}
template<class T, class U> inline UnsignedInt pixelSizeAdl(T format, U formatExtra) {
return pixelSize(format, formatExtra);
}
}
template<UnsignedInt dimensions, class T> template<class U, class V> inline ImageView<dimensions, T>::ImageView(const PixelStorage storage, const U format, const V formatExtra, const VectorTypeFor<dimensions, Int>& size, const Containers::ArrayView<ErasedType> data) noexcept: ImageView{storage, UnsignedInt(format), UnsignedInt(formatExtra), Implementation::pixelSizeAdl(format, formatExtra), size, data} { template<UnsignedInt dimensions, class T> template<class U, class V> inline ImageView<dimensions, T>::ImageView(const PixelStorage storage, const U format, const V formatExtra, const VectorTypeFor<dimensions, Int>& size, const Containers::ArrayView<ErasedType> data) noexcept: ImageView{storage, UnsignedInt(format), UnsignedInt(formatExtra), Implementation::pixelSizeAdl(format, formatExtra), size, data} {
static_assert(sizeof(T) <= 4 && sizeof(U) <= 4, static_assert(sizeof(T) <= 4 && sizeof(U) <= 4,
"format types larger than 32bits are not supported"); "format types larger than 32bits are not supported");

16
src/Magnum/Implementation/ImagePixelView.h → src/Magnum/Implementation/ImageProperties.h

@ -1,5 +1,5 @@
#ifndef Magnum_Implementation_ImagePixelView_h #ifndef Magnum_Implementation_ImageProperties_h
#define Magnum_Implementation_ImagePixelView_h #define Magnum_Implementation_ImageProperties_h
/* /*
This file is part of Magnum. This file is part of Magnum.
@ -33,6 +33,18 @@
namespace Magnum { namespace Implementation { namespace Magnum { namespace Implementation {
/* Used in *Image::dataProperties() */
template<std::size_t dimensions, class T> std::pair<Math::Vector<dimensions, std::size_t>, Math::Vector<dimensions, std::size_t>> imageDataProperties(const T& image) {
std::pair<Math::Vector3<std::size_t>, Math::Vector3<std::size_t>> dataProperties = image.storage().dataProperties(image.pixelSize(), Vector3i::pad(image.size(), 1));
return std::make_pair(Math::Vector<dimensions, std::size_t>::pad(dataProperties.first), Math::Vector<dimensions, std::size_t>::pad(dataProperties.second));
}
/* Used in Compressed*Image::dataProperties() */
template<std::size_t dimensions, class T> std::pair<Math::Vector<dimensions, std::size_t>, Math::Vector<dimensions, std::size_t>> compressedImageDataProperties(const T& image) {
std::pair<Math::Vector3<std::size_t>, Math::Vector3<std::size_t>> dataProperties = image.storage().dataProperties(Vector3i::pad(image.size(), 1));
return std::make_pair(Math::Vector<dimensions, std::size_t>::pad(dataProperties.first), Math::Vector<dimensions, std::size_t>::pad(dataProperties.second));
}
template<UnsignedInt dimensions, class T, class Image> Containers::StridedArrayView<dimensions + 1, T> imagePixelView(Image& image) { template<UnsignedInt dimensions, class T, class Image> Containers::StridedArrayView<dimensions + 1, T> imagePixelView(Image& image) {
const std::pair<VectorTypeFor<dimensions, std::size_t>, VectorTypeFor<dimensions, std::size_t>> properties = image.dataProperties(); const std::pair<VectorTypeFor<dimensions, std::size_t>, VectorTypeFor<dimensions, std::size_t>> properties = image.dataProperties();

1
src/Magnum/MeshTools/Test/CompileGLTest.cpp

@ -28,6 +28,7 @@
#include <Corrade/Utility/Directory.h> #include <Corrade/Utility/Directory.h>
#include "Magnum/Image.h" #include "Magnum/Image.h"
#include "Magnum/ImageView.h"
#include "Magnum/Mesh.h" #include "Magnum/Mesh.h"
#include "Magnum/PixelFormat.h" #include "Magnum/PixelFormat.h"
#include "Magnum/DebugTools/CompareImage.h" #include "Magnum/DebugTools/CompareImage.h"

13
src/Magnum/PixelStorage.h

@ -246,16 +246,13 @@ class MAGNUM_EXPORT CompressedPixelStorage: public PixelStorage {
constexpr PixelStorage::PixelStorage() noexcept: _rowLength{0}, _imageHeight{0}, _skip{0}, _alignment{4} {} constexpr PixelStorage::PixelStorage() noexcept: _rowLength{0}, _imageHeight{0}, _skip{0}, _alignment{4} {}
namespace Implementation { namespace Implementation {
/* Used in *Image::dataProperties() */ /* Used in templated image[view] constructors */
template<std::size_t dimensions, class T> std::pair<Math::Vector<dimensions, std::size_t>, Math::Vector<dimensions, std::size_t>> imageDataProperties(const T& image) { template<class T> inline UnsignedInt pixelSizeAdl(T format) {
std::pair<Math::Vector3<std::size_t>, Math::Vector3<std::size_t>> dataProperties = image.storage().dataProperties(image.pixelSize(), Vector3i::pad(image.size(), 1)); return pixelSize(format);
return std::make_pair(Math::Vector<dimensions, std::size_t>::pad(dataProperties.first), Math::Vector<dimensions, std::size_t>::pad(dataProperties.second));
} }
/* Used in Compressed*Image::dataProperties() */ template<class T, class U> inline UnsignedInt pixelSizeAdl(T format, U formatExtra) {
template<std::size_t dimensions, class T> std::pair<Math::Vector<dimensions, std::size_t>, Math::Vector<dimensions, std::size_t>> compressedImageDataProperties(const T& image) { return pixelSize(format, formatExtra);
std::pair<Math::Vector3<std::size_t>, Math::Vector3<std::size_t>> dataProperties = image.storage().dataProperties(Vector3i::pad(image.size(), 1));
return std::make_pair(Math::Vector<dimensions, std::size_t>::pad(dataProperties.first), Math::Vector<dimensions, std::size_t>::pad(dataProperties.second));
} }
/* Used in image query functions */ /* Used in image query functions */

1
src/Magnum/Test/ImageTest.cpp

@ -29,6 +29,7 @@
#include <Corrade/Utility/DebugStl.h> #include <Corrade/Utility/DebugStl.h>
#include "Magnum/Image.h" #include "Magnum/Image.h"
#include "Magnum/ImageView.h"
#include "Magnum/Math/Color.h" #include "Magnum/Math/Color.h"
#include "Magnum/PixelFormat.h" #include "Magnum/PixelFormat.h"

1
src/Magnum/Text/AbstractGlyphCache.cpp

@ -26,6 +26,7 @@
#include "AbstractGlyphCache.h" #include "AbstractGlyphCache.h"
#include "Magnum/Image.h" #include "Magnum/Image.h"
#include "Magnum/ImageView.h"
#include "Magnum/TextureTools/Atlas.h" #include "Magnum/TextureTools/Atlas.h"
namespace Magnum { namespace Text { namespace Magnum { namespace Text {

1
src/Magnum/Text/Test/AbstractGlyphCacheTest.cpp

@ -29,6 +29,7 @@
#include <Corrade/Utility/DebugStl.h> #include <Corrade/Utility/DebugStl.h>
#include "Magnum/Image.h" #include "Magnum/Image.h"
#include "Magnum/ImageView.h"
#include "Magnum/PixelFormat.h" #include "Magnum/PixelFormat.h"
#include "Magnum/Text/AbstractGlyphCache.h" #include "Magnum/Text/AbstractGlyphCache.h"

1
src/Magnum/TextureTools/Test/DistanceFieldGLTest.cpp

@ -27,6 +27,7 @@
#include <Corrade/Utility/Directory.h> #include <Corrade/Utility/Directory.h>
#include "Magnum/Image.h" #include "Magnum/Image.h"
#include "Magnum/ImageView.h"
#include "Magnum/PixelFormat.h" #include "Magnum/PixelFormat.h"
#include "Magnum/Math/Color.h" #include "Magnum/Math/Color.h"
#include "Magnum/Math/Range.h" #include "Magnum/Math/Range.h"

1
src/Magnum/TextureTools/distancefieldconverter.cpp

@ -30,6 +30,7 @@
#include <Corrade/PluginManager/Manager.h> #include <Corrade/PluginManager/Manager.h>
#include "Magnum/Image.h" #include "Magnum/Image.h"
#include "Magnum/ImageView.h"
#include "Magnum/PixelFormat.h" #include "Magnum/PixelFormat.h"
#include "Magnum/Math/ConfigurationValue.h" #include "Magnum/Math/ConfigurationValue.h"
#include "Magnum/Math/Range.h" #include "Magnum/Math/Range.h"

1
src/Magnum/Trade/AbstractImageConverter.cpp

@ -33,6 +33,7 @@
#include <Corrade/Utility/DebugStl.h> #include <Corrade/Utility/DebugStl.h>
#include "Magnum/Image.h" #include "Magnum/Image.h"
#include "Magnum/ImageView.h"
#include "Magnum/Trade/ImageData.h" #include "Magnum/Trade/ImageData.h"
#ifndef CORRADE_PLUGINMANAGER_NO_DYNAMIC_PLUGIN_SUPPORT #ifndef CORRADE_PLUGINMANAGER_NO_DYNAMIC_PLUGIN_SUPPORT

43
src/Magnum/Trade/ImageData.cpp

@ -27,8 +27,9 @@
#include <Corrade/Containers/StridedArrayView.h> #include <Corrade/Containers/StridedArrayView.h>
#include "Magnum/ImageView.h"
#include "Magnum/PixelFormat.h" #include "Magnum/PixelFormat.h"
#include "Magnum/Implementation/ImagePixelView.h" #include "Magnum/Implementation/ImageProperties.h"
namespace Magnum { namespace Trade { namespace Magnum { namespace Trade {
@ -44,10 +45,44 @@ template<UnsignedInt dimensions> ImageData<dimensions>::ImageData(const Compress
template<UnsignedInt dimensions> ImageData<dimensions>::ImageData(const CompressedPixelStorage storage, const UnsignedInt format, const VectorTypeFor<dimensions, Int>& size, Containers::Array<char>&& data, const void* const importerState) noexcept: ImageData{storage, compressedPixelFormatWrap(format), size, std::move(data), importerState} {} template<UnsignedInt dimensions> ImageData<dimensions>::ImageData(const CompressedPixelStorage storage, const UnsignedInt format, const VectorTypeFor<dimensions, Int>& size, Containers::Array<char>&& data, const void* const importerState) noexcept: ImageData{storage, compressedPixelFormatWrap(format), size, std::move(data), importerState} {}
template<UnsignedInt dimensions> ImageData<dimensions>::ImageData(ImageData<dimensions>&& other) noexcept: _compressed{std::move(other._compressed)}, _size{std::move(other._size)}, _data{std::move(other._data)}, _importerState{std::move(other._importerState)} {
if(_compressed) {
new(&_compressedStorage) CompressedPixelStorage{std::move(other._compressedStorage)};
_compressedFormat = std::move(other._compressedFormat);
}
else {
new(&_storage) PixelStorage{std::move(other._storage)};
_format = std::move(other._format);
_formatExtra = std::move(other._formatExtra);
_pixelSize = std::move(other._pixelSize);
}
other._size = {};
}
template<UnsignedInt dimensions> ImageData<dimensions>::ImageData(ImageData<dimensions>&& other, const void* const importerState) noexcept: ImageData{std::move(other)} { template<UnsignedInt dimensions> ImageData<dimensions>::ImageData(ImageData<dimensions>&& other, const void* const importerState) noexcept: ImageData{std::move(other)} {
_importerState = importerState; _importerState = importerState;
} }
template<UnsignedInt dimensions> ImageData<dimensions>& ImageData<dimensions>::operator=(ImageData<dimensions>&& other) noexcept {
using std::swap;
swap(_compressed, other._compressed);
if(_compressed) {
swap(_compressedStorage, other._compressedStorage);
swap(_compressedFormat, other._compressedFormat);
}
else {
swap(_storage, other._storage);
swap(_format, other._format);
}
swap(_formatExtra, other._formatExtra);
swap(_pixelSize, other._pixelSize);
swap(_size, other._size);
swap(_data, other._data);
swap(_importerState, other._importerState);
return *this;
}
template<UnsignedInt dimensions> PixelStorage ImageData<dimensions>::storage() const { template<UnsignedInt dimensions> PixelStorage ImageData<dimensions>::storage() const {
CORRADE_ASSERT(!_compressed, "Trade::ImageData::storage(): the image is compressed", {}); CORRADE_ASSERT(!_compressed, "Trade::ImageData::storage(): the image is compressed", {});
return _storage; return _storage;
@ -117,6 +152,12 @@ template<UnsignedInt dimensions> ImageData<dimensions>::operator CompressedImage
_compressedFormat, _size, _data}; _compressedFormat, _size, _data};
} }
template<UnsignedInt dimensions> Containers::Array<char> ImageData<dimensions>::release() {
Containers::Array<char> data{std::move(_data)};
_size = {};
return data;
}
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
template class MAGNUM_TRADE_EXPORT ImageData<1>; template class MAGNUM_TRADE_EXPORT ImageData<1>;
template class MAGNUM_TRADE_EXPORT ImageData<2>; template class MAGNUM_TRADE_EXPORT ImageData<2>;

43
src/Magnum/Trade/ImageData.h

@ -31,7 +31,8 @@
#include <Corrade/Containers/Array.h> #include <Corrade/Containers/Array.h>
#include "Magnum/ImageView.h" #include "Magnum/DimensionTraits.h"
#include "Magnum/PixelStorage.h"
#include "Magnum/Trade/visibility.h" #include "Magnum/Trade/visibility.h"
namespace Magnum { namespace Trade { namespace Magnum { namespace Trade {
@ -468,46 +469,6 @@ template<UnsignedInt dimensions> template<class T> ImageData<dimensions>::ImageD
"format types larger than 32bits are not supported"); "format types larger than 32bits are not supported");
} }
template<UnsignedInt dimensions> inline ImageData<dimensions>::ImageData(ImageData<dimensions>&& other) noexcept: _compressed{std::move(other._compressed)}, _size{std::move(other._size)}, _data{std::move(other._data)}, _importerState{std::move(other._importerState)} {
if(_compressed) {
new(&_compressedStorage) CompressedPixelStorage{std::move(other._compressedStorage)};
_compressedFormat = std::move(other._compressedFormat);
}
else {
new(&_storage) PixelStorage{std::move(other._storage)};
_format = std::move(other._format);
_formatExtra = std::move(other._formatExtra);
_pixelSize = std::move(other._pixelSize);
}
other._size = {};
}
template<UnsignedInt dimensions> inline ImageData<dimensions>& ImageData<dimensions>::operator=(ImageData<dimensions>&& other) noexcept {
using std::swap;
swap(_compressed, other._compressed);
if(_compressed) {
swap(_compressedStorage, other._compressedStorage);
swap(_compressedFormat, other._compressedFormat);
}
else {
swap(_storage, other._storage);
swap(_format, other._format);
}
swap(_formatExtra, other._formatExtra);
swap(_pixelSize, other._pixelSize);
swap(_size, other._size);
swap(_data, other._data);
swap(_importerState, other._importerState);
return *this;
}
template<UnsignedInt dimensions> inline Containers::Array<char> ImageData<dimensions>::release() {
Containers::Array<char> data{std::move(_data)};
_size = {};
return data;
}
}} }}
#endif #endif

1
src/Magnum/Trade/Test/AbstractImageConverterTest.cpp

@ -33,6 +33,7 @@
#include <Corrade/Utility/Directory.h> #include <Corrade/Utility/Directory.h>
#include "Magnum/Image.h" #include "Magnum/Image.h"
#include "Magnum/ImageView.h"
#include "Magnum/PixelFormat.h" #include "Magnum/PixelFormat.h"
#include "Magnum/Trade/AbstractImageConverter.h" #include "Magnum/Trade/AbstractImageConverter.h"
#include "Magnum/Trade/ImageData.h" #include "Magnum/Trade/ImageData.h"

1
src/Magnum/Trade/Test/ImageDataTest.cpp

@ -28,6 +28,7 @@
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h> #include <Corrade/Utility/DebugStl.h>
#include "Magnum/ImageView.h"
#include "Magnum/Math/Color.h" #include "Magnum/Math/Color.h"
#include "Magnum/PixelFormat.h" #include "Magnum/PixelFormat.h"
#include "Magnum/Trade/ImageData.h" #include "Magnum/Trade/ImageData.h"

1
src/MagnumPlugins/AnyImageConverter/Test/AnyImageConverterTest.cpp

@ -30,6 +30,7 @@
#include <Corrade/Utility/DebugStl.h> #include <Corrade/Utility/DebugStl.h>
#include <Corrade/Utility/FormatStl.h> #include <Corrade/Utility/FormatStl.h>
#include "Magnum/ImageView.h"
#include "Magnum/PixelFormat.h" #include "Magnum/PixelFormat.h"
#include "Magnum/Trade/AbstractImageConverter.h" #include "Magnum/Trade/AbstractImageConverter.h"
#include "Magnum/Trade/ImageData.h" #include "Magnum/Trade/ImageData.h"

1
src/MagnumPlugins/MagnumFont/MagnumFont.cpp

@ -32,6 +32,7 @@
#include <Corrade/Utility/Directory.h> #include <Corrade/Utility/Directory.h>
#include <Corrade/Utility/Unicode.h> #include <Corrade/Utility/Unicode.h>
#include "Magnum/ImageView.h"
#include "Magnum/Math/ConfigurationValue.h" #include "Magnum/Math/ConfigurationValue.h"
#include "Magnum/Text/GlyphCache.h" #include "Magnum/Text/GlyphCache.h"
#include "Magnum/Trade/ImageData.h" #include "Magnum/Trade/ImageData.h"

1
src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.cpp

@ -32,6 +32,7 @@
#include <Corrade/Utility/Directory.h> #include <Corrade/Utility/Directory.h>
#include "Magnum/Image.h" #include "Magnum/Image.h"
#include "Magnum/ImageView.h"
#include "Magnum/PixelFormat.h" #include "Magnum/PixelFormat.h"
#include "Magnum/Math/ConfigurationValue.h" #include "Magnum/Math/ConfigurationValue.h"
#include "Magnum/Text/AbstractFont.h" #include "Magnum/Text/AbstractFont.h"

2
src/MagnumPlugins/TgaImageConverter/Test/TgaImageConverterTest.cpp

@ -32,7 +32,7 @@
#include <Corrade/Utility/DebugStl.h> #include <Corrade/Utility/DebugStl.h>
#include <Corrade/Utility/Directory.h> #include <Corrade/Utility/Directory.h>
#include "Magnum/Image.h" #include "Magnum/ImageView.h"
#include "Magnum/PixelFormat.h" #include "Magnum/PixelFormat.h"
#include "Magnum/Trade/ImageData.h" #include "Magnum/Trade/ImageData.h"
#include "Magnum/Trade/AbstractImageConverter.h" #include "Magnum/Trade/AbstractImageConverter.h"

2
src/MagnumPlugins/TgaImageConverter/TgaImageConverter.cpp

@ -31,7 +31,7 @@
#include <Corrade/Containers/Array.h> #include <Corrade/Containers/Array.h>
#include <Corrade/Utility/Endianness.h> #include <Corrade/Utility/Endianness.h>
#include "Magnum/Image.h" #include "Magnum/ImageView.h"
#include "Magnum/PixelFormat.h" #include "Magnum/PixelFormat.h"
#include "Magnum/Math/Swizzle.h" #include "Magnum/Math/Swizzle.h"
#include "Magnum/Math/Vector4.h" #include "Magnum/Math/Vector4.h"

Loading…
Cancel
Save