Flutter Linux Embedder
fl_compositor_opengl_shader.h File Reference
#include <glib-object.h>
#include "flutter/shell/platform/linux/fl_opengl_manager.h"

Go to the source code of this file.

Functions

G_BEGIN_DECLS G_DECLARE_FINAL_TYPE (FlCompositorOpenGLShader, fl_compositor_opengl_shader, FL, COMPOSITOR_OPENGL_SHADER, GObject) FlCompositorOpenGLShader *fl_compositor_opengl_shader_new(FlOpenGLManager *opengl_manager)
 
void fl_compositor_opengl_shader_use (FlCompositorOpenGLShader *shader)
 
void fl_compositor_opengl_shader_set_offset (FlCompositorOpenGLShader *shader, double x, double y)
 
void fl_compositor_opengl_shader_set_scale (FlCompositorOpenGLShader *shader, double x, double y)
 

Function Documentation

◆ fl_compositor_opengl_shader_set_offset()

void fl_compositor_opengl_shader_set_offset ( FlCompositorOpenGLShader *  shader,
double  x,
double  y 
)

fl_compositor_opengl_shader_set_offset: @shader: an #FlCompositorOpenGLShader. @x: horizontal offset. @y: vertical offset.

Sets the layer offset uniform. The program must be current (see fl_compositor_opengl_shader_use).

Definition at line 206 of file fl_compositor_opengl_shader.cc.

208  {
209  g_return_if_fail(FL_IS_COMPOSITOR_OPENGL_SHADER(self));
210  glUniform2f(self->offset_location, x, y);
211 }
FlFramebuffer double x
FlFramebuffer double double y

References x, and y.

◆ fl_compositor_opengl_shader_set_scale()

void fl_compositor_opengl_shader_set_scale ( FlCompositorOpenGLShader *  shader,
double  x,
double  y 
)

fl_compositor_opengl_shader_set_scale: @shader: an #FlCompositorOpenGLShader. @x: horizontal scale. @y: vertical scale.

Sets the layer scale uniform. The program must be current (see fl_compositor_opengl_shader_use).

Definition at line 213 of file fl_compositor_opengl_shader.cc.

215  {
216  g_return_if_fail(FL_IS_COMPOSITOR_OPENGL_SHADER(self));
217  glUniform2f(self->scale_location, x, y);
218 }

References x, and y.

◆ fl_compositor_opengl_shader_use()

void fl_compositor_opengl_shader_use ( FlCompositorOpenGLShader *  shader)

fl_compositor_opengl_shader_use: @shader: an #FlCompositorOpenGLShader.

Binds the shader's vertex buffer, configures the vertex attributes and makes the program current. Requires a valid OpenGL context.

Definition at line 189 of file fl_compositor_opengl_shader.cc.

189  {
190  g_return_if_fail(FL_IS_COMPOSITOR_OPENGL_SHADER(self));
191 
192  glBindBuffer(GL_ARRAY_BUFFER, self->vertex_buffer);
193  GLint position_location = glGetAttribLocation(self->program, "position");
194  glEnableVertexAttribArray(position_location);
195  glVertexAttribPointer(position_location, 2, GL_FLOAT, GL_FALSE,
196  sizeof(GLfloat) * 4, 0);
197  GLint texcoord_location = glGetAttribLocation(self->program, "in_texcoord");
198  glEnableVertexAttribArray(texcoord_location);
199  glVertexAttribPointer(texcoord_location, 2, GL_FLOAT, GL_FALSE,
200  sizeof(GLfloat) * 4,
201  reinterpret_cast<void*>(sizeof(GLfloat) * 2));
202 
203  glUseProgram(self->program);
204 }

Referenced by fl_compositor_opengl_present_layers().

◆ G_DECLARE_FINAL_TYPE()

G_BEGIN_DECLS G_DECLARE_FINAL_TYPE ( FlCompositorOpenGLShader  ,
fl_compositor_opengl_shader  ,
FL  ,
COMPOSITOR_OPENGL_SHADER  ,
GObject   
)

FlCompositorOpenGLShader:

#FlCompositorOpenGLShader is the shader program used by #FlCompositorOpenGL to composite Flutter layers onto the framebuffer. fl_compositor_opengl_shader_new: @opengl_manager: an #FlOpenGLManager.

Creates and compiles the compositor shader program. Requires a valid OpenGL context to create.

Returns: a new #FlCompositorOpenGLShader.