Use gdk_memory_texture_new() instead.
<TITLE>Textures</TITLE>
<FILE>textures</FILE>
GdkTexture
-gdk_texture_new_for_data
gdk_texture_new_for_pixbuf
gdk_texture_new_from_resource
gdk_texture_new_from_file
{
}
-/**
- * gdk_texture_new_for_data:
- * @data: (array): the pixel data
- * @width: the number of pixels in each row
- * @height: the number of rows
- * @stride: the distance from the beginning of one row to the next, in bytes
- *
- * Creates a new texture object holding the given data.
- * The data is assumed to be in CAIRO_FORMAT_ARGB32 format.
- *
- * Returns: a new #GdkTexture
- */
-GdkTexture *
-gdk_texture_new_for_data (const guchar *data,
- int width,
- int height,
- int stride)
-{
- GdkTexture *texture;
- cairo_surface_t *original, *copy;
- cairo_t *cr;
-
- g_return_val_if_fail (width > 0, NULL);
- g_return_val_if_fail (height > 0, NULL);
-
- original = cairo_image_surface_create_for_data ((guchar *) data, CAIRO_FORMAT_ARGB32, width, height, stride);
- copy = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
-
- cr = cairo_create (copy);
- cairo_set_source_surface (cr, original, 0, 0);
- cairo_paint (cr);
- cairo_destroy (cr);
-
- texture = gdk_texture_new_for_surface (copy);
-
- cairo_surface_destroy (copy);
- cairo_surface_finish (original);
- cairo_surface_destroy (original);
-
- return texture;
-}
-
/**
* gdk_texture_new_for_surface:
* @surface: a cairo image surface
GDK_AVAILABLE_IN_ALL
GType gdk_texture_get_type (void) G_GNUC_CONST;
-GDK_AVAILABLE_IN_ALL
-GdkTexture * gdk_texture_new_for_data (const guchar *data,
- int width,
- int height,
- int stride);
GDK_AVAILABLE_IN_ALL
GdkTexture * gdk_texture_new_for_pixbuf (GdkPixbuf *pixbuf);
GDK_AVAILABLE_IN_ALL
#include "gskdebugprivate.h"
#include "gskrendererprivate.h"
#include "gskroundedrectprivate.h"
+
+#include "gdk/gdkmemorytextureprivate.h"
#include "gdk/gdktextureprivate.h"
static gboolean
guint32 width, height;
GVariant *pixel_variant;
gsize n_pixels;
+ GBytes *bytes;
if (!check_variant_type (variant, GSK_TEXTURE_NODE_VARIANT_TYPE, error))
return NULL;
&width, &height, &pixel_variant);
/* XXX: Make this work without copying the data */
- texture = gdk_texture_new_for_data (g_variant_get_fixed_array (pixel_variant, &n_pixels, sizeof (guint32)),
- width, height, width * 4);
- g_variant_unref (pixel_variant);
+ bytes = g_bytes_new_with_free_func (g_variant_get_fixed_array (pixel_variant, &n_pixels, sizeof (guint32)),
+ width * height * sizeof (guint32),
+ (GDestroyNotify) g_variant_unref,
+ pixel_variant);
+ if (n_pixels != width * height)
+ {
+ g_set_error (error, GSK_SERIALIZATION_ERROR, GSK_SERIALIZATION_INVALID_DATA,
+ "Expected %u pixels but got %"G_GSIZE_FORMAT" for %ux%u image",
+ width * height, n_pixels, width, height);
+ g_bytes_unref (bytes);
+ return NULL;
+ }
+
+ texture = gdk_memory_texture_new (width, height,
+ GDK_MEMORY_CAIRO_FORMAT_ARGB32,
+ bytes,
+ width * 4);
node = gsk_texture_node_new (texture, &GRAPHENE_RECT_INIT(bounds[0], bounds[1], bounds[2], bounds[3]));
#include "gskvulkanmemoryprivate.h"
#include "gskvulkanpipelineprivate.h"
+#include "gdk/gdkmemorytextureprivate.h"
+
#include <string.h>
struct _GskVulkanUploader
{
GskVulkanBuffer *buffer;
GdkTexture *texture;
+ GBytes *bytes;
guchar *mem;
gsk_vulkan_uploader_add_image_barrier (uploader,
GSK_VK_CHECK (vkQueueWaitIdle, gdk_vulkan_context_get_queue (self->vulkan));
mem = gsk_vulkan_buffer_map (buffer);
- texture = gdk_texture_new_for_data (mem, self->width, self->height, self->width * 4);
+ bytes = g_bytes_new (mem, self->width * self->height * 4);
+ texture = gdk_memory_texture_new (self->width, self->height,
+ GDK_MEMORY_CAIRO_FORMAT_ARGB32,
+ bytes,
+ self->width * 4);
gsk_vulkan_buffer_unmap (buffer);
gsk_vulkan_buffer_free (buffer);
#include "inspector/init.h"
#include "inspector/window.h"
+#include "gdk/gdktextureprivate.h"
#include "gdk/gdk-private.h"
#include <cairo-gobject.h>
cairo_destroy (cr);
cairo_surface_destroy (source);
- texture = gdk_texture_new_for_data (cairo_image_surface_get_data (target),
- cairo_image_surface_get_width (target),
- cairo_image_surface_get_height (target),
- cairo_image_surface_get_stride (target));
+ texture = gdk_texture_new_for_surface (target);
cairo_surface_destroy (target);
return texture;