#include <glib/gi18n-lib.h>
#include "gdkmemoryformatprivate.h"
-#include "gdkmemorytextureprivate.h"
+#include "gdkmemorytexture.h"
#include "gdkprofilerprivate.h"
-#include "gdktexture.h"
+#include "gdktexturedownloaderprivate.h"
#include "gdktextureprivate.h"
#include "gsk/gl/fp16private.h"
#include <png.h>
png_info *info;
png_io io = { NULL, 0, 0 };
int width, height;
- gsize stride;
- const guchar *data;
int y;
- GdkMemoryTexture *memtex;
GdkMemoryFormat format;
+ GdkTextureDownloader downloader;
+ GBytes *bytes;
+ gsize stride;
+ const guchar *data;
int png_format;
int depth;
return NULL;
}
- memtex = gdk_memory_texture_from_texture (texture, format);
+ gdk_texture_downloader_init (&downloader, texture);
+ gdk_texture_downloader_set_format (&downloader, format);
+ bytes = gdk_texture_downloader_download_bytes (&downloader, &stride);
+ gdk_texture_downloader_finish (&downloader);
+ data = g_bytes_get_data (bytes, NULL);
if (sigsetjmp (png_jmpbuf (png), 1))
{
- g_object_unref (memtex);
+ g_bytes_unref (bytes);
g_free (io.data);
png_destroy_read_struct (&png, &info, NULL);
return NULL;
png_set_swap (png);
#endif
- data = gdk_memory_texture_get_data (memtex);
- stride = gdk_memory_texture_get_stride (memtex);
for (y = 0; y < height; y++)
png_write_row (png, data + y * stride);
png_destroy_write_struct (&png, &info);
- g_object_unref (memtex);
+ g_bytes_unref (bytes);
return g_bytes_new_take (io.data, io.size);
}