From 01e272732629d2ba7ecedce40f38cd5fa6761529 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 29 Mar 2018 00:43:11 +0200 Subject: [PATCH] Removed PixelStorage::setSwapBytes(). Too much burden to implement. Nope. Sorry. All APIs were just asserting that it's not enabled at the moment, so I may as well just remove it completely. --- doc/changelog.dox | 3 ++ doc/opengl-support.dox | 4 ++ src/Magnum/DebugTools/CompareImage.cpp | 4 -- src/Magnum/DebugTools/CompareImage.h | 7 ++-- src/Magnum/Implementation/RendererState.cpp | 6 --- src/Magnum/Implementation/RendererState.h | 4 -- src/Magnum/PixelStorage.cpp | 10 ----- src/Magnum/PixelStorage.h | 37 +------------------ src/Magnum/Test/PixelStorageTest.cpp | 6 --- .../TgaImageConverter/TgaImageConverter.cpp | 7 ---- .../TgaImageConverter/TgaImageConverter.h | 4 -- 11 files changed, 12 insertions(+), 80 deletions(-) diff --git a/doc/changelog.dox b/doc/changelog.dox index bf68af5e6..8c9860668 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -150,6 +150,9 @@ See also: @subsection changelog-latest-compatibility Potential compatibility breakages, removed APIs +- Removed `PixelStorage::setSwapBytes()`, as every Magnum API dealing with + images basically only asserted that it's not set. Use + @ref Corrade::Utility::Endianness instead. - Removed the @cpp Buffer::Usage @ce enum that was deprecated in 2014.01, use the global @ref BufferUsage enum instead - Removed the `Magnum/Query.h` header that was deprecated in 2015.05, use one diff --git a/doc/opengl-support.dox b/doc/opengl-support.dox index 39c14185f..86f2f1b2b 100644 --- a/doc/opengl-support.dox +++ b/doc/opengl-support.dox @@ -543,6 +543,10 @@ add any performance gains, is not supported in Magnum. See also code. - Direct vertex data specification (as opposed to using buffers) is not supported, as it encourages bad practices. +- @fn_gl{glPixelStore} with @def_gl{PACK_SWAP_BYTES} / @def_gl{UNPACK_SWAP_BYTES}. + Too much burden imposed on every API that deals with pixel storage. Use + @ref Corrade::Utility::Endianness instead. Note that this state is also not + tracked, so it won't get reset in case a 3rd party code enables it. @subsection opengl-unsupported-extensions Unsupported ARB / Khronos extensions diff --git a/src/Magnum/DebugTools/CompareImage.cpp b/src/Magnum/DebugTools/CompareImage.cpp index b8843bbfe..0ee265a29 100644 --- a/src/Magnum/DebugTools/CompareImage.cpp +++ b/src/Magnum/DebugTools/CompareImage.cpp @@ -447,10 +447,6 @@ bool Comparator::operator()(const ImageView2D& actual, formatSupported, "DebugTools::CompareImage: format" << expected.format() << Debug::nospace << "/" << expected.type() << "is not supported", {}); #endif - #ifndef MAGNUM_TARGET_GLES - CORRADE_ASSERT(!actual.storage().swapBytes() && !expected.storage().swapBytes(), - "DebugTools::CompareImage: pixel storage with byte swap is not supported", {}); - #endif std::vector delta; std::tie(delta, _max, _mean) = DebugTools::Implementation::calculateImageDelta(actual, expected); diff --git a/src/Magnum/DebugTools/CompareImage.h b/src/Magnum/DebugTools/CompareImage.h index 75a4d14d4..18f2c9bc2 100644 --- a/src/Magnum/DebugTools/CompareImage.h +++ b/src/Magnum/DebugTools/CompareImage.h @@ -113,10 +113,9 @@ In OpenGL ES 2.0 and WebGL 1.0, @ref PixelFormat::Luminance and @ref PixelFormat::LuminanceAlpha are also accepted in place of @ref PixelFormat::Red and @ref PixelFormat::RG. -Supports all @ref PixelStorage parameters *except* non-default -@ref PixelStorage::swapBytes() values. The images don't need to have the same -pixel storage parameters, meaning you are able to compare different subimages -of a larger image as long as they have the same size. +Supports all @ref PixelStorage parameters. The images don't need to have the +same pixel storage parameters, meaning you are able to compare different +subimages of a larger image as long as they have the same size. The comparator first compares both images to have the same pixel format/type combination and size. Each pixel is then first converted to @ref Magnum::Float "Float" diff --git a/src/Magnum/Implementation/RendererState.cpp b/src/Magnum/Implementation/RendererState.cpp index e72bd24cc..03e67e132 100644 --- a/src/Magnum/Implementation/RendererState.cpp +++ b/src/Magnum/Implementation/RendererState.cpp @@ -86,9 +86,6 @@ RendererState::RendererState(Context& context, std::vector& extensi } RendererState::PixelStorage::PixelStorage(): - #ifndef MAGNUM_TARGET_GLES - swapBytes{false}, - #endif alignment{4} #if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL)) , rowLength{0} @@ -104,9 +101,6 @@ RendererState::PixelStorage::PixelStorage(): {} void RendererState::PixelStorage::reset() { - #ifndef MAGNUM_TARGET_GLES - swapBytes = Containers::NullOpt; - #endif alignment = DisengagedValue; #if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL)) /* Resets to 0 instead of DisengagedValue in case the EXT_unpack_subimage/ diff --git a/src/Magnum/Implementation/RendererState.h b/src/Magnum/Implementation/RendererState.h index 862dc670a..41397cc09 100644 --- a/src/Magnum/Implementation/RendererState.h +++ b/src/Magnum/Implementation/RendererState.h @@ -27,7 +27,6 @@ #include #include -#include #include "Magnum/Renderer.h" #include "Magnum/Math/Vector3.h" @@ -51,9 +50,6 @@ struct RendererState { void reset(); - #ifndef MAGNUM_TARGET_GLES - Containers::Optional swapBytes; - #endif Int alignment; #if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL)) Int rowLength; diff --git a/src/Magnum/PixelStorage.cpp b/src/Magnum/PixelStorage.cpp index ce56af7c9..d575e5aa4 100644 --- a/src/Magnum/PixelStorage.cpp +++ b/src/Magnum/PixelStorage.cpp @@ -171,9 +171,6 @@ bool PixelStorage::operator==(const PixelStorage& other) const { _imageHeight == other._imageHeight && #endif _skip == other._skip && - #ifndef MAGNUM_TARGET_GLES - _swapBytes == other._swapBytes && - #endif _alignment == other._alignment; } @@ -218,13 +215,6 @@ void PixelStorage::applyInternal(const bool isUnpack) { Context::current().state().renderer->unpackPixelStorage : Context::current().state().renderer->packPixelStorage; - #ifndef MAGNUM_TARGET_GLES - /* Byte swap */ - if(state.swapBytes == Containers::NullOpt || state.swapBytes != _swapBytes) - glPixelStorei(isUnpack ? GL_UNPACK_SWAP_BYTES : GL_PACK_SWAP_BYTES, - *(state.swapBytes = _swapBytes)); - #endif - /* Alignment */ if(state.alignment == Implementation::RendererState::PixelStorage::DisengagedValue || state.alignment != _alignment) glPixelStorei(isUnpack ? GL_UNPACK_ALIGNMENT : GL_PACK_ALIGNMENT, diff --git a/src/Magnum/PixelStorage.h b/src/Magnum/PixelStorage.h index cd38b2f6b..3a11f8926 100644 --- a/src/Magnum/PixelStorage.h +++ b/src/Magnum/PixelStorage.h @@ -87,29 +87,6 @@ class MAGNUM_EXPORT PixelStorage { return !operator==(other); } - #ifndef MAGNUM_TARGET_GLES - /** - * @brief Whether to reverse byte order - * - * @requires_gl Not available in OpenGL ES or WebGL. - */ - constexpr bool swapBytes() const { return _swapBytes; } - - /** - * @brief Enable or disable byte order reversion - * - * Not applicable for @ref CompressedPixelStorage. Default is - * @cpp false @ce. - * @see @fn_gl{PixelStore} with @def_gl_keyword{PACK_SWAP_BYTES}/ - * @def_gl_keyword{UNPACK_SWAP_BYTES} - * @requires_gl Not available in OpenGL ES or WebGL. - */ - PixelStorage& setSwapBytes(bool enabled) { - _swapBytes = enabled; - return *this; - } - #endif - /** @brief Row alignment */ constexpr Int alignment() const { return _alignment; } @@ -245,9 +222,6 @@ class MAGNUM_EXPORT PixelStorage { void MAGNUM_LOCAL applyUnpack(); void MAGNUM_LOCAL applyPack() { applyInternal(false); } - #ifndef MAGNUM_TARGET_GLES - bool _swapBytes; - #endif Int _alignment; }; @@ -262,8 +236,8 @@ Descibes how to interpret data which are read from or stored into @ref Texture::compressedImage() "*Texture::compressedImage()" and @ref Texture::compressedSubImage() "*Texture::compressedSubImage()". -Includes all parameters from @ref PixelStorage, except for @ref swapBytes() and -@ref alignment(), which are ignored for compressed images. +Includes all parameters from @ref PixelStorage, except for @ref alignment(), +which is ignored for compressed images. @requires_gl42 Extension @extension{ARB,compressed_texture_pixel_storage} @requires_gl Compressed pixel storage is hardcoded in OpenGL ES and WebGL. @@ -352,10 +326,6 @@ class MAGNUM_EXPORT CompressedPixelStorage: public PixelStorage { #endif private: - #ifndef MAGNUM_TARGET_GLES - using PixelStorage::swapBytes; - using PixelStorage::setSwapBytes; - #endif using PixelStorage::alignment; using PixelStorage::setAlignment; @@ -381,9 +351,6 @@ constexpr PixelStorage::PixelStorage() noexcept: _imageHeight{0}, #endif _skip{0}, - #ifndef MAGNUM_TARGET_GLES - _swapBytes{false}, - #endif _alignment{4} {} namespace Implementation { diff --git a/src/Magnum/Test/PixelStorageTest.cpp b/src/Magnum/Test/PixelStorageTest.cpp index 2264b81e7..430bd9d15 100644 --- a/src/Magnum/Test/PixelStorageTest.cpp +++ b/src/Magnum/Test/PixelStorageTest.cpp @@ -115,9 +115,6 @@ void PixelStorageTest::compare() { .setImageHeight(15) #endif .setSkip({1, 3, 4}) - #ifndef MAGNUM_TARGET_GLES - .setSwapBytes(true) - #endif .setAlignment(3); CORRADE_VERIFY(a == a); @@ -130,9 +127,6 @@ void PixelStorageTest::compare() { CORRADE_VERIFY(PixelStorage{}.setImageHeight(32) != PixelStorage{}.setImageHeight(31)); #endif CORRADE_VERIFY(PixelStorage{}.setSkip({1, 5, 7}) != PixelStorage{}.setSkip({7, 1, 5})); - #ifndef MAGNUM_TARGET_GLES - CORRADE_VERIFY(PixelStorage{}.setSwapBytes(false) != PixelStorage{}.setSwapBytes(true)); - #endif CORRADE_VERIFY(PixelStorage{}.setAlignment(3) != PixelStorage{}.setAlignment(5)); } diff --git a/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.cpp b/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.cpp index 5caec852c..799b2ac29 100644 --- a/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.cpp +++ b/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.cpp @@ -46,13 +46,6 @@ TgaImageConverter::TgaImageConverter(PluginManager::AbstractManager& manager, co auto TgaImageConverter::doFeatures() const -> Features { return Feature::ConvertData; } Containers::Array TgaImageConverter::doExportToData(const ImageView2D& image) { - #ifndef MAGNUM_TARGET_GLES - if(image.storage().swapBytes()) { - Error() << "Trade::TgaImageConverter::exportToData(): pixel byte swap is not supported"; - return nullptr; - } - #endif - if(image.format() != PixelFormat::RGB && image.format() != PixelFormat::RGBA #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) diff --git a/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.h b/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.h index 37b6ed8b7..1fb5fcd7f 100644 --- a/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.h +++ b/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.h @@ -67,10 +67,6 @@ dependency of another plugin with CMake, you need to request the `TgaImageConverter` component of the `Magnum` package and link to the `Magnum::TgaImageConverter` target. See @ref building, @ref cmake and @ref plugins for more information. - -@section Trade-TgaImageConverter-limitations Behavior and limitations - -Does *not* support non-default @ref PixelStorage::swapBytes() values. */ class MAGNUM_TGAIMAGECONVERTER_EXPORT TgaImageConverter: public AbstractImageConverter { public: