| Flutter Linux Embedder |

Classes | Functions | Variables
fl_pixel_buffer_texture.cc File Reference
`#include "flutter/shell/platform/linux/public/flutter_linux/fl_pixel_buffer_texture.h"`
`#include <epoxy/gl.h>`
`#include <gmodule.h>`
`#include "flutter/shell/platform/linux/fl_pixel_buffer_texture_private.h"`

Go to the source code of this file.

## Classes
struct | FlPixelBufferTexturePrivate

## Functions
static void | fl_pixel_buffer_texture_iface_init (FlTextureInterface *iface)
| G_DEFINE_TYPE_WITH_CODE (FlPixelBufferTexture, fl_pixel_buffer_texture, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE(fl_texture_get_type(), fl_pixel_buffer_texture_iface_init);G_ADD_PRIVATE(FlPixelBufferTexture)) static void fl_pixel_buffer_texture_set_id(FlTexture *texture
static int64_t | fl_pixel_buffer_texture_get_id (FlTexture *texture)
static void | fl_pixel_buffer_texture_dispose (GObject *object)
static void | check_gl_error (int line)
gboolean | fl_pixel_buffer_texture_populate (FlPixelBufferTexture *texture, uint32_t width, uint32_t height, FlutterOpenGLTexture *opengl_texture, GError **error)
static void | fl_pixel_buffer_texture_class_init (FlPixelBufferTextureClass *klass)
static void | fl_pixel_buffer_texture_init (FlPixelBufferTexture *self)

## Variables
int64_t | id
FlPixelBufferTexturePrivate * | priv

## Function Documentation

## ◆ check_gl_error()

static void check_gl_error | ( | int | line | ) |
| static

Definition at line 64 of file fl_pixel_buffer_texture.cc.

64 {
65 GLenum err = glGetError();
66 if (err) {
67 g_warning("glGetError %x (%s:%d)\n", err, __FILE__, line);
68 }
69 }

Referenced by fl_pixel_buffer_texture_populate().

## ◆ fl_pixel_buffer_texture_class_init()

static void fl_pixel_buffer_texture_class_init | ( | FlPixelBufferTextureClass * | klass | ) |
| static

Definition at line 119 of file fl_pixel_buffer_texture.cc.

120 {
121 G_OBJECT_CLASS(klass)->dispose = fl_pixel_buffer_texture_dispose;
122 }
fl_pixel_buffer_texture_dispose
static void fl_pixel_buffer_texture_dispose(GObject *object)
Definition: fl_pixel_buffer_texture.cc:50

References fl_pixel_buffer_texture_dispose().

## ◆ fl_pixel_buffer_texture_dispose()

static void fl_pixel_buffer_texture_dispose | ( | GObject * | object | ) |
| static

Definition at line 50 of file fl_pixel_buffer_texture.cc.

50 {
51 FlPixelBufferTexture* self = FL_PIXEL_BUFFER_TEXTURE(object);
52 FlPixelBufferTexturePrivate* priv =
53 reinterpret_cast<FlPixelBufferTexturePrivate*>(
54 fl_pixel_buffer_texture_get_instance_private(self));
55
56 if (priv->texture_id) {
57 glDeleteTextures(1, &priv->texture_id);
58 priv->texture_id = 0;
59 }
60
61 G_OBJECT_CLASS(fl_pixel_buffer_texture_parent_class)->dispose(object);
62 }
priv
FlPixelBufferTexturePrivate * priv
Definition: fl_pixel_buffer_texture.cc:30
FlPixelBufferTexturePrivate
Definition: fl_pixel_buffer_texture.cc:12
FlPixelBufferTexturePrivate::texture_id
GLuint texture_id
Definition: fl_pixel_buffer_texture.cc:14

References priv, and FlPixelBufferTexturePrivate::texture_id.

Referenced by fl_pixel_buffer_texture_class_init().

## ◆ fl_pixel_buffer_texture_get_id()

static int64_t fl_pixel_buffer_texture_get_id | ( | FlTexture * | texture | ) |
| static

Definition at line 37 of file fl_pixel_buffer_texture.cc.

37 {
38 FlPixelBufferTexture* self = FL_PIXEL_BUFFER_TEXTURE(texture);
39 FlPixelBufferTexturePrivate* priv =
40 reinterpret_cast<FlPixelBufferTexturePrivate*>(
41 fl_pixel_buffer_texture_get_instance_private(self));
42 return priv->id;
43 }
FlPixelBufferTexturePrivate::id
int64_t id
Definition: fl_pixel_buffer_texture.cc:13

References FlPixelBufferTexturePrivate::id, and priv.

Referenced by fl_pixel_buffer_texture_iface_init().

## ◆ fl_pixel_buffer_texture_iface_init()

static void fl_pixel_buffer_texture_iface_init | ( | FlTextureInterface * | iface | ) |
| static

Definition at line 45 of file fl_pixel_buffer_texture.cc.

45 {
46 iface->set_id = fl_pixel_buffer_texture_set_id;
47 iface->get_id = fl_pixel_buffer_texture_get_id;
48 }
fl_pixel_buffer_texture_get_id
static int64_t fl_pixel_buffer_texture_get_id(FlTexture *texture)
Definition: fl_pixel_buffer_texture.cc:37

References fl_pixel_buffer_texture_get_id().

## ◆ fl_pixel_buffer_texture_init()

static void fl_pixel_buffer_texture_init | ( | FlPixelBufferTexture * | self | ) |
| static

Definition at line 124 of file fl_pixel_buffer_texture.cc.

124 {}

## ◆ fl_pixel_buffer_texture_populate()

gboolean fl_pixel_buffer_texture_populate | ( | FlPixelBufferTexture * | texture,
|  | uint32_t | width,
|  | uint32_t | height,
|  | FlutterOpenGLTexture * | opengl_texture,
|  | GError ** | error
| ) |  |

fl_pixel_buffer_texture_populate: @texture: an #FlPixelBufferTexture. @width: width of the texture. @height: height of the texture. @opengl_texture: (out): return an #FlutterOpenGLTexture. @error: (allow-none): #GError location to store the error occurring, or NULL to ignore. If `error` is not NULL, `*error` must be initialized (typically NULL, but an error from a previous call using GLib error handling is explicitly valid).

Attempts to populate the specified @opengl_texture with texture details such as the name, width, height and the pixel format.

Returns: TRUE on success.

Definition at line 71 of file fl_pixel_buffer_texture.cc.

75 {
76 FlPixelBufferTexture* self = FL_PIXEL_BUFFER_TEXTURE(texture);
77 FlPixelBufferTexturePrivate* priv =
78 reinterpret_cast<FlPixelBufferTexturePrivate*>(
79 fl_pixel_buffer_texture_get_instance_private(self));
80
81 const uint8_t* buffer = nullptr;
82 if (!FL_PIXEL_BUFFER_TEXTURE_GET_CLASS(self)->copy_pixels(
83 self, &buffer, &width, &height, error)) {
84 return FALSE;
85 }
86
87 if (priv->texture_id == 0) {
88 glGenTextures(1, &priv->texture_id);
89 check_gl_error(__LINE__);
90 glBindTexture(GL_TEXTURE_2D, priv->texture_id);
91 check_gl_error(__LINE__);
92 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
93 check_gl_error(__LINE__);
94 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
95 check_gl_error(__LINE__);
96 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
97 check_gl_error(__LINE__);
98 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
99 check_gl_error(__LINE__);
100 } else {
101 glBindTexture(GL_TEXTURE_2D, priv->texture_id);
102 check_gl_error(__LINE__);
103 }
104 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA,
105 GL_UNSIGNED_BYTE, buffer);
106 check_gl_error(__LINE__);
107
108 opengl_texture->target = GL_TEXTURE_2D;
109 opengl_texture->name = priv->texture_id;
110 opengl_texture->format = GL_RGBA8;
111 opengl_texture->destruction_callback = nullptr;
112 opengl_texture->user_data = nullptr;
113 opengl_texture->width = width;
114 opengl_texture->height = height;
115
116 return TRUE;
117 }
height
self height
Definition: fl_compositor_software.cc:43
width
self width
Definition: fl_compositor_software.cc:42
TRUE
return TRUE
Definition: fl_compositor_software.cc:68
check_gl_error
static void check_gl_error(int line)
Definition: fl_pixel_buffer_texture.cc:64
buffer
static const uint8_t buffer[]
Definition: fl_pixel_buffer_texture_test.cc:44
error
const uint8_t uint32_t uint32_t GError ** error
Definition: fl_pixel_buffer_texture_test.cc:40

