Bumping manifests a=b2g-bump
[gecko.git] / gfx / layers / LayersLogging.h
blob6523b382ceb509914640cba51d1a71631f126144
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef GFX_LAYERSLOGGING_H
7 #define GFX_LAYERSLOGGING_H
9 #include "FrameMetrics.h" // for FrameMetrics, etc
10 #include "GraphicsFilter.h" // for GraphicsFilter
11 #include "mozilla/gfx/Point.h" // for IntSize, etc
12 #include "mozilla/gfx/Types.h" // for Filter, SurfaceFormat
13 #include "mozilla/layers/CompositorTypes.h" // for TextureFlags
14 #include "nsAString.h"
15 #include "nsPrintfCString.h" // for nsPrintfCString
16 #include "nsRegion.h" // for nsIntRegion
17 #include "nscore.h" // for nsACString, etc
19 struct gfxRGBA;
20 struct nsIntPoint;
21 struct nsIntRect;
22 struct nsIntSize;
24 namespace mozilla {
25 namespace gfx {
26 class Matrix4x4;
27 template <class units> struct RectTyped;
30 namespace layers {
32 void
33 AppendToString(std::stringstream& aStream, const void* p,
34 const char* pfx="", const char* sfx="");
36 void
37 AppendToString(std::stringstream& aStream, const GraphicsFilter& f,
38 const char* pfx="", const char* sfx="");
40 void
41 AppendToString(std::stringstream& aStream, FrameMetrics::ViewID n,
42 const char* pfx="", const char* sfx="");
44 void
45 AppendToString(std::stringstream& aStream, const gfxRGBA& c,
46 const char* pfx="", const char* sfx="");
48 void
49 AppendToString(std::stringstream& aStream, const nsIntPoint& p,
50 const char* pfx="", const char* sfx="");
52 template<class T>
53 void
54 AppendToString(std::stringstream& aStream, const mozilla::gfx::PointTyped<T>& p,
55 const char* pfx="", const char* sfx="")
57 aStream << pfx << p << sfx;
60 void
61 AppendToString(std::stringstream& aStream, const nsIntRect& r,
62 const char* pfx="", const char* sfx="");
64 template<class T>
65 void
66 AppendToString(std::stringstream& aStream, const mozilla::gfx::RectTyped<T>& r,
67 const char* pfx="", const char* sfx="")
69 aStream << pfx;
70 aStream << nsPrintfCString(
71 "(x=%f, y=%f, w=%f, h=%f)",
72 r.x, r.y, r.width, r.height).get();
73 aStream << sfx;
76 template<class T>
77 void
78 AppendToString(std::stringstream& aStream, const mozilla::gfx::IntRectTyped<T>& r,
79 const char* pfx="", const char* sfx="")
81 aStream << pfx;
82 aStream << nsPrintfCString(
83 "(x=%d, y=%d, w=%d, h=%d)",
84 r.x, r.y, r.width, r.height).get();
85 aStream << sfx;
88 void
89 AppendToString(std::stringstream& aStream, const nsIntRegion& r,
90 const char* pfx="", const char* sfx="");
92 void
93 AppendToString(std::stringstream& aStream, const nsIntSize& sz,
94 const char* pfx="", const char* sfx="");
96 void
97 AppendToString(std::stringstream& aStream, const FrameMetrics& m,
98 const char* pfx="", const char* sfx="", bool detailed = false);
100 void
101 AppendToString(std::stringstream& aStream, const ScrollableLayerGuid& s,
102 const char* pfx="", const char* sfx="");
104 template<class T>
105 void
106 AppendToString(std::stringstream& aStream, const mozilla::gfx::MarginTyped<T>& m,
107 const char* pfx="", const char* sfx="")
109 aStream << pfx;
110 aStream << nsPrintfCString(
111 "(l=%f, t=%f, r=%f, b=%f)",
112 m.left, m.top, m.right, m.bottom).get();
113 aStream << sfx;
116 template<class T>
117 void
118 AppendToString(std::stringstream& aStream, const mozilla::gfx::SizeTyped<T>& sz,
119 const char* pfx="", const char* sfx="")
121 aStream << pfx;
122 aStream << nsPrintfCString(
123 "(w=%f, h=%f)",
124 sz.width, sz.height).get();
125 aStream << sfx;
128 template<class T>
129 void
130 AppendToString(std::stringstream& aStream, const mozilla::gfx::IntSizeTyped<T>& sz,
131 const char* pfx="", const char* sfx="")
133 aStream << pfx;
134 aStream << nsPrintfCString(
135 "(w=%d, h=%d)",
136 sz.width, sz.height).get();
137 aStream << sfx;
140 void
141 AppendToString(std::stringstream& aStream, const mozilla::gfx::Matrix4x4& m,
142 const char* pfx="", const char* sfx="");
144 void
145 AppendToString(std::stringstream& aStream, const mozilla::gfx::Matrix5x4& m,
146 const char* pfx="", const char* sfx="");
148 void
149 AppendToString(std::stringstream& aStream, const mozilla::gfx::Filter filter,
150 const char* pfx="", const char* sfx="");
152 void
153 AppendToString(std::stringstream& aStream, mozilla::layers::TextureFlags flags,
154 const char* pfx="", const char* sfx="");
156 void
157 AppendToString(std::stringstream& aStream, mozilla::gfx::SurfaceFormat format,
158 const char* pfx="", const char* sfx="");
160 // Sometimes, you just want a string from a single value.
161 template <typename T>
162 std::string
163 Stringify(const T& obj)
165 std::stringstream ss;
166 AppendToString(ss, obj);
167 return ss.str();
170 } // namespace
171 } // namespace
173 // versions of printf_stderr and fprintf_stderr that deal with line
174 // truncation on android by printing individual lines out of the
175 // stringstream as separate calls to logcat.
176 void print_stderr(std::stringstream& aStr);
177 void fprint_stderr(FILE* aFile, std::stringstream& aStr);
179 #endif /* GFX_LAYERSLOGGING_H */