Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit d1934a9

Browse files
Improve Linux texture examples. (#40289)
Use 'MyTexture' naming to match the Linux shell 'MyApplication'. Show how to connect up the virtual methods.
1 parent cbd0c10 commit d1934a9

File tree

2 files changed

+26
-17
lines changed

2 files changed

+26
-17
lines changed

shell/platform/linux/public/flutter_linux/fl_pixel_buffer_texture.h

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,22 @@ G_DECLARE_DERIVABLE_TYPE(FlPixelBufferTexture,
2727
*
2828
* The following example shows how to implement an #FlPixelBufferTexture.
2929
* ![<!-- language="C" -->
30-
* // Type definition, constructor, init, destructor and class_init are
31-
* // omitted.
32-
* struct _VideoPixelBufferTexture { // extends FlPixelBufferTexture
30+
* struct _MyTexture {
3331
* FlPixelBufferTexture parent_instance;
3432
*
3533
* uint8_t *buffer; // your pixel buffer.
3634
* }
3735
*
38-
* G_DEFINE_TYPE(VideoTexture,
39-
* video_texture,
36+
* G_DEFINE_TYPE(MyTexture,
37+
* my_texture,
4038
* fl_pixel_buffer_texture_get_type ())
4139
*
4240
* static gboolean
43-
* video_texture_copy_pixels (FlPixelBufferTexture* texture,
44-
* const uint8_t** out_buffer,
45-
* uint32_t* width,
46-
* uint32_t* height,
47-
* GError** error) {
41+
* my_texture_copy_pixels (FlPixelBufferTexture* texture,
42+
* const uint8_t** out_buffer,
43+
* uint32_t* width,
44+
* uint32_t* height,
45+
* GError** error) {
4846
* // This method is called on Render Thread. Be careful with your
4947
* // cross-thread operation.
5048
*
@@ -72,6 +70,13 @@ G_DECLARE_DERIVABLE_TYPE(FlPixelBufferTexture,
7270
* return FALSE;
7371
* }
7472
* }
73+
*
74+
* static void my_texture_class_init(MyTextureClass* klass) {
75+
* FL_PIXEL_BUFFER_TEXTURE_CLASS(klass)->copy_pixels =
76+
* my_texture_copy_pixels;
77+
* }
78+
*
79+
* static void my_texture_init(MyTexture* self) {}
7580
* ]|
7681
*/
7782

shell/platform/linux/public/flutter_linux/fl_texture_gl.h

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,24 @@ G_DECLARE_DERIVABLE_TYPE(FlTextureGL, fl_texture_gl, FL, TEXTURE_GL, GObject)
3030
* ![<!-- language="C" -->
3131
* #include <epoxy/gl.h>
3232
*
33-
* // Type definition, constructor, init, destructor, and class_init are
34-
* // omitted.
35-
* struct _VideoTextureGL { // extends FlTextureGL
33+
* struct _MyTextureGL {
3634
* FlTextureGL parent_instance;
3735
*
3836
* GLuint texture_id;
3937
* };
4038
*
41-
* G_DEFINE_TYPE(VideoTexture,
42-
* video_texture,
39+
* G_DEFINE_TYPE(MyTextureGL,
40+
* my_texture_gl,
4341
* fl_texture_gl_get_type ())
4442
*
4543
* static gboolean
46-
* video_texture_populate (FlTextureGL *texture,
44+
* my_texture_gl_populate (FlTextureGL *texture,
4745
* uint32_t *target,
4846
* uint32_t *name,
4947
* uint32_t *width,
5048
* uint32_t *height,
5149
* GError **error) {
52-
* VideoTextureGL *self = VIDEO_TEXTURE_GL (texture);
50+
* MyTextureGL *self = MY_TEXTURE_GL (texture);
5351
* if (self->texture_id == 0) {
5452
* glGenTextures (1, &self->texture_id);
5553
* glBindTexture (GL_TEXTURE_2D, self->texture_id);
@@ -71,6 +69,12 @@ G_DECLARE_DERIVABLE_TYPE(FlTextureGL, fl_texture_gl, FL, TEXTURE_GL, GObject)
7169
*
7270
* return TRUE;
7371
* }
72+
*
73+
* static void my_texture_class_init(MyTextureClass* klass) {
74+
* FL_TEXTURE_GL_CLASS(klass)->populate = my_texture_gl_populate;
75+
* }
76+
*
77+
* static void my_texture_init(MyTexture* self) {}
7478
* ]|
7579
*/
7680

0 commit comments

Comments
 (0)