forked from AuroraMiddleware/gtk
Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master Closes #3615 See merge request GNOME/gtk!3132
This commit is contained in:
commit
8eb46bbfb2
@ -13,6 +13,7 @@
|
||||
<property name="right-margin">20</property>
|
||||
<property name="top-margin">20</property>
|
||||
<property name="bottom-margin">20</property>
|
||||
<property name="monospace">1</property>
|
||||
<property name="buffer">
|
||||
<object class="GtkTextBuffer" id="buffer"/>
|
||||
</property>
|
||||
|
@ -910,6 +910,26 @@ node_editor_window_init (NodeEditorWindow *self)
|
||||
self->text_buffer = gtk_text_buffer_new (self->tag_table);
|
||||
g_signal_connect (self->text_buffer, "changed", G_CALLBACK (text_changed), self);
|
||||
gtk_text_view_set_buffer (GTK_TEXT_VIEW (self->text_view), self->text_buffer);
|
||||
|
||||
/* Default */
|
||||
gtk_text_buffer_set_text (self->text_buffer,
|
||||
"shadow {\n"
|
||||
" child: texture {\n"
|
||||
" bounds: 0 0 128 128;\n"
|
||||
" texture: url(\"resource:///org/gtk/gtk4/node-editor/icons/apps/org.gtk.gtk4.NodeEditor.Devel.svg\");\n"
|
||||
" }\n"
|
||||
" shadows: rgba(0,0,0,0.5) 0 1 12;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"transform {\n"
|
||||
" child: text {\n"
|
||||
" color: rgb(46,52,54);\n"
|
||||
" font: \"Cantarell Bold 11\";\n"
|
||||
" glyphs: \"GTK Node Editor\";\n"
|
||||
" offset: 8 14.418;\n"
|
||||
" }\n"
|
||||
" transform: translate(0, 140);\n"
|
||||
"}", -1);
|
||||
}
|
||||
|
||||
NodeEditorWindow *
|
||||
|
@ -3833,7 +3833,7 @@ add_offscreen_ops (GskGLRenderer *self,
|
||||
{
|
||||
const float dx = builder->dx;
|
||||
const float dy = builder->dy;
|
||||
float width, height;
|
||||
float scaled_width, scaled_height;
|
||||
float scale_x;
|
||||
float scale_y;
|
||||
int render_target;
|
||||
@ -3889,8 +3889,6 @@ add_offscreen_ops (GskGLRenderer *self,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
width = bounds->size.width;
|
||||
height = bounds->size.height;
|
||||
scale_x = builder->scale_x;
|
||||
scale_y = builder->scale_y;
|
||||
|
||||
@ -3901,23 +3899,23 @@ add_offscreen_ops (GskGLRenderer *self,
|
||||
{
|
||||
const int max_texture_size = gsk_gl_driver_get_max_texture_size (self->gl_driver);
|
||||
|
||||
width = ceilf (width * scale_x);
|
||||
if (width > max_texture_size)
|
||||
scaled_width = ceilf (bounds->size.width * scale_x);
|
||||
if (scaled_width > max_texture_size)
|
||||
{
|
||||
scale_x *= (float)max_texture_size / width;
|
||||
width = max_texture_size;
|
||||
scale_x *= (float)max_texture_size / scaled_width;
|
||||
scaled_width = max_texture_size;
|
||||
}
|
||||
|
||||
height = ceilf (height * scale_y);
|
||||
if (height > max_texture_size)
|
||||
scaled_height = ceilf (bounds->size.height * scale_y);
|
||||
if (scaled_height > max_texture_size)
|
||||
{
|
||||
scale_y *= (float)max_texture_size / height;
|
||||
height = max_texture_size;
|
||||
scale_y *= (float)max_texture_size / scaled_height;
|
||||
scaled_height = max_texture_size;
|
||||
}
|
||||
}
|
||||
|
||||
gsk_gl_driver_create_render_target (self->gl_driver,
|
||||
width, height,
|
||||
scaled_width, scaled_height,
|
||||
filter, filter,
|
||||
&texture_id, &render_target);
|
||||
if (gdk_gl_context_has_debug (self->gl_context))
|
||||
@ -3932,9 +3930,11 @@ add_offscreen_ops (GskGLRenderer *self,
|
||||
render_target);
|
||||
}
|
||||
|
||||
viewport = GRAPHENE_RECT_INIT ((bounds->origin.x + dx) * scale_x,
|
||||
(bounds->origin.y + dy) * scale_y,
|
||||
width, height);
|
||||
ops_transform_bounds_modelview (builder, bounds, &viewport);
|
||||
/* Code above will scale the size with the scale we use in the render ops,
|
||||
* but for the viewport size, we need our own size limited by the texture size */
|
||||
viewport.size.width = scaled_width;
|
||||
viewport.size.height = scaled_height;
|
||||
|
||||
init_projection_matrix (&item_proj, &viewport);
|
||||
prev_render_target = ops_set_render_target (builder, render_target);
|
||||
@ -3962,7 +3962,7 @@ add_offscreen_ops (GskGLRenderer *self,
|
||||
g_type_name_from_instance ((GTypeInstance *) child_node),
|
||||
child_node,
|
||||
k ++),
|
||||
width, height);
|
||||
scaled_width, scaled_height);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -64,8 +64,10 @@ prepend_line_numbers (char *code,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
check_shader_error (int shader_id,
|
||||
GError **error)
|
||||
check_shader_error (int shader_id,
|
||||
int shader_type,
|
||||
const char *resource_path,
|
||||
GError **error)
|
||||
{
|
||||
int status;
|
||||
int log_len;
|
||||
@ -91,7 +93,9 @@ check_shader_error (int shader_id,
|
||||
prepend_line_numbers (code, s);
|
||||
|
||||
g_set_error (error, GDK_GL_ERROR, GDK_GL_ERROR_COMPILATION_FAILED,
|
||||
"Compilation failure in shader.\nSource Code: %s\n\nError Message:\n%s\n\n",
|
||||
"Compilation failure in %s shader %s.\nSource Code:\n%s\n\nError Message:\n%s\n\n",
|
||||
(shader_type == GL_FRAGMENT_SHADER ? "fragment" : "vertex"),
|
||||
resource_path,
|
||||
s->str,
|
||||
buffer);
|
||||
|
||||
@ -184,7 +188,7 @@ gsk_gl_shader_builder_create_program (GskGLShaderBuilder *self,
|
||||
});
|
||||
glCompileShader (vertex_id);
|
||||
|
||||
if (!check_shader_error (vertex_id, error))
|
||||
if (!check_shader_error (vertex_id, GL_VERTEX_SHADER, resource_path, error))
|
||||
{
|
||||
glDeleteShader (vertex_id);
|
||||
goto out;
|
||||
@ -218,7 +222,7 @@ gsk_gl_shader_builder_create_program (GskGLShaderBuilder *self,
|
||||
});
|
||||
glCompileShader (fragment_id);
|
||||
|
||||
if (!check_shader_error (fragment_id, error))
|
||||
if (!check_shader_error (fragment_id, GL_FRAGMENT_SHADER, resource_path, error))
|
||||
{
|
||||
glDeleteShader (fragment_id);
|
||||
goto out;
|
||||
|
@ -22,6 +22,7 @@ struct _GtkNodeView
|
||||
GtkWidget parent_instance;
|
||||
|
||||
GskRenderNode *node;
|
||||
GFileMonitor *file_monitor;
|
||||
};
|
||||
|
||||
struct _GtkNodeViewClass
|
||||
@ -34,6 +35,73 @@ GType gtk_node_view_get_type (void) G_GNUC_CONST;
|
||||
|
||||
G_DEFINE_TYPE(GtkNodeView, gtk_node_view, GTK_TYPE_WIDGET)
|
||||
|
||||
static void
|
||||
deserialize_error_func (const GskParseLocation *start,
|
||||
const GskParseLocation *end,
|
||||
const GError *error,
|
||||
gpointer user_data)
|
||||
{
|
||||
GString *string = g_string_new ("<data>");
|
||||
|
||||
g_string_append_printf (string, ":%zu:%zu",
|
||||
start->lines + 1, start->line_chars + 1);
|
||||
if (start->lines != end->lines || start->line_chars != end->line_chars)
|
||||
{
|
||||
g_string_append (string, "-");
|
||||
if (start->lines != end->lines)
|
||||
g_string_append_printf (string, "%zu:", end->lines + 1);
|
||||
g_string_append_printf (string, "%zu", end->line_chars + 1);
|
||||
}
|
||||
|
||||
g_warning ("Error at %s: %s", string->str, error->message);
|
||||
|
||||
g_string_free (string, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
load_file_contents (GtkNodeView *self,
|
||||
GFile *file)
|
||||
{
|
||||
GBytes *bytes;
|
||||
GError *error = NULL;
|
||||
|
||||
bytes = g_file_load_bytes (file, NULL, NULL, NULL);
|
||||
if (bytes == NULL)
|
||||
return;
|
||||
|
||||
if (!g_utf8_validate (g_bytes_get_data (bytes, NULL), g_bytes_get_size (bytes), NULL))
|
||||
{
|
||||
g_bytes_unref (bytes);
|
||||
return;
|
||||
}
|
||||
|
||||
self->node = gsk_render_node_deserialize (bytes, deserialize_error_func, &error);
|
||||
|
||||
if (error)
|
||||
{
|
||||
g_critical ("Invalid node file: %s", error->message);
|
||||
g_clear_error (&error);
|
||||
return;
|
||||
}
|
||||
|
||||
gtk_widget_queue_draw (GTK_WIDGET (self));
|
||||
|
||||
g_bytes_unref (bytes);
|
||||
}
|
||||
|
||||
static void
|
||||
file_changed_cb (GFileMonitor *monitor,
|
||||
GFile *file,
|
||||
GFile *other_file,
|
||||
GFileMonitorEvent event_type,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkNodeView *self = user_data;
|
||||
|
||||
if (event_type == G_FILE_MONITOR_EVENT_CHANGED)
|
||||
load_file_contents (self, file);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_node_view_measure (GtkWidget *widget,
|
||||
GtkOrientation orientation,
|
||||
@ -101,29 +169,6 @@ gtk_node_view_class_init (GtkNodeViewClass *klass)
|
||||
widget_class->snapshot = gtk_node_view_snapshot;
|
||||
}
|
||||
|
||||
static void
|
||||
deserialize_error_func (const GskParseLocation *start,
|
||||
const GskParseLocation *end,
|
||||
const GError *error,
|
||||
gpointer user_data)
|
||||
{
|
||||
GString *string = g_string_new ("<data>");
|
||||
|
||||
g_string_append_printf (string, ":%zu:%zu",
|
||||
start->lines + 1, start->line_chars + 1);
|
||||
if (start->lines != end->lines || start->line_chars != end->line_chars)
|
||||
{
|
||||
g_string_append (string, "-");
|
||||
if (start->lines != end->lines)
|
||||
g_string_append_printf (string, "%zu:", end->lines + 1);
|
||||
g_string_append_printf (string, "%zu", end->line_chars + 1);
|
||||
}
|
||||
|
||||
g_warning ("Error at %s: %s", string->str, error->message);
|
||||
|
||||
g_string_free (string, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
quit_cb (GtkWidget *widget,
|
||||
gpointer data)
|
||||
@ -140,13 +185,11 @@ main (int argc, char **argv)
|
||||
{
|
||||
GtkWidget *window;
|
||||
GtkWidget *nodeview;
|
||||
char *contents;
|
||||
gsize len;
|
||||
GBytes *bytes;
|
||||
graphene_rect_t node_bounds;
|
||||
GOptionContext *option_context;
|
||||
GError *error = NULL;
|
||||
gboolean done = FALSE;
|
||||
GFile *file;
|
||||
|
||||
option_context = g_option_context_new ("NODE-FILE [-o OUTPUT] [--compare]");
|
||||
g_option_context_add_main_entries (option_context, options, NULL);
|
||||
@ -175,23 +218,19 @@ main (int argc, char **argv)
|
||||
|
||||
gtk_window_set_decorated (GTK_WINDOW (window), FALSE);
|
||||
|
||||
g_file_get_contents (argv[1], &contents, &len, &error);
|
||||
file = g_file_new_for_path (argv[1]);
|
||||
load_file_contents (GTK_NODE_VIEW (nodeview), file);
|
||||
GTK_NODE_VIEW (nodeview)->file_monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, NULL, &error);
|
||||
g_object_unref (file);
|
||||
|
||||
if (error)
|
||||
{
|
||||
g_warning ("%s", error->message);
|
||||
return -1;
|
||||
}
|
||||
|
||||
bytes = g_bytes_new_take (contents, len);
|
||||
GTK_NODE_VIEW (nodeview)->node = gsk_render_node_deserialize (bytes, deserialize_error_func, &error);
|
||||
g_bytes_unref (bytes);
|
||||
|
||||
if (GTK_NODE_VIEW (nodeview)->node == NULL)
|
||||
{
|
||||
g_critical ("Invalid node file: %s", error->message);
|
||||
g_clear_error (&error);
|
||||
return -1;
|
||||
}
|
||||
g_signal_connect (GTK_NODE_VIEW (nodeview)->file_monitor,
|
||||
"changed", G_CALLBACK (file_changed_cb), nodeview);
|
||||
|
||||
if (write_to_filename != NULL)
|
||||
{
|
||||
|
27
testsuite/gsk/compare/issue-3615.node
Normal file
27
testsuite/gsk/compare/issue-3615.node
Normal file
@ -0,0 +1,27 @@
|
||||
transform {
|
||||
child: clip {
|
||||
child: transform {
|
||||
child: rounded-clip {
|
||||
child: color {
|
||||
bounds: 0 0 50 50;
|
||||
color: rgb(255,0,0);
|
||||
}
|
||||
clip: 0 0 30 30 / 15;
|
||||
}
|
||||
transform: scale(10);
|
||||
}
|
||||
clip: 250 0 587 166;
|
||||
}
|
||||
transform: translate(0, 100);
|
||||
}
|
||||
|
||||
color { color: black; bounds: 250 135 5 10; }
|
||||
color { color: black; bounds: 255 140 5 10; }
|
||||
color { color: black; bounds: 260 145 5 10; }
|
||||
color { color: black; bounds: 265 150 5 10; }
|
||||
color { color: black; bounds: 270 158 5 10; }
|
||||
color { color: black; bounds: 275 166 5 10; }
|
||||
color { color: black; bounds: 280 175 5 10; }
|
||||
color { color: black; bounds: 285 184 5 13; }
|
||||
color { color: black; bounds: 290 195 5 20; }
|
||||
color { color: black; bounds: 295 211 5 55; }
|
BIN
testsuite/gsk/compare/issue-3615.png
Normal file
BIN
testsuite/gsk/compare/issue-3615.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 385 B |
@ -75,6 +75,7 @@ compare_render_tests = [
|
||||
'clip-in-rounded-clip1',
|
||||
'clip-in-rounded-clip2',
|
||||
'clip-in-rounded-clip3',
|
||||
'issue-3615'
|
||||
]
|
||||
|
||||
# these are too sensitive to differences in the renderers
|
||||
|
Loading…
Reference in New Issue
Block a user