1/*
2 * Copyright (c) 2016 Red Hat, Inc.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "config.h"
19#include <glib/gi18n-lib.h>
20
21#include "renderrecording.h"
22
23G_DEFINE_TYPE (GtkInspectorRenderRecording, gtk_inspector_render_recording, GTK_TYPE_INSPECTOR_RECORDING)
24
25static void
26gtk_inspector_render_recording_finalize (GObject *object)
27{
28 GtkInspectorRenderRecording *recording = GTK_INSPECTOR_RENDER_RECORDING (object);
29
30 g_clear_pointer (&recording->clip_region, cairo_region_destroy);
31 g_clear_pointer (&recording->node, gsk_render_node_unref);
32 g_clear_pointer (&recording->profiler_info, g_free);
33
34 G_OBJECT_CLASS (gtk_inspector_render_recording_parent_class)->finalize (object);
35}
36
37static void
38gtk_inspector_render_recording_class_init (GtkInspectorRenderRecordingClass *klass)
39{
40 GObjectClass *object_class = G_OBJECT_CLASS (klass);
41
42 object_class->finalize = gtk_inspector_render_recording_finalize;
43}
44
45static void
46gtk_inspector_render_recording_init (GtkInspectorRenderRecording *vis)
47{
48}
49
50static void
51collect_profiler_info (GtkInspectorRenderRecording *recording,
52 GskProfiler *profiler)
53{
54 GString *string;
55
56 string = g_string_new (NULL);
57 gsk_profiler_append_timers (profiler, buffer: string);
58 gsk_profiler_append_counters (profiler, buffer: string);
59 recording->profiler_info = g_string_free (string, FALSE);
60}
61
62GtkInspectorRecording *
63gtk_inspector_render_recording_new (gint64 timestamp,
64 GskProfiler *profiler,
65 const GdkRectangle *area,
66 const cairo_region_t *clip_region,
67 GskRenderNode *node)
68{
69 GtkInspectorRenderRecording *recording;
70
71 recording = g_object_new (GTK_TYPE_INSPECTOR_RENDER_RECORDING,
72 first_property_name: "timestamp", timestamp,
73 NULL);
74
75 collect_profiler_info (recording, profiler);
76 recording->area = *area;
77 recording->clip_region = cairo_region_copy (original: clip_region);
78 recording->node = gsk_render_node_ref (node);
79
80 return GTK_INSPECTOR_RECORDING (recording);
81}
82
83GskRenderNode *
84gtk_inspector_render_recording_get_node (GtkInspectorRenderRecording *recording)
85{
86 return recording->node;
87}
88
89const cairo_region_t *
90gtk_inspector_render_recording_get_clip_region (GtkInspectorRenderRecording *recording)
91{
92 return recording->clip_region;
93}
94
95const cairo_rectangle_int_t *
96gtk_inspector_render_recording_get_area (GtkInspectorRenderRecording *recording)
97{
98 return &recording->area;
99}
100
101const char *
102gtk_inspector_render_recording_get_profiler_info (GtkInspectorRenderRecording *recording)
103{
104 return recording->profiler_info;
105}
106
107// vim: set et sw=2 ts=2:
108

source code of gtk/gtk/inspector/renderrecording.c