libsysprof-gtk: rename depth layer to column layer

I would like this to eventually be a bit more re-usable for XYSeries and
more than just "stack depth" for the traceables.
This commit is contained in:
Christian Hergert
2023-06-20 14:30:03 -07:00
parent b40be19530
commit faf2303015
5 changed files with 88 additions and 86 deletions

View File

@ -2,7 +2,7 @@ libsysprof_gtk_public_sources = [
'sysprof-callgraph-view.c', 'sysprof-callgraph-view.c',
'sysprof-chart.c', 'sysprof-chart.c',
'sysprof-chart-layer.c', 'sysprof-chart-layer.c',
'sysprof-depth-layer.c', 'sysprof-column-layer.c',
'sysprof-mark-chart.c', 'sysprof-mark-chart.c',
'sysprof-mark-table.c', 'sysprof-mark-table.c',
'sysprof-session.c', 'sysprof-session.c',
@ -15,7 +15,7 @@ libsysprof_gtk_public_headers = [
'sysprof-callgraph-view.h', 'sysprof-callgraph-view.h',
'sysprof-chart.h', 'sysprof-chart.h',
'sysprof-chart-layer.h', 'sysprof-chart-layer.h',
'sysprof-depth-layer.h', 'sysprof-column-layer.h',
'sysprof-mark-chart.h', 'sysprof-mark-chart.h',
'sysprof-mark-table.h', 'sysprof-mark-table.h',
'sysprof-session.h', 'sysprof-session.h',

View File

@ -1,4 +1,4 @@
/* sysprof-depth-layer.c /* sysprof-column-layer.c
* *
* Copyright 2023 Christian Hergert <chergert@redhat.com> * Copyright 2023 Christian Hergert <chergert@redhat.com>
* *
@ -20,9 +20,9 @@
#include "config.h" #include "config.h"
#include "sysprof-depth-layer.h" #include "sysprof-column-layer.h"
struct _SysprofDepthLayer struct _SysprofColumnLayer
{ {
SysprofChartLayer parent_instance; SysprofChartLayer parent_instance;
SysprofXYSeries *series; SysprofXYSeries *series;
@ -38,15 +38,15 @@ enum {
N_PROPS N_PROPS
}; };
G_DEFINE_FINAL_TYPE (SysprofDepthLayer, sysprof_depth_layer, SYSPROF_TYPE_CHART_LAYER) G_DEFINE_FINAL_TYPE (SysprofColumnLayer, sysprof_column_layer, SYSPROF_TYPE_CHART_LAYER)
static GParamSpec *properties [N_PROPS]; static GParamSpec *properties [N_PROPS];
static void static void
sysprof_depth_layer_snapshot (GtkWidget *widget, sysprof_column_layer_snapshot (GtkWidget *widget,
GtkSnapshot *snapshot) GtkSnapshot *snapshot)
{ {
SysprofDepthLayer *self = (SysprofDepthLayer *)widget; SysprofColumnLayer *self = (SysprofColumnLayer *)widget;
const SysprofXYSeriesValue *values; const SysprofXYSeriesValue *values;
guint n_values; guint n_values;
double min_x, max_x; double min_x, max_x;
@ -54,7 +54,7 @@ sysprof_depth_layer_snapshot (GtkWidget *widget,
int width; int width;
int height; int height;
g_assert (SYSPROF_IS_DEPTH_LAYER (self)); g_assert (SYSPROF_IS_COLUMN_LAYER (self));
g_assert (GTK_IS_SNAPSHOT (snapshot)); g_assert (GTK_IS_SNAPSHOT (snapshot));
width = gtk_widget_get_width (widget); width = gtk_widget_get_width (widget);
@ -92,10 +92,10 @@ sysprof_depth_layer_snapshot (GtkWidget *widget,
} }
static const SysprofXYSeriesValue * static const SysprofXYSeriesValue *
sysprof_depth_layer_get_value_at_coord (SysprofDepthLayer *self, sysprof_column_layer_get_value_at_coord (SysprofColumnLayer *self,
double x, double x,
double y, double y,
graphene_rect_t *area) graphene_rect_t *area)
{ {
const SysprofXYSeriesValue *values; const SysprofXYSeriesValue *values;
graphene_point_t point; graphene_point_t point;
@ -106,7 +106,7 @@ sysprof_depth_layer_get_value_at_coord (SysprofDepthLayer *self,
int width; int width;
int height; int height;
g_assert (SYSPROF_IS_DEPTH_LAYER (self)); g_assert (SYSPROF_IS_COLUMN_LAYER (self));
width = gtk_widget_get_width (GTK_WIDGET (self)); width = gtk_widget_get_width (GTK_WIDGET (self));
height = gtk_widget_get_height (GTK_WIDGET (self)); height = gtk_widget_get_height (GTK_WIDGET (self));
@ -145,55 +145,55 @@ sysprof_depth_layer_get_value_at_coord (SysprofDepthLayer *self,
} }
static void static void
sysprof_depth_layer_snapshot_motion (SysprofChartLayer *layer, sysprof_column_layer_snapshot_motion (SysprofChartLayer *layer,
GtkSnapshot *snapshot, GtkSnapshot *snapshot,
double x, double x,
double y) double y)
{ {
SysprofDepthLayer *self = (SysprofDepthLayer *)layer; SysprofColumnLayer *self = (SysprofColumnLayer *)layer;
const SysprofXYSeriesValue *v; const SysprofXYSeriesValue *v;
graphene_rect_t rect; graphene_rect_t rect;
g_assert (SYSPROF_IS_DEPTH_LAYER (self)); g_assert (SYSPROF_IS_COLUMN_LAYER (self));
g_assert (GTK_IS_SNAPSHOT (snapshot)); g_assert (GTK_IS_SNAPSHOT (snapshot));
if ((v = sysprof_depth_layer_get_value_at_coord (self, x, y, &rect))) if ((v = sysprof_column_layer_get_value_at_coord (self, x, y, &rect)))
gtk_snapshot_append_color (snapshot, &self->hover_color, &rect); gtk_snapshot_append_color (snapshot, &self->hover_color, &rect);
} }
static gpointer static gpointer
sysprof_depth_layer_lookup_item (SysprofChartLayer *layer, sysprof_column_layer_lookup_item (SysprofChartLayer *layer,
double x, double x,
double y) double y)
{ {
SysprofDepthLayer *self = (SysprofDepthLayer *)layer; SysprofColumnLayer *self = (SysprofColumnLayer *)layer;
const SysprofXYSeriesValue *v; const SysprofXYSeriesValue *v;
g_assert (SYSPROF_IS_DEPTH_LAYER (self)); g_assert (SYSPROF_IS_COLUMN_LAYER (self));
if ((v = sysprof_depth_layer_get_value_at_coord (self, x, y, NULL))) if ((v = sysprof_column_layer_get_value_at_coord (self, x, y, NULL)))
return g_list_model_get_item (sysprof_xy_series_get_model (self->series), v->index); return g_list_model_get_item (sysprof_xy_series_get_model (self->series), v->index);
return NULL; return NULL;
} }
static void static void
sysprof_depth_layer_dispose (GObject *object) sysprof_column_layer_dispose (GObject *object)
{ {
SysprofDepthLayer *self = (SysprofDepthLayer *)object; SysprofColumnLayer *self = (SysprofColumnLayer *)object;
g_clear_pointer (&self->series, sysprof_xy_series_unref); g_clear_pointer (&self->series, sysprof_xy_series_unref);
G_OBJECT_CLASS (sysprof_depth_layer_parent_class)->dispose (object); G_OBJECT_CLASS (sysprof_column_layer_parent_class)->dispose (object);
} }
static void static void
sysprof_depth_layer_get_property (GObject *object, sysprof_column_layer_get_property (GObject *object,
guint prop_id, guint prop_id,
GValue *value, GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
SysprofDepthLayer *self = SYSPROF_DEPTH_LAYER (object); SysprofColumnLayer *self = SYSPROF_COLUMN_LAYER (object);
switch (prop_id) switch (prop_id)
{ {
@ -215,25 +215,25 @@ sysprof_depth_layer_get_property (GObject *object,
} }
static void static void
sysprof_depth_layer_set_property (GObject *object, sysprof_column_layer_set_property (GObject *object,
guint prop_id, guint prop_id,
const GValue *value, const GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
SysprofDepthLayer *self = SYSPROF_DEPTH_LAYER (object); SysprofColumnLayer *self = SYSPROF_COLUMN_LAYER (object);
switch (prop_id) switch (prop_id)
{ {
case PROP_COLOR: case PROP_COLOR:
sysprof_depth_layer_set_color (self, g_value_get_boxed (value)); sysprof_column_layer_set_color (self, g_value_get_boxed (value));
break; break;
case PROP_HOVER_COLOR: case PROP_HOVER_COLOR:
sysprof_depth_layer_set_hover_color (self, g_value_get_boxed (value)); sysprof_column_layer_set_hover_color (self, g_value_get_boxed (value));
break; break;
case PROP_SERIES: case PROP_SERIES:
sysprof_depth_layer_set_series (self, g_value_get_boxed (value)); sysprof_column_layer_set_series (self, g_value_get_boxed (value));
break; break;
default: default:
@ -242,20 +242,20 @@ sysprof_depth_layer_set_property (GObject *object,
} }
static void static void
sysprof_depth_layer_class_init (SysprofDepthLayerClass *klass) sysprof_column_layer_class_init (SysprofColumnLayerClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
SysprofChartLayerClass *chart_layer_class = SYSPROF_CHART_LAYER_CLASS (klass); SysprofChartLayerClass *chart_layer_class = SYSPROF_CHART_LAYER_CLASS (klass);
object_class->dispose = sysprof_depth_layer_dispose; object_class->dispose = sysprof_column_layer_dispose;
object_class->get_property = sysprof_depth_layer_get_property; object_class->get_property = sysprof_column_layer_get_property;
object_class->set_property = sysprof_depth_layer_set_property; object_class->set_property = sysprof_column_layer_set_property;
widget_class->snapshot = sysprof_depth_layer_snapshot; widget_class->snapshot = sysprof_column_layer_snapshot;
chart_layer_class->lookup_item = sysprof_depth_layer_lookup_item; chart_layer_class->lookup_item = sysprof_column_layer_lookup_item;
chart_layer_class->snapshot_motion = sysprof_depth_layer_snapshot_motion; chart_layer_class->snapshot_motion = sysprof_column_layer_snapshot_motion;
properties[PROP_COLOR] = properties[PROP_COLOR] =
g_param_spec_boxed ("color", NULL, NULL, g_param_spec_boxed ("color", NULL, NULL,
@ -276,33 +276,33 @@ sysprof_depth_layer_class_init (SysprofDepthLayerClass *klass)
} }
static void static void
sysprof_depth_layer_init (SysprofDepthLayer *self) sysprof_column_layer_init (SysprofColumnLayer *self)
{ {
gdk_rgba_parse (&self->color, "#000"); gdk_rgba_parse (&self->color, "#000");
gdk_rgba_parse (&self->hover_color, "#F00"); gdk_rgba_parse (&self->hover_color, "#F00");
} }
SysprofChartLayer * SysprofChartLayer *
sysprof_depth_layer_new (void) sysprof_column_layer_new (void)
{ {
return g_object_new (SYSPROF_TYPE_DEPTH_LAYER, NULL); return g_object_new (SYSPROF_TYPE_COLUMN_LAYER, NULL);
} }
const GdkRGBA * const GdkRGBA *
sysprof_depth_layer_get_color (SysprofDepthLayer *self) sysprof_column_layer_get_color (SysprofColumnLayer *self)
{ {
g_return_val_if_fail (SYSPROF_IS_DEPTH_LAYER (self), NULL); g_return_val_if_fail (SYSPROF_IS_COLUMN_LAYER (self), NULL);
return &self->color; return &self->color;
} }
void void
sysprof_depth_layer_set_color (SysprofDepthLayer *self, sysprof_column_layer_set_color (SysprofColumnLayer *self,
const GdkRGBA *color) const GdkRGBA *color)
{ {
static const GdkRGBA black = {0,0,0,1}; static const GdkRGBA black = {0,0,0,1};
g_return_if_fail (SYSPROF_IS_DEPTH_LAYER (self)); g_return_if_fail (SYSPROF_IS_COLUMN_LAYER (self));
if (color == NULL) if (color == NULL)
color = &black; color = &black;
@ -315,20 +315,20 @@ sysprof_depth_layer_set_color (SysprofDepthLayer *self,
} }
const GdkRGBA * const GdkRGBA *
sysprof_depth_layer_get_hover_color (SysprofDepthLayer *self) sysprof_column_layer_get_hover_color (SysprofColumnLayer *self)
{ {
g_return_val_if_fail (SYSPROF_IS_DEPTH_LAYER (self), NULL); g_return_val_if_fail (SYSPROF_IS_COLUMN_LAYER (self), NULL);
return &self->hover_color; return &self->hover_color;
} }
void void
sysprof_depth_layer_set_hover_color (SysprofDepthLayer *self, sysprof_column_layer_set_hover_color (SysprofColumnLayer *self,
const GdkRGBA *hover_color) const GdkRGBA *hover_color)
{ {
static const GdkRGBA red = {1,0,0,1}; static const GdkRGBA red = {1,0,0,1};
g_return_if_fail (SYSPROF_IS_DEPTH_LAYER (self)); g_return_if_fail (SYSPROF_IS_COLUMN_LAYER (self));
if (hover_color == NULL) if (hover_color == NULL)
hover_color = &red; hover_color = &red;
@ -341,26 +341,26 @@ sysprof_depth_layer_set_hover_color (SysprofDepthLayer *self,
} }
/** /**
* sysprof_depth_layer_get_series: * sysprof_column_layer_get_series:
* @self: a #SysprofDepthLayer * @self: a #SysprofColumnLayer
* *
* Gets the data series to be drawn. * Gets the data series to be drawn.
* *
* Returns: (transfer none) (nullable): a #SysprofXYSeries or %NULL * Returns: (transfer none) (nullable): a #SysprofXYSeries or %NULL
*/ */
SysprofXYSeries * SysprofXYSeries *
sysprof_depth_layer_get_series (SysprofDepthLayer *self) sysprof_column_layer_get_series (SysprofColumnLayer *self)
{ {
g_return_val_if_fail (SYSPROF_IS_DEPTH_LAYER (self), NULL); g_return_val_if_fail (SYSPROF_IS_COLUMN_LAYER (self), NULL);
return self->series; return self->series;
} }
void void
sysprof_depth_layer_set_series (SysprofDepthLayer *self, sysprof_column_layer_set_series (SysprofColumnLayer *self,
SysprofXYSeries *series) SysprofXYSeries *series)
{ {
g_return_if_fail (SYSPROF_IS_DEPTH_LAYER (self)); g_return_if_fail (SYSPROF_IS_COLUMN_LAYER (self));
if (series == self->series) if (series == self->series)
return; return;
@ -374,3 +374,4 @@ sysprof_depth_layer_set_series (SysprofDepthLayer *self,
gtk_widget_queue_draw (GTK_WIDGET (self)); gtk_widget_queue_draw (GTK_WIDGET (self));
} }

View File

@ -1,4 +1,4 @@
/* sysprof-depth-layer.h /* sysprof-column-layer.h
* *
* Copyright 2023 Christian Hergert <chergert@redhat.com> * Copyright 2023 Christian Hergert <chergert@redhat.com>
* *
@ -28,27 +28,28 @@
G_BEGIN_DECLS G_BEGIN_DECLS
#define SYSPROF_TYPE_DEPTH_LAYER (sysprof_depth_layer_get_type()) #define SYSPROF_TYPE_COLUMN_LAYER (sysprof_column_layer_get_type())
SYSPROF_AVAILABLE_IN_ALL SYSPROF_AVAILABLE_IN_ALL
G_DECLARE_FINAL_TYPE (SysprofDepthLayer, sysprof_depth_layer, SYSPROF, DEPTH_LAYER, SysprofChartLayer) G_DECLARE_FINAL_TYPE (SysprofColumnLayer, sysprof_column_layer, SYSPROF, COLUMN_LAYER, SysprofChartLayer)
SYSPROF_AVAILABLE_IN_ALL SYSPROF_AVAILABLE_IN_ALL
SysprofChartLayer *sysprof_depth_layer_new (void); SysprofChartLayer *sysprof_column_layer_new (void);
SYSPROF_AVAILABLE_IN_ALL SYSPROF_AVAILABLE_IN_ALL
const GdkRGBA *sysprof_depth_layer_get_color (SysprofDepthLayer *self); const GdkRGBA *sysprof_column_layer_get_color (SysprofColumnLayer *self);
SYSPROF_AVAILABLE_IN_ALL SYSPROF_AVAILABLE_IN_ALL
void sysprof_depth_layer_set_color (SysprofDepthLayer *self, void sysprof_column_layer_set_color (SysprofColumnLayer *self,
const GdkRGBA *color); const GdkRGBA *color);
SYSPROF_AVAILABLE_IN_ALL SYSPROF_AVAILABLE_IN_ALL
const GdkRGBA *sysprof_depth_layer_get_hover_color (SysprofDepthLayer *self); const GdkRGBA *sysprof_column_layer_get_hover_color (SysprofColumnLayer *self);
SYSPROF_AVAILABLE_IN_ALL SYSPROF_AVAILABLE_IN_ALL
void sysprof_depth_layer_set_hover_color (SysprofDepthLayer *self, void sysprof_column_layer_set_hover_color (SysprofColumnLayer *self,
const GdkRGBA *hover_color); const GdkRGBA *hover_color);
SYSPROF_AVAILABLE_IN_ALL SYSPROF_AVAILABLE_IN_ALL
SysprofXYSeries *sysprof_depth_layer_get_series (SysprofDepthLayer *self); SysprofXYSeries *sysprof_column_layer_get_series (SysprofColumnLayer *self);
SYSPROF_AVAILABLE_IN_ALL SYSPROF_AVAILABLE_IN_ALL
void sysprof_depth_layer_set_series (SysprofDepthLayer *self, void sysprof_column_layer_set_series (SysprofColumnLayer *self,
SysprofXYSeries *series); SysprofXYSeries *series);
G_END_DECLS G_END_DECLS

View File

@ -26,7 +26,7 @@ G_BEGIN_DECLS
# include "sysprof-callgraph-view.h" # include "sysprof-callgraph-view.h"
# include "sysprof-chart.h" # include "sysprof-chart.h"
# include "sysprof-chart-layer.h" # include "sysprof-chart-layer.h"
# include "sysprof-depth-layer.h" # include "sysprof-column-layer.h"
# include "sysprof-mark-chart.h" # include "sysprof-mark-chart.h"
# include "sysprof-mark-table.h" # include "sysprof-mark-table.h"
# include "sysprof-session.h" # include "sysprof-session.h"

View File

@ -167,7 +167,7 @@ main (int argc,
"activate-layer-item", "activate-layer-item",
G_CALLBACK (activate_layer_item_cb), G_CALLBACK (activate_layer_item_cb),
document); document);
layer = g_object_new (SYSPROF_TYPE_DEPTH_LAYER, layer = g_object_new (SYSPROF_TYPE_COLUMN_LAYER,
"series", samples_series, "series", samples_series,
"title", "Stack Depth", "title", "Stack Depth",
NULL); NULL);