Browse Source

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.
pull/233/head
Vladimír Vondruš 8 years ago
parent
commit
01e2727326
  1. 3
      doc/changelog.dox
  2. 4
      doc/opengl-support.dox
  3. 4
      src/Magnum/DebugTools/CompareImage.cpp
  4. 7
      src/Magnum/DebugTools/CompareImage.h
  5. 6
      src/Magnum/Implementation/RendererState.cpp
  6. 4
      src/Magnum/Implementation/RendererState.h
  7. 10
      src/Magnum/PixelStorage.cpp
  8. 37
      src/Magnum/PixelStorage.h
  9. 6
      src/Magnum/Test/PixelStorageTest.cpp
  10. 7
      src/MagnumPlugins/TgaImageConverter/TgaImageConverter.cpp
  11. 4
      src/MagnumPlugins/TgaImageConverter/TgaImageConverter.h

3
doc/changelog.dox

@ -150,6 +150,9 @@ See also:
@subsection changelog-latest-compatibility Potential compatibility breakages, removed APIs @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 - Removed the @cpp Buffer::Usage @ce enum that was deprecated in 2014.01, use
the global @ref BufferUsage enum instead the global @ref BufferUsage enum instead
- Removed the `Magnum/Query.h` header that was deprecated in 2015.05, use one - Removed the `Magnum/Query.h` header that was deprecated in 2015.05, use one

4
doc/opengl-support.dox

@ -543,6 +543,10 @@ add any performance gains, is not supported in Magnum. See also
code. code.
- Direct vertex data specification (as opposed to using buffers) is not - Direct vertex data specification (as opposed to using buffers) is not
supported, as it encourages bad practices. 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 @subsection opengl-unsupported-extensions Unsupported ARB / Khronos extensions

4
src/Magnum/DebugTools/CompareImage.cpp

@ -447,10 +447,6 @@ bool Comparator<DebugTools::CompareImage>::operator()(const ImageView2D& actual,
formatSupported, formatSupported,
"DebugTools::CompareImage: format" << expected.format() << Debug::nospace << "/" << expected.type() << "is not supported", {}); "DebugTools::CompareImage: format" << expected.format() << Debug::nospace << "/" << expected.type() << "is not supported", {});
#endif #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<Float> delta; std::vector<Float> delta;
std::tie(delta, _max, _mean) = DebugTools::Implementation::calculateImageDelta(actual, expected); std::tie(delta, _max, _mean) = DebugTools::Implementation::calculateImageDelta(actual, expected);

7
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::LuminanceAlpha are also accepted in place of
@ref PixelFormat::Red and @ref PixelFormat::RG. @ref PixelFormat::Red and @ref PixelFormat::RG.
Supports all @ref PixelStorage parameters *except* non-default Supports all @ref PixelStorage parameters. The images don't need to have the
@ref PixelStorage::swapBytes() values. The images don't need to have the same same pixel storage parameters, meaning you are able to compare different
pixel storage parameters, meaning you are able to compare different subimages subimages of a larger image as long as they have the same size.
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 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" combination and size. Each pixel is then first converted to @ref Magnum::Float "Float"

6
src/Magnum/Implementation/RendererState.cpp

