@@ -50,8 +50,7 @@ tile_dispose(GObject *object)
5050#endif /*DEBUG*/
5151
5252 VIPS_UNREF (tile -> texture );
53- VIPS_UNREF (tile -> pixbuf );
54- VIPS_FREE (tile -> data_copy );
53+ VIPS_FREEF (g_bytes_unref , tile -> bytes );
5554 VIPS_UNREF (tile -> region );
5655
5756 G_OBJECT_CLASS (tile_parent_class )-> dispose (object );
@@ -145,31 +144,32 @@ tile_get_texture(Tile *tile)
145144 * 1. We must make a copy of the pixel data from libvips, to stop
146145 * it being changed under our feet.
147146 *
148- * 2. Wrap a pixbuf around that copy.
147+ * 2. Wrap a GBytes around that copy.
149148 *
150149 * 3. Tag it as a texture that may need upload to the GPU.
151150 */
152151 if (!tile -> texture ) {
153- VIPS_FREE (tile -> data_copy );
154- tile -> data_copy = g_memdup2 (
152+ gpointer copy = g_memdup2 (
155153 VIPS_REGION_ADDR (tile -> region ,
156154 tile -> region -> valid .left ,
157155 tile -> region -> valid .top ),
158156 VIPS_REGION_SIZEOF_LINE (tile -> region ) *
159157 tile -> region -> valid .height );
160158
161- VIPS_UNREF (tile -> pixbuf );
162- tile -> pixbuf = gdk_pixbuf_new_from_data (
163- tile -> data_copy ,
164- GDK_COLORSPACE_RGB ,
165- tile -> region -> im -> Bands == 4 ,
166- 8 ,
159+ VIPS_FREEF (g_bytes_unref , tile -> bytes );
160+ tile -> bytes = g_bytes_new_take (
161+ copy ,
162+ VIPS_REGION_SIZEOF_LINE (tile -> region ) *
163+ tile -> region -> valid .height );
164+
165+ tile -> texture = gdk_memory_texture_new (
167166 tile -> region -> valid .width ,
168167 tile -> region -> valid .height ,
169- VIPS_REGION_LSKIP (tile -> region ),
170- NULL , NULL );
171-
172- tile -> texture = gdk_texture_new_for_pixbuf (tile -> pixbuf );
168+ tile -> region -> im -> Bands == 4
169+ ? GDK_MEMORY_R8G8B8A8
170+ : GDK_MEMORY_R8G8B8 ,
171+ tile -> bytes ,
172+ VIPS_REGION_LSKIP (tile -> region ));
173173 }
174174
175175 return tile -> texture ;
@@ -184,5 +184,5 @@ tile_free_texture(Tile *tile)
184184 g_assert (tile -> valid );
185185
186186 VIPS_UNREF (tile -> texture );
187- VIPS_UNREF ( tile -> pixbuf );
187+ VIPS_FREEF ( g_bytes_unref , tile -> bytes );
188188}
0 commit comments