Skip to content

Commit

Permalink
embedder_tizen
Browse files Browse the repository at this point in the history
  • Loading branch information
JSUYA committed Jun 20, 2024
1 parent ea8373f commit e8c370a
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 18 deletions.
5 changes: 4 additions & 1 deletion shell/platform/embedder/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,10 @@ embedder_source_set("embedder_as_internal_library") {
}

source_set("embedder_headers") {
public = [ "embedder.h" ]
public = [
"embedder.h",
"embedder_tizen.h",
]

public_configs = [ "//flutter:config" ]
}
Expand Down
15 changes: 1 addition & 14 deletions shell/platform/embedder/embedder.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ typedef struct {
} FlutterTransformation;

typedef void (*VoidCallback)(void* /* user data */);
typedef bool (*BoolCallback)(void* /* user data */);

typedef enum {
/// Specifies an OpenGL texture target type. Textures are specified using
Expand Down Expand Up @@ -362,11 +361,6 @@ typedef enum {
kFlutterSoftwarePixelFormatNative32,
} FlutterSoftwarePixelFormat;

typedef enum {
kFlutterGLImpellerTexturePixelBuffer,
kFlutterGLImpellerTextureGpuSurface,
} FlutterGLImpellerTextureType;

typedef struct {
/// Target texture of the active texture unit (example GL_TEXTURE_2D or
/// GL_TEXTURE_RECTANGLE).
Expand All @@ -375,14 +369,6 @@ typedef struct {
uint32_t name;
/// The texture format (example GL_RGBA8).
uint32_t format;
/// The pixel data buffer.
const uint8_t* buffer;
/// The size of pixel buffer.
size_t buffer_size;
/// Callback invoked that the gpu surface texture start binding.
BoolCallback bind_callback;
/// The type of the texture.
FlutterGLImpellerTextureType impeller_texture_type;
/// User data to be returned on the invocation of the destruction callback.
void* user_data;
/// Callback invoked (on an engine managed thread) that asks the embedder to
Expand Down Expand Up @@ -415,6 +401,7 @@ typedef struct {
VoidCallback destruction_callback;
} FlutterOpenGLFramebuffer;

typedef bool (*BoolCallback)(void* /* user data */);
typedef FlutterTransformation (*TransformationCallback)(void* /* user data */);
typedef uint32_t (*UIntCallback)(void* /* user data */);
typedef bool (*SoftwareSurfacePresentCallback)(void* /* user data */,
Expand Down
14 changes: 11 additions & 3 deletions shell/platform/embedder/embedder_external_texture_gl_impeller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "flutter/impeller/display_list/dl_image_impeller.h"
#include "flutter/impeller/renderer/backend/gles/context_gles.h"
#include "flutter/impeller/renderer/backend/gles/texture_gles.h"
#include "flutter/shell/platform/embedder/embedder_tizen.h"
#include "impeller/aiks/aiks_context.h"
#include "impeller/renderer/backend/gles/gles.h"
#include "include/core/SkCanvas.h"
Expand Down Expand Up @@ -80,7 +81,9 @@ sk_sp<DlImage> EmbedderExternalTextureGLImpeller::ResolveTexture(
width = texture->width;
height = texture->height;
}
if (texture->impeller_texture_type ==
FlutterOpenGLTextureTizen* texture_tizen =
static_cast<FlutterOpenGLTextureTizen*>(texture->user_data);
if (texture_tizen->impeller_texture_type ==
FlutterGLImpellerTextureType::kFlutterGLImpellerTexturePixelBuffer) {
return ResolvePixelBufferTexture(texture.get(), context,
SkISize::Make(width, height));
Expand All @@ -106,7 +109,10 @@ sk_sp<DlImage> EmbedderExternalTextureGLImpeller::ResolvePixelBufferTexture(

auto textureGLES =
std::make_shared<impeller::TextureGLES>(gl_context.GetReactor(), desc);
if (!textureGLES->SetContents(texture->buffer, texture->buffer_size)) {
FlutterOpenGLTextureTizen* texture_tizen =
static_cast<FlutterOpenGLTextureTizen*>(texture->user_data);
if (!textureGLES->SetContents(texture_tizen->buffer,
texture_tizen->buffer_size)) {
if (texture->destruction_callback) {
texture->destruction_callback(texture->user_data);
}
Expand Down Expand Up @@ -143,7 +149,9 @@ sk_sp<DlImage> EmbedderExternalTextureGLImpeller::ResolveGpuSurfaceTexture(
return nullptr;
}

if (!texture->bind_callback(texture->user_data)) {
FlutterOpenGLTextureTizen* texture_tizen =
static_cast<FlutterOpenGLTextureTizen*>(texture->user_data);
if (!texture_tizen->bind_callback(texture->user_data)) {
if (texture->destruction_callback) {
texture->destruction_callback(texture->user_data);
}
Expand Down
42 changes: 42 additions & 0 deletions shell/platform/embedder/embedder_tizen.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// 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_EMBEDDER_EMBEDDER_TIZEN_H_
#define FLUTTER_SHELL_PLATFORM_EMBEDDER_EMBEDDER_TIZEN_H_

#include <memory.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "flutter/shell/platform/embedder/embedder.h"

#if defined(__cplusplus)
extern "C" {
#endif

typedef enum {
kFlutterGLImpellerTexturePixelBuffer,
kFlutterGLImpellerTextureGpuSurface,
} FlutterGLImpellerTextureType;

typedef bool (*BoolCallback)(void* /* user data */);

typedef struct {
/// Callback invoked that texture start binding.
BoolCallback bind_callback;
/// The pixel data buffer.
const uint8_t* buffer;
/// The size of buffer.
size_t buffer_size;
/// The type of the texture.
FlutterGLImpellerTextureType impeller_texture_type;
///
void* embedder_external_texture;
} FlutterOpenGLTextureTizen;

#if defined(__cplusplus)
} // extern "C"
#endif

#endif // FLUTTER_SHELL_PLATFORM_EMBEDDER_EMBEDDER_TIZEN_H_

0 comments on commit e8c370a

Please sign in to comment.