@@ -49,8 +49,7 @@ tile_dispose(GObject *object)
4949#endif /*DEBUG*/
5050
5151 VIPS_UNREF (tile -> texture );
52- VIPS_UNREF (tile -> pixbuf );
53- VIPS_FREE (tile -> data_copy );
52+ VIPS_FREEF (g_bytes_unref , tile -> bytes );
5453 VIPS_UNREF (tile -> region );
5554
5655 G_OBJECT_CLASS (tile_parent_class )-> dispose (object );
@@ -144,31 +143,28 @@ tile_get_texture(Tile *tile)
144143 * 1. We must make a copy of the pixel data from libvips, to stop
145144 * it being changed under our feet.
146145 *
147- * 2. Wrap a pixbuf around that copy.
146+ * 2. Wrap a GBytes around that copy.
148147 *
149148 * 3. Tag it as a texture that may need upload to the GPU.
150149 */
151150 if (!tile -> texture ) {
152- VIPS_FREE (tile -> data_copy );
153- tile -> data_copy = g_memdup2 (
154- VIPS_REGION_ADDR (tile -> region ,
155- tile -> region -> valid .left ,
156- tile -> region -> valid .top ),
157- VIPS_REGION_SIZEOF_LINE (tile -> region ) *
158- tile -> region -> valid .height );
159-
160- VIPS_UNREF (tile -> pixbuf );
161- tile -> pixbuf = gdk_pixbuf_new_from_data (
162- tile -> data_copy ,
163- GDK_COLORSPACE_RGB ,
164- tile -> region -> im -> Bands == 4 ,
165- 8 ,
166- tile -> region -> valid .width ,
167- tile -> region -> valid .height ,
168- VIPS_REGION_LSKIP (tile -> region ),
169- NULL , NULL );
170-
171- tile -> texture = gdk_texture_new_for_pixbuf (tile -> pixbuf );
151+ gpointer copy = g_memdup2 (
152+ VIPS_REGION_ADDR (tile -> region ,
153+ tile -> region -> valid .left ,
154+ tile -> region -> valid .top ),
155+ VIPS_REGION_SIZEOF_LINE (tile -> region ) * tile -> region -> valid .height );
156+
157+ VIPS_FREEF (g_bytes_unref , tile -> bytes );
158+ tile -> bytes = g_bytes_new_take (copy ,
159+ VIPS_REGION_SIZEOF_LINE (tile -> region ) * tile -> region -> valid .height );
160+
161+ tile -> texture = gdk_memory_texture_new (
162+ tile -> region -> valid .width ,
163+ tile -> region -> valid .height ,
164+ tile -> region -> im -> Bands == 4 ?
165+ GDK_MEMORY_R8G8B8A8 : GDK_MEMORY_R8G8B8 ,
166+ tile -> bytes ,
167+ VIPS_REGION_LSKIP (tile -> region ));
172168 }
173169
174170 return tile -> texture ;
@@ -183,5 +179,5 @@ tile_free_texture(Tile *tile)
183179 g_assert (tile -> valid );
184180
185181 VIPS_UNREF (tile -> texture );
186- VIPS_UNREF ( tile -> pixbuf );
182+ VIPS_FREEF ( g_bytes_unref , tile -> bytes );
187183}
0 commit comments