Source code

Revision control

Other Tools

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
// This is a general tool that will let you visualize platform operation.
8
// Currently used for the layer system, the general syntax allows this
9
// tools to be adapted to trace other operations.
10
//
11
// For the front end see: https://github.com/staktrace/rendertrace
12
13
// Uncomment this line to enable RENDERTRACE
14
//#define MOZ_RENDERTRACE
15
16
#ifndef GFX_RENDERTRACE_H
17
#define GFX_RENDERTRACE_H
18
19
#include "nsRect.h"
20
#include "mozilla/gfx/Matrix.h"
21
22
namespace mozilla {
23
namespace layers {
24
25
class Layer;
26
27
void RenderTraceLayers(Layer* aLayer, const char* aColor,
28
const gfx::Matrix4x4 aRootTransform = gfx::Matrix4x4(),
29
bool aReset = true);
30
31
void RenderTraceInvalidateStart(Layer* aLayer, const char* aColor,
32
const gfx::IntRect aRect);
33
void RenderTraceInvalidateEnd(Layer* aLayer, const char* aColor);
34
35
void renderTraceEventStart(const char* aComment, const char* aColor);
36
void renderTraceEventEnd(const char* aComment, const char* aColor);
37
void renderTraceEventEnd(const char* aColor);
38
39
struct RenderTraceScope {
40
public:
41
RenderTraceScope(const char* aComment, const char* aColor)
42
: mComment(aComment), mColor(aColor) {
43
renderTraceEventStart(mComment, mColor);
44
}
45
~RenderTraceScope() { renderTraceEventEnd(mComment, mColor); }
46
47
private:
48
const char* mComment;
49
const char* mColor;
50
};
51
52
#ifndef MOZ_RENDERTRACE
53
inline void RenderTraceLayers(Layer* aLayer, const char* aColor,
54
const gfx::Matrix4x4 aRootTransform,
55
bool aReset) {}
56
57
inline void RenderTraceInvalidateStart(Layer* aLayer, const char* aColor,
58
const gfx::IntRect aRect) {}
59
60
inline void RenderTraceInvalidateEnd(Layer* aLayer, const char* aColor) {}
61
62
inline void renderTraceEventStart(const char* aComment, const char* aColor) {}
63
64
inline void renderTraceEventEnd(const char* aComment, const char* aColor) {}
65
66
inline void renderTraceEventEnd(const char* aColor) {}
67
68
#endif // MOZ_RENDERTRACE
69
70
} // namespace layers
71
} // namespace mozilla
72
73
#endif // GFX_RENDERTRACE_H