1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4 /* This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 #include "LayersLogging.h"
9 #include <stdint.h> // for uint8_t
10 #include "gfx3DMatrix.h" // for gfx3DMatrix
11 #include "gfxColor.h" // for gfxRGBA
12 #include "gfxMatrix.h" // for gfxMatrix
13 #include "mozilla/gfx/Matrix.h" // for Matrix4x4, Matrix
14 #include "nsDebug.h" // for NS_ERROR
15 #include "nsPoint.h" // for nsIntPoint
16 #include "nsRect.h" // for nsIntRect
17 #include "nsSize.h" // for nsIntSize
19 using namespace mozilla::gfx
;
25 AppendToString(nsACString
& s
, const void* p
,
26 const char* pfx
, const char* sfx
)
29 s
+= nsPrintfCString("%p", p
);
34 AppendToString(nsACString
& s
, const GraphicsFilter
& f
,
35 const char* pfx
, const char* sfx
)
39 case GraphicsFilter::FILTER_FAST
: s
+= "fast"; break;
40 case GraphicsFilter::FILTER_GOOD
: s
+= "good"; break;
41 case GraphicsFilter::FILTER_BEST
: s
+= "best"; break;
42 case GraphicsFilter::FILTER_NEAREST
: s
+= "nearest"; break;
43 case GraphicsFilter::FILTER_BILINEAR
: s
+= "bilinear"; break;
44 case GraphicsFilter::FILTER_GAUSSIAN
: s
+= "gaussian"; break;
46 NS_ERROR("unknown filter type");
53 AppendToString(nsACString
& s
, FrameMetrics::ViewID n
,
54 const char* pfx
, const char* sfx
)
62 AppendToString(nsACString
& s
, const gfxRGBA
& c
,
63 const char* pfx
, const char* sfx
)
67 "rgba(%d, %d, %d, %g)",
68 uint8_t(c
.r
*255.0), uint8_t(c
.g
*255.0), uint8_t(c
.b
*255.0), c
.a
);
73 AppendToString(nsACString
& s
, const gfx3DMatrix
& m
,
74 const char* pfx
, const char* sfx
)
81 if (m
.Is2D(&matrix
)) {
83 "[ %g %g; %g %g; %g %g; ]",
84 matrix
.xx
, matrix
.yx
, matrix
.xy
, matrix
.yy
, matrix
.x0
, matrix
.y0
);
87 "[ %g %g %g %g; %g %g %g %g; %g %g %g %g; %g %g %g %g; ]",
88 m
._11
, m
._12
, m
._13
, m
._14
,
89 m
._21
, m
._22
, m
._23
, m
._24
,
90 m
._31
, m
._32
, m
._33
, m
._34
,
91 m
._41
, m
._42
, m
._43
, m
._44
);
98 AppendToString(nsACString
& s
, const nsIntPoint
& p
,
99 const char* pfx
, const char* sfx
)
102 s
+= nsPrintfCString("(x=%d, y=%d)", p
.x
, p
.y
);
107 AppendToString(nsACString
& s
, const nsIntRect
& r
,
108 const char* pfx
, const char* sfx
)
111 s
+= nsPrintfCString(
112 "(x=%d, y=%d, w=%d, h=%d)",
113 r
.x
, r
.y
, r
.width
, r
.height
);
118 AppendToString(nsACString
& s
, const nsIntRegion
& r
,
119 const char* pfx
, const char* sfx
)
123 nsIntRegionRectIterator
it(r
);
125 while (const nsIntRect
* sr
= it
.Next())
126 AppendToString(s
, *sr
) += "; ";
133 AppendToString(nsACString
& s
, const nsIntSize
& sz
,
134 const char* pfx
, const char* sfx
)
137 s
+= nsPrintfCString("(w=%d, h=%d)", sz
.width
, sz
.height
);
142 AppendToString(nsACString
& s
, const FrameMetrics
& m
,
143 const char* pfx
, const char* sfx
)
146 AppendToString(s
, m
.mViewport
, "{ viewport=");
147 AppendToString(s
, m
.mScrollOffset
, " viewportScroll=");
148 AppendToString(s
, m
.mDisplayPort
, " displayport=");
149 AppendToString(s
, m
.mScrollId
, " scrollId=", " }");
154 AppendToString(nsACString
& s
, const IntSize
& size
,
155 const char* pfx
, const char* sfx
)
158 s
+= nsPrintfCString(
159 "(width=%d, height=%d)",
160 size
.width
, size
.height
);
165 AppendToString(nsACString
& s
, const Matrix4x4
& m
,
166 const char* pfx
, const char* sfx
)
170 Matrix matrix
= m
.As2D();
171 if (matrix
.IsIdentity()) {
175 s
+= nsPrintfCString(
176 "[ %g %g; %g %g; %g %g; ]",
177 matrix
._11
, matrix
._12
, matrix
._21
, matrix
._22
, matrix
._31
, matrix
._32
);
179 s
+= nsPrintfCString(
180 "[ %g %g %g %g; %g %g %g %g; %g %g %g %g; %g %g %g %g; ]",
181 m
._11
, m
._12
, m
._13
, m
._14
,
182 m
._21
, m
._22
, m
._23
, m
._24
,
183 m
._31
, m
._32
, m
._33
, m
._34
,
184 m
._41
, m
._42
, m
._43
, m
._44
);
190 AppendToString(nsACString
& s
, const Filter filter
,
191 const char* pfx
, const char* sfx
)
196 case FILTER_GOOD
: s
+= "FILTER_GOOD"; break;
197 case FILTER_LINEAR
: s
+= "FILTER_LINEAR"; break;
198 case FILTER_POINT
: s
+= "FILTER_POINT"; break;
204 AppendToString(nsACString
& s
, TextureFlags flags
,
205 const char* pfx
, const char* sfx
)
212 #define AppendFlag(test) \
214 if (flags & test) { \
222 bool previous
= false;
223 AppendFlag(TEXTURE_USE_NEAREST_FILTER
);
224 AppendFlag(TEXTURE_NEEDS_Y_FLIP
);
225 AppendFlag(TEXTURE_DISALLOW_BIGIMAGE
);
226 AppendFlag(TEXTURE_ALLOW_REPEAT
);
227 AppendFlag(TEXTURE_NEW_TILE
);
235 AppendToString(nsACString
& s
, mozilla::gfx::SurfaceFormat format
,
236 const char* pfx
, const char* sfx
)
240 case FORMAT_B8G8R8A8
: s
+= "FORMAT_B8G8R8A8"; break;
241 case FORMAT_B8G8R8X8
: s
+= "FORMAT_B8G8R8X8"; break;
242 case FORMAT_R8G8B8A8
: s
+= "FORMAT_R8G8B8A8"; break;
243 case FORMAT_R8G8B8X8
: s
+= "FORMAT_R8G8B8X8"; break;
244 case FORMAT_R5G6B5
: s
+= "FORMAT_R5G6B5"; break;
245 case FORMAT_A8
: s
+= "FORMAT_A8"; break;
246 case FORMAT_YUV
: s
+= "FORMAT_YUV"; break;
247 case FORMAT_UNKNOWN
: s
+= "FORMAT_UNKNOWN"; break;