Browse Source

Packed debug output for enums used by Trade.

Again not publicly documented because I don't like the naming and I
don't have the full behavior and interactions figured out yet -- i.e.,
an array of VertexFormats would be printed with Debug::packed as a long
string of characters without any whitespace. Not good, thus this
feature probably needs to be split in two, with this being named
"compact" or something else.
pull/556/head
Vladimír Vondruš 4 years ago
parent
commit
3f13bdb25c
  1. 18
      src/Magnum/Animation/Interpolation.cpp
  2. 21
      src/Magnum/Animation/Test/InterpolationTest.cpp
  3. 22
      src/Magnum/Mesh.cpp
  4. 22
      src/Magnum/PixelFormat.cpp
  5. 27
      src/Magnum/Sampler.cpp
  6. 38
      src/Magnum/Test/MeshTest.cpp
  7. 40
      src/Magnum/Test/PixelFormatTest.cpp
  8. 29
      src/Magnum/Test/SamplerTest.cpp
  9. 18
      src/Magnum/Test/VertexFormatTest.cpp
  10. 20
      src/Magnum/Trade/AnimationData.cpp
  11. 9
      src/Magnum/Trade/CameraData.cpp
  12. 11
      src/Magnum/Trade/Data.cpp
  13. 9
      src/Magnum/Trade/LightData.cpp
  14. 38
      src/Magnum/Trade/MaterialData.cpp
  15. 11
      src/Magnum/Trade/MeshData.cpp
  16. 40
      src/Magnum/Trade/SceneData.cpp
  17. 20
      src/Magnum/Trade/Test/AnimationDataTest.cpp
  18. 11
      src/Magnum/Trade/Test/CameraDataTest.cpp
  19. 20
      src/Magnum/Trade/Test/DataTest.cpp
  20. 11
      src/Magnum/Trade/Test/LightDataTest.cpp
  21. 49
      src/Magnum/Trade/Test/MaterialDataTest.cpp
  22. 9
      src/Magnum/Trade/Test/MeshDataTest.cpp
  23. 45
      src/Magnum/Trade/Test/SceneDataTest.cpp
  24. 11
      src/Magnum/Trade/Test/TextureDataTest.cpp
  25. 9
      src/Magnum/Trade/TextureData.cpp
  26. 11
      src/Magnum/VertexFormat.cpp

18
src/Magnum/Animation/Interpolation.cpp

@ -32,11 +32,14 @@ namespace Magnum { namespace Animation {
#ifndef DOXYGEN_GENERATING_OUTPUT
Debug& operator<<(Debug& debug, const Interpolation value) {
debug << "Animation::Interpolation" << Debug::nospace;
const bool packed = debug.immediateFlags() >= Debug::Flag::Packed;
if(!packed)
debug << "Animation::Interpolation" << Debug::nospace;
switch(value) {
/* LCOV_EXCL_START */
#define _c(value) case Interpolation::value: return debug << "::" #value;
#define _c(value) case Interpolation::value: return debug << (packed ? "" : "::") << Debug::nospace << #value;
_c(Constant)
_c(Linear)
_c(Spline)
@ -45,15 +48,18 @@ Debug& operator<<(Debug& debug, const Interpolation value) {
/* LCOV_EXCL_STOP */
}
return debug << "(" << Debug::nospace << reinterpret_cast<void*>(UnsignedByte(value)) << Debug::nospace << ")";
return debug << (packed ? "" : "(") << Debug::nospace << reinterpret_cast<void*>(UnsignedByte(value)) << Debug::nospace << (packed ? "" : ")");
}
Debug& operator<<(Debug& debug, const Extrapolation value) {
debug << "Animation::Extrapolation" << Debug::nospace;
const bool packed = debug.immediateFlags() >= Debug::Flag::Packed;
if(!packed)
debug << "Animation::Extrapolation" << Debug::nospace;
switch(value) {
/* LCOV_EXCL_START */
#define _c(value) case Extrapolation::value: return debug << "::" #value;
#define _c(value) case Extrapolation::value: return debug << (packed ? "" : "::") << Debug::nospace << #value;
_c(DefaultConstructed)
_c(Constant)
_c(Extrapolated)
@ -61,7 +67,7 @@ Debug& operator<<(Debug& debug, const Extrapolation value) {
/* LCOV_EXCL_STOP */
}
return debug << "(" << Debug::nospace << reinterpret_cast<void*>(UnsignedByte(value)) << Debug::nospace << ")";
return debug << (packed ? "" : "(") << Debug::nospace << reinterpret_cast<void*>(UnsignedByte(value)) << Debug::nospace << (packed ? "" : ")");
}
#endif

21
src/Magnum/Animation/Test/InterpolationTest.cpp

@ -85,7 +85,9 @@ struct InterpolationTest: TestSuite::Tester {
void unpackEaseClamped();
void debugInterpolation();
void debugInterpolationPacked();
void debugExtrapolation();
void debugExtrapolationPacked();
};
using namespace Math::Literals;
@ -207,7 +209,9 @@ InterpolationTest::InterpolationTest() {
&InterpolationTest::unpackEaseClamped,
&InterpolationTest::debugInterpolation,
&InterpolationTest::debugExtrapolation});
&InterpolationTest::debugInterpolationPacked,
&InterpolationTest::debugExtrapolation,
&InterpolationTest::debugExtrapolationPacked});
}
void InterpolationTest::interpolatorFor() {
@ -654,6 +658,13 @@ void InterpolationTest::debugInterpolation() {
CORRADE_COMPARE(out.str(), "Animation::Interpolation::Custom Animation::Interpolation(0xde)\n");
}
void InterpolationTest::debugInterpolationPacked() {
std::ostringstream out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << Interpolation::Custom << Debug::packed << Interpolation(0xde) << Interpolation::Constant;
CORRADE_COMPARE(out.str(), "Custom 0xde Animation::Interpolation::Constant\n");
}
void InterpolationTest::debugExtrapolation() {
std::ostringstream out;
@ -661,6 +672,14 @@ void InterpolationTest::debugExtrapolation() {
CORRADE_COMPARE(out.str(), "Animation::Extrapolation::DefaultConstructed Animation::Extrapolation(0xde)\n");
}
void InterpolationTest::debugExtrapolationPacked() {
std::ostringstream out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << Extrapolation::DefaultConstructed << Debug::packed << Extrapolation(0xde) << Extrapolation::Constant;
CORRADE_COMPARE(out.str(), "DefaultConstructed 0xde Animation::Extrapolation::Constant\n");
}
}}}}
CORRADE_TEST_MAIN(Magnum::Animation::Test::InterpolationTest)

22
src/Magnum/Mesh.cpp

