Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
fl_texture_gl.h
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#ifndef FLUTTER_SHELL_PLATFORM_LINUX_PUBLIC_FLUTTER_LINUX_FL_TEXTURE_GL_H_
6#define FLUTTER_SHELL_PLATFORM_LINUX_PUBLIC_FLUTTER_LINUX_FL_TEXTURE_GL_H_
7
8#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION)
9#error "Only <flutter_linux/flutter_linux.h> can be included directly."
10#endif
11
12#include <glib-object.h>
13#include <gmodule.h>
14#include <stdint.h>
15#include "fl_texture.h"
16
17G_BEGIN_DECLS
18
19G_MODULE_EXPORT
20G_DECLARE_DERIVABLE_TYPE(FlTextureGL, fl_texture_gl, FL, TEXTURE_GL, GObject)
21
22/**
23 * FlTextureGL:
24 *
25 * #FlTextureGL is an abstract class that represents an OpenGL texture.
26 *
27 * The following example shows how to implement an #FlTextureGL.
28 * ![<!-- language="C" -->
29 * #include <epoxy/gl.h>
30 *
31 * struct _MyTextureGL {
32 * FlTextureGL parent_instance;
33 *
34 * GLuint texture_id;
35 * };
36 *
37 * G_DEFINE_TYPE(MyTextureGL,
38 * my_texture_gl,
39 * fl_texture_gl_get_type ())
40 *
41 * static gboolean
42 * my_texture_gl_populate (FlTextureGL *texture,
43 * uint32_t *target,
44 * uint32_t *name,
45 * uint32_t *width,
46 * uint32_t *height,
47 * GError **error) {
48 * MyTextureGL *self = MY_TEXTURE_GL (texture);
49 * if (self->texture_id == 0) {
50 * glGenTextures (1, &self->texture_id);
51 * glBindTexture (GL_TEXTURE_2D, self->texture_id);
52 * // further configuration here.
53 * } else {
54 * glBindTexture (GL_TEXTURE_2D, self->texture_id);
55 * }
56 *
57 * // For example, we render pixel buffer here.
58 * // Note that Flutter only accepts textures in GL_RGBA8 format.
59 * static char buffer[] = { 0x1f, 0x2f, 0x3f, 0x4f }; // 1x1 pixel.
60 * glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 1, 1, 0, GL_RGBA,
61 * GL_UNSIGNED_BYTE, buffer);
62 *
63 * *target = GL_TEXTURE_2D;
64 * *name = self->texture_id;
65 * *width = 1;
66 * *height = 1;
67 *
68 * return TRUE;
69 * }
70 *
71 * static void my_texture_class_init(MyTextureClass* klass) {
72 * FL_TEXTURE_GL_CLASS(klass)->populate = my_texture_gl_populate;
73 * }
74 *
75 * static void my_texture_init(MyTexture* self) {}
76 * ]|
77 */
78
80 GObjectClass parent_class;
81
82 /**
83 * Virtual method called when Flutter populates this texture. The OpenGL
84 * context used by Flutter has been already set.
85 * @texture: an #FlTexture.
86 * @target: texture target (example GL_TEXTURE_2D or GL_TEXTURE_RECTANGLE).
87 * @name: (out): name of texture.
88 * @width: (inout): width of the texture in pixels.
89 * @height: (inout): height of the texture in pixels.
90 * @error: (allow-none): #GError location to store the error occurring, or
91 * %NULL to ignore. If `error` is not %NULL, `*error` must be initialized
92 * (typically %NULL, but an error from a previous call using GLib error
93 * handling is explicitly valid).
94 *
95 * Returns: %TRUE on success.
96 */
97 gboolean (*populate)(FlTextureGL* texture,
98 uint32_t* target,
99 uint32_t* name,
100 uint32_t* width,
101 uint32_t* height,
102 GError** error);
103};
104
105G_END_DECLS
106
107#endif // FLUTTER_SHELL_PLATFORM_LINUX_PUBLIC_FLUTTER_LINUX_FL_TEXTURE_GL_H_
G_BEGIN_DECLS G_DECLARE_DERIVABLE_TYPE(FlAccessibilityHandler, fl_accessibility_handler, FL, ACCESSIBILITY_HANDLER, GObject)
const uint8_t uint32_t uint32_t GError ** error
uint32_t * target
const char * name
Definition fuchsia.cc:50
FlTexture * texture
int32_t height
int32_t width
GObjectClass parent_class