Bug 1749390 - Add debug support for mozilla::Side. r=gfx-reviewers,lsalzman

This was useful so may as well land it. Need to use mozilla::Side in the
header because otherwise it is ambiguous with mozilla::ipc::Side, yay
C++.

Depends on D135562

Differential Revision: https://phabricator.services.mozilla.com/D135563
This commit is contained in:
Emilio Cobos Álvarez 2022-01-11 08:47:23 +00:00
Родитель f6525aeca7
Коммит a5d45cd2fe
2 изменённых файлов: 24 добавлений и 0 удалений

Просмотреть файл

@ -11,6 +11,28 @@
#include <ostream>
namespace mozilla {
std::ostream& operator<<(std::ostream& aOut, const Side& aSide) {
#define Emit(x) \
case x: \
aOut << #x; \
break
switch (aSide) {
Emit(eSideTop);
Emit(eSideBottom);
Emit(eSideLeft);
Emit(eSideRight);
default:
NS_ERROR("unknown side");
aOut << int(aSide);
break;
}
#undef Emit
return aOut;
}
namespace gfx {
std::ostream& operator<<(std::ostream& aOut, const SurfaceFormat& aFormat) {

Просмотреть файл

@ -858,6 +858,8 @@ namespace mozilla {
// Side constants for use in various places.
enum Side : uint8_t { eSideTop, eSideRight, eSideBottom, eSideLeft };
std::ostream& operator<<(std::ostream&, const mozilla::Side&);
constexpr auto AllPhysicalSides() {
return mozilla::MakeInclusiveEnumeratedRange(eSideTop, eSideLeft);
}