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
27 template <class units
> struct RectTyped
;
33 AppendToString(std::stringstream
& aStream
, const void* p
,
34 const char* pfx
="", const char* sfx
="");
37 AppendToString(std::stringstream
& aStream
, const GraphicsFilter
& f
,
38 const char* pfx
="", const char* sfx
="");
41 AppendToString(std::stringstream
& aStream
, FrameMetrics::ViewID n
,
42 const char* pfx
="", const char* sfx
="");
45 AppendToString(std::stringstream
& aStream
, const gfxRGBA
& c
,
46 const char* pfx
="", const char* sfx
="");
49 AppendToString(std::stringstream
& aStream
, const nsIntPoint
& p
,
50 const char* pfx
="", const char* sfx
="");
54 AppendToString(std::stringstream
& aStream
, const mozilla::gfx::PointTyped
<T
>& p
,
55 const char* pfx
="", const char* sfx
="")
57 aStream
<< pfx
<< p
<< sfx
;
61 AppendToString(std::stringstream
& aStream
, const nsIntRect
& r
,
62 const char* pfx
="", const char* sfx
="");
66 AppendToString(std::stringstream
& aStream
, const mozilla::gfx::RectTyped
<T
>& r
,
67 const char* pfx
="", const char* sfx
="")
70 aStream
<< nsPrintfCString(
71 "(x=%f, y=%f, w=%f, h=%f)",
72 r
.x
, r
.y
, r
.width
, r
.height
).get();
78 AppendToString(std::stringstream
& aStream
, const mozilla::gfx::IntRectTyped
<T
>& r
,
79 const char* pfx
="", const char* sfx
="")
82 aStream
<< nsPrintfCString(
83 "(x=%d, y=%d, w=%d, h=%d)",
84 r
.x
, r
.y
, r
.width
, r
.height
).get();
89 AppendToString(std::stringstream
& aStream
, const nsIntRegion
& r
,
90 const char* pfx
="", const char* sfx
="");
93 AppendToString(std::stringstream
& aStream
, const nsIntSize
& sz
,
94 const char* pfx
="", const char* sfx
="");
97 AppendToString(std::stringstream
& aStream
, const FrameMetrics
& m
,
98 const char* pfx
="", const char* sfx
="", bool detailed
= false);
101 AppendToString(std::stringstream
& aStream
, const ScrollableLayerGuid
& s
,
102 const char* pfx
="", const char* sfx
="");
106 AppendToString(std::stringstream
& aStream
, const mozilla::gfx::MarginTyped
<T
>& m
,
107 const char* pfx
="", const char* sfx
="")
110 aStream
<< nsPrintfCString(
111 "(l=%f, t=%f, r=%f, b=%f)",
112 m
.left
, m
.top
, m
.right
, m
.bottom
).get();
118 AppendToString(std::stringstream
& aStream
, const mozilla::gfx::SizeTyped
<T
>& sz
,
119 const char* pfx
="", const char* sfx
="")
122 aStream
<< nsPrintfCString(
124 sz
.width
, sz
.height
).get();
130 AppendToString(std::stringstream
& aStream
, const mozilla::gfx::IntSizeTyped
<T
>& sz
,
131 const char* pfx
="", const char* sfx
="")
134 aStream
<< nsPrintfCString(
136 sz
.width
, sz
.height
).get();
141 AppendToString(std::stringstream
& aStream
, const mozilla::gfx::Matrix4x4
& m
,
142 const char* pfx
="", const char* sfx
="");
145 AppendToString(std::stringstream
& aStream
, const mozilla::gfx::Matrix5x4
& m
,
146 const char* pfx
="", const char* sfx
="");
149 AppendToString(std::stringstream
& aStream
, const mozilla::gfx::Filter filter
,
150 const char* pfx
="", const char* sfx
="");
153 AppendToString(std::stringstream
& aStream
, mozilla::layers::TextureFlags flags
,
154 const char* pfx
="", const char* sfx
="");
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
>
163 Stringify(const T
& obj
)
165 std::stringstream ss
;
166 AppendToString(ss
, obj
);
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 */