Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 123d9e9

Browse files
committed
Rename FlBackingStoreProvider to FlFramebuffer
The name was confusing, as it only provided one type of backing store. FlBackingStoreProvider sounds more like an interface that the FlFramebuffer would implement if we had multiple backing stores. Use OpenGL types for values. Fix cases where this was sometimes called a texture. Improve documentation. Remove the use of GdkRectangle for dimensions - the framebuffer only has a width and a height. There was code that was using the x,y values which would always have been zero - this has now been removed.
1 parent c8b9571 commit 123d9e9

File tree

8 files changed

+174
-181
lines changed

8 files changed

+174
-181
lines changed

ci/licenses_golden/licenses_flutter

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44061,8 +44061,6 @@ ORIGIN: ../../../flutter/shell/platform/linux/fl_accessible_node_test.cc + ../..
4406144061
ORIGIN: ../../../flutter/shell/platform/linux/fl_accessible_text_field.cc + ../../../flutter/LICENSE
4406244062
ORIGIN: ../../../flutter/shell/platform/linux/fl_accessible_text_field.h + ../../../flutter/LICENSE
4406344063
ORIGIN: ../../../flutter/shell/platform/linux/fl_accessible_text_field_test.cc + ../../../flutter/LICENSE
44064-
ORIGIN: ../../../flutter/shell/platform/linux/fl_backing_store_provider.cc + ../../../flutter/LICENSE
44065-
ORIGIN: ../../../flutter/shell/platform/linux/fl_backing_store_provider.h + ../../../flutter/LICENSE
4406644064
ORIGIN: ../../../flutter/shell/platform/linux/fl_basic_message_channel.cc + ../../../flutter/LICENSE
4406744065
ORIGIN: ../../../flutter/shell/platform/linux/fl_basic_message_channel_test.cc + ../../../flutter/LICENSE
4406844066
ORIGIN: ../../../flutter/shell/platform/linux/fl_binary_codec.cc + ../../../flutter/LICENSE
@@ -44078,6 +44076,8 @@ ORIGIN: ../../../flutter/shell/platform/linux/fl_engine_private.h + ../../../flu
4407844076
ORIGIN: ../../../flutter/shell/platform/linux/fl_engine_test.cc + ../../../flutter/LICENSE
4407944077
ORIGIN: ../../../flutter/shell/platform/linux/fl_event_channel.cc + ../../../flutter/LICENSE
4408044078
ORIGIN: ../../../flutter/shell/platform/linux/fl_event_channel_test.cc + ../../../flutter/LICENSE
44079+
ORIGIN: ../../../flutter/shell/platform/linux/fl_framebuffer.cc + ../../../flutter/LICENSE
44080+
ORIGIN: ../../../flutter/shell/platform/linux/fl_framebuffer.h + ../../../flutter/LICENSE
4408144081
ORIGIN: ../../../flutter/shell/platform/linux/fl_gnome_settings.cc + ../../../flutter/LICENSE
4408244082
ORIGIN: ../../../flutter/shell/platform/linux/fl_gnome_settings.h + ../../../flutter/LICENSE
4408344083
ORIGIN: ../../../flutter/shell/platform/linux/fl_gnome_settings_test.cc + ../../../flutter/LICENSE
@@ -46968,8 +46968,6 @@ FILE: ../../../flutter/shell/platform/linux/fl_accessible_node_test.cc
4696846968
FILE: ../../../flutter/shell/platform/linux/fl_accessible_text_field.cc
4696946969
FILE: ../../../flutter/shell/platform/linux/fl_accessible_text_field.h
4697046970
FILE: ../../../flutter/shell/platform/linux/fl_accessible_text_field_test.cc
46971-
FILE: ../../../flutter/shell/platform/linux/fl_backing_store_provider.cc
46972-
FILE: ../../../flutter/shell/platform/linux/fl_backing_store_provider.h
4697346971
FILE: ../../../flutter/shell/platform/linux/fl_basic_message_channel.cc
4697446972
FILE: ../../../flutter/shell/platform/linux/fl_basic_message_channel_test.cc
4697546973
FILE: ../../../flutter/shell/platform/linux/fl_binary_codec.cc
@@ -46985,6 +46983,8 @@ FILE: ../../../flutter/shell/platform/linux/fl_engine_private.h
4698546983
FILE: ../../../flutter/shell/platform/linux/fl_engine_test.cc
4698646984
FILE: ../../../flutter/shell/platform/linux/fl_event_channel.cc
4698746985
FILE: ../../../flutter/shell/platform/linux/fl_event_channel_test.cc
46986+
FILE: ../../../flutter/shell/platform/linux/fl_framebuffer.cc
46987+
FILE: ../../../flutter/shell/platform/linux/fl_framebuffer.h
4698846988
FILE: ../../../flutter/shell/platform/linux/fl_gnome_settings.cc
4698946989
FILE: ../../../flutter/shell/platform/linux/fl_gnome_settings.h
4699046990
FILE: ../../../flutter/shell/platform/linux/fl_gnome_settings_test.cc

shell/platform/linux/BUILD.gn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,13 @@ source_set("flutter_linux_sources") {
9999
sources = [
100100
"fl_accessible_node.cc",
101101
"fl_accessible_text_field.cc",
102-
"fl_backing_store_provider.cc",
103102
"fl_basic_message_channel.cc",
104103
"fl_binary_codec.cc",
105104
"fl_binary_messenger.cc",
106105
"fl_dart_project.cc",
107106
"fl_engine.cc",
108107
"fl_event_channel.cc",
108+
"fl_framebuffer.cc",
109109
"fl_gnome_settings.cc",
110110
"fl_json_message_codec.cc",
111111
"fl_json_method_codec.cc",

shell/platform/linux/fl_backing_store_provider.h

Lines changed: 0 additions & 96 deletions
This file was deleted.

shell/platform/linux/fl_backing_store_provider.cc renamed to shell/platform/linux/fl_framebuffer.cc

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,49 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
#include "fl_backing_store_provider.h"
5+
#include "fl_framebuffer.h"
66

77
#include <epoxy/gl.h>
88

9-
struct _FlBackingStoreProvider {
9+
struct _FlFramebuffer {
1010
GObject parent_instance;
1111

12-
uint32_t framebuffer_id;
13-
uint32_t texture_id;
14-
GdkRectangle geometry;
12+
// Width of framebuffer in pixels.
13+
size_t width;
14+
15+
// Height of framebuffer in pixels.
16+
size_t height;
17+
18+
// Framebuffer ID.
19+
GLuint framebuffer_id;
20+
21+
// Texture backing framebuffer.
22+
GLuint texture_id;
1523
};
1624

17-
G_DEFINE_TYPE(FlBackingStoreProvider, fl_backing_store_provider, G_TYPE_OBJECT)
25+
G_DEFINE_TYPE(FlFramebuffer, fl_framebuffer, G_TYPE_OBJECT)
1826

19-
static void fl_backing_store_provider_dispose(GObject* object) {
20-
FlBackingStoreProvider* self = FL_BACKING_STORE_PROVIDER(object);
27+
static void fl_framebuffer_dispose(GObject* object) {
28+
FlFramebuffer* self = FL_FRAMEBUFFER(object);
2129

2230
glDeleteFramebuffers(1, &self->framebuffer_id);
2331
glDeleteTextures(1, &self->texture_id);
2432

25-
G_OBJECT_CLASS(fl_backing_store_provider_parent_class)->dispose(object);
33+
G_OBJECT_CLASS(fl_framebuffer_parent_class)->dispose(object);
2634
}
2735

28-
static void fl_backing_store_provider_class_init(
29-
FlBackingStoreProviderClass* klass) {
30-
G_OBJECT_CLASS(klass)->dispose = fl_backing_store_provider_dispose;
36+
static void fl_framebuffer_class_init(FlFramebufferClass* klass) {
37+
G_OBJECT_CLASS(klass)->dispose = fl_framebuffer_dispose;
3138
}
3239

33-
static void fl_backing_store_provider_init(FlBackingStoreProvider* self) {}
40+
static void fl_framebuffer_init(FlFramebuffer* self) {}
3441

35-
FlBackingStoreProvider* fl_backing_store_provider_new(int width, int height) {
36-
FlBackingStoreProvider* provider = FL_BACKING_STORE_PROVIDER(
37-
g_object_new(fl_backing_store_provider_get_type(), nullptr));
42+
FlFramebuffer* fl_framebuffer_new(size_t width, size_t height) {
43+
FlFramebuffer* provider =
44+
FL_FRAMEBUFFER(g_object_new(fl_framebuffer_get_type(), nullptr));
3845

39-
provider->geometry = {
40-
.x = 0,
41-
.y = 0,
42-
.width = width,
43-
.height = height,
44-
};
46+
provider->width = width;
47+
provider->height = height;
4548

4649
glGenTextures(1, &provider->texture_id);
4750
glGenFramebuffers(1, &provider->framebuffer_id);
@@ -63,21 +66,19 @@ FlBackingStoreProvider* fl_backing_store_provider_new(int width, int height) {
6366
return provider;
6467
}
6568

66-
uint32_t fl_backing_store_provider_get_gl_framebuffer_id(
67-
FlBackingStoreProvider* self) {
69+
GLuint fl_framebuffer_get_id(FlFramebuffer* self) {
6870
return self->framebuffer_id;
6971
}
7072

71-
uint32_t fl_backing_store_provider_get_gl_texture_id(
72-
FlBackingStoreProvider* self) {
73+
GLuint fl_framebuffer_get_texture_id(FlFramebuffer* self) {
7374
return self->texture_id;
7475
}
7576

76-
uint32_t fl_backing_store_provider_get_gl_target(FlBackingStoreProvider* self) {
77+
GLenum fl_framebuffer_get_target(FlFramebuffer* self) {
7778
return GL_TEXTURE_2D;
7879
}
7980

80-
uint32_t fl_backing_store_provider_get_gl_format(FlBackingStoreProvider* self) {
81+
GLenum fl_framebuffer_get_format(FlFramebuffer* self) {
8182
// Flutter defines SK_R32_SHIFT=16, so SK_PMCOLOR_BYTE_ORDER should be BGRA.
8283
// In Linux kN32_SkColorType is assumed to be kBGRA_8888_SkColorType.
8384
// So we must choose a valid gl format to be compatible with surface format
@@ -102,7 +103,10 @@ uint32_t fl_backing_store_provider_get_gl_format(FlBackingStoreProvider* self) {
102103
return GL_RGBA8;
103104
}
104105

105-
GdkRectangle fl_backing_store_provider_get_geometry(
106-
FlBackingStoreProvider* self) {
107-
return self->geometry;
106+
size_t fl_framebuffer_get_width(FlFramebuffer* self) {
107+
return self->width;
108+
}
109+
110+
size_t fl_framebuffer_get_height(FlFramebuffer* self) {
111+
return self->height;
108112
}
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
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_FL_FRAMEBUFFER_H_
6+
#define FLUTTER_SHELL_PLATFORM_LINUX_FL_FRAMEBUFFER_H_
7+
8+
#include <epoxy/gl.h>
9+
#include <glib-object.h>
10+
11+
G_BEGIN_DECLS
12+
13+
G_DECLARE_FINAL_TYPE(FlFramebuffer, fl_framebuffer, FL, FRAMEBUFFER, GObject)
14+
15+
/**
16+
* FlFramebuffer:
17+
*
18+
* #FlFramebuffer creates framebuffers and their backing textures
19+
* for use by the Flutter compositor.
20+
*/
21+
22+
/**
23+
* fl_framebuffer_new:
24+
* @width: width of texture.
25+
* @height: height of texture.
26+
*
27+
* Creates a new frame buffer. Requires a valid OpenGL context to create.
28+
*
29+
* Returns: a new #FlFramebuffer.
30+
*/
31+
FlFramebuffer* fl_framebuffer_new(size_t width, size_t height);
32+
33+
/**
34+
* fl_framebuffer_get_id:
35+
* @framebuffer: an #FlFramebuffer.
36+
*
37+
* Gets the ID for this framebuffer.
38+
*
39+
* Returns: OpenGL framebuffer id or 0 if creation failed.
40+
*/
41+
GLuint fl_framebuffer_get_id(FlFramebuffer* framebuffer);
42+
43+
/**
44+
* fl_framebuffer_get_texture_id:
45+
* @framebuffer: an #FlFramebuffer.
46+
*
47+
* Gets the ID of the texture associated with this framebuffer.
48+
*
49+
* Returns: OpenGL texture id or 0 if creation failed.
50+
*/
51+
GLuint fl_framebuffer_get_texture_id(FlFramebuffer* framebuffer);
52+
53+
/**
54+
* fl_framebuffer_get_target:
55+
* @framebuffer: an #FlFramebuffer.
56+
*
57+
* Gets target texture (example GL_TEXTURE_2D or GL_TEXTURE_RECTANGLE).
58+
*
59+
* Returns: target texture.
60+
*/
61+
GLenum fl_framebuffer_get_target(FlFramebuffer* framebuffer);
62+
63+
/**
64+
* fl_framebuffer_get_format:
65+
* @framebuffer: an #FlFramebuffer.
66+
*
67+
* Gets format of texture backing the framebuffer (example GL_RGBA8).
68+
*
69+
* Returns: texture format.
70+
*/
71+
GLenum fl_framebuffer_get_format(FlFramebuffer* framebuffer);
72+
73+
/**
74+
* fl_framebuffer_get_width:
75+
* @framebuffer: an #FlFramebuffer.
76+
*
77+
* Gets the width of the framebuffer in pixels.
78+
*
79+
* Returns: width in pixels.
80+
*/
81+
size_t fl_framebuffer_get_width(FlFramebuffer* framebuffer);
82+
83+
/**
84+
* fl_framebuffer_get_height:
85+
* @framebuffer: an #FlFramebuffer.
86+
*
87+
* Gets the height of the framebuffer in pixels.
88+
*
89+
* Returns: height in pixels.
90+
*/
91+
size_t fl_framebuffer_get_height(FlFramebuffer* framebuffer);
92+
93+
G_END_DECLS
94+
95+
#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_FRAMEBUFFER_H_

0 commit comments

Comments
 (0)