@ -86,9 +86,6 @@ RendererState::RendererState(Context& context, std::vector<std::string>& extensi
} }
RendererState::PixelStorage::PixelStorage(): RendererState::PixelStorage::PixelStorage():
#ifndef MAGNUM_TARGET_GLES
swapBytes{false},
#endif
alignment{4} alignment{4}
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL)) #if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
, rowLength{0} , rowLength{0}
@ -104,9 +101,6 @@ RendererState::PixelStorage::PixelStorage():
{} {}
void RendererState::PixelStorage::reset() { void RendererState::PixelStorage::reset() {
#ifndef MAGNUM_TARGET_GLES
swapBytes = Containers::NullOpt;
#endif
alignment = DisengagedValue; alignment = DisengagedValue;
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL)) #if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
/* Resets to 0 instead of DisengagedValue in case the EXT_unpack_subimage/ /* Resets to 0 instead of DisengagedValue in case the EXT_unpack_subimage/

4
src/Magnum/Implementation/RendererState.h

@ -27,7 +27,6 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <Corrade/Containers/Optional.h>
#include "Magnum/Renderer.h" #include "Magnum/Renderer.h"
#include "Magnum/Math/Vector3.h" #include "Magnum/Math/Vector3.h"
@ -51,9 +50,6 @@ struct RendererState {
void reset(); void reset();
#ifndef MAGNUM_TARGET_GLES
Containers::Optional<bool> swapBytes;
#endif
Int alignment; Int alignment;
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL)) #if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
Int rowLength; Int rowLength;

10
src/Magnum/PixelStorage.cpp

@ -171,9 +171,6 @@ bool PixelStorage::operator==(const PixelStorage& other) const {
_imageHeight == other._imageHeight && _imageHeight == other._imageHeight &&
#endif #endif
_skip == other._skip && _skip == other._skip &&
#ifndef MAGNUM_TARGET_GLES
_swapBytes == other._swapBytes &&
#endif
_alignment == other._alignment; _alignment == other._alignment;
} }
@ -218,13 +215,6 @@ void PixelStorage::applyInternal(const bool isUnpack) {
Context::current().state().renderer->unpackPixelStorage : Context::current().state().renderer->unpackPixelStorage :
Context::current().state().renderer->packPixelStorage; 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 */ /* Alignment */
if(state.alignment == Implementation::RendererState::PixelStorage::DisengagedValue || state.alignment != _alignment) if(state.alignment == Implementation::RendererState::PixelStorage::DisengagedValue || state.alignment != _alignment)
glPixelStorei(isUnpack ? GL_UNPACK_ALIGNMENT : GL_PACK_ALIGNMENT, glPixelStorei(isUnpack ? GL_UNPACK_ALIGNMENT : GL_PACK_ALIGNMENT,

37
src/Magnum/PixelStorage.h

@ -87,29 +87,6 @@ class MAGNUM_EXPORT PixelStorage {
return !operator==(other); 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 */ /** @brief Row alignment */
constexpr Int alignment() const { return _alignment; } constexpr Int alignment() const { return _alignment; }
@ -245,9 +222,6 @@ class MAGNUM_EXPORT PixelStorage {
void MAGNUM_LOCAL applyUnpack(); void MAGNUM_LOCAL applyUnpack();
void MAGNUM_LOCAL applyPack() { applyInternal(false); } void MAGNUM_LOCAL applyPack() { applyInternal(false); }
#ifndef MAGNUM_TARGET_GLES
bool _swapBytes;
#endif
Int _alignment; 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::compressedImage() "*Texture::compressedImage()" and
@ref Texture::compressedSubImage() "*Texture::compressedSubImage()". @ref Texture::compressedSubImage() "*Texture::compressedSubImage()".
Includes all parameters from @ref PixelStorage, except for @ref swapBytes() and Includes all parameters from @ref PixelStorage, except for @ref alignment(),
@ref alignment(), which are ignored for compressed images. which is ignored for compressed images.
@requires_gl42 Extension @extension{ARB,compressed_texture_pixel_storage} @requires_gl42 Extension @extension{ARB,compressed_texture_pixel_storage}
@requires_gl Compressed pixel storage is hardcoded in OpenGL ES and WebGL. @requires_gl Compressed pixel storage is hardcoded in OpenGL ES and WebGL.
@ -352,10 +326,6 @@ class MAGNUM_EXPORT CompressedPixelStorage: public PixelStorage {
#endif #endif
private: private:
#ifndef MAGNUM_TARGET_GLES
using PixelStorage::swapBytes;
using PixelStorage::setSwapBytes;
#endif
using PixelStorage::alignment; using PixelStorage::alignment;
using PixelStorage::setAlignment; using PixelStorage::setAlignment;
@ -381,9 +351,6 @@ constexpr PixelStorage::PixelStorage() noexcept:
_imageHeight{0}, _imageHeight{0},
#endif #endif
_skip{0}, _skip{0},
#ifndef MAGNUM_TARGET_GLES
_swapBytes{false},
#endif
_alignment{4} {} _alignment{4} {}
namespace Implementation { namespace Implementation {

6
src/Magnum/Test/PixelStorageTest.cpp

@ -115,9 +115,6 @@ void PixelStorageTest::compare() {
.setImageHeight(15) .setImageHeight(15)
#endif #endif
.setSkip({1, 3, 4}) .setSkip({1, 3, 4})
#ifndef MAGNUM_TARGET_GLES
.setSwapBytes(true)
#endif
.setAlignment(3); .setAlignment(3);
CORRADE_VERIFY(a == a); CORRADE_VERIFY(a == a);
@ -130,9 +127,6 @@ void PixelStorageTest::compare() {
CORRADE_VERIFY(PixelStorage{}.setImageHeight(32) != PixelStorage{}.setImageHeight(31)); CORRADE_VERIFY(PixelStorage{}.setImageHeight(32) != PixelStorage{}.setImageHeight(31));
#endif #endif
CORRADE_VERIFY(PixelStorage{}.setSkip({1, 5, 7}) != PixelStorage{}.setSkip({7, 1, 5})); 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)); CORRADE_VERIFY(PixelStorage{}.setAlignment(3) != PixelStorage{}.setAlignment(5));
} }

7
src/MagnumPlugins/TgaImageConverter/TgaImageConverter.cpp

@ -46,13 +46,6 @@ TgaImageConverter::TgaImageConverter(PluginManager::AbstractManager& manager, co
auto TgaImageConverter::doFeatures() const -> Features { return Feature::ConvertData; } auto TgaImageConverter::doFeatures() const -> Features { return Feature::ConvertData; }
Containers::Array<char> TgaImageConverter::doExportToData(const ImageView2D& image) { Containers::Array<char> 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 && if(image.format() != PixelFormat::RGB &&
image.format() != PixelFormat::RGBA image.format() != PixelFormat::RGBA
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))

4
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 `TgaImageConverter` component of the `Magnum` package and link to the
`Magnum::TgaImageConverter` target. See @ref building, @ref cmake and `Magnum::TgaImageConverter` target. See @ref building, @ref cmake and
@ref plugins for more information. @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 { class MAGNUM_TGAIMAGECONVERTER_EXPORT TgaImageConverter: public AbstractImageConverter {
public: public:

Loading…
Cancel
Save