Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
fl_egl_image.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "fl_egl_image.h"
6
7#include <epoxy/egl.h>
8#include <epoxy/gl.h>
9
12
13 EGLImage image;
14};
15
16static EGLImage create_egl_image(GLuint texture_id) {
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}
34
35G_DEFINE_TYPE(FlEGLImage, fl_egl_image, G_TYPE_OBJECT)
36
37static void fl_egl_image_dispose(GObject* object) {
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}
52
53static void fl_egl_image_class_init(FlEGLImageClass* klass) {
54 G_OBJECT_CLASS(klass)->dispose = fl_egl_image_dispose;
55}
56
57static void fl_egl_image_init(FlEGLImage* self) {}
58
59FlEGLImage* fl_egl_image_new(GLuint texture) {
60 FlEGLImage* self =
61 FL_EGL_IMAGE(g_object_new(fl_egl_image_get_type(), nullptr));
62
64
65 return self;
66}
67
68EGLImage fl_egl_image_get_image(FlEGLImage* image) {
69 g_return_val_if_fail(FL_IS_EGL_IMAGE(image), EGL_NO_IMAGE_KHR);
70 return image->image;
71}
FlutterVulkanImage * image
G_DEFINE_TYPE(FlBasicMessageChannelResponseHandle, fl_basic_message_channel_response_handle, G_TYPE_OBJECT) static void fl_basic_message_channel_response_handle_dispose(GObject *object)
static EGLImage create_egl_image(GLuint texture_id)
FlEGLImage * fl_egl_image_new(GLuint texture)
static void fl_egl_image_init(FlEGLImage *self)
EGLImage fl_egl_image_get_image(FlEGLImage *image)
static void fl_egl_image_dispose(GObject *object)
static void fl_egl_image_class_init(FlEGLImageClass *klass)
FlTexture * texture
GObject parent_instance
EGLImage image
FlutterVulkanImageHandle image
Definition embedder.h:938
int64_t texture_id