Flutter Linux Embedder
fl_egl_image.cc File Reference
#include "fl_egl_image.h"
#include <epoxy/egl.h>
#include <epoxy/gl.h>

Go to the source code of this file.

Classes

struct  _FlEGLImage
 

Functions

static EGLImage create_egl_image (GLuint texture_id)
 
static void fl_egl_image_dispose (GObject *object)
 
static void fl_egl_image_class_init (FlEGLImageClass *klass)
 
static void fl_egl_image_init (FlEGLImage *self)
 
FlEGLImage * fl_egl_image_new (GLuint texture)
 
EGLImage fl_egl_image_get_image (FlEGLImage *image)
 

Function Documentation

◆ create_egl_image()

static EGLImage create_egl_image ( GLuint  texture_id)
static

Definition at line 16 of file fl_egl_image.cc.

16  {
17  EGLDisplay egl_display = eglGetCurrentDisplay();
18  if (egl_display == EGL_NO_DISPLAY) {
19  g_warning("Failed to create EGL image: Failed to get current EGL display");
20  return EGL_NO_IMAGE_KHR;
21  }
22 
23  EGLContext egl_context = eglGetCurrentContext();
24  if (egl_context == EGL_NO_CONTEXT) {
25  g_warning("Failed to create EGL image: Failed to get current EGL context");
26  return EGL_NO_IMAGE_KHR;
27  }
28 
29  return eglCreateImageKHR(
30  egl_display, egl_context, EGL_GL_TEXTURE_2D,
31  reinterpret_cast<EGLClientBuffer>(static_cast<intptr_t>(texture_id)),
32  nullptr);
33 }
int64_t texture_id

References texture_id.

Referenced by fl_egl_image_new().

◆ fl_egl_image_class_init()

static void fl_egl_image_class_init ( FlEGLImageClass *  klass)
static

Definition at line 53 of file fl_egl_image.cc.

53  {
54  G_OBJECT_CLASS(klass)->dispose = fl_egl_image_dispose;
55 }
static void fl_egl_image_dispose(GObject *object)
Definition: fl_egl_image.cc:37

References fl_egl_image_dispose().

◆ fl_egl_image_dispose()

static void fl_egl_image_dispose ( GObject *  object)
static

Definition at line 37 of file fl_egl_image.cc.

37  {
38  FlEGLImage* self = FL_EGL_IMAGE(object);
39 
40  if (self->image != EGL_NO_IMAGE_KHR) {
41  EGLDisplay egl_display = eglGetCurrentDisplay();
42  if (egl_display == EGL_NO_DISPLAY) {
43  g_warning(
44  "Failed to destroy EGL image: Failed to get current EGL display");
45  } else {
46  eglDestroyImageKHR(egl_display, self->image);
47  }
48  }
49 
50  G_OBJECT_CLASS(fl_egl_image_parent_class)->dispose(object);
51 }

Referenced by fl_egl_image_class_init().

◆ fl_egl_image_get_image()

EGLImage fl_egl_image_get_image ( FlEGLImage *  image)

fl_egl_image_get_image: an #FlEGLImage.

Gets the EGL image managed by this object.

Returns: the EGL image.

Definition at line 68 of file fl_egl_image.cc.

68  {
69  g_return_val_if_fail(FL_IS_EGL_IMAGE(image), EGL_NO_IMAGE_KHR);
70  return image->image;
71 }

Referenced by fl_framebuffer_create_sibling(), and TEST().

◆ fl_egl_image_init()

static void fl_egl_image_init ( FlEGLImage *  self)
static

Definition at line 57 of file fl_egl_image.cc.

57 {}

◆ fl_egl_image_new()

FlEGLImage* fl_egl_image_new ( GLuint  texture)

fl_egl_image_new: @texture: the texture to create an EGL image for.

Creates an object that manages an EGL image.

Returns: a new #FlEGLImage.

Definition at line 59 of file fl_egl_image.cc.

59  {
60  FlEGLImage* self =
61  FL_EGL_IMAGE(g_object_new(fl_egl_image_get_type(), nullptr));
62 
63  self->image = create_egl_image(texture);
64 
65  return self;
66 }
static EGLImage create_egl_image(GLuint texture_id)
Definition: fl_egl_image.cc:16

References create_egl_image().

Referenced by fl_framebuffer_new(), and TEST().