Skip to content

Commit

Permalink
Improve Linux texture examples. (flutter#40289)
Browse files Browse the repository at this point in the history
Use 'MyTexture' naming to match the Linux shell 'MyApplication'.

Show how to connect up the virtual methods.
  • Loading branch information
robert-ancell authored Mar 15, 2023
1 parent cbd0c10 commit d1934a9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 17 deletions.
25 changes: 15 additions & 10 deletions shell/platform/linux/public/flutter_linux/fl_pixel_buffer_texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,22 @@ G_DECLARE_DERIVABLE_TYPE(FlPixelBufferTexture,
*
* The following example shows how to implement an #FlPixelBufferTexture.
* ![<!-- language="C" -->
* // Type definition, constructor, init, destructor and class_init are
* // omitted.
* struct _VideoPixelBufferTexture { // extends FlPixelBufferTexture
* struct _MyTexture {
* FlPixelBufferTexture parent_instance;
*
* uint8_t *buffer; // your pixel buffer.
* }
*
* G_DEFINE_TYPE(VideoTexture,
* video_texture,
* G_DEFINE_TYPE(MyTexture,
* my_texture,
* fl_pixel_buffer_texture_get_type ())
*
* static gboolean
* video_texture_copy_pixels (FlPixelBufferTexture* texture,
* const uint8_t** out_buffer,
* uint32_t* width,
* uint32_t* height,
* GError** error) {
* my_texture_copy_pixels (FlPixelBufferTexture* texture,
* const uint8_t** out_buffer,
* uint32_t* width,
* uint32_t* height,
* GError** error) {
* // This method is called on Render Thread. Be careful with your
* // cross-thread operation.
*
Expand Down Expand Up @@ -72,6 +70,13 @@ G_DECLARE_DERIVABLE_TYPE(FlPixelBufferTexture,
* return FALSE;
* }
* }
*
* static void my_texture_class_init(MyTextureClass* klass) {
* FL_PIXEL_BUFFER_TEXTURE_CLASS(klass)->copy_pixels =
* my_texture_copy_pixels;
* }
*
* static void my_texture_init(MyTexture* self) {}
* ]|
*/

Expand Down
18 changes: 11 additions & 7 deletions shell/platform/linux/public/flutter_linux/fl_texture_gl.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,24 @@ G_DECLARE_DERIVABLE_TYPE(FlTextureGL, fl_texture_gl, FL, TEXTURE_GL, GObject)
* ![<!-- language="C" -->
* #include <epoxy/gl.h>
*
* // Type definition, constructor, init, destructor, and class_init are
* // omitted.
* struct _VideoTextureGL { // extends FlTextureGL
* struct _MyTextureGL {
* FlTextureGL parent_instance;
*
* GLuint texture_id;
* };
*
* G_DEFINE_TYPE(VideoTexture,
* video_texture,
* G_DEFINE_TYPE(MyTextureGL,
* my_texture_gl,
* fl_texture_gl_get_type ())
*
* static gboolean
* video_texture_populate (FlTextureGL *texture,
* my_texture_gl_populate (FlTextureGL *texture,
* uint32_t *target,
* uint32_t *name,
* uint32_t *width,
* uint32_t *height,
* GError **error) {
* VideoTextureGL *self = VIDEO_TEXTURE_GL (texture);
* MyTextureGL *self = MY_TEXTURE_GL (texture);
* if (self->texture_id == 0) {
* glGenTextures (1, &self->texture_id);
* glBindTexture (GL_TEXTURE_2D, self->texture_id);
Expand All @@ -71,6 +69,12 @@ G_DECLARE_DERIVABLE_TYPE(FlTextureGL, fl_texture_gl, FL, TEXTURE_GL, GObject)
*
* return TRUE;
* }
*
* static void my_texture_class_init(MyTextureClass* klass) {
* FL_TEXTURE_GL_CLASS(klass)->populate = my_texture_gl_populate;
* }
*
* static void my_texture_init(MyTexture* self) {}
* ]|
*/

Expand Down

0 comments on commit d1934a9

Please sign in to comment.