Browse Source

[plugin] Add embedder_texture plugin for aurora

embedder_texture
Vitaliy Zarubin 1 year ago
parent
commit
fed1031ab4
  1. 26
      packages/embedder_texture/aurora/CMakeLists.txt
  2. 47
      packages/embedder_texture/aurora/embedder_texture_plugin.cpp
  3. 28
      packages/embedder_texture/aurora/include/embedder_texture/embedder_texture_plugin.h
  4. 1
      packages/embedder_texture/lib/embedder_texture.dart
  5. 2
      packages/embedder_texture/pubspec.yaml

26
packages/embedder_texture/aurora/CMakeLists.txt

@ -0,0 +1,26 @@
# SPDX-FileCopyrightText: Copyright 2023 Open Mobile Platform LLC <community@omp.ru>
# SPDX-License-Identifier: BSD-3-Clause
cmake_minimum_required(VERSION 3.10)
set(PROJECT_NAME embedder_texture)
set(PLUGIN_NAME embedder_texture_platform_plugin)
project(${PROJECT_NAME} LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-psabi")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
find_package(PkgConfig REQUIRED)
pkg_check_modules(FlutterEmbedder REQUIRED IMPORTED_TARGET flutter-embedder)
add_library(${PLUGIN_NAME} SHARED embedder_texture_plugin.cpp)
set_target_properties(${PLUGIN_NAME} PROPERTIES CXX_VISIBILITY_PRESET hidden)
target_link_libraries(${PLUGIN_NAME} PRIVATE PkgConfig::FlutterEmbedder)
target_include_directories(${PLUGIN_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_compile_definitions(${PLUGIN_NAME} PRIVATE PLUGIN_IMPL)

47
packages/embedder_texture/aurora/embedder_texture_plugin.cpp

@ -0,0 +1,47 @@
/**
* SPDX-FileCopyrightText: Copyright 2023 Open Mobile Platform LLC <community@omp.ru>
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <embedder_texture/embedder_texture_plugin.h>
#include <flutter/method-channel.h>
#include <flutter/platform-methods.h>
#include <sys/utsname.h>
void EmbedderTexturePlugin::RegisterWithRegistrar(PluginRegistrar &registrar)
{
registrar.RegisterMethodChannel("embedder_texture",
MethodCodecType::Standard,
[this](const MethodCall &call) { this->onMethodCall(call); });
}
void EmbedderTexturePlugin::onMethodCall(const MethodCall &call)
{
const auto &method = call.GetMethod();
if (method == "create") {
onCreate(call);
return;
}
if (method == "remove") {
onRemove(call);
return;
}
unimplemented(call);
}
void EmbedderTexturePlugin::onCreate(const MethodCall &call)
{
call.SendSuccessResponse(0);
}
void EmbedderTexturePlugin::onRemove(const MethodCall &call)
{
call.SendSuccessResponse(nullptr);
}
void EmbedderTexturePlugin::unimplemented(const MethodCall &call)
{
call.SendSuccessResponse(nullptr);
}

28
packages/embedder_texture/aurora/include/embedder_texture/embedder_texture_plugin.h

@ -0,0 +1,28 @@
/**
* SPDX-FileCopyrightText: Copyright 2023 Open Mobile Platform LLC <community@omp.ru>
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef EMBEDDER_TEXTURE_PLUGIN_H
#define EMBEDDER_TEXTURE_PLUGIN_H
#include <flutter/plugin-interface.h>
#ifdef PLUGIN_IMPL
#define PLUGIN_EXPORT __attribute__((visibility("default")))
#else
#define PLUGIN_EXPORT
#endif
class PLUGIN_EXPORT EmbedderTexturePlugin final : public PluginInterface
{
public:
void RegisterWithRegistrar(PluginRegistrar &registrar) override;
private:
void onMethodCall(const MethodCall &call);
void onCreate(const MethodCall &call);
void onRemove(const MethodCall &call);
void unimplemented(const MethodCall &call);
};
#endif /* EMBEDDER_TEXTURE_PLUGIN_H */

1
packages/embedder_texture/lib/embedder_texture.dart

@ -28,6 +28,7 @@ class _EmbedderTextureState extends State<EmbedderTexture> {
.then((value) => setState(() {
if (mounted) {
_textureID = value!;
debugPrint(_textureID.toString());
}
}));
}

2
packages/embedder_texture/pubspec.yaml

@ -21,3 +21,5 @@ flutter:
platforms:
linux:
pluginClass: EmbedderTexturePlugin
aurora:
pluginClass: EmbedderTexturePlugin

Loading…
Cancel
Save