Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/gfx/layers/LayersLogging.h
Line
Count
Source (jump to first uncovered line)
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
#ifndef GFX_LAYERSLOGGING_H
8
#define GFX_LAYERSLOGGING_H
9
10
#include "FrameMetrics.h"               // for FrameMetrics, etc
11
#include "mozilla/gfx/Matrix.h"         // for Matrix4x4
12
#include "mozilla/gfx/Point.h"          // for IntSize, etc
13
#include "mozilla/gfx/TiledRegion.h"    // for TiledRegion
14
#include "mozilla/gfx/Types.h"          // for SamplingFilter, SurfaceFormat
15
#include "mozilla/layers/CompositorTypes.h"  // for TextureFlags
16
#include "mozilla/layers/WebRenderLayersLogging.h"
17
#include "nsAString.h"
18
#include "nsPrintfCString.h"            // for nsPrintfCString
19
#include "nsRegion.h"                   // for nsRegion, nsIntRegion
20
#include "nscore.h"                     // for nsACString, etc
21
22
struct nsRectAbsolute;
23
24
namespace mozilla {
25
26
namespace gfx {
27
template <class units, class F> struct RectTyped;
28
} // namespace gfx
29
30
enum class ImageFormat;
31
32
namespace layers {
33
34
void
35
AppendToString(std::stringstream& aStream, const void* p,
36
               const char* pfx="", const char* sfx="");
37
38
void
39
AppendToString(std::stringstream& aStream, FrameMetrics::ViewID n,
40
               const char* pfx="", const char* sfx="");
41
42
void
43
AppendToString(std::stringstream& aStream, const gfx::Color& c,
44
               const char* pfx="", const char* sfx="");
45
46
void
47
AppendToString(std::stringstream& aStream, const nsPoint& p,
48
               const char* pfx="", const char* sfx="");
49
50
void
51
AppendToString(std::stringstream& aStream, const nsRect& r,
52
               const char* pfx="", const char* sfx="");
53
54
void
55
AppendToString(std::stringstream& aStream, const nsRectAbsolute& r,
56
               const char* pfx="", const char* sfx="");
57
58
template<class T>
59
void
60
AppendToString(std::stringstream& aStream, const mozilla::gfx::PointTyped<T>& p,
61
               const char* pfx="", const char* sfx="")
62
0
{
63
0
  aStream << pfx << p << sfx;
64
0
}
65
66
template<class T>
67
void
68
AppendToString(std::stringstream& aStream, const mozilla::gfx::Point3DTyped<T>& p,
69
               const char* pfx="", const char* sfx="")
70
{
71
  aStream << pfx << p << sfx;
72
}
73
74
template<class T>
75
void
76
AppendToString(std::stringstream& aStream, const mozilla::gfx::IntPointTyped<T>& p,
77
               const char* pfx="", const char* sfx="")
78
0
{
79
0
  aStream << pfx << p << sfx;
80
0
}
81
82
template<class T>
83
void
84
AppendToString(std::stringstream& aStream, const mozilla::gfx::RectTyped<T>& r,
85
               const char* pfx="", const char* sfx="")
86
0
{
87
0
  aStream << pfx;
88
0
  aStream << nsPrintfCString(
89
0
    "(x=%f, y=%f, w=%f, h=%f)",
90
0
    r.X(), r.Y(), r.Width(), r.Height()).get();
91
0
  aStream << sfx;
92
0
}
Unexecuted instantiation: void mozilla::layers::AppendToString<mozilla::gfx::UnknownUnits>(std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, mozilla::gfx::RectTyped<mozilla::gfx::UnknownUnits, float> const&, char const*, char const*)
Unexecuted instantiation: void mozilla::layers::AppendToString<mozilla::ParentLayerPixel>(std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, mozilla::gfx::RectTyped<mozilla::ParentLayerPixel, float> const&, char const*, char const*)
Unexecuted instantiation: void mozilla::layers::AppendToString<mozilla::CSSPixel>(std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, mozilla::gfx::RectTyped<mozilla::CSSPixel, float> const&, char const*, char const*)
93
94
template<class T>
95
void
96
AppendToString(std::stringstream& aStream, const mozilla::gfx::IntRectTyped<T>& r,
97
               const char* pfx="", const char* sfx="")
98
0
{
99
0
  aStream << pfx;
100
0
  aStream << nsPrintfCString(
101
0
    "(x=%d, y=%d, w=%d, h=%d)",
102
0
    r.X(), r.Y(), r.Width(), r.Height()).get();
103
0
  aStream << sfx;
104
0
}
Unexecuted instantiation: void mozilla::layers::AppendToString<mozilla::ParentLayerPixel>(std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, mozilla::gfx::IntRectTyped<mozilla::ParentLayerPixel> const&, char const*, char const*)
Unexecuted instantiation: void mozilla::layers::AppendToString<mozilla::gfx::UnknownUnits>(std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, mozilla::gfx::IntRectTyped<mozilla::gfx::UnknownUnits> const&, char const*, char const*)
Unexecuted instantiation: void mozilla::layers::AppendToString<mozilla::LayerPixel>(std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, mozilla::gfx::IntRectTyped<mozilla::LayerPixel> const&, char const*, char const*)
105
106
template<class T>
107
void
108
AppendToString(std::stringstream& aStream, const mozilla::gfx::RectAbsoluteTyped<T>& r,
109
               const char* pfx="", const char* sfx="")
110
{
111
  aStream << pfx;
112
  aStream << nsPrintfCString(
113
    "(l=%f, t=%f, r=%f, b=%f)",
114
    r.Left(), r.Top(), r.Right(), r.Bottom()).get();
115
  aStream << sfx;
116
}
117
118
template<class T>
119
void
120
AppendToString(std::stringstream& aStream, const mozilla::gfx::IntRectAbsoluteTyped<T>& r,
121
               const char* pfx="", const char* sfx="")
122
{
123
  aStream << pfx;
124
  aStream << nsPrintfCString(
125
    "(l=%d, t=%d, r=%d, b=%d)",
126
    r.Left(), r.Top(), r.Right(), r.Bottom()).get();
127
  aStream << sfx;
128
}
129
130
void
131
AppendToString(std::stringstream& aStream, const wr::ColorF& c,
132
               const char* pfx="", const char* sfx="");
133
134
void
135
AppendToString(std::stringstream& aStream, const wr::LayoutRect& r,
136
               const char* pfx="", const char* sfx="");
137
138
void
139
AppendToString(std::stringstream& aStream, const wr::LayoutSize& s,
140
               const char* pfx="", const char* sfx="");
141
142
void
143
AppendToString(std::stringstream& aStream, const nsSize& sz,
144
               const char* pfx="", const char* sfx="");
145
146
void
147
AppendToString(std::stringstream& aStream, const wr::StickyOffsetBounds& s,
148
               const char* pfx="", const char* sfx="");
149
150
void
151
AppendToString(std::stringstream& aStream, const nsRegion& r,
152
               const char* pfx="", const char* sfx="");
153
154
void
155
AppendToString(std::stringstream& aStream, const nsIntRegion& r,
156
               const char* pfx="", const char* sfx="");
157
158
template <typename units>
159
void
160
AppendToString(std::stringstream& aStream, const mozilla::gfx::IntRegionTyped<units>& r,
161
               const char* pfx="", const char* sfx="")
162
0
{
163
0
  aStream << pfx;
164
0
165
0
  aStream << "< ";
166
0
  for (auto iter = r.RectIter(); !iter.Done(); iter.Next()) {
167
0
    AppendToString(aStream, iter.Get());
168
0
    aStream << "; ";
169
0
  }
170
0
  aStream << ">";
171
0
172
0
  aStream << sfx;
173
0
}
Unexecuted instantiation: void mozilla::layers::AppendToString<mozilla::LayerPixel>(std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, mozilla::gfx::IntRegionTyped<mozilla::LayerPixel> const&, char const*, char const*)
Unexecuted instantiation: void mozilla::layers::AppendToString<mozilla::ParentLayerPixel>(std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, mozilla::gfx::IntRegionTyped<mozilla::ParentLayerPixel> const&, char const*, char const*)
174
175
template <typename T>
176
void
177
AppendToString(std::stringstream& aStream, const mozilla::gfx::TiledRegion<T>& r,
178
               const char* pfx="", const char* sfx="")
179
{
180
  aStream << pfx;
181
  AppendToString(aStream, r.GetRegion());
182
  aStream << " (bounds=";
183
  AppendToString(aStream, r.GetBounds());
184
  aStream << ", covers=" << r.CoversBounds() << ")" << sfx;
185
}
186
187
void
188
AppendToString(std::stringstream& aStream, const EventRegions& e,
189
               const char* pfx="", const char* sfx="");
190
191
void
192
AppendToString(std::stringstream& aStream, OverscrollBehavior aBehavior,
193
               const char* pfx="", const char* sfx="");
194
195
void
196
AppendToString(std::stringstream& aStream, const ScrollMetadata& m,
197
               const char* pfx="", const char* sfx="");
198
199
void
200
AppendToString(std::stringstream& aStream, const FrameMetrics& m,
201
               const char* pfx="", const char* sfx="", bool detailed = false);
202
203
void
204
AppendToString(std::stringstream& aStream, const ScrollableLayerGuid& s,
205
               const char* pfx="", const char* sfx="");
206
207
void
208
AppendToString(std::stringstream& aStream, const ZoomConstraints& z,
209
               const char* pfx="", const char* sfx="");
210
211
template<class T>
212
void
213
AppendToString(std::stringstream& aStream, const mozilla::gfx::MarginTyped<T>& m,
214
               const char* pfx="", const char* sfx="")
215
0
{
216
0
  aStream << pfx;
217
0
  aStream << nsPrintfCString(
218
0
    "(l=%f, t=%f, r=%f, b=%f)",
219
0
    m.left, m.top, m.right, m.bottom).get();
220
0
  aStream << sfx;
221
0
}
222
223
template<class T>
224
void
225
AppendToString(std::stringstream& aStream, const mozilla::gfx::SizeTyped<T>& sz,
226
               const char* pfx="", const char* sfx="")
227
0
{
228
0
  aStream << pfx;
229
0
  aStream << nsPrintfCString(
230
0
    "(w=%f, h=%f)",
231
0
    sz.width, sz.height).get();
232
0
  aStream << sfx;
233
0
}
234
235
template<class T>
236
void
237
AppendToString(std::stringstream& aStream, const mozilla::gfx::IntSizeTyped<T>& sz,
238
               const char* pfx="", const char* sfx="")
239
0
{
240
0
  aStream << pfx;
241
0
  aStream << nsPrintfCString(
242
0
    "(w=%d, h=%d)",
243
0
    sz.width, sz.height).get();
244
0
  aStream << sfx;
245
0
}
246
247
template<class src, class dst>
248
void
249
AppendToString(std::stringstream& aStream, const mozilla::gfx::ScaleFactors2D<src, dst>& scale,
250
               const char* pfx="", const char* sfx="")
251
0
{
252
0
  aStream << pfx;
253
0
  std::streamsize oldPrecision = aStream.precision(3);
254
0
  if (scale.AreScalesSame()) {
255
0
    aStream << scale.xScale;
256
0
  } else {
257
0
    aStream << '(' << scale.xScale << ',' << scale.yScale << ')';
258
0
  }
259
0
  aStream.precision(oldPrecision);
260
0
  aStream << sfx;
261
0
}
Unexecuted instantiation: void mozilla::layers::AppendToString<mozilla::CSSPixel, mozilla::ParentLayerPixel>(std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, mozilla::gfx::ScaleFactors2D<mozilla::CSSPixel, mozilla::ParentLayerPixel> const&, char const*, char const*)
Unexecuted instantiation: void mozilla::layers::AppendToString<mozilla::LayoutDevicePixel, mozilla::LayerPixel>(std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, mozilla::gfx::ScaleFactors2D<mozilla::LayoutDevicePixel, mozilla::LayerPixel> const&, char const*, char const*)
Unexecuted instantiation: void mozilla::layers::AppendToString<mozilla::ScreenPixel, mozilla::LayerPixel>(std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, mozilla::gfx::ScaleFactors2D<mozilla::ScreenPixel, mozilla::LayerPixel> const&, char const*, char const*)
262
263
void
264
AppendToString(std::stringstream& aStream, const mozilla::gfx::Matrix& m,
265
               const char* pfx="", const char* sfx="");
266
267
template<class SourceUnits, class TargetUnits>
268
void
269
AppendToString(std::stringstream& aStream, const mozilla::gfx::Matrix4x4Typed<SourceUnits, TargetUnits>& m,
270
               const char* pfx="", const char* sfx="")
271
0
{
272
0
  if (m.Is2D()) {
273
0
    mozilla::gfx::Matrix matrix = m.As2D();
274
0
    AppendToString(aStream, matrix, pfx, sfx);
275
0
    return;
276
0
  }
277
0
278
0
  aStream << pfx;
279
0
  aStream << nsPrintfCString(
280
0
    "[ %g %g %g %g; %g %g %g %g; %g %g %g %g; %g %g %g %g; ]",
281
0
    m._11, m._12, m._13, m._14,
282
0
    m._21, m._22, m._23, m._24,
283
0
    m._31, m._32, m._33, m._34,
284
0
    m._41, m._42, m._43, m._44).get();
285
0
  aStream << sfx;
286
0
}
Unexecuted instantiation: void mozilla::layers::AppendToString<mozilla::gfx::UnknownUnits, mozilla::gfx::UnknownUnits>(std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, mozilla::gfx::Matrix4x4Typed<mozilla::gfx::UnknownUnits, mozilla::gfx::UnknownUnits> const&, char const*, char const*)
Unexecuted instantiation: void mozilla::layers::AppendToString<mozilla::LayerPixel, mozilla::CSSTransformedLayerPixel>(std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, mozilla::gfx::Matrix4x4Typed<mozilla::LayerPixel, mozilla::CSSTransformedLayerPixel> const&, char const*, char const*)
287
288
void
289
AppendToString(std::stringstream& aStream, const mozilla::gfx::Matrix5x4& m,
290
               const char* pfx="", const char* sfx="");
291
292
void
293
AppendToString(std::stringstream& aStream,
294
               const mozilla::gfx::SamplingFilter samplingFilter,
295
               const char* pfx="", const char* sfx="");
296
297
void
298
AppendToString(std::stringstream& aStream, mozilla::layers::TextureFlags flags,
299
               const char* pfx="", const char* sfx="");
300
301
void
302
AppendToString(std::stringstream& aStream, mozilla::gfx::SurfaceFormat format,
303
               const char* pfx="", const char* sfx="");
304
305
void
306
AppendToString(std::stringstream& aStream, gfx::SurfaceType format,
307
               const char* pfx="", const char* sfx="");
308
309
void
310
AppendToString(std::stringstream& aStream, ImageFormat format,
311
               const char* pfx="", const char* sfx="");
312
313
// Sometimes, you just want a string from a single value.
314
template <typename T>
315
std::string
316
Stringify(const T& obj)
317
0
{
318
0
  std::stringstream ss;
319
0
  AppendToString(ss, obj);
320
0
  return ss.str();
321
0
}
Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > mozilla::layers::Stringify<mozilla::layers::ScrollMetadata>(mozilla::layers::ScrollMetadata const&)
Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > mozilla::layers::Stringify<mozilla::gfx::Matrix4x4Typed<mozilla::gfx::UnknownUnits, mozilla::gfx::UnknownUnits> >(mozilla::gfx::Matrix4x4Typed<mozilla::gfx::UnknownUnits, mozilla::gfx::UnknownUnits> const&)
Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > mozilla::layers::Stringify<mozilla::gfx::IntRegionTyped<mozilla::LayerPixel> >(mozilla::gfx::IntRegionTyped<mozilla::LayerPixel> const&)
Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > mozilla::layers::Stringify<mozilla::layers::EventRegions>(mozilla::layers::EventRegions const&)
Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > mozilla::layers::Stringify<mozilla::layers::ScrollableLayerGuid>(mozilla::layers::ScrollableLayerGuid const&)
Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > mozilla::layers::Stringify<mozilla::gfx::Matrix4x4Typed<mozilla::LayerPixel, mozilla::CSSTransformedLayerPixel> >(mozilla::gfx::Matrix4x4Typed<mozilla::LayerPixel, mozilla::CSSTransformedLayerPixel> const&)
Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > mozilla::layers::Stringify<mozilla::gfx::IntRegionTyped<mozilla::ParentLayerPixel> >(mozilla::gfx::IntRegionTyped<mozilla::ParentLayerPixel> const&)
Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > mozilla::layers::Stringify<mozilla::gfx::IntSizeTyped<mozilla::gfx::UnknownUnits> >(mozilla::gfx::IntSizeTyped<mozilla::gfx::UnknownUnits> const&)
322
323
} // namespace layers
324
} // namespace mozilla
325
326
// versions of printf_stderr and fprintf_stderr that deal with line
327
// truncation on android by printing individual lines out of the
328
// stringstream as separate calls to logcat.
329
void print_stderr(std::stringstream& aStr);
330
void fprint_stderr(FILE* aFile, std::stringstream& aStr);
331
332
#endif /* GFX_LAYERSLOGGING_H */