Flutter Linux Embedder
fl_texture_gl.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 
7 
8 #include <epoxy/gl.h>
9 #include <gmodule.h>
10 #include <cstdio>
11 
12 typedef struct {
13  int64_t id;
15 
16 static void fl_texture_gl_texture_iface_init(FlTextureInterface* iface);
17 
18 G_DEFINE_TYPE_WITH_CODE(FlTextureGL,
19  fl_texture_gl,
20  G_TYPE_OBJECT,
21  G_IMPLEMENT_INTERFACE(fl_texture_get_type(),
23  G_ADD_PRIVATE(FlTextureGL))
24 
25 // Implements FlTexture::set_id
26 static void fl_texture_gl_set_id(FlTexture* texture, int64_t id) {
27  FlTextureGL* self = FL_TEXTURE_GL(texture);
29  fl_texture_gl_get_instance_private(self));
30  priv->id = id;
31 }
32 
33 // Implements FlTexture::set_id
34 static int64_t fl_texture_gl_get_id(FlTexture* texture) {
35  FlTextureGL* self = FL_TEXTURE_GL(texture);
36  FlTextureGLPrivate* priv = reinterpret_cast<FlTextureGLPrivate*>(
37  fl_texture_gl_get_instance_private(self));
38  return priv->id;
39 }
40 
41 static void fl_texture_gl_texture_iface_init(FlTextureInterface* iface) {
42  iface->set_id = fl_texture_gl_set_id;
43  iface->get_id = fl_texture_gl_get_id;
44 }
45 
46 static void fl_texture_gl_class_init(FlTextureGLClass* klass) {}
47 
48 static void fl_texture_gl_init(FlTextureGL* self) {}
49 
50 gboolean fl_texture_gl_populate(FlTextureGL* self,
51  uint32_t width,
52  uint32_t height,
53  FlutterOpenGLTexture* opengl_texture,
54  GError** error) {
55  uint32_t target = 0, name = 0;
56  if (!FL_TEXTURE_GL_GET_CLASS(self)->populate(self, &target, &name, &width,
57  &height, error)) {
58  return FALSE;
59  }
60 
61  opengl_texture->target = target;
62  opengl_texture->name = name;
63  opengl_texture->format = GL_RGBA8;
64  opengl_texture->destruction_callback = nullptr;
65  opengl_texture->user_data = nullptr;
66  opengl_texture->width = width;
67  opengl_texture->height = height;
68 
69  return TRUE;
70 }
id
int64_t id
Definition: fl_texture_gl.cc:26
fl_texture_gl_get_id
static int64_t fl_texture_gl_get_id(FlTexture *texture)
Definition: fl_texture_gl.cc:34
fl_texture_gl_private.h
FlTextureGLPrivate
Definition: fl_texture_gl.cc:12
FlTextureGLPrivate::id
int64_t id
Definition: fl_texture_gl.cc:13
G_DEFINE_TYPE_WITH_CODE
G_DEFINE_TYPE_WITH_CODE(FlTextureGL, fl_texture_gl, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE(fl_texture_get_type(), fl_texture_gl_texture_iface_init);G_ADD_PRIVATE(FlTextureGL)) static void fl_texture_gl_set_id(FlTexture *texture
fl_texture_gl.h
TRUE
return TRUE
Definition: fl_pixel_buffer_texture_test.cc:53
priv
FlTextureGLPrivate * priv
Definition: fl_texture_gl.cc:28
height
const uint8_t uint32_t uint32_t * height
Definition: fl_pixel_buffer_texture_test.cc:39
fl_texture_gl_populate
gboolean fl_texture_gl_populate(FlTextureGL *self, uint32_t width, uint32_t height, FlutterOpenGLTexture *opengl_texture, GError **error)
Definition: fl_texture_gl.cc:50
fl_texture_gl_texture_iface_init
static void fl_texture_gl_texture_iface_init(FlTextureInterface *iface)
Definition: fl_texture_gl.cc:41
error
const uint8_t uint32_t uint32_t GError ** error
Definition: fl_pixel_buffer_texture_test.cc:40
target
uint32_t * target
Definition: fl_texture_registrar_test.cc:40
width
const uint8_t uint32_t * width
Definition: fl_pixel_buffer_texture_test.cc:38
fl_texture_gl_class_init
static void fl_texture_gl_class_init(FlTextureGLClass *klass)
Definition: fl_texture_gl.cc:46
fl_texture_gl_init
static void fl_texture_gl_init(FlTextureGL *self)
Definition: fl_texture_gl.cc:48