| Flutter Linux Embedder |

Classes | Functions
fl_framebuffer.cc File Reference
`#include "fl_framebuffer.h"`
`#include <epoxy/gl.h>`

Go to the source code of this file.

## Classes
struct | _FlFramebuffer

## Functions
static void | fl_framebuffer_dispose (GObject *object)
static void | fl_framebuffer_class_init (FlFramebufferClass *klass)
static void | fl_framebuffer_init (FlFramebuffer *self)
FlFramebuffer * | fl_framebuffer_new (GLint format, size_t width, size_t height)
GLuint | fl_framebuffer_get_id (FlFramebuffer *self)
GLuint | fl_framebuffer_get_texture_id (FlFramebuffer *self)
GLenum | fl_framebuffer_get_target (FlFramebuffer *self)
size_t | fl_framebuffer_get_width (FlFramebuffer *self)
size_t | fl_framebuffer_get_height (FlFramebuffer *self)

## Function Documentation

## ◆ fl_framebuffer_class_init()

static void fl_framebuffer_class_init | ( | FlFramebufferClass * | klass | ) |
| static

Definition at line 40 of file fl_framebuffer.cc.

40 {
41 G_OBJECT_CLASS(klass)->dispose = fl_framebuffer_dispose;
42 }
fl_framebuffer_dispose
static void fl_framebuffer_dispose(GObject *object)
Definition: fl_framebuffer.cc:30

References fl_framebuffer_dispose().

## ◆ fl_framebuffer_dispose()

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

Definition at line 30 of file fl_framebuffer.cc.

30 {
31 FlFramebuffer* self = FL_FRAMEBUFFER(object);
32
33 glDeleteFramebuffers(1, &self->framebuffer_id);
34 glDeleteTextures(1, &self->texture_id);
35 glDeleteRenderbuffers(1, &self->depth_stencil);
36
37 G_OBJECT_CLASS(fl_framebuffer_parent_class)->dispose(object);
38 }

Referenced by fl_framebuffer_class_init().

## ◆ fl_framebuffer_get_height()

size_t fl_framebuffer_get_height | ( | FlFramebuffer * | framebuffer | ) |

fl_framebuffer_get_height: @framebuffer: an #FlFramebuffer.

Gets the height of the framebuffer in pixels.

Returns: height in pixels.

Definition at line 101 of file fl_framebuffer.cc.

101 {
102 return self->height;
103 }

Referenced by present_layers(), render_with_blit(), and render_with_textures().

## ◆ fl_framebuffer_get_id()

GLuint fl_framebuffer_get_id | ( | FlFramebuffer * | framebuffer | ) |

fl_framebuffer_get_id: @framebuffer: an #FlFramebuffer.

Gets the ID for this framebuffer.

Returns: OpenGL framebuffer id or 0 if creation failed.

Definition at line 85 of file fl_framebuffer.cc.

85 {
86 return self->framebuffer_id;
87 }

Referenced by create_opengl_backing_store(), present_layers(), and render_with_blit().

## ◆ fl_framebuffer_get_target()

GLenum fl_framebuffer_get_target | ( | FlFramebuffer * | framebuffer | ) |

fl_framebuffer_get_target: @framebuffer: an #FlFramebuffer.

Gets target texture (example GL_TEXTURE_2D or GL_TEXTURE_RECTANGLE).

Returns: target texture.

Definition at line 93 of file fl_framebuffer.cc.

93 {
94 return GL_TEXTURE_2D;
95 }

## ◆ fl_framebuffer_get_texture_id()

GLuint fl_framebuffer_get_texture_id | ( | FlFramebuffer * | framebuffer | ) |

fl_framebuffer_get_texture_id: @framebuffer: an #FlFramebuffer.

Gets the ID of the texture associated with this framebuffer.

Returns: OpenGL texture id or 0 if creation failed.

Definition at line 89 of file fl_framebuffer.cc.

89 {
90 return self->texture_id;
91 }

Referenced by present_layers(), and render_with_textures().

## ◆ fl_framebuffer_get_width()

size_t fl_framebuffer_get_width | ( | FlFramebuffer * | framebuffer | ) |

fl_framebuffer_get_width: @framebuffer: an #FlFramebuffer.

Gets the width of the framebuffer in pixels.

Returns: width in pixels.

Definition at line 97 of file fl_framebuffer.cc.

97 {
98 return self->width;
99 }

Referenced by present_layers(), render_with_blit(), and render_with_textures().

## ◆ fl_framebuffer_init()

static void fl_framebuffer_init | ( | FlFramebuffer * | self | ) |
| static

Definition at line 44 of file fl_framebuffer.cc.

44 {}

## ◆ fl_framebuffer_new()

FlFramebuffer* fl_framebuffer_new | ( | GLint | format,
|  | size_t | width,
|  | size_t | height
| ) |  |

FlFramebuffer:

#FlFramebuffer creates framebuffers and their backing textures for use by the Flutter compositor. fl_framebuffer_new: @format: format, e.g. GL_RGB, GL_BGR @width: width of texture. @height: height of texture.

Creates a new frame buffer. Requires a valid OpenGL context to create.

Returns: a new #FlFramebuffer.

Definition at line 46 of file fl_framebuffer.cc.

46 {
47 FlFramebuffer* provider =
48 FL_FRAMEBUFFER(g_object_new(fl_framebuffer_get_type(), nullptr));
49
50 provider->width = width;
51 provider->height = height;
52
53 glGenTextures(1, &provider->texture_id);
54 glGenFramebuffers(1, &provider->framebuffer_id);
55
56 glBindFramebuffer(GL_FRAMEBUFFER, provider->framebuffer_id);
57
58 glBindTexture(GL_TEXTURE_2D, provider->texture_id);
59 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
60 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
61 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
62 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
63 glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, format,
64 GL_UNSIGNED_BYTE, NULL);
65 glBindTexture(GL_TEXTURE_2D, 0);
66
67 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
68 provider->texture_id, 0);
69
70 glGenRenderbuffers(1, &provider->depth_stencil);
71 glBindRenderbuffer(GL_RENDERBUFFER, provider->depth_stencil);
72 glRenderbufferStorage(GL_RENDERBUFFER, // target
73 GL_DEPTH24_STENCIL8, // internal format
74 width, // width
75 height // height
76 );
77 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
78 GL_RENDERBUFFER, provider->depth_stencil);
79 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
80 GL_RENDERBUFFER, provider->depth_stencil);
81
82 return provider;
83 }
height
const uint8_t uint32_t uint32_t * height
Definition: fl_pixel_buffer_texture_test.cc:39
width
const uint8_t uint32_t * width
Definition: fl_pixel_buffer_texture_test.cc:38
format
uint32_t uint32_t * format
Definition: fl_texture_registrar_test.cc:42

References format, height, and width.

Referenced by create_opengl_backing_store(), present_layers(), and TEST().