Skip to content

Commit

Permalink
Update embedder header
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaowei-guan committed Apr 25, 2024
1 parent 6928a00 commit 9702833
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 12 deletions.
16 changes: 11 additions & 5 deletions flutter/shell/platform/embedder/embedder.h
Original file line number Diff line number Diff line change
Expand Up @@ -384,10 +384,8 @@ typedef struct {
size_t height;
/// The pixel data buffer.
const uint8_t* buffer;
/// The length of buffer.
size_t length;
/// The egl image.
const void* egl_image;
/// The size of buffer.
size_t buffer_size;
} FlutterOpenGLTexture;

typedef struct {
Expand Down Expand Up @@ -2651,7 +2649,8 @@ FlutterEngineResult FlutterEngineRegisterExternalTexture(
FLUTTER_EXPORT
FlutterEngineResult FlutterEngineRegisterExternalTextureWithType(
FLUTTER_API_SYMBOL(FlutterEngine) engine,
int64_t texture_identifier, FlutterTextureType type);
int64_t texture_identifier,
FlutterTextureType type);

//------------------------------------------------------------------------------
/// @brief Unregister a previous texture registration.
Expand Down Expand Up @@ -3105,6 +3104,11 @@ typedef FlutterEngineResult (*FlutterEngineSendPlatformMessageResponseFnPtr)(
typedef FlutterEngineResult (*FlutterEngineRegisterExternalTextureFnPtr)(
FLUTTER_API_SYMBOL(FlutterEngine) engine,
int64_t texture_identifier);
typedef FlutterEngineResult (
*FlutterEngineRegisterExternalTextureWithTypeFnPtr)(
FLUTTER_API_SYMBOL(FlutterEngine) engine,
int64_t texture_identifier,
FlutterTextureType type);
typedef FlutterEngineResult (*FlutterEngineUnregisterExternalTextureFnPtr)(
FLUTTER_API_SYMBOL(FlutterEngine) engine,
int64_t texture_identifier);
Expand Down Expand Up @@ -3191,6 +3195,8 @@ typedef struct {
PlatformMessageReleaseResponseHandle;
FlutterEngineSendPlatformMessageResponseFnPtr SendPlatformMessageResponse;
FlutterEngineRegisterExternalTextureFnPtr RegisterExternalTexture;
FlutterEngineRegisterExternalTextureWithTypeFnPtr
RegisterExternalTextureWithType;
FlutterEngineUnregisterExternalTextureFnPtr UnregisterExternalTexture;
FlutterEngineMarkExternalTextureFrameAvailableFnPtr
MarkExternalTextureFrameAvailable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@
#include <EGL/eglext.h>
#include <GLES3/gl32.h>

#include "flutter/shell/platform/tizen/logger.h"

namespace flutter {

bool ExternalTexturePixelEGLImpeller::PopulateTexture(
size_t width,
size_t height,
FlutterOpenGLTexture* opengl_texture) {
FT_LOG(Error) << "PopulateTexture";
if (!texture_callback_) {
return false;
}
Expand All @@ -30,7 +33,8 @@ bool ExternalTexturePixelEGLImpeller::PopulateTexture(

// Populate the texture object used by the engine.
opengl_texture->buffer = pixel_buffer->buffer;
opengl_texture->length = size_t(pixel_buffer->width) * size_t(pixel_buffer->height) * (32 >> 3);
opengl_texture->buffer_size =
size_t(pixel_buffer->width) * size_t(pixel_buffer->height) * (32 >> 3);
opengl_texture->destruction_callback = nullptr;
opengl_texture->user_data = nullptr;
opengl_texture->width = width;
Expand All @@ -43,6 +47,8 @@ ExternalTexturePixelEGLImpeller::ExternalTexturePixelEGLImpeller(
void* user_data)
: ExternalTexture(),
texture_callback_(texture_callback),
user_data_(user_data) {}
user_data_(user_data) {
FT_LOG(Error) << "ExternalTexturePixelEGLImpeller";
}

} // namespace flutter
17 changes: 13 additions & 4 deletions flutter/shell/platform/tizen/flutter_tizen_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@ bool FlutterTizenEngine::RunEngine() {
internal_plugin_registrar_->messenger());

if (IsHeaded()) {
texture_registrar_ = std::make_unique<FlutterTizenTextureRegistrar>(this, project_->HasArgument("--enable-impeller"));
texture_registrar_ = std::make_unique<FlutterTizenTextureRegistrar>(
this, project_->HasArgument("--enable-impeller"));
keyboard_channel_ = std::make_unique<KeyboardChannel>(
internal_plugin_registrar_->messenger(),
[this](const FlutterKeyEvent& event, FlutterKeyEventCallback callback,
Expand Down Expand Up @@ -377,9 +378,10 @@ void FlutterTizenEngine::SetupLocales() {
// Convert the locale list to the locale pointer list that must be provided.
std::vector<const FlutterLocale*> flutter_locale_list;
flutter_locale_list.reserve(flutter_locales.size());
std::transform(flutter_locales.begin(), flutter_locales.end(),
std::back_inserter(flutter_locale_list),
[](const auto& arg) -> const auto* { return &arg; });
std::transform(
flutter_locales.begin(), flutter_locales.end(),
std::back_inserter(flutter_locale_list),
[](const auto& arg) -> const auto* { return &arg; });

embedder_api_.UpdateLocales(engine_, flutter_locale_list.data(),
flutter_locale_list.size());
Expand All @@ -394,6 +396,13 @@ bool FlutterTizenEngine::RegisterExternalTexture(int64_t texture_id) {
kSuccess);
}

bool FlutterTizenEngine::RegisterExternalTextureWithType(
int64_t texture_id,
FlutterTextureType type) {
return (embedder_api_.RegisterExternalTextureWithType(engine_, texture_id,
type) == kSuccess);
}

bool FlutterTizenEngine::UnregisterExternalTexture(int64_t texture_id) {
return (embedder_api_.UnregisterExternalTexture(engine_, texture_id) ==
kSuccess);
Expand Down
3 changes: 3 additions & 0 deletions flutter/shell/platform/tizen/flutter_tizen_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ class FlutterTizenEngine {
// Attempts to register the texture with the given |texture_id|.
bool RegisterExternalTexture(int64_t texture_id);

bool RegisterExternalTextureWithType(int64_t texture_id,
FlutterTextureType type);

// Attempts to unregister the texture with the given |texture_id|.
bool UnregisterExternalTexture(int64_t texture_id);

Expand Down
12 changes: 11 additions & 1 deletion flutter/shell/platform/tizen/flutter_tizen_texture_registrar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,18 @@ int64_t FlutterTizenTextureRegistrar::RegisterTexture(
std::lock_guard<std::mutex> lock(map_mutex_);
textures_[texture_id] = std::move(texture_gl);
}
if (enable_impeller_) {
if (texture_info->type == kFlutterDesktopPixelBufferTexture) {
engine_->RegisterExternalTextureWithType(texture_id,
kFlutterPixelBufferTexture);
} else {
engine_->RegisterExternalTextureWithType(texture_id,
kFlutterGpuSurfaceTexture);
}
} else {
engine_->RegisterExternalTexture(texture_id);
}

engine_->RegisterExternalTexture(texture_id);
return texture_id;
}

Expand Down

0 comments on commit 9702833

Please sign in to comment.