Skip to content

Commit

Permalink
[trace] Disable mark dirty tracing.
Browse files Browse the repository at this point in the history
Applications like firefox have a very conservative approach and mark
surfaces dirty before every render. As we record the image data every
time, firefox traces can grow very large with redundant data - so allow
the user to disable mark dirty tracing.
  • Loading branch information
ickle committed Mar 4, 2009
1 parent addeb32 commit 9099c7e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 11 deletions.
19 changes: 15 additions & 4 deletions util/cairo-trace/cairo-trace.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ exec_prefix=@exec_prefix@
nofile=
flush=
nocallers=
nomarkdirty=

usage() {
cat << EOF
Expand All @@ -14,10 +15,11 @@ cairo-trace will generate a log of all calls made by command to
cairo. This log will be stored in a file in the local directory
called command.pid.trace.
Whatever else happens is driven by its argument:
--flush - Flush the output trace after every call.
--no-file - Disable the creation of an output file. Outputs to the
terminal instead.
--no-callers - Do not lookup the caller address/symbol/line whilst tracing.
--flush - Flush the output trace after every call.
--no-file - Disable the creation of an output file. Outputs to the
terminal instead.
--no-callers - Do not lookup the caller address/symbol/line whilst tracing.
--no-mark-dirty - Do not record image data for cairo_mark_dirty()
Enviroment variables understood by cairo-trace:
CAIRO_TRACE_FLUSH - flush the output after every function call.
Expand All @@ -42,6 +44,10 @@ while test $skip -eq 1; do
skip=1
nocallers=1
;;
--no-mark-dirty)
skip=1
nomarkdirty=1
;;
--version)
echo "cairo-trace, version @CAIRO_VERSION_MAJOR@.@CAIRO_VERSION_MINOR@.@CAIRO_VERSION_MICRO@."
exit
Expand Down Expand Up @@ -69,6 +75,11 @@ if test -n "$nocallers"; then
export CAIRO_TRACE_LINE_INFO
fi

if test -n "$nomarkdirty"; then
CAIRO_TRACE_MARK_DIRTY=0
export CAIRO_TRACE_MARK_DIRTY
fi

if test -n "$flush"; then
CAIRO_TRACE_FLUSH=1
export CAIRO_TRACE_FLUSH
Expand Down
27 changes: 20 additions & 7 deletions util/cairo-trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ static FILE *logfile;
static bool _flush;
static bool _error;
static bool _line_info;
static bool _mark_dirty;
static const cairo_user_data_key_t destroy_key;

#if __GNUC__ >= 3
Expand Down Expand Up @@ -692,6 +693,11 @@ _init_logfile (void)
if (env != NULL)
_line_info = atoi (env);

_mark_dirty = true;
env = getenv ("CAIRO_TRACE_MARK_DIRTY");
if (env != NULL)
_mark_dirty = atoi (env);

filename = getenv ("CAIRO_TRACE_FD");
if (filename != NULL) {
int fd = atoi (filename);
Expand Down Expand Up @@ -3115,9 +3121,12 @@ cairo_surface_mark_dirty (cairo_surface_t *surface)
{
_emit_line_info ();
if (surface != NULL && _write_lock ()) {
_emit_surface (surface);
_trace_printf ("%% mark-dirty\n");
_emit_source_image (surface);
if (_mark_dirty) {
_emit_surface (surface);
_trace_printf ("%% mark-dirty\n");
_emit_source_image (surface);
} else
_trace_printf ("%% s%ld mark-dirty\n", _get_surface_id (surface));
_write_unlock ();
}

Expand All @@ -3130,10 +3139,14 @@ cairo_surface_mark_dirty_rectangle (cairo_surface_t *surface,
{
_emit_line_info ();
if (surface != NULL && _write_lock ()) {
_emit_surface (surface);
_trace_printf ("%% %d %d %d %d mark-dirty-rectangle\n",
x, y, width, height);
_emit_source_image_rectangle (surface, x,y, width, height);
if (_mark_dirty) {
_emit_surface (surface);
_trace_printf ("%% %d %d %d %d mark-dirty-rectangle\n",
x, y, width, height);
_emit_source_image_rectangle (surface, x,y, width, height);
} else
_trace_printf ("%% s%ld %d %d %d %d mark-dirty-rectangle\n",
_get_surface_id (surface), x, y, width, height);
_write_unlock ();
}

Expand Down

0 comments on commit 9099c7e

Please sign in to comment.