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 namespace gfx {
15 
operator <<(std::ostream & aOut,const SurfaceFormat & aFormat)16 std::ostream& operator<<(std::ostream& aOut, const SurfaceFormat& aFormat) {
17 #define Emit(x) \
18   case x:       \
19     aOut << #x; \
20     break
21 
22   switch (aFormat) {
23     Emit(SurfaceFormat::B8G8R8A8);
24     Emit(SurfaceFormat::B8G8R8X8);
25     Emit(SurfaceFormat::R8G8B8A8);
26     Emit(SurfaceFormat::R8G8B8X8);
27     Emit(SurfaceFormat::A8R8G8B8);
28     Emit(SurfaceFormat::X8R8G8B8);
29     Emit(SurfaceFormat::R8G8B8);
30     Emit(SurfaceFormat::B8G8R8);
31     Emit(SurfaceFormat::R5G6B5_UINT16);
32     Emit(SurfaceFormat::A8);
33     Emit(SurfaceFormat::A16);
34     Emit(SurfaceFormat::R8G8);
35     Emit(SurfaceFormat::R16G16);
36     Emit(SurfaceFormat::YUV);
37     Emit(SurfaceFormat::NV12);
38     Emit(SurfaceFormat::P016);
39     Emit(SurfaceFormat::P010);
40     Emit(SurfaceFormat::YUV422);
41     Emit(SurfaceFormat::HSV);
42     Emit(SurfaceFormat::Lab);
43     Emit(SurfaceFormat::Depth);
44     default:
45       NS_ERROR("unknown surface format");
46       aOut << "???";
47   }
48 
49 #undef Emit
50 
51   return aOut;
52 }
53 
operator <<(std::ostream & aOut,const DeviceColor & aColor)54 std::ostream& operator<<(std::ostream& aOut, const DeviceColor& aColor) {
55   aOut << nsPrintfCString("dev_rgba(%d, %d, %d, %f)", uint8_t(aColor.r * 255.f),
56                           uint8_t(aColor.g * 255.f), uint8_t(aColor.b * 255.f),
57                           aColor.a)
58               .get();
59   return aOut;
60 }
61 
operator <<(std::ostream & aOut,const SamplingFilter & aFilter)62 std::ostream& operator<<(std::ostream& aOut, const SamplingFilter& aFilter) {
63   switch (aFilter) {
64     case SamplingFilter::GOOD:
65       aOut << "SamplingFilter::GOOD";
66       break;
67     case SamplingFilter::LINEAR:
68       aOut << "SamplingFilter::LINEAR";
69       break;
70     case SamplingFilter::POINT:
71       aOut << "SamplingFilter::POINT";
72       break;
73     default:
74       aOut << "???";
75   }
76   return aOut;
77 }
78 
79 }  // namespace gfx
80 }  // namespace mozilla
81