Flutter Engine
The Flutter Engine
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
5#include "flutter/shell/platform/linux/public/flutter_linux/fl_texture_gl.h"
6#include "flutter/shell/platform/linux/fl_texture_gl_private.h"
7
8#include <epoxy/gl.h>
9#include <gmodule.h>
10#include <cstdio>
11
12typedef struct {
13 int64_t id;
15
16static void fl_texture_gl_texture_iface_init(FlTextureInterface* iface);
17
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
26static 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
34static 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
41static 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
46static void fl_texture_gl_class_init(FlTextureGLClass* klass) {}
47
48static void fl_texture_gl_init(FlTextureGL* self) {}
49
50gboolean 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}
const uint8_t uint32_t uint32_t GError ** error
FlTextureGLPrivate * priv
int64_t id
gboolean fl_texture_gl_populate(FlTextureGL *self, uint32_t width, uint32_t height, FlutterOpenGLTexture *opengl_texture, GError **error)
static void fl_texture_gl_texture_iface_init(FlTextureInterface *iface)
static void fl_texture_gl_init(FlTextureGL *self)
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
static int64_t fl_texture_gl_get_id(FlTexture *texture)
static void fl_texture_gl_class_init(FlTextureGLClass *klass)
uint32_t * target
return FALSE
FlTexture * texture
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32
int32_t height
int32_t width
uint32_t name
The name of the texture.
Definition: embedder.h:371
VoidCallback destruction_callback
Definition: embedder.h:378
void * user_data
User data to be returned on the invocation of the destruction callback.
Definition: embedder.h:375
size_t height
Height of the texture.
Definition: embedder.h:386
uint32_t format
The texture format (example GL_RGBA8).
Definition: embedder.h:373