@ -44,17 +44,20 @@ constexpr const char* MeshPrimitiveNames[] {
}
Debug& operator<<(Debug& debug, const MeshPrimitive value) {
debug << "MeshPrimitive" << Debug::nospace;
const bool packed = debug.immediateFlags() >= Debug::Flag::Packed;
if(!packed)
debug << "MeshPrimitive" << Debug::nospace;
if(isMeshPrimitiveImplementationSpecific(value)) {
return debug << "::ImplementationSpecific(" << Debug::nospace << reinterpret_cast<void*>(meshPrimitiveUnwrap(value)) << Debug::nospace << ")";
return debug << (packed ? "ImplementationSpecific(" : "::ImplementationSpecific(") << Debug::nospace << reinterpret_cast<void*>(meshPrimitiveUnwrap(value)) << Debug::nospace << ")";
}
if(UnsignedInt(value) - 1 < Containers::arraySize(MeshPrimitiveNames)) {
return debug << "::" << Debug::nospace << MeshPrimitiveNames[UnsignedInt(value) - 1];
return debug << (packed ? "" : "::") << Debug::nospace << MeshPrimitiveNames[UnsignedInt(value) - 1];
}
return debug << "(" << Debug::nospace << reinterpret_cast<void*>(UnsignedInt(value)) << Debug::nospace << ")";
return debug << (packed ? "" : "(") << Debug::nospace << reinterpret_cast<void*>(UnsignedInt(value)) << Debug::nospace << (packed ? "" : ")");
}
namespace {
@ -68,17 +71,20 @@ constexpr const char* MeshIndexTypeNames[] {
}
Debug& operator<<(Debug& debug, const MeshIndexType value) {
debug << "MeshIndexType" << Debug::nospace;
const bool packed = debug.immediateFlags() >= Debug::Flag::Packed;
if(!packed)
debug << "MeshIndexType" << Debug::nospace;
if(isMeshIndexTypeImplementationSpecific(value)) {
return debug << "::ImplementationSpecific(" << Debug::nospace << reinterpret_cast<void*>(meshIndexTypeUnwrap(value)) << Debug::nospace << ")";
return debug << (packed ? "ImplementationSpecific(" : "::ImplementationSpecific(") << Debug::nospace << reinterpret_cast<void*>(meshIndexTypeUnwrap(value)) << Debug::nospace << ")";
}
if(UnsignedInt(value) - 1 < Containers::arraySize(MeshIndexTypeNames)) {
return debug << "::" << Debug::nospace << MeshIndexTypeNames[UnsignedInt(value) - 1];
return debug << (packed ? "" : "::") << Debug::nospace << MeshIndexTypeNames[UnsignedInt(value) - 1];
}
return debug << "(" << Debug::nospace << reinterpret_cast<void*>(UnsignedInt(value)) << Debug::nospace << ")";
return debug << (packed ? "" : "(") << Debug::nospace << reinterpret_cast<void*>(UnsignedInt(value)) << Debug::nospace << (packed ? "" : ")");
}
#endif

22
src/Magnum/PixelFormat.cpp

@ -132,17 +132,20 @@ constexpr const char* PixelFormatNames[] {
#ifndef DOXYGEN_GENERATING_OUTPUT
Debug& operator<<(Debug& debug, const PixelFormat value) {
debug << "PixelFormat" << Debug::nospace;
const bool packed = debug.immediateFlags() >= Debug::Flag::Packed;
if(!packed)
debug << "PixelFormat" << Debug::nospace;
if(isPixelFormatImplementationSpecific(value)) {
return debug << "::ImplementationSpecific(" << Debug::nospace << reinterpret_cast<void*>(pixelFormatUnwrap(value)) << Debug::nospace << ")";
return debug << (packed ? "ImplementationSpecific(" : "::ImplementationSpecific(") << Debug::nospace << reinterpret_cast<void*>(pixelFormatUnwrap(value)) << Debug::nospace << ")";
}
if(UnsignedInt(value) - 1 < Containers::arraySize(PixelFormatNames)) {
return debug << "::" << Debug::nospace << PixelFormatNames[UnsignedInt(value) - 1];
return debug << (packed ? "" : "::") << Debug::nospace << PixelFormatNames[UnsignedInt(value) - 1];
}
return debug << "(" << Debug::nospace << reinterpret_cast<void*>(UnsignedInt(value)) << Debug::nospace << ")";
return debug << (packed ? "" : "(") << Debug::nospace << reinterpret_cast<void*>(UnsignedInt(value)) << Debug::nospace << (packed ? "" : ")");
}
#endif
@ -198,17 +201,20 @@ UnsignedInt compressedBlockDataSize(const CompressedPixelFormat format) {
#ifndef DOXYGEN_GENERATING_OUTPUT
Debug& operator<<(Debug& debug, const CompressedPixelFormat value) {
debug << "CompressedPixelFormat" << Debug::nospace;
const bool packed = debug.immediateFlags() >= Debug::Flag::Packed;
if(!packed)
debug << "CompressedPixelFormat" << Debug::nospace;
if(isCompressedPixelFormatImplementationSpecific(value)) {
return debug << "::ImplementationSpecific(" << Debug::nospace << reinterpret_cast<void*>(compressedPixelFormatUnwrap(value)) << Debug::nospace << ")";
return debug << (packed ? "ImplementationSpecific(" : "::ImplementationSpecific(") << Debug::nospace << reinterpret_cast<void*>(compressedPixelFormatUnwrap(value)) << Debug::nospace << ")";
}
if(UnsignedInt(value) - 1 < Containers::arraySize(CompressedPixelFormatNames)) {
return debug << "::" << Debug::nospace << CompressedPixelFormatNames[UnsignedInt(value) - 1];
return debug << (packed ? "" : "::") << Debug::nospace << CompressedPixelFormatNames[UnsignedInt(value) - 1];
}
return debug << "(" << Debug::nospace << reinterpret_cast<void*>(UnsignedInt(value)) << Debug::nospace << ")";
return debug << (packed ? "" : "(") << Debug::nospace << reinterpret_cast<void*>(UnsignedInt(value)) << Debug::nospace << (packed ? "" : ")");
}
#endif

27
src/Magnum/Sampler.cpp

@ -31,26 +31,32 @@ namespace Magnum {
#ifndef DOXYGEN_GENERATING_OUTPUT
Debug& operator<<(Debug& debug, const SamplerFilter value) {
debug << "SamplerFilter" << Debug::nospace;
const bool packed = debug.immediateFlags() >= Debug::Flag::Packed;
if(!packed)
debug << "SamplerFilter" << Debug::nospace;
switch(value) {
/* LCOV_EXCL_START */
#define _c(value) case SamplerFilter::value: return debug << "::" #value;
#define _c(value) case SamplerFilter::value: return debug << (packed ? "" : "::") << Debug::nospace << #value;
_c(Nearest)
_c(Linear)
#undef _c
/* LCOV_EXCL_STOP */
}
return debug << "(" << Debug::nospace << reinterpret_cast<void*>(UnsignedInt(value)) << Debug::nospace << ")";
return debug << (packed ? "" : "(") << Debug::nospace << reinterpret_cast<void*>(UnsignedInt(value)) << Debug::nospace << (packed ? "" : ")");
}
Debug& operator<<(Debug& debug, const SamplerMipmap value) {
debug << "SamplerMipmap" << Debug::nospace;
const bool packed = debug.immediateFlags() >= Debug::Flag::Packed;
if(!packed)
debug << "SamplerMipmap" << Debug::nospace;
switch(value) {
/* LCOV_EXCL_START */
#define _c(value) case SamplerMipmap::value: return debug << "::" #value;
#define _c(value) case SamplerMipmap::value: return debug << (packed ? "" : "::") << Debug::nospace << #value;
_c(Base)
_c(Nearest)
_c(Linear)
@ -58,15 +64,18 @@ Debug& operator<<(Debug& debug, const SamplerMipmap value) {
/* LCOV_EXCL_STOP */
}
return debug << "(" << Debug::nospace << reinterpret_cast<void*>(UnsignedInt(value)) << Debug::nospace << ")";
return debug << (packed ? "" : "(") << Debug::nospace << reinterpret_cast<void*>(UnsignedInt(value)) << Debug::nospace << (packed ? "" : ")");
}
Debug& operator<<(Debug& debug, const SamplerWrapping value) {
debug << "SamplerWrapping" << Debug::nospace;
const bool packed = debug.immediateFlags() >= Debug::Flag::Packed;
if(!packed)
debug << "SamplerWrapping" << Debug::nospace;
switch(value) {
/* LCOV_EXCL_START */
#define _c(value) case SamplerWrapping::value: return debug << "::" #value;
#define _c(value) case SamplerWrapping::value: return debug << (packed ? "" : "::") << Debug::nospace << #value;
_c(Repeat)
_c(MirroredRepeat)
_c(ClampToEdge)
@ -76,7 +85,7 @@ Debug& operator<<(Debug& debug, const SamplerWrapping value) {
/* LCOV_EXCL_STOP */
}
return debug << "(" << Debug::nospace << reinterpret_cast<void*>(UnsignedInt(value)) << Debug::nospace << ")";
return debug << (packed ? "" : "(") << Debug::nospace << reinterpret_cast<void*>(UnsignedInt(value)) << Debug::nospace << (packed ? "" : ")");
}
#endif

38
src/Magnum/Test/MeshTest.cpp

@ -54,9 +54,13 @@ struct MeshTest: TestSuite::Tester {
void indexTypeSizeImplementationSpecific();
void debugPrimitive();
void debugPrimitivePacked();
void debugPrimitiveImplementationSpecific();
void debugPrimitiveImplementationSpecificPacked();
void debugIndexType();
void debugIndexTypePacked();
void debugIndexTypeImplementationSpecific();
void debugIndexTypeImplementationSpecificPacked();
void configurationPrimitive();
void configurationIndexType();
@ -81,9 +85,13 @@ MeshTest::MeshTest() {
&MeshTest::indexTypeSizeImplementationSpecific,
&MeshTest::debugPrimitive,
&MeshTest::debugPrimitivePacked,
&MeshTest::debugPrimitiveImplementationSpecific,
&MeshTest::debugPrimitiveImplementationSpecificPacked,
&MeshTest::debugIndexType,
&MeshTest::debugIndexTypePacked,
&MeshTest::debugIndexTypeImplementationSpecific,
&MeshTest::debugIndexTypeImplementationSpecificPacked,
&MeshTest::configurationPrimitive,
&MeshTest::configurationIndexType});
@ -288,6 +296,13 @@ void MeshTest::debugPrimitive() {
CORRADE_COMPARE(o.str(), "MeshPrimitive::TriangleFan MeshPrimitive(0x70fe)\n");
}
void MeshTest::debugPrimitivePacked() {
std::ostringstream out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << MeshPrimitive::TriangleFan << Debug::packed << MeshPrimitive(0x70fe) << MeshPrimitive::Triangles;
CORRADE_COMPARE(out.str(), "TriangleFan 0x70fe MeshPrimitive::Triangles\n");
}
void MeshTest::debugPrimitiveImplementationSpecific() {
std::ostringstream out;
Debug{&out} << meshPrimitiveWrap(0xdead);
@ -295,10 +310,24 @@ void MeshTest::debugPrimitiveImplementationSpecific() {
CORRADE_COMPARE(out.str(), "MeshPrimitive::ImplementationSpecific(0xdead)\n");
}
void MeshTest::debugPrimitiveImplementationSpecificPacked() {
std::ostringstream out;
/* Second is not packed, the first should not make any flags persistent */
Debug{&out} << Debug::packed << meshPrimitiveWrap(0xdead) << MeshPrimitive::Triangles;
CORRADE_COMPARE(out.str(), "ImplementationSpecific(0xdead) MeshPrimitive::Triangles\n");
}
void MeshTest::debugIndexType() {
std::ostringstream o;
Debug(&o) << MeshIndexType::UnsignedShort << MeshIndexType(0x70fe);
CORRADE_COMPARE(o.str(), "MeshIndexType::UnsignedShort MeshIndexType(0xfe)\n");
CORRADE_COMPARE(o.str(), "MeshIndexType::UnsignedShort MeshIndexType(0x70fe)\n");
}
void MeshTest::debugIndexTypePacked() {
std::ostringstream out;
/* Last is not packed, ones before should not make any flags persistent */
Debug(&out) << Debug::packed << MeshIndexType::UnsignedShort << Debug::packed << MeshIndexType(0x70fe) << MeshIndexType::UnsignedInt;
CORRADE_COMPARE(out.str(), "UnsignedShort 0x70fe MeshIndexType::UnsignedInt\n");
}
void MeshTest::debugIndexTypeImplementationSpecific() {
@ -308,6 +337,13 @@ void MeshTest::debugIndexTypeImplementationSpecific() {
CORRADE_COMPARE(out.str(), "MeshIndexType::ImplementationSpecific(0xdead)\n");
}
void MeshTest::debugIndexTypeImplementationSpecificPacked() {
std::ostringstream out;
/* Second is not packed, the first should not make any flags persistent */
Debug{&out} << Debug::packed << meshIndexTypeWrap(0xdead) << MeshIndexType::UnsignedInt;
CORRADE_COMPARE(out.str(), "ImplementationSpecific(0xdead) MeshIndexType::UnsignedInt\n");
}
void MeshTest::configurationPrimitive() {
Utility::Configuration c;

40
src/Magnum/Test/PixelFormatTest.cpp

@ -61,10 +61,14 @@ struct PixelFormatTest: TestSuite::Tester {
void compressedUnwrapInvalid();
void debug();
void debugPacked();
void debugImplementationSpecific();
void debugImplementationSpecificPacked();
void compressedDebug();
void compressedDebugPacked();
void compressedDebugImplementationSpecific();
void compressedDebugImplementationSpecificPacked();
void configuration();
void compresedConfiguration();
@ -95,10 +99,14 @@ PixelFormatTest::PixelFormatTest() {
&PixelFormatTest::compressedUnwrapInvalid,
&PixelFormatTest::debug,
&PixelFormatTest::debugPacked,
&PixelFormatTest::debugImplementationSpecific,
&PixelFormatTest::debugImplementationSpecificPacked,
&PixelFormatTest::compressedDebug,
&PixelFormatTest::compressedDebugPacked,
&PixelFormatTest::compressedDebugImplementationSpecific,
&PixelFormatTest::compressedDebugImplementationSpecificPacked,
&PixelFormatTest::configuration,
&PixelFormatTest::compresedConfiguration});
@ -367,6 +375,14 @@ void PixelFormatTest::debug() {
CORRADE_COMPARE(out.str(), "PixelFormat::RG16Snorm PixelFormat(0xdead)\n");
}
void PixelFormatTest::debugPacked() {
std::ostringstream out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << PixelFormat::RG16Snorm << Debug::packed << PixelFormat(0xdead) << PixelFormat::RGBA8Unorm;
CORRADE_COMPARE(out.str(), "RG16Snorm 0xdead PixelFormat::RGBA8Unorm\n");
}
void PixelFormatTest::debugImplementationSpecific() {
std::ostringstream out;
Debug{&out} << pixelFormatWrap(0xdead);
@ -374,6 +390,14 @@ void PixelFormatTest::debugImplementationSpecific() {
CORRADE_COMPARE(out.str(), "PixelFormat::ImplementationSpecific(0xdead)\n");
}
void PixelFormatTest::debugImplementationSpecificPacked() {
std::ostringstream out;
/* Second is not packed, the first should not make any flags persistent */
Debug{&out} << Debug::packed << pixelFormatWrap(0xdead) << PixelFormat::RGBA8Unorm;
CORRADE_COMPARE(out.str(), "ImplementationSpecific(0xdead) PixelFormat::RGBA8Unorm\n");
}
void PixelFormatTest::compressedDebug() {
std::ostringstream out;
Debug{&out} << CompressedPixelFormat::Bc3RGBAUnorm << CompressedPixelFormat(0xdead);
@ -381,6 +405,14 @@ void PixelFormatTest::compressedDebug() {
CORRADE_COMPARE(out.str(), "CompressedPixelFormat::Bc3RGBAUnorm CompressedPixelFormat(0xdead)\n");
}
void PixelFormatTest::compressedDebugPacked() {
std::ostringstream out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << CompressedPixelFormat::Bc3RGBAUnorm << Debug::packed << CompressedPixelFormat(0xdead) << CompressedPixelFormat::Astc10x10RGBAF;
CORRADE_COMPARE(out.str(), "Bc3RGBAUnorm 0xdead CompressedPixelFormat::Astc10x10RGBAF\n");
}
void PixelFormatTest::compressedDebugImplementationSpecific() {
std::ostringstream out;
Debug{&out} << compressedPixelFormatWrap(0xdead);
@ -388,6 +420,14 @@ void PixelFormatTest::compressedDebugImplementationSpecific() {
CORRADE_COMPARE(out.str(), "CompressedPixelFormat::ImplementationSpecific(0xdead)\n");
}
void PixelFormatTest::compressedDebugImplementationSpecificPacked() {
std::ostringstream out;
/* Second is not packed, the first should not make any flags persistent */
Debug{&out} << compressedPixelFormatWrap(0xdead) << CompressedPixelFormat::Astc10x10RGBAF;
CORRADE_COMPARE(out.str(), "CompressedPixelFormat::ImplementationSpecific(0xdead) CompressedPixelFormat::Astc10x10RGBAF\n");
}
void PixelFormatTest::configuration() {
Utility::Configuration c;

29
src/Magnum/Test/SamplerTest.cpp

@ -35,14 +35,20 @@ struct SamplerTest: TestSuite::Tester {
explicit SamplerTest();
void debugFilter();
void debugFilterPacked();
void debugMipmap();
void debugMipmapPacked();
void debugWrapping();
void debugWrappingPacked();
};
SamplerTest::SamplerTest() {
addTests({&SamplerTest::debugFilter,
&SamplerTest::debugFilterPacked,
&SamplerTest::debugMipmap,
&SamplerTest::debugWrapping});
&SamplerTest::debugMipmapPacked,
&SamplerTest::debugWrapping,
&SamplerTest::debugWrappingPacked});
}
void SamplerTest::debugFilter() {
@ -52,6 +58,13 @@ void SamplerTest::debugFilter() {
CORRADE_COMPARE(out.str(), "SamplerFilter::Linear SamplerFilter(0xdead)\n");
}
void SamplerTest::debugFilterPacked() {
std::ostringstream out;
/* Last is not packed, ones before should not make any flags persistent */
Debug(&out) << Debug::packed << SamplerFilter::Linear << Debug::packed << SamplerFilter(0xdead) << SamplerFilter::Nearest;
CORRADE_COMPARE(out.str(), "Linear 0xdead SamplerFilter::Nearest\n");
}
void SamplerTest::debugMipmap() {
std::ostringstream out;
@ -59,6 +72,13 @@ void SamplerTest::debugMipmap() {
CORRADE_COMPARE(out.str(), "SamplerMipmap::Base SamplerMipmap(0xdead)\n");
}
void SamplerTest::debugMipmapPacked() {
std::ostringstream out;
/* Last is not packed, ones before should not make any flags persistent */
Debug(&out) << Debug::packed << SamplerMipmap::Base << Debug::packed << SamplerMipmap(0xdead) << SamplerMipmap::Nearest;
CORRADE_COMPARE(out.str(), "Base 0xdead SamplerMipmap::Nearest\n");
}
void SamplerTest::debugWrapping() {
std::ostringstream out;
@ -66,6 +86,13 @@ void SamplerTest::debugWrapping() {
CORRADE_COMPARE(out.str(), "SamplerWrapping::ClampToEdge SamplerWrapping(0xdead)\n");
}
void SamplerTest::debugWrappingPacked() {
std::ostringstream out;
/* Last is not packed, ones before should not make any flags persistent */
Debug(&out) << Debug::packed << SamplerWrapping::ClampToEdge << Debug::packed << SamplerWrapping(0xdead) << SamplerWrapping::Repeat;
CORRADE_COMPARE(out.str(), "ClampToEdge 0xdead SamplerWrapping::Repeat\n");
}
}}}
CORRADE_TEST_MAIN(Magnum::Test::SamplerTest)

18
src/Magnum/Test/VertexFormatTest.cpp

@ -77,7 +77,9 @@ struct VertexFormatTest: TestSuite::Tester {
void assembleMatrixImplementationSpecific();
void debug();
void debugPacked();
void debugImplementationSpecific();
void debugImplementationSpecificPacked();
void configuration();
};
@ -171,7 +173,9 @@ VertexFormatTest::VertexFormatTest() {
&VertexFormatTest::assembleMatrixImplementationSpecific,
&VertexFormatTest::debug,
&VertexFormatTest::debugPacked,
&VertexFormatTest::debugImplementationSpecific,
&VertexFormatTest::debugImplementationSpecificPacked,
&VertexFormatTest::configuration});
}
@ -677,12 +681,26 @@ void VertexFormatTest::debug() {
CORRADE_COMPARE(o.str(), "VertexFormat::Vector4 VertexFormat(0xdead)\n");
}
void VertexFormatTest::debugPacked() {
std::ostringstream out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << VertexFormat::Vector4 << Debug::packed << VertexFormat(0xdead) << VertexFormat::Float;
CORRADE_COMPARE(out.str(), "Vector4 0xdead VertexFormat::Float\n");
}
void VertexFormatTest::debugImplementationSpecific() {
std::ostringstream o;
Debug(&o) << Magnum::vertexFormatWrap(0xdead);
CORRADE_COMPARE(o.str(), "VertexFormat::ImplementationSpecific(0xdead)\n");
}
void VertexFormatTest::debugImplementationSpecificPacked() {
std::ostringstream out;
/* Second is not packed, the first should not make any flags persistent */
Debug{&out} << Debug::packed << Magnum::vertexFormatWrap(0xdead) << VertexFormat::Float;
CORRADE_COMPARE(out.str(), "ImplementationSpecific(0xdead) VertexFormat::Float\n");
}
void VertexFormatTest::configuration() {
Utility::Configuration c;

20
src/Magnum/Trade/AnimationData.cpp

@ -145,11 +145,14 @@ template MAGNUM_TRADE_EXPORT auto animationInterpolatorFor<CubicHermiteComplex,
template MAGNUM_TRADE_EXPORT auto animationInterpolatorFor<CubicHermiteQuaternion, Quaternion>(Animation::Interpolation) -> Quaternion(*)(const CubicHermiteQuaternion&, const CubicHermiteQuaternion&, Float);
Debug& operator<<(Debug& debug, const AnimationTrackType value) {
debug << "Trade::AnimationTrackType" << Debug::nospace;
const bool packed = debug.immediateFlags() >= Debug::Flag::Packed;
if(!packed)
debug << "Trade::AnimationTrackType" << Debug::nospace;
switch(value) {
/* LCOV_EXCL_START */
#define _c(value) case AnimationTrackType::value: return debug << "::" #value;
#define _c(value) case AnimationTrackType::value: return debug << (packed ? "" : "::") << Debug::nospace << #value;
_c(Bool)
_c(Float)
_c(UnsignedInt)
@ -178,16 +181,21 @@ Debug& operator<<(Debug& debug, const AnimationTrackType value) {
/* LCOV_EXCL_STOP */
}
return debug << "(" << Debug::nospace << reinterpret_cast<void*>(UnsignedByte(value)) << Debug::nospace << ")";
return debug << (packed ? "" : "(") << Debug::nospace << reinterpret_cast<void*>(UnsignedByte(value)) << Debug::nospace << (packed ? "" : ")");
}
Debug& operator<<(Debug& debug, const AnimationTrackTargetType value) {
const bool packed = debug.immediateFlags() >= Debug::Flag::Packed;
if(!packed)
debug << "Trade::AnimationTrackTargetType" << Debug::nospace;
if(UnsignedByte(value) >= UnsignedByte(AnimationTrackTargetType::Custom))
return debug << "Trade::AnimationTrackTargetType::Custom(" << Debug::nospace << UnsignedByte(value) << Debug::nospace << ")";
return debug << (packed ? "Custom(" : "::Custom(") << Debug::nospace << UnsignedByte(value) << Debug::nospace << ")";
switch(value) {
/* LCOV_EXCL_START */
#define _c(value) case AnimationTrackTargetType::value: return debug << "Trade::AnimationTrackTargetType::" #value;
#define _c(value) case AnimationTrackTargetType::value: return debug << (packed ? "" : "::") << Debug::nospace << #value;
_c(Translation2D)
_c(Translation3D)
_c(Rotation2D)
@ -201,7 +209,7 @@ Debug& operator<<(Debug& debug, const AnimationTrackTargetType value) {
case AnimationTrackTargetType::Custom: CORRADE_INTERNAL_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
}
return debug << "Trade::AnimationTrackTargetType(" << Debug::nospace << reinterpret_cast<void*>(UnsignedByte(value)) << Debug::nospace << ")";
return debug << (packed ? "" : "(") << Debug::nospace << reinterpret_cast<void*>(UnsignedByte(value)) << Debug::nospace << (packed ? "" : ")");
}
#endif

9
src/Magnum/Trade/CameraData.cpp

@ -47,11 +47,14 @@ Rad CameraData::fov() const {
}
Debug& operator<<(Debug& debug, const CameraType value) {
debug << "Trade::CameraType" << Debug::nospace;
const bool packed = debug.immediateFlags() >= Debug::Flag::Packed;
if(!packed)
debug << "Trade::CameraType" << Debug::nospace;
switch(value) {
/* LCOV_EXCL_START */
#define _c(value) case CameraType::value: return debug << "::" #value;
#define _c(value) case CameraType::value: return debug << (packed ? "" : "::") << Debug::nospace << #value;
_c(Orthographic2D)
_c(Orthographic3D)
_c(Perspective3D)
@ -59,7 +62,7 @@ Debug& operator<<(Debug& debug, const CameraType value) {
/* LCOV_EXCL_STOP */
}
return debug << "(" << Debug::nospace << reinterpret_cast<void*>(UnsignedByte(value)) << Debug::nospace << ")";
return debug << (packed ? "" : "(") << Debug::nospace << reinterpret_cast<void*>(UnsignedByte(value)) << Debug::nospace << (packed ? "" : ")");
}
}}

11
src/Magnum/Trade/Data.cpp

@ -30,11 +30,14 @@
namespace Magnum { namespace Trade {
Debug& operator<<(Debug& debug, const DataFlag value) {
debug << "Trade::DataFlag" << Debug::nospace;
const bool packed = debug.immediateFlags() >= Debug::Flag::Packed;
if(!packed)
debug << "Trade::DataFlag" << Debug::nospace;
switch(value) {
/* LCOV_EXCL_START */
#define _c(v) case DataFlag::v: return debug << "::" #v;
#define _c(v) case DataFlag::v: return debug << (packed ? "" : "::") << Debug::nospace << #v;
_c(Owned)
_c(ExternallyOwned)
_c(Mutable)
@ -42,11 +45,11 @@ Debug& operator<<(Debug& debug, const DataFlag value) {
/* LCOV_EXCL_STOP */
}
return debug << "(" << Debug::nospace << reinterpret_cast<void*>(UnsignedByte(value)) << Debug::nospace << ")";
return debug << (packed ? "" : "(") << Debug::nospace << reinterpret_cast<void*>(UnsignedByte(value)) << Debug::nospace << (packed ? "" : ")");
}
Debug& operator<<(Debug& debug, const DataFlags value) {
return Containers::enumSetDebugOutput(debug, value, "Trade::DataFlags{}", {
return Containers::enumSetDebugOutput(debug, value, debug.immediateFlags() >= Debug::Flag::Packed ? "{}" : "Trade::DataFlags{}", {
DataFlag::Owned,
DataFlag::ExternallyOwned,
DataFlag::Mutable});

9
src/Magnum/Trade/LightData.cpp

@ -65,11 +65,14 @@ LightData::LightData(const Type type, const Color3& color, const Float intensity
#ifndef DOXYGEN_GENERATING_OUTPUT
Debug& operator<<(Debug& debug, const LightData::Type value) {
debug << "Trade::LightData::Type" << Debug::nospace;
const bool packed = debug.immediateFlags() >= Debug::Flag::Packed;
if(!packed)
debug << "Trade::LightData::Type" << Debug::nospace;
switch(value) {
/* LCOV_EXCL_START */
#define _c(value) case LightData::Type::value: return debug << "::" #value;
#define _c(value) case LightData::Type::value: return debug << (packed ? "" : "::") << Debug::nospace << #value;
_c(Ambient)
_c(Directional)
_c(Point)
@ -78,7 +81,7 @@ Debug& operator<<(Debug& debug, const LightData::Type value) {
/* LCOV_EXCL_STOP */
}
return debug << "(" << Debug::nospace << reinterpret_cast<void*>(UnsignedByte(value)) << Debug::nospace << ")";
return debug << (packed ? "" : "(") << Debug::nospace << reinterpret_cast<void*>(UnsignedByte(value)) << Debug::nospace << (packed ? "" : ")");
}
#endif

38
src/Magnum/Trade/MaterialData.cpp

@ -968,16 +968,24 @@ Debug& operator<<(Debug& debug, const MaterialTextureSwizzle value) {
a char. Worst case this will print nothing or four garbage letters.
Sorry in that case. GCC 4.8 doesn't understand just {}, wants to have
a full MaterialTextureSwizzle{} here. */
MaterialTextureSwizzle values[]{value, MaterialTextureSwizzle{}};
return debug << "Trade::MaterialTextureSwizzle::" << Debug::nospace << reinterpret_cast<const char*>(values);
const MaterialTextureSwizzle values[]{value, MaterialTextureSwizzle{}};
const bool packed = debug.immediateFlags() >= Debug::Flag::Packed;
if(!packed)
debug << "Trade::MaterialTextureSwizzle::" << Debug::nospace;
return debug << reinterpret_cast<const char*>(values);
}
Debug& operator<<(Debug& debug, const MaterialAttributeType value) {
debug << "Trade::MaterialAttributeType" << Debug::nospace;
const bool packed = debug.immediateFlags() >= Debug::Flag::Packed;
if(!packed)
debug << "Trade::MaterialAttributeType" << Debug::nospace;
switch(value) {
/* LCOV_EXCL_START */
#define _c(value) case MaterialAttributeType::value: return debug << "::" #value;
#define _c(value) case MaterialAttributeType::value: return debug << (packed ? "" : "::") << Debug::nospace << #value;
_c(Bool)
_c(Float)
_c(Deg)
@ -1011,15 +1019,18 @@ Debug& operator<<(Debug& debug, const MaterialAttributeType value) {
/* LCOV_EXCL_STOP */
}
return debug << "(" << Debug::nospace << reinterpret_cast<void*>(UnsignedShort(value)) << Debug::nospace << ")";
return debug << (packed ? "" : "(") << Debug::nospace << reinterpret_cast<void*>(UnsignedShort(value)) << Debug::nospace << (packed ? "" : ")");
}
Debug& operator<<(Debug& debug, const MaterialType value) {
debug << "Trade::MaterialType" << Debug::nospace;
const bool packed = debug.immediateFlags() >= Debug::Flag::Packed;
if(!packed)
debug << "Trade::MaterialType" << Debug::nospace;
switch(value) {
/* LCOV_EXCL_START */
#define _c(value) case MaterialType::value: return debug << "::" #value;
#define _c(value) case MaterialType::value: return debug << (packed ? "" : "::") << Debug::nospace << #value;
_c(Flat)
_c(Phong)
_c(PbrMetallicRoughness)
@ -1029,11 +1040,11 @@ Debug& operator<<(Debug& debug, const MaterialType value) {
/* LCOV_EXCL_STOP */
}
return debug << "(" << Debug::nospace << reinterpret_cast<void*>(UnsignedByte(value)) << Debug::nospace << ")";
return debug << (packed ? "" : "(") << Debug::nospace << reinterpret_cast<void*>(UnsignedByte(value)) << Debug::nospace << (packed ? "" : ")");
}
Debug& operator<<(Debug& debug, const MaterialTypes value) {
return Containers::enumSetDebugOutput(debug, value, "Trade::MaterialTypes{}", {
return Containers::enumSetDebugOutput(debug, value, debug.immediateFlags() >= Debug::Flag::Packed ? "{}" : "Trade::MaterialTypes{}", {
MaterialType::Flat,
MaterialType::Phong,
MaterialType::PbrMetallicRoughness,
@ -1067,11 +1078,14 @@ CORRADE_IGNORE_DEPRECATED_POP
#endif
Debug& operator<<(Debug& debug, const MaterialAlphaMode value) {
debug << "Trade::MaterialAlphaMode" << Debug::nospace;
const bool packed = debug.immediateFlags() >= Debug::Flag::Packed;
if(!packed)
debug << "Trade::MaterialAlphaMode" << Debug::nospace;
switch(value) {
/* LCOV_EXCL_START */
#define _c(value) case MaterialAlphaMode::value: return debug << "::" #value;
#define _c(value) case MaterialAlphaMode::value: return debug << (packed ? "" : "::") << Debug::nospace << #value;
_c(Opaque)
_c(Mask)
_c(Blend)
@ -1079,7 +1093,7 @@ Debug& operator<<(Debug& debug, const MaterialAlphaMode value) {
/* LCOV_EXCL_STOP */
}
return debug << "(" << Debug::nospace << reinterpret_cast<void*>(UnsignedByte(value)) << Debug::nospace << ")";
return debug << (packed ? "" : "(") << Debug::nospace << reinterpret_cast<void*>(UnsignedByte(value)) << Debug::nospace << (packed ? "" : ")");
}
}}

11
src/Magnum/Trade/MeshData.cpp

@ -869,14 +869,17 @@ Containers::Array<char> MeshData::releaseVertexData() {
}
Debug& operator<<(Debug& debug, const MeshAttribute value) {
debug << "Trade::MeshAttribute" << Debug::nospace;
const bool packed = debug.immediateFlags() >= Debug::Flag::Packed;
if(!packed)
debug << "Trade::MeshAttribute" << Debug::nospace;
if(UnsignedShort(value) >= UnsignedShort(MeshAttribute::Custom))
return debug << "::Custom(" << Debug::nospace << (UnsignedShort(value) - UnsignedShort(MeshAttribute::Custom)) << Debug::nospace << ")";
return debug << (packed ? "Custom(" : "::Custom(") << Debug::nospace << (UnsignedInt(value) - UnsignedInt(MeshAttribute::Custom)) << Debug::nospace << ")";
switch(value) {
/* LCOV_EXCL_START */
#define _c(value) case MeshAttribute::value: return debug << "::" #value;
#define _c(value) case MeshAttribute::value: return debug << (packed ? "" : "::") << Debug::nospace << #value;
_c(Position)
_c(Tangent)
_c(Bitangent)
@ -891,7 +894,7 @@ Debug& operator<<(Debug& debug, const MeshAttribute value) {
case MeshAttribute::Custom: CORRADE_INTERNAL_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
}
return debug << "(" << Debug::nospace << reinterpret_cast<void*>(UnsignedShort(value)) << Debug::nospace << ")";
return debug << (packed ? "" : "(") << Debug::nospace << reinterpret_cast<void*>(UnsignedShort(value)) << Debug::nospace << (packed ? "" : ")");
}
}}

40
src/Magnum/Trade/SceneData.cpp

@ -51,11 +51,14 @@
namespace Magnum { namespace Trade {
Debug& operator<<(Debug& debug, const SceneMappingType value) {
debug << "Trade::SceneMappingType" << Debug::nospace;
const bool packed = debug.immediateFlags() >= Debug::Flag::Packed;
if(!packed)
debug << "Trade::SceneMappingType" << Debug::nospace;
switch(value) {
/* LCOV_EXCL_START */
#define _c(value) case SceneMappingType::value: return debug << "::" #value;
#define _c(value) case SceneMappingType::value: return debug << (packed ? "" : "::") << Debug::nospace << #value;
_c(UnsignedByte)
_c(UnsignedInt)
_c(UnsignedShort)
@ -64,7 +67,7 @@ Debug& operator<<(Debug& debug, const SceneMappingType value) {
/* LCOV_EXCL_STOP */
}
return debug << "(" << Debug::nospace << reinterpret_cast<void*>(UnsignedByte(value)) << Debug::nospace << ")";
return debug << (packed ? "" : "(") << Debug::nospace << reinterpret_cast<void*>(UnsignedByte(value)) << Debug::nospace << (packed ? "" : ")");
}
UnsignedInt sceneMappingTypeSize(const SceneMappingType type) {
@ -104,14 +107,17 @@ UnsignedInt sceneMappingTypeAlignment(const SceneMappingType type) {
}
Debug& operator<<(Debug& debug, const SceneField value) {
debug << "Trade::SceneField" << Debug::nospace;
const bool packed = debug.immediateFlags() >= Debug::Flag::Packed;
if(!packed)
debug << "Trade::SceneField" << Debug::nospace;
if(UnsignedInt(value) >= UnsignedInt(SceneField::Custom))
return debug << "::Custom(" << Debug::nospace << (UnsignedInt(value) - UnsignedInt(SceneField::Custom)) << Debug::nospace << ")";
return debug << (packed ? "Custom(" : "::Custom(") << Debug::nospace << (UnsignedInt(value) - UnsignedInt(SceneField::Custom)) << Debug::nospace << ")";
switch(value) {
/* LCOV_EXCL_START */
#define _c(value) case SceneField::value: return debug << "::" #value;
#define _c(value) case SceneField::value: return debug << (packed ? "" : "::") << Debug::nospace << #value;
_c(Parent)
_c(Transformation)
_c(Translation)
@ -130,15 +136,18 @@ Debug& operator<<(Debug& debug, const SceneField value) {
case SceneField::Custom: CORRADE_INTERNAL_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
}
return debug << "(" << Debug::nospace << reinterpret_cast<void*>(UnsignedInt(value)) << Debug::nospace << ")";
return debug << (packed ? "" : "(") << Debug::nospace << reinterpret_cast<void*>(UnsignedInt(value)) << Debug::nospace << (packed ? "" : ")");
}
Debug& operator<<(Debug& debug, const SceneFieldType value) {
debug << "Trade::SceneFieldType" << Debug::nospace;
const bool packed = debug.immediateFlags() >= Debug::Flag::Packed;
if(!packed)
debug << "Trade::SceneFieldType" << Debug::nospace;
switch(value) {
/* LCOV_EXCL_START */
#define _c(value) case SceneFieldType::value: return debug << "::" #value;
#define _c(value) case SceneFieldType::value: return debug << (debug.immediateFlags() & Debug::Flag::Packed ? "" : "::") << Debug::nospace << #value;
_c(Float)
_c(Half)
_c(Double)
@ -236,7 +245,7 @@ Debug& operator<<(Debug& debug, const SceneFieldType value) {
/* LCOV_EXCL_STOP */
}
return debug << "(" << Debug::nospace << reinterpret_cast<void*>(UnsignedShort(value)) << Debug::nospace << ")";
return debug << (packed ? "" : "(") << Debug::nospace << reinterpret_cast<void*>(UnsignedShort(value)) << Debug::nospace << (packed ? "" : ")");
}
UnsignedInt sceneFieldTypeSize(const SceneFieldType type) {
@ -477,11 +486,14 @@ UnsignedInt sceneFieldTypeAlignment(const SceneFieldType type) {
}
Debug& operator<<(Debug& debug, const SceneFieldFlag value) {
debug << "Trade::SceneFieldFlag" << Debug::nospace;
const bool packed = debug.immediateFlags() >= Debug::Flag::Packed;
if(!packed)
debug << "Trade::SceneFieldFlag" << Debug::nospace;
switch(value) {
/* LCOV_EXCL_START */
#define _c(value) case SceneFieldFlag::value: return debug << "::" #value;
#define _c(value) case SceneFieldFlag::value: return debug << (packed ? "" : "::") << Debug::nospace << #value;
_c(OffsetOnly)
_c(ImplicitMapping)
_c(OrderedMapping)
@ -489,11 +501,11 @@ Debug& operator<<(Debug& debug, const SceneFieldFlag value) {
/* LCOV_EXCL_STOP */
}
return debug << "(" << Debug::nospace << reinterpret_cast<void*>(UnsignedShort(value)) << Debug::nospace << ")";
return debug << (packed ? "" : "(") << Debug::nospace << reinterpret_cast<void*>(UnsignedShort(value)) << Debug::nospace << (packed ? "" : ")");
}
Debug& operator<<(Debug& debug, const SceneFieldFlags value) {
return Containers::enumSetDebugOutput(debug, value, "Trade::SceneFieldFlags{}", {
return Containers::enumSetDebugOutput(debug, value, debug.immediateFlags() >= Debug::Flag::Packed ? "{}" : "Trade::SceneFieldFlags{}", {
SceneFieldFlag::OffsetOnly,
SceneFieldFlag::ImplicitMapping,
/* This one is implied by ImplicitMapping, so has to be after */

20
src/Magnum/Trade/Test/AnimationDataTest.cpp

@ -62,7 +62,9 @@ struct AnimationDataTest: TestSuite::Tester {
void release();
void debugAnimationTrackType();
void debugAnimationTrackTypePacked();
void debugAnimationTrackTargetType();
void debugAnimationTrackTargetTypePacked();
};
struct {
@ -103,7 +105,9 @@ AnimationDataTest::AnimationDataTest() {
&AnimationDataTest::release,
&AnimationDataTest::debugAnimationTrackType,
&AnimationDataTest::debugAnimationTrackTargetType});
&AnimationDataTest::debugAnimationTrackTypePacked,
&AnimationDataTest::debugAnimationTrackTargetType,
&AnimationDataTest::debugAnimationTrackTargetTypePacked});
}
using namespace Math::Literals;
@ -661,6 +665,13 @@ void AnimationDataTest::debugAnimationTrackType() {
CORRADE_COMPARE(out.str(), "Trade::AnimationTrackType::DualQuaternion Trade::AnimationTrackType(0xde)\n");
}
void AnimationDataTest::debugAnimationTrackTypePacked() {
std::ostringstream out;
/* Second is not packed, the first should not make any flags persistent */
Debug{&out} << Debug::packed << AnimationTrackType::DualQuaternion << Debug::packed << AnimationTrackType(0xde) << AnimationTrackType::Float;
CORRADE_COMPARE(out.str(), "DualQuaternion 0xde Trade::AnimationTrackType::Float\n");
}
void AnimationDataTest::debugAnimationTrackTargetType() {
std::ostringstream out;
@ -668,6 +679,13 @@ void AnimationDataTest::debugAnimationTrackTargetType() {
CORRADE_COMPARE(out.str(), "Trade::AnimationTrackTargetType::Rotation3D Trade::AnimationTrackTargetType::Custom(135) Trade::AnimationTrackTargetType(0x42)\n");
}
void AnimationDataTest::debugAnimationTrackTargetTypePacked() {
std::ostringstream out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << AnimationTrackTargetType::Rotation3D << Debug::packed << AnimationTrackTargetType(135) << Debug::packed << AnimationTrackTargetType(0x42) << AnimationTrackType::Float;
CORRADE_COMPARE(out.str(), "Rotation3D Custom(135) 0x42 Trade::AnimationTrackType::Float\n");
}
}}}}
CORRADE_TEST_MAIN(Magnum::Trade::Test::AnimationDataTest)

11
src/Magnum/Trade/Test/CameraDataTest.cpp

@ -47,6 +47,7 @@ struct CameraDataTest: TestSuite::Tester {
void fovNonPerspective();
void debugType();
void debugTypePacked();
};
CameraDataTest::CameraDataTest() {
@ -62,7 +63,8 @@ CameraDataTest::CameraDataTest() {
&CameraDataTest::fovNonPerspective,
&CameraDataTest::debugType});
&CameraDataTest::debugType,
&CameraDataTest::debugTypePacked});
}
using namespace Math::Literals;
@ -184,6 +186,13 @@ void CameraDataTest::debugType() {
CORRADE_COMPARE(out.str(), "Trade::CameraType::Orthographic3D Trade::CameraType(0xde)\n");
}
void CameraDataTest::debugTypePacked() {
std::ostringstream out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << CameraType::Orthographic3D << Debug::packed << CameraType(0xde) << CameraType::Perspective3D;
CORRADE_COMPARE(out.str(), "Orthographic3D 0xde Trade::CameraType::Perspective3D\n");
}
}}}}
CORRADE_TEST_MAIN(Magnum::Trade::Test::CameraDataTest)

20
src/Magnum/Trade/Test/DataTest.cpp

@ -35,12 +35,16 @@ struct DataTest: TestSuite::Tester {
explicit DataTest();
void debugDataFlag();
void debugDataFlagPacked();
void debugDataFlags();
void debugDataFlagsPacked();
};
DataTest::DataTest() {
addTests({&DataTest::debugDataFlag,
&DataTest::debugDataFlags});
&DataTest::debugDataFlagPacked,
&DataTest::debugDataFlags,
&DataTest::debugDataFlagsPacked});
}
void DataTest::debugDataFlag() {
@ -50,6 +54,13 @@ void DataTest::debugDataFlag() {
CORRADE_COMPARE(out.str(), "Trade::DataFlag::Owned Trade::DataFlag(0xf0)\n");
}
void DataTest::debugDataFlagPacked() {
std::ostringstream out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << DataFlag::Owned << Debug::packed << DataFlag(0xf0) << DataFlag::Mutable;
CORRADE_COMPARE(out.str(), "Owned 0xf0 Trade::DataFlag::Mutable\n");
}
void DataTest::debugDataFlags() {
std::ostringstream out;
@ -57,6 +68,13 @@ void DataTest::debugDataFlags() {
CORRADE_COMPARE(out.str(), "Trade::DataFlag::Owned|Trade::DataFlag::Mutable Trade::DataFlags{}\n");
}
void DataTest::debugDataFlagsPacked() {
std::ostringstream out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << (DataFlag::Owned|DataFlag::Mutable) << Debug::packed << DataFlags{} << (DataFlag::ExternallyOwned|DataFlag::Mutable);
CORRADE_COMPARE(out.str(), "Owned|Mutable {} Trade::DataFlag::ExternallyOwned|Trade::DataFlag::Mutable\n");
}
}}}}
CORRADE_TEST_MAIN(Magnum::Trade::Test::DataTest)

11
src/Magnum/Trade/Test/LightDataTest.cpp

@ -46,6 +46,7 @@ struct LightDataTest: TestSuite::Tester {
void constructMove();
void debugType();
void debugTypePacked();
};
using namespace Math::Literals;
@ -97,7 +98,8 @@ LightDataTest::LightDataTest() {
addTests({&LightDataTest::constructCopy,
&LightDataTest::constructMove,
&LightDataTest::debugType});
&LightDataTest::debugType,
&LightDataTest::debugTypePacked});
}
void LightDataTest::construct() {
@ -441,6 +443,13 @@ void LightDataTest::debugType() {
CORRADE_COMPARE(out.str(), "Trade::LightData::Type::Spot Trade::LightData::Type(0xbe)\n");
}
void LightDataTest::debugTypePacked() {
std::ostringstream out;
/* Last is not packed, ones before should not make any flags persistent */
Debug(&out) << Debug::packed << LightData::Type::Spot << Debug::packed << LightData::Type(0xbe) << LightData::Type::Ambient;
CORRADE_COMPARE(out.str(), "Spot 0xbe Trade::LightData::Type::Ambient\n");
}
}}}}
CORRADE_TEST_MAIN(Magnum::Trade::Test::LightDataTest)

49
src/Magnum/Trade/Test/MaterialDataTest.cpp

@ -152,17 +152,24 @@ class MaterialDataTest: public TestSuite::Tester {
void templateLayerAccessMutable();
void debugLayer();
/* No packed version, as layer name is stored as a string */
void debugAttribute();
/* No packed version, as attribute name is stored as a string */
void debugTextureSwizzle();
void debugTextureSwizzlePacked();
void debugAttributeType();
void debugAttributeTypePacked();
void debugType();
void debugTypePacked();
void debugTypes();
void debugTypesPacked();
#ifdef MAGNUM_BUILD_DEPRECATED
void debugFlag();
void debugFlags();
#endif
void debugAlphaMode();
void debugAlphaModePacked();
};
MaterialDataTest::MaterialDataTest() {
@ -300,15 +307,20 @@ MaterialDataTest::MaterialDataTest() {
&MaterialDataTest::debugLayer,
&MaterialDataTest::debugAttribute,
&MaterialDataTest::debugTextureSwizzle,
&MaterialDataTest::debugTextureSwizzlePacked,
&MaterialDataTest::debugAttributeType,
&MaterialDataTest::debugAttributeTypePacked,
&MaterialDataTest::debugType,
&MaterialDataTest::debugTypePacked,
&MaterialDataTest::debugTypes,
&MaterialDataTest::debugTypesPacked,
#ifdef MAGNUM_BUILD_DEPRECATED
&MaterialDataTest::debugFlag,
&MaterialDataTest::debugFlags,
#endif
&MaterialDataTest::debugAlphaMode});
&MaterialDataTest::debugAlphaMode,
&MaterialDataTest::debugAlphaModePacked});
}
using namespace Containers::Literals;
@ -3016,6 +3028,13 @@ void MaterialDataTest::debugTextureSwizzle() {
CORRADE_COMPARE(out.str(), "Trade::MaterialTextureSwizzle::BA Trade::MaterialTextureSwizzle::\n");
}
void MaterialDataTest::debugTextureSwizzlePacked() {
std::ostringstream out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << MaterialTextureSwizzle::BA << Debug::packed << MaterialTextureSwizzle{} << MaterialTextureSwizzle::RG;
CORRADE_COMPARE(out.str(), "BA Trade::MaterialTextureSwizzle::RG\n");
}
void MaterialDataTest::debugAttributeType() {
std::ostringstream out;
@ -3023,6 +3042,13 @@ void MaterialDataTest::debugAttributeType() {
CORRADE_COMPARE(out.str(), "Trade::MaterialAttributeType::Matrix3x2 Trade::MaterialAttributeType(0xfe)\n");
}
void MaterialDataTest::debugAttributeTypePacked() {
std::ostringstream out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << MaterialAttributeType::Matrix3x2 << Debug::packed << MaterialAttributeType(0xfe) << MaterialAttributeType::Float;
CORRADE_COMPARE(out.str(), "Matrix3x2 0xfe Trade::MaterialAttributeType::Float\n");
}
void MaterialDataTest::debugType() {
std::ostringstream out;
@ -3030,6 +3056,13 @@ void MaterialDataTest::debugType() {
CORRADE_COMPARE(out.str(), "Trade::MaterialType::Phong Trade::MaterialType(0xbe)\n");
}
void MaterialDataTest::debugTypePacked() {
std::ostringstream out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << MaterialType::Phong << Debug::packed << MaterialType(0xbe) << MaterialType::Flat;
CORRADE_COMPARE(out.str(), "Phong 0xbe Trade::MaterialType::Flat\n");
}
void MaterialDataTest::debugTypes() {
std::ostringstream out;
@ -3037,6 +3070,13 @@ void MaterialDataTest::debugTypes() {
CORRADE_COMPARE(out.str(), "Trade::MaterialType::Phong|Trade::MaterialType(0xe0) Trade::MaterialTypes{}\n");
}
void MaterialDataTest::debugTypesPacked() {
std::ostringstream out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << (MaterialType::Phong|MaterialType(0xe0)) << Debug::packed << MaterialTypes{} << MaterialType::Flat;
CORRADE_COMPARE(out.str(), "Phong|0xe0 {} Trade::MaterialType::Flat\n");
}
#ifdef MAGNUM_BUILD_DEPRECATED
CORRADE_IGNORE_DEPRECATED_PUSH
void MaterialDataTest::debugFlag() {
@ -3062,6 +3102,13 @@ void MaterialDataTest::debugAlphaMode() {
CORRADE_COMPARE(out.str(), "Trade::MaterialAlphaMode::Opaque Trade::MaterialAlphaMode(0xee)\n");
}
void MaterialDataTest::debugAlphaModePacked() {
std::ostringstream out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << MaterialAlphaMode::Opaque << Debug::packed << MaterialAlphaMode(0xee) << MaterialAlphaMode::Blend;
CORRADE_COMPARE(out.str(), "Opaque 0xee Trade::MaterialAlphaMode::Blend\n");
}
}}}}
CORRADE_TEST_MAIN(Magnum::Trade::Test::MaterialDataTest)

9
src/Magnum/Trade/Test/MeshDataTest.cpp

@ -43,6 +43,7 @@ struct MeshDataTest: TestSuite::Tester {
void customAttributeNameTooLarge();
void customAttributeNameNotCustom();
void debugAttributeName();
void debugAttributeNamePacked();
void constructIndexContiguous();
void constructIndexStrided();
@ -215,6 +216,7 @@ MeshDataTest::MeshDataTest() {
&MeshDataTest::customAttributeNameTooLarge,
&MeshDataTest::customAttributeNameNotCustom,
&MeshDataTest::debugAttributeName,
&MeshDataTest::debugAttributeNamePacked,
&MeshDataTest::constructIndexContiguous,
&MeshDataTest::constructIndexStrided,
@ -464,6 +466,13 @@ void MeshDataTest::debugAttributeName() {
CORRADE_COMPARE(out.str(), "Trade::MeshAttribute::Position Trade::MeshAttribute::Custom(73) Trade::MeshAttribute(0x73)\n");
}
void MeshDataTest::debugAttributeNamePacked() {
std::ostringstream out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << MeshAttribute::Position << Debug::packed << meshAttributeCustom(73) << Debug::packed << MeshAttribute(0x73) << MeshAttribute::Normal;
CORRADE_COMPARE(out.str(), "Position Custom(73) 0x73 Trade::MeshAttribute::Normal\n");
}
using namespace Math::Literals;
constexpr UnsignedByte IndexBytes[]{25, 132, 3};

45
src/Magnum/Trade/Test/SceneDataTest.cpp

@ -53,18 +53,23 @@ struct SceneDataTest: TestSuite::Tester {
void mappingTypeSizeAlignment();
void mappingTypeSizeAlignmentInvalid();
void debugMappingType();
void debugMappingTypePacked();
void customFieldName();
void customFieldNameTooLarge();
void customFieldNameNotCustom();
void debugFieldName();
void debugFieldNamePacked();
void fieldTypeSizeAlignment();
void fieldTypeSizeAlignmentInvalid();
void debugFieldType();
void debugFieldTypePacked();
void debugFieldFlag();
void debugFieldFlagPacked();
void debugFieldFlags();
void debugFieldFlagsPacked();
void debugFieldFlagsSupersets();
void constructField();
@ -344,18 +349,23 @@ SceneDataTest::SceneDataTest() {
addTests({&SceneDataTest::mappingTypeSizeAlignment,
&SceneDataTest::mappingTypeSizeAlignmentInvalid,
&SceneDataTest::debugMappingType,
&SceneDataTest::debugMappingTypePacked,
&SceneDataTest::customFieldName,
&SceneDataTest::customFieldNameTooLarge,
&SceneDataTest::customFieldNameNotCustom,
&SceneDataTest::debugFieldName,
&SceneDataTest::debugFieldNamePacked,
&SceneDataTest::fieldTypeSizeAlignment,
&SceneDataTest::fieldTypeSizeAlignmentInvalid,
&SceneDataTest::debugFieldType,
&SceneDataTest::debugFieldTypePacked,
&SceneDataTest::debugFieldFlag,
&SceneDataTest::debugFieldFlagPacked,
&SceneDataTest::debugFieldFlags,
&SceneDataTest::debugFieldFlagsPacked,
&SceneDataTest::debugFieldFlagsSupersets,
&SceneDataTest::constructField,
@ -605,6 +615,13 @@ void SceneDataTest::debugMappingType() {
CORRADE_COMPARE(out.str(), "Trade::SceneMappingType::UnsignedLong Trade::SceneMappingType(0x73)\n");
}
void SceneDataTest::debugMappingTypePacked() {
std::ostringstream out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << SceneMappingType::UnsignedLong << Debug::packed << SceneMappingType(0x73) << SceneMappingType::UnsignedInt;
CORRADE_COMPARE(out.str(), "UnsignedLong 0x73 Trade::SceneMappingType::UnsignedInt\n");
}
void SceneDataTest::customFieldName() {
CORRADE_VERIFY(!isSceneFieldCustom(SceneField::Rotation));
CORRADE_VERIFY(!isSceneFieldCustom(SceneField(0x0fffffffu)));
@ -655,6 +672,13 @@ void SceneDataTest::debugFieldName() {
CORRADE_COMPARE(out.str(), "Trade::SceneField::Transformation Trade::SceneField::Custom(73) Trade::SceneField(0xdeadda7)\n");
}
void SceneDataTest::debugFieldNamePacked() {
std::ostringstream out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << SceneField::Transformation << Debug::packed << sceneFieldCustom(73) << Debug::packed << SceneField(0xdeadda7) << SceneField::Parent;
CORRADE_COMPARE(out.str(), "Transformation Custom(73) 0xdeadda7 Trade::SceneField::Parent\n");
}
void SceneDataTest::fieldTypeSizeAlignment() {
/* Test at least one of every size */
CORRADE_COMPARE(sceneFieldTypeSize(SceneFieldType::Byte), sizeof(Byte));
@ -711,6 +735,13 @@ void SceneDataTest::debugFieldType() {
CORRADE_COMPARE(out.str(), "Trade::SceneFieldType::Matrix3x4h Trade::SceneFieldType(0xdead)\n");
}
void SceneDataTest::debugFieldTypePacked() {
std::ostringstream out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << SceneFieldType::Matrix3x4h << Debug::packed << SceneFieldType(0xdead) << SceneFieldType::Float;
CORRADE_COMPARE(out.str(), "Matrix3x4h 0xdead Trade::SceneFieldType::Float\n");
}
void SceneDataTest::debugFieldFlag() {
std::ostringstream out;
@ -718,6 +749,13 @@ void SceneDataTest::debugFieldFlag() {
CORRADE_COMPARE(out.str(), "Trade::SceneFieldFlag::OffsetOnly Trade::SceneFieldFlag(0xbe)\n");
}
void SceneDataTest::debugFieldFlagPacked() {
std::ostringstream out;
/* Last is not packed, ones before should not make any flags persistent */
Debug(&out) << Debug::packed << SceneFieldFlag::OffsetOnly << Debug::packed << SceneFieldFlag(0xbe) << SceneFieldFlag::ImplicitMapping;
CORRADE_COMPARE(out.str(), "OffsetOnly 0xbe Trade::SceneFieldFlag::ImplicitMapping\n");
}
void SceneDataTest::debugFieldFlags() {
std::ostringstream out;
@ -725,6 +763,13 @@ void SceneDataTest::debugFieldFlags() {
CORRADE_COMPARE(out.str(), "Trade::SceneFieldFlag::OffsetOnly|Trade::SceneFieldFlag(0xe0) Trade::SceneFieldFlags{}\n");
}
void SceneDataTest::debugFieldFlagsPacked() {
std::ostringstream out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << (SceneFieldFlag::OffsetOnly|SceneFieldFlag(0xe0)) << Debug::packed << SceneFieldFlags{} << (SceneFieldFlag::OffsetOnly|SceneFieldFlag::ImplicitMapping);
CORRADE_COMPARE(out.str(), "OffsetOnly|0xe0 {} Trade::SceneFieldFlag::OffsetOnly|Trade::SceneFieldFlag::ImplicitMapping\n");
}
void SceneDataTest::debugFieldFlagsSupersets() {
/* ImplicitMapping is a superset of OrderedMapping, so only one should be
printed */

11
src/Magnum/Trade/Test/TextureDataTest.cpp

@ -40,6 +40,7 @@ class TextureDataTest: public TestSuite::Tester {
void constructMove();
void debugType();
void debugTypePacked();
};
TextureDataTest::TextureDataTest() {
@ -47,7 +48,8 @@ TextureDataTest::TextureDataTest() {
&TextureDataTest::constructCopy,
&TextureDataTest::constructMove,
&TextureDataTest::debugType});
&TextureDataTest::debugType,
&TextureDataTest::debugTypePacked});
}
void TextureDataTest::construct() {
@ -123,6 +125,13 @@ void TextureDataTest::debugType() {
CORRADE_COMPARE(out.str(), "Trade::TextureType::Texture3D Trade::TextureType(0xbe)\n");
}
void TextureDataTest::debugTypePacked() {
std::ostringstream out;
/* Last is not packed, ones before should not make any flags persistent */
Debug(&out) << Debug::packed << TextureType::Texture3D << Debug::packed << TextureType(0xbe) << TextureType::Texture2D;
CORRADE_COMPARE(out.str(), "Texture3D 0xbe Trade::TextureType::Texture2D\n");
}
}}}}
CORRADE_TEST_MAIN(Magnum::Trade::Test::TextureDataTest)

9
src/Magnum/Trade/TextureData.cpp

@ -29,11 +29,14 @@ namespace Magnum { namespace Trade {
#ifndef DOXYGEN_GENERATING_OUTPUT
Debug& operator<<(Debug& debug, const TextureType value) {
debug << "Trade::TextureType" << Debug::nospace;
const bool packed = debug.immediateFlags() >= Debug::Flag::Packed;
if(!packed)
debug << "Trade::TextureType" << Debug::nospace;
switch(value) {
/* LCOV_EXCL_START */
#define _c(value) case TextureType::value: return debug << "::" #value;
#define _c(value) case TextureType::value: return debug << (packed ? "" : "::") << Debug::nospace << #value;
_c(Texture1D)
_c(Texture1DArray)
_c(Texture2D)
@ -45,7 +48,7 @@ Debug& operator<<(Debug& debug, const TextureType value) {
/* LCOV_EXCL_STOP */
}
return debug << "(" << Debug::nospace << reinterpret_cast<void*>(UnsignedByte(value)) << Debug::nospace << ")";
return debug << (packed ? "" : "(") << Debug::nospace << reinterpret_cast<void*>(UnsignedByte(value)) << Debug::nospace << (packed ? "" : ")");
}
#endif

11
src/Magnum/VertexFormat.cpp

@ -910,17 +910,20 @@ constexpr const char* VertexFormatNames[] {
}
Debug& operator<<(Debug& debug, const VertexFormat value) {
debug << "VertexFormat" << Debug::nospace;
const bool packed = debug.immediateFlags() >= Debug::Flag::Packed;
if(!packed)
debug << "VertexFormat" << Debug::nospace;
if(isVertexFormatImplementationSpecific(value)) {
return debug << "::ImplementationSpecific(" << Debug::nospace << reinterpret_cast<void*>(vertexFormatUnwrap(value)) << Debug::nospace << ")";
return debug << (packed ? "ImplementationSpecific(" : "::ImplementationSpecific(") << Debug::nospace << reinterpret_cast<void*>(vertexFormatUnwrap(value)) << Debug::nospace << ")";
}
if(UnsignedInt(value) - 1 < Containers::arraySize(VertexFormatNames)) {
return debug << "::" << Debug::nospace << VertexFormatNames[UnsignedInt(value) - 1];
return debug << (packed ? "" : "::") << Debug::nospace << VertexFormatNames[UnsignedInt(value) - 1];
}
return debug << "(" << Debug::nospace << reinterpret_cast<void*>(UnsignedInt(value)) << Debug::nospace << ")";
return debug << (packed ? "" : "(") << Debug::nospace << reinterpret_cast<void*>(UnsignedInt(value)) << Debug::nospace << (packed ? "" : ")");
}
}

Loading…
Cancel
Save