1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/layers/LayersLogging.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,229 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- 1.5 + * vim: sw=2 ts=8 et : 1.6 + */ 1.7 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.8 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.9 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.10 + 1.11 +#include "LayersLogging.h" 1.12 +#include <stdint.h> // for uint8_t 1.13 +#include "gfx3DMatrix.h" // for gfx3DMatrix 1.14 +#include "gfxColor.h" // for gfxRGBA 1.15 +#include "mozilla/gfx/Matrix.h" // for Matrix4x4, Matrix 1.16 +#include "nsDebug.h" // for NS_ERROR 1.17 +#include "nsPoint.h" // for nsIntPoint 1.18 +#include "nsRect.h" // for nsIntRect 1.19 +#include "nsSize.h" // for nsIntSize 1.20 + 1.21 +using namespace mozilla::gfx; 1.22 + 1.23 +namespace mozilla { 1.24 +namespace layers { 1.25 + 1.26 +nsACString& 1.27 +AppendToString(nsACString& s, const void* p, 1.28 + const char* pfx, const char* sfx) 1.29 +{ 1.30 + s += pfx; 1.31 + s += nsPrintfCString("%p", p); 1.32 + return s += sfx; 1.33 +} 1.34 + 1.35 +nsACString& 1.36 +AppendToString(nsACString& s, const GraphicsFilter& f, 1.37 + const char* pfx, const char* sfx) 1.38 +{ 1.39 + s += pfx; 1.40 + switch (f) { 1.41 + case GraphicsFilter::FILTER_FAST: s += "fast"; break; 1.42 + case GraphicsFilter::FILTER_GOOD: s += "good"; break; 1.43 + case GraphicsFilter::FILTER_BEST: s += "best"; break; 1.44 + case GraphicsFilter::FILTER_NEAREST: s += "nearest"; break; 1.45 + case GraphicsFilter::FILTER_BILINEAR: s += "bilinear"; break; 1.46 + case GraphicsFilter::FILTER_GAUSSIAN: s += "gaussian"; break; 1.47 + default: 1.48 + NS_ERROR("unknown filter type"); 1.49 + s += "???"; 1.50 + } 1.51 + return s += sfx; 1.52 +} 1.53 + 1.54 +nsACString& 1.55 +AppendToString(nsACString& s, FrameMetrics::ViewID n, 1.56 + const char* pfx, const char* sfx) 1.57 +{ 1.58 + s += pfx; 1.59 + s.AppendInt(n); 1.60 + return s += sfx; 1.61 +} 1.62 + 1.63 +nsACString& 1.64 +AppendToString(nsACString& s, const gfxRGBA& c, 1.65 + const char* pfx, const char* sfx) 1.66 +{ 1.67 + s += pfx; 1.68 + s += nsPrintfCString( 1.69 + "rgba(%d, %d, %d, %g)", 1.70 + uint8_t(c.r*255.0), uint8_t(c.g*255.0), uint8_t(c.b*255.0), c.a); 1.71 + return s += sfx; 1.72 +} 1.73 + 1.74 +nsACString& 1.75 +AppendToString(nsACString& s, const nsIntPoint& p, 1.76 + const char* pfx, const char* sfx) 1.77 +{ 1.78 + s += pfx; 1.79 + s += nsPrintfCString("(x=%d, y=%d)", p.x, p.y); 1.80 + return s += sfx; 1.81 +} 1.82 + 1.83 +nsACString& 1.84 +AppendToString(nsACString& s, const nsIntRect& r, 1.85 + const char* pfx, const char* sfx) 1.86 +{ 1.87 + s += pfx; 1.88 + s += nsPrintfCString( 1.89 + "(x=%d, y=%d, w=%d, h=%d)", 1.90 + r.x, r.y, r.width, r.height); 1.91 + return s += sfx; 1.92 +} 1.93 + 1.94 +nsACString& 1.95 +AppendToString(nsACString& s, const nsIntRegion& r, 1.96 + const char* pfx, const char* sfx) 1.97 +{ 1.98 + s += pfx; 1.99 + 1.100 + nsIntRegionRectIterator it(r); 1.101 + s += "< "; 1.102 + while (const nsIntRect* sr = it.Next()) 1.103 + AppendToString(s, *sr) += "; "; 1.104 + s += ">"; 1.105 + 1.106 + return s += sfx; 1.107 +} 1.108 + 1.109 +nsACString& 1.110 +AppendToString(nsACString& s, const nsIntSize& sz, 1.111 + const char* pfx, const char* sfx) 1.112 +{ 1.113 + s += pfx; 1.114 + s += nsPrintfCString("(w=%d, h=%d)", sz.width, sz.height); 1.115 + return s += sfx; 1.116 +} 1.117 + 1.118 +nsACString& 1.119 +AppendToString(nsACString& s, const FrameMetrics& m, 1.120 + const char* pfx, const char* sfx) 1.121 +{ 1.122 + s += pfx; 1.123 + AppendToString(s, m.mViewport, "{ viewport="); 1.124 + AppendToString(s, m.GetScrollOffset(), " viewportScroll="); 1.125 + AppendToString(s, m.mDisplayPort, " displayport="); 1.126 + AppendToString(s, m.mScrollableRect, " scrollableRect="); 1.127 + AppendToString(s, m.GetScrollId(), " scrollId=", " }"); 1.128 + return s += sfx; 1.129 +} 1.130 + 1.131 +nsACString& 1.132 +AppendToString(nsACString& s, const IntSize& size, 1.133 + const char* pfx, const char* sfx) 1.134 +{ 1.135 + s += pfx; 1.136 + s += nsPrintfCString( 1.137 + "(width=%d, height=%d)", 1.138 + size.width, size.height); 1.139 + return s += sfx; 1.140 +} 1.141 + 1.142 +nsACString& 1.143 +AppendToString(nsACString& s, const Matrix4x4& m, 1.144 + const char* pfx, const char* sfx) 1.145 +{ 1.146 + s += pfx; 1.147 + if (m.Is2D()) { 1.148 + Matrix matrix = m.As2D(); 1.149 + if (matrix.IsIdentity()) { 1.150 + s += "[ I ]"; 1.151 + return s += sfx; 1.152 + } 1.153 + s += nsPrintfCString( 1.154 + "[ %g %g; %g %g; %g %g; ]", 1.155 + matrix._11, matrix._12, matrix._21, matrix._22, matrix._31, matrix._32); 1.156 + } else { 1.157 + s += nsPrintfCString( 1.158 + "[ %g %g %g %g; %g %g %g %g; %g %g %g %g; %g %g %g %g; ]", 1.159 + m._11, m._12, m._13, m._14, 1.160 + m._21, m._22, m._23, m._24, 1.161 + m._31, m._32, m._33, m._34, 1.162 + m._41, m._42, m._43, m._44); 1.163 + } 1.164 + return s += sfx; 1.165 +} 1.166 + 1.167 +nsACString& 1.168 +AppendToString(nsACString& s, const Filter filter, 1.169 + const char* pfx, const char* sfx) 1.170 +{ 1.171 + s += pfx; 1.172 + 1.173 + switch (filter) { 1.174 + case Filter::GOOD: s += "Filter::GOOD"; break; 1.175 + case Filter::LINEAR: s += "Filter::LINEAR"; break; 1.176 + case Filter::POINT: s += "Filter::POINT"; break; 1.177 + } 1.178 + return s += sfx; 1.179 +} 1.180 + 1.181 +nsACString& 1.182 +AppendToString(nsACString& s, TextureFlags flags, 1.183 + const char* pfx, const char* sfx) 1.184 +{ 1.185 + s += pfx; 1.186 + if (!flags) { 1.187 + s += "NoFlags"; 1.188 + } else { 1.189 + 1.190 +#define AppendFlag(test) \ 1.191 +{ \ 1.192 + if (flags & test) { \ 1.193 + if (previous) { \ 1.194 + s += "|"; \ 1.195 + } \ 1.196 + s += #test; \ 1.197 + previous = true; \ 1.198 + } \ 1.199 +} 1.200 + bool previous = false; 1.201 + AppendFlag(TEXTURE_USE_NEAREST_FILTER); 1.202 + AppendFlag(TEXTURE_NEEDS_Y_FLIP); 1.203 + AppendFlag(TEXTURE_DISALLOW_BIGIMAGE); 1.204 + AppendFlag(TEXTURE_ALLOW_REPEAT); 1.205 + AppendFlag(TEXTURE_NEW_TILE); 1.206 + 1.207 +#undef AppendFlag 1.208 + } 1.209 + return s += sfx; 1.210 +} 1.211 + 1.212 +nsACString& 1.213 +AppendToString(nsACString& s, mozilla::gfx::SurfaceFormat format, 1.214 + const char* pfx, const char* sfx) 1.215 +{ 1.216 + s += pfx; 1.217 + switch (format) { 1.218 + case SurfaceFormat::B8G8R8A8: s += "SurfaceFormat::B8G8R8A8"; break; 1.219 + case SurfaceFormat::B8G8R8X8: s += "SurfaceFormat::B8G8R8X8"; break; 1.220 + case SurfaceFormat::R8G8B8A8: s += "SurfaceFormat::R8G8B8A8"; break; 1.221 + case SurfaceFormat::R8G8B8X8: s += "SurfaceFormat::R8G8B8X8"; break; 1.222 + case SurfaceFormat::R5G6B5: s += "SurfaceFormat::R5G6B5"; break; 1.223 + case SurfaceFormat::A8: s += "SurfaceFormat::A8"; break; 1.224 + case SurfaceFormat::YUV: s += "SurfaceFormat::YUV"; break; 1.225 + case SurfaceFormat::UNKNOWN: s += "SurfaceFormat::UNKNOWN"; break; 1.226 + } 1.227 + 1.228 + return s += sfx; 1.229 +} 1.230 + 1.231 +} // namespace 1.232 +} // namespace