Merge branch 'wip/otte/for-main' into 'main'
glrenderer: Don't return NULL form render_texture() See merge request GNOME/gtk!4522
This commit is contained in:
@@ -306,10 +306,9 @@ gsk_gl_renderer_render_texture (GskRenderer *renderer,
|
||||
GskGLRenderer *self = (GskGLRenderer *)renderer;
|
||||
GskGLRenderTarget *render_target;
|
||||
GskGLRenderJob *job;
|
||||
GdkTexture *texture = NULL;
|
||||
GdkTexture *texture;
|
||||
guint texture_id;
|
||||
int width;
|
||||
int height;
|
||||
int width, height, max_size;
|
||||
int format;
|
||||
|
||||
g_assert (GSK_IS_GL_RENDERER (renderer));
|
||||
@@ -317,6 +316,37 @@ gsk_gl_renderer_render_texture (GskRenderer *renderer,
|
||||
|
||||
width = ceilf (viewport->size.width);
|
||||
height = ceilf (viewport->size.height);
|
||||
max_size = self->command_queue->max_texture_size;
|
||||
if (width > max_size || height > max_size)
|
||||
{
|
||||
gsize x, y, size, stride;
|
||||
GBytes *bytes;
|
||||
guchar *data;
|
||||
|
||||
stride = width * 4;
|
||||
size = stride * height;
|
||||
data = g_malloc_n (stride, height);
|
||||
|
||||
for (y = 0; y < height; y += max_size)
|
||||
{
|
||||
for (x = 0; x < width; x += max_size)
|
||||
{
|
||||
texture = gsk_gl_renderer_render_texture (renderer, root,
|
||||
&GRAPHENE_RECT_INIT (x, y,
|
||||
MIN (max_size, viewport->size.width - x),
|
||||
MIN (max_size, viewport->size.height - y)));
|
||||
gdk_texture_download (texture,
|
||||
data + stride * y + x * 4,
|
||||
stride);
|
||||
g_object_unref (texture);
|
||||
}
|
||||
}
|
||||
|
||||
bytes = g_bytes_new_take (data, size);
|
||||
texture = gdk_memory_texture_new (width, height, GDK_MEMORY_DEFAULT, bytes, stride);
|
||||
g_bytes_unref (bytes);
|
||||
return texture;
|
||||
}
|
||||
|
||||
format = gsk_render_node_prefers_high_depth (root) ? GL_RGBA32F : GL_RGBA8;
|
||||
|
||||
@@ -342,6 +372,10 @@ gsk_gl_renderer_render_texture (GskRenderer *renderer,
|
||||
|
||||
gsk_gl_driver_after_frame (self->driver);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
return g_steal_pointer (&texture);
|
||||
}
|
||||
|
||||
@@ -107,8 +107,44 @@ gsk_cairo_renderer_render_texture (GskRenderer *renderer,
|
||||
GdkTexture *texture;
|
||||
cairo_surface_t *surface;
|
||||
cairo_t *cr;
|
||||
int width, height;
|
||||
/* limit from cairo's source code */
|
||||
#define MAX_IMAGE_SIZE 32767
|
||||
|
||||
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, ceil (viewport->size.width), ceil (viewport->size.height));
|
||||
width = ceil (viewport->size.width);
|
||||
height = ceil (viewport->size.height);
|
||||
if (width > MAX_IMAGE_SIZE || height > MAX_IMAGE_SIZE)
|
||||
{
|
||||
gsize x, y, size, stride;
|
||||
GBytes *bytes;
|
||||
guchar *data;
|
||||
|
||||
stride = width * 4;
|
||||
size = stride * height;
|
||||
data = g_malloc_n (stride, height);
|
||||
|
||||
for (y = 0; y < height; y += MAX_IMAGE_SIZE)
|
||||
{
|
||||
for (x = 0; x < width; x += MAX_IMAGE_SIZE)
|
||||
{
|
||||
texture = gsk_cairo_renderer_render_texture (renderer, root,
|
||||
&GRAPHENE_RECT_INIT (x, y,
|
||||
MIN (MAX_IMAGE_SIZE, viewport->size.width - x),
|
||||
MIN (MAX_IMAGE_SIZE, viewport->size.height - y)));
|
||||
gdk_texture_download (texture,
|
||||
data + stride * y + x * 4,
|
||||
stride);
|
||||
g_object_unref (texture);
|
||||
}
|
||||
}
|
||||
|
||||
bytes = g_bytes_new_take (data, size);
|
||||
texture = gdk_memory_texture_new (width, height, GDK_MEMORY_DEFAULT, bytes, stride);
|
||||
g_bytes_unref (bytes);
|
||||
return texture;
|
||||
}
|
||||
|
||||
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
|
||||
cr = cairo_create (surface);
|
||||
|
||||
cairo_translate (cr, - viewport->origin.x, - viewport->origin.y);
|
||||
|
||||
@@ -72,8 +72,8 @@ static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
|
||||
|
||||
static FlattenNode *
|
||||
gtk_flatten_list_model_get_nth (GtkRbTree *tree,
|
||||
guint position,
|
||||
guint *model_position)
|
||||
guint position,
|
||||
guint *model_position)
|
||||
{
|
||||
FlattenNode *node, *tmp;
|
||||
guint model_n_items;
|
||||
@@ -110,8 +110,8 @@ gtk_flatten_list_model_get_nth (GtkRbTree *tree,
|
||||
|
||||
static FlattenNode *
|
||||
gtk_flatten_list_model_get_nth_model (GtkRbTree *tree,
|
||||
guint position,
|
||||
guint *items_before)
|
||||
guint position,
|
||||
guint *items_before)
|
||||
{
|
||||
FlattenNode *node, *tmp;
|
||||
guint before;
|
||||
@@ -202,11 +202,11 @@ G_DEFINE_TYPE_WITH_CODE (GtkFlattenListModel, gtk_flatten_list_model, G_TYPE_OBJ
|
||||
G_IMPLEMENT_INTERFACE (G_TYPE_LIST_MODEL, gtk_flatten_list_model_model_init))
|
||||
|
||||
static void
|
||||
gtk_flatten_list_model_items_changed_cb (GListModel *model,
|
||||
guint position,
|
||||
guint removed,
|
||||
guint added,
|
||||
gpointer _node)
|
||||
gtk_flatten_list_model_items_changed_cb (GListModel *model,
|
||||
guint position,
|
||||
guint removed,
|
||||
guint added,
|
||||
gpointer _node)
|
||||
{
|
||||
FlattenNode *node = _node, *parent, *left;
|
||||
GtkFlattenListModel *self = node->list;
|
||||
@@ -323,10 +323,10 @@ gtk_flatten_list_model_set_property (GObject *object,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_flatten_list_model_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
gtk_flatten_list_model_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkFlattenListModel *self = GTK_FLATTEN_LIST_MODEL (object);
|
||||
|
||||
|
||||
@@ -1291,7 +1291,7 @@ gtk_grid_view_set_factory (GtkGridView *self,
|
||||
GtkListItemFactory *factory)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_GRID_VIEW (self));
|
||||
g_return_if_fail (factory == NULL || GTK_LIST_ITEM_FACTORY (factory));
|
||||
g_return_if_fail (factory == NULL || GTK_IS_LIST_ITEM_FACTORY (factory));
|
||||
|
||||
if (factory == gtk_list_item_manager_get_factory (self->item_manager))
|
||||
return;
|
||||
|
||||
@@ -825,7 +825,7 @@ gtk_list_item_manager_set_factory (GtkListItemManager *self,
|
||||
GSList *l;
|
||||
|
||||
g_return_if_fail (GTK_IS_LIST_ITEM_MANAGER (self));
|
||||
g_return_if_fail (GTK_IS_LIST_ITEM_FACTORY (factory));
|
||||
g_return_if_fail (factory == NULL || GTK_IS_LIST_ITEM_FACTORY (factory));
|
||||
|
||||
if (self->factory == factory)
|
||||
return;
|
||||
|
||||
@@ -1032,7 +1032,7 @@ gtk_list_view_set_factory (GtkListView *self,
|
||||
GtkListItemFactory *factory)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_LIST_VIEW (self));
|
||||
g_return_if_fail (factory == NULL || GTK_LIST_ITEM_FACTORY (factory));
|
||||
g_return_if_fail (factory == NULL || GTK_IS_LIST_ITEM_FACTORY (factory));
|
||||
|
||||
if (factory == gtk_list_item_manager_get_factory (self->item_manager))
|
||||
return;
|
||||
|
||||
7
testsuite/gsk/compare/huge-height.node
Normal file
7
testsuite/gsk/compare/huge-height.node
Normal file
@@ -0,0 +1,7 @@
|
||||
color {
|
||||
color: transparent;
|
||||
/* - more than 32k, to trip modern GPUs and Cairo
|
||||
* - non-integer to test rounding code
|
||||
*/
|
||||
bounds: 0 0 135.7 33333.3;
|
||||
}
|
||||
BIN
testsuite/gsk/compare/huge-height.png
Normal file
BIN
testsuite/gsk/compare/huge-height.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 689 B |
7
testsuite/gsk/compare/huge-width.node
Normal file
7
testsuite/gsk/compare/huge-width.node
Normal file
@@ -0,0 +1,7 @@
|
||||
color {
|
||||
color: transparent;
|
||||
/* - more than 32k, to trip modern GPUs and Cairo
|
||||
* - non-integer to test rounding code
|
||||
*/
|
||||
bounds: 0 0 33333.3 135.7;
|
||||
}
|
||||
BIN
testsuite/gsk/compare/huge-width.png
Normal file
BIN
testsuite/gsk/compare/huge-width.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 657 B |
@@ -58,6 +58,8 @@ compare_render_tests = [
|
||||
'empty-shadow',
|
||||
'empty-texture',
|
||||
'empty-transform',
|
||||
'huge-height',
|
||||
'huge-width',
|
||||
'inset-shadow-multiple',
|
||||
'invalid-transform',
|
||||
'issue-3615',
|
||||
|
||||
Reference in New Issue
Block a user