References buffer, check_gl_error(), error, height, priv, FlPixelBufferTexturePrivate::texture_id, TRUE, and width.

Referenced by fl_engine_gl_external_texture_frame_callback(), and TEST().

## ◆ G_DEFINE_TYPE_WITH_CODE()

G_DEFINE_TYPE_WITH_CODE | ( | FlPixelBufferTexture | ,
|  | fl_pixel_buffer_texture | ,
|  | G_TYPE_OBJECT | ,
|  | G_IMPLEMENT_INTERFACE(fl_texture_get_type(), fl_pixel_buffer_texture_iface_init);G_ADD_PRIVATE(FlPixelBufferTexture) |
| ) |  |

## Variable Documentation

## ◆ id

priv id

Initial value:
{
FlPixelBufferTexture* self = FL_PIXEL_BUFFER_TEXTURE(texture)

Definition at line 28 of file fl_pixel_buffer_texture.cc.

Referenced by flutter::AccessibilityBridge::CreateFlutterPlatformNodeDelegate(), flutter::testing::CreateSemanticsNode(), fl_engine_for_id(), G_DECLARE_INTERFACE(), get_generated_id(), and TEST().

## ◆ priv

FlPixelBufferTexturePrivate* priv

Initial value:
=
reinterpret_cast<FlPixelBufferTexturePrivate*>(
fl_pixel_buffer_texture_get_instance_private(self))

Definition at line 30 of file fl_pixel_buffer_texture.cc.

Referenced by create_regular(), destroy_window(), fl_accessible_node_dispose(), fl_accessible_node_do_action(), fl_accessible_node_get_extents(), fl_accessible_node_get_index_in_parent(), fl_accessible_node_get_n_actions(), fl_accessible_node_get_n_children(), fl_accessible_node_get_name(), fl_accessible_node_get_parent(), fl_accessible_node_get_role(), fl_accessible_node_init(), fl_accessible_node_perform_action_impl(), fl_accessible_node_ref_child(), fl_accessible_node_ref_state_set(), fl_accessible_node_set_actions_impl(), fl_accessible_node_set_children(), fl_accessible_node_set_extents_impl(), fl_accessible_node_set_flags_impl(), fl_accessible_node_set_name_impl(), fl_accessible_node_set_parent(), fl_accessible_node_set_property(), fl_application_activate(), fl_application_dispose(), fl_application_local_command_line(), fl_pixel_buffer_texture_dispose(), fl_pixel_buffer_texture_get_id(), fl_pixel_buffer_texture_populate(), fl_windowing_handler_dispose(), fl_windowing_handler_init(), fl_windowing_handler_new(), get_action(), and get_window_data().