Types.cpp (3108B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #include "Types.h" 8 9 #include "nsPrintfCString.h" 10 11 #include <ostream> 12 13 namespace mozilla { 14 15 std::ostream& operator<<(std::ostream& aOut, const Side& aSide) { 16 #define Emit(x) \ 17 case x: \ 18 aOut << #x; \ 19 break 20 21 switch (aSide) { 22 Emit(eSideTop); 23 Emit(eSideBottom); 24 Emit(eSideLeft); 25 Emit(eSideRight); 26 } 27 28 #undef Emit 29 return aOut; 30 } 31 32 namespace gfx { 33 34 std::ostream& operator<<(std::ostream& aOut, const SurfaceFormat& aFormat) { 35 #define Emit(x) \ 36 case x: \ 37 aOut << #x; \ 38 break 39 40 switch (aFormat) { 41 Emit(SurfaceFormat::B8G8R8A8); 42 Emit(SurfaceFormat::B8G8R8X8); 43 Emit(SurfaceFormat::R8G8B8A8); 44 Emit(SurfaceFormat::R8G8B8X8); 45 Emit(SurfaceFormat::A8R8G8B8); 46 Emit(SurfaceFormat::X8R8G8B8); 47 Emit(SurfaceFormat::R8G8B8); 48 Emit(SurfaceFormat::B8G8R8); 49 Emit(SurfaceFormat::R5G6B5_UINT16); 50 Emit(SurfaceFormat::R10G10B10A2_UINT32); 51 Emit(SurfaceFormat::R10G10B10X2_UINT32); 52 Emit(SurfaceFormat::R16G16B16A16F); 53 Emit(SurfaceFormat::A8); 54 Emit(SurfaceFormat::A16); 55 Emit(SurfaceFormat::R8G8); 56 Emit(SurfaceFormat::R16G16); 57 Emit(SurfaceFormat::YUV420); 58 Emit(SurfaceFormat::YUV420P10); 59 Emit(SurfaceFormat::YUV422P10); 60 Emit(SurfaceFormat::NV12); 61 Emit(SurfaceFormat::P016); 62 Emit(SurfaceFormat::P010); 63 Emit(SurfaceFormat::NV16); 64 Emit(SurfaceFormat::YUY2); 65 Emit(SurfaceFormat::HSV); 66 Emit(SurfaceFormat::Lab); 67 Emit(SurfaceFormat::Depth); 68 Emit(SurfaceFormat::UNKNOWN); 69 } 70 71 #undef Emit 72 73 return aOut; 74 } 75 76 std::ostream& operator<<(std::ostream& aOut, const DeviceColor& aColor) { 77 aOut << nsPrintfCString("dev_rgba(%d, %d, %d, %f)", uint8_t(aColor.r * 255.f), 78 uint8_t(aColor.g * 255.f), uint8_t(aColor.b * 255.f), 79 aColor.a) 80 .get(); 81 return aOut; 82 } 83 84 std::ostream& operator<<(std::ostream& aOut, const SamplingFilter& aFilter) { 85 switch (aFilter) { 86 case SamplingFilter::GOOD: 87 aOut << "SamplingFilter::GOOD"; 88 break; 89 case SamplingFilter::LINEAR: 90 aOut << "SamplingFilter::LINEAR"; 91 break; 92 case SamplingFilter::POINT: 93 aOut << "SamplingFilter::POINT"; 94 break; 95 case SamplingFilter::SENTINEL: 96 aOut << "???"; 97 break; 98 } 99 return aOut; 100 } 101 102 std::ostream& operator<<(std::ostream& aOut, const ColorDepth& aColorDepth) { 103 switch (aColorDepth) { 104 case ColorDepth::COLOR_8: 105 aOut << "ColorDepth::COLOR_8"; 106 break; 107 case ColorDepth::COLOR_10: 108 aOut << "ColorDepth::COLOR_10"; 109 break; 110 case ColorDepth::COLOR_12: 111 aOut << "ColorDepth::COLOR_12"; 112 break; 113 case ColorDepth::COLOR_16: 114 aOut << "ColorDepth::COLOR_16"; 115 break; 116 } 117 return aOut; 118 } 119 120 } // namespace gfx 121 } // namespace mozilla