Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -44061,8 +44061,6 @@ ORIGIN: ../../../flutter/shell/platform/linux/fl_accessible_node_test.cc + ../..
ORIGIN: ../../../flutter/shell/platform/linux/fl_accessible_text_field.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/linux/fl_accessible_text_field.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/linux/fl_accessible_text_field_test.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/linux/fl_backing_store_provider.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/linux/fl_backing_store_provider.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/linux/fl_basic_message_channel.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/linux/fl_basic_message_channel_test.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/linux/fl_binary_codec.cc + ../../../flutter/LICENSE
Expand All @@ -44078,6 +44076,8 @@ ORIGIN: ../../../flutter/shell/platform/linux/fl_engine_private.h + ../../../flu
ORIGIN: ../../../flutter/shell/platform/linux/fl_engine_test.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/linux/fl_event_channel.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/linux/fl_event_channel_test.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/linux/fl_framebuffer.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/linux/fl_framebuffer.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/linux/fl_gnome_settings.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/linux/fl_gnome_settings.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/linux/fl_gnome_settings_test.cc + ../../../flutter/LICENSE
Expand Down Expand Up @@ -46968,8 +46968,6 @@ FILE: ../../../flutter/shell/platform/linux/fl_accessible_node_test.cc
FILE: ../../../flutter/shell/platform/linux/fl_accessible_text_field.cc
FILE: ../../../flutter/shell/platform/linux/fl_accessible_text_field.h
FILE: ../../../flutter/shell/platform/linux/fl_accessible_text_field_test.cc
FILE: ../../../flutter/shell/platform/linux/fl_backing_store_provider.cc
FILE: ../../../flutter/shell/platform/linux/fl_backing_store_provider.h
FILE: ../../../flutter/shell/platform/linux/fl_basic_message_channel.cc
FILE: ../../../flutter/shell/platform/linux/fl_basic_message_channel_test.cc
FILE: ../../../flutter/shell/platform/linux/fl_binary_codec.cc
Expand All @@ -46985,6 +46983,8 @@ FILE: ../../../flutter/shell/platform/linux/fl_engine_private.h
FILE: ../../../flutter/shell/platform/linux/fl_engine_test.cc
FILE: ../../../flutter/shell/platform/linux/fl_event_channel.cc
FILE: ../../../flutter/shell/platform/linux/fl_event_channel_test.cc
FILE: ../../../flutter/shell/platform/linux/fl_framebuffer.cc
FILE: ../../../flutter/shell/platform/linux/fl_framebuffer.h
FILE: ../../../flutter/shell/platform/linux/fl_gnome_settings.cc
FILE: ../../../flutter/shell/platform/linux/fl_gnome_settings.h
FILE: ../../../flutter/shell/platform/linux/fl_gnome_settings_test.cc
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/linux/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ source_set("flutter_linux_sources") {
sources = [
"fl_accessible_node.cc",
"fl_accessible_text_field.cc",
"fl_backing_store_provider.cc",
"fl_basic_message_channel.cc",
"fl_binary_codec.cc",
"fl_binary_messenger.cc",
"fl_dart_project.cc",
"fl_engine.cc",
"fl_event_channel.cc",
"fl_framebuffer.cc",
"fl_gnome_settings.cc",
"fl_json_message_codec.cc",
"fl_json_method_codec.cc",
Expand Down
96 changes: 0 additions & 96 deletions shell/platform/linux/fl_backing_store_provider.h

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,49 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "fl_backing_store_provider.h"
#include "fl_framebuffer.h"

#include <epoxy/gl.h>

struct _FlBackingStoreProvider {
struct _FlFramebuffer {
GObject parent_instance;

uint32_t framebuffer_id;
uint32_t texture_id;
GdkRectangle geometry;
// Width of framebuffer in pixels.
size_t width;

// Height of framebuffer in pixels.
size_t height;

// Framebuffer ID.
GLuint framebuffer_id;

// Texture backing framebuffer.
GLuint texture_id;
};

G_DEFINE_TYPE(FlBackingStoreProvider, fl_backing_store_provider, G_TYPE_OBJECT)
G_DEFINE_TYPE(FlFramebuffer, fl_framebuffer, G_TYPE_OBJECT)

static void fl_backing_store_provider_dispose(GObject* object) {
FlBackingStoreProvider* self = FL_BACKING_STORE_PROVIDER(object);
static void fl_framebuffer_dispose(GObject* object) {
FlFramebuffer* self = FL_FRAMEBUFFER(object);

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

G_OBJECT_CLASS(fl_backing_store_provider_parent_class)->dispose(object);
G_OBJECT_CLASS(fl_framebuffer_parent_class)->dispose(object);
}

static void fl_backing_store_provider_class_init(
FlBackingStoreProviderClass* klass) {
G_OBJECT_CLASS(klass)->dispose = fl_backing_store_provider_dispose;
static void fl_framebuffer_class_init(FlFramebufferClass* klass) {
G_OBJECT_CLASS(klass)->dispose = fl_framebuffer_dispose;
}

static void fl_backing_store_provider_init(FlBackingStoreProvider* self) {}
static void fl_framebuffer_init(FlFramebuffer* self) {}

FlBackingStoreProvider* fl_backing_store_provider_new(int width, int height) {
FlBackingStoreProvider* provider = FL_BACKING_STORE_PROVIDER(
g_object_new(fl_backing_store_provider_get_type(), nullptr));
FlFramebuffer* fl_framebuffer_new(size_t width, size_t height) {
FlFramebuffer* provider =
FL_FRAMEBUFFER(g_object_new(fl_framebuffer_get_type(), nullptr));

provider->geometry = {
.x = 0,
.y = 0,
.width = width,
.height = height,
};
provider->width = width;
provider->height = height;

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

uint32_t fl_backing_store_provider_get_gl_framebuffer_id(
FlBackingStoreProvider* self) {
GLuint fl_framebuffer_get_id(FlFramebuffer* self) {
return self->framebuffer_id;
}

uint32_t fl_backing_store_provider_get_gl_texture_id(
FlBackingStoreProvider* self) {
GLuint fl_framebuffer_get_texture_id(FlFramebuffer* self) {
return self->texture_id;
}

uint32_t fl_backing_store_provider_get_gl_target(FlBackingStoreProvider* self) {
GLenum fl_framebuffer_get_target(FlFramebuffer* self) {
return GL_TEXTURE_2D;
}

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

GdkRectangle fl_backing_store_provider_get_geometry(
FlBackingStoreProvider* self) {
return self->geometry;
size_t fl_framebuffer_get_width(FlFramebuffer* self) {
return self->width;
}

size_t fl_framebuffer_get_height(FlFramebuffer* self) {
return self->height;
}
95 changes: 95 additions & 0 deletions shell/platform/linux/fl_framebuffer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_FRAMEBUFFER_H_
#define FLUTTER_SHELL_PLATFORM_LINUX_FL_FRAMEBUFFER_H_

#include <epoxy/gl.h>
#include <glib-object.h>

G_BEGIN_DECLS

G_DECLARE_FINAL_TYPE(FlFramebuffer, fl_framebuffer, FL, FRAMEBUFFER, GObject)

/**
* FlFramebuffer:
*
* #FlFramebuffer creates framebuffers and their backing textures
* for use by the Flutter compositor.
*/

/**
* fl_framebuffer_new:
* @width: width of texture.
* @height: height of texture.
*
* Creates a new frame buffer. Requires a valid OpenGL context to create.
*
* Returns: a new #FlFramebuffer.
*/
FlFramebuffer* fl_framebuffer_new(size_t width, size_t height);

/**
* fl_framebuffer_get_id:
* @framebuffer: an #FlFramebuffer.
*
* Gets the ID for this framebuffer.
*
* Returns: OpenGL framebuffer id or 0 if creation failed.
*/
GLuint fl_framebuffer_get_id(FlFramebuffer* framebuffer);

/**
* fl_framebuffer_get_texture_id:
* @framebuffer: an #FlFramebuffer.
*
* Gets the ID of the texture associated with this framebuffer.
*
* Returns: OpenGL texture id or 0 if creation failed.
*/
GLuint fl_framebuffer_get_texture_id(FlFramebuffer* framebuffer);

/**
* fl_framebuffer_get_target:
* @framebuffer: an #FlFramebuffer.
*
* Gets target texture (example GL_TEXTURE_2D or GL_TEXTURE_RECTANGLE).
*
* Returns: target texture.
*/
GLenum fl_framebuffer_get_target(FlFramebuffer* framebuffer);

/**
* fl_framebuffer_get_format:
* @framebuffer: an #FlFramebuffer.
*
* Gets format of texture backing the framebuffer (example GL_RGBA8).
*
* Returns: texture format.
*/
GLenum fl_framebuffer_get_format(FlFramebuffer* framebuffer);

/**
* fl_framebuffer_get_width:
* @framebuffer: an #FlFramebuffer.
*
* Gets the width of the framebuffer in pixels.
*
* Returns: width in pixels.
*/
size_t fl_framebuffer_get_width(FlFramebuffer* framebuffer);

/**
* fl_framebuffer_get_height:
* @framebuffer: an #FlFramebuffer.
*
* Gets the height of the framebuffer in pixels.
*
* Returns: height in pixels.
*/
size_t fl_framebuffer_get_height(FlFramebuffer* framebuffer);

G_END_DECLS

#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_FRAMEBUFFER_H_
Loading