Vitaliy Zarubin
1 year ago
5 changed files with 104 additions and 0 deletions
@ -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) |
@ -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 ®istrar) |
||||
{ |
||||
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); |
||||
} |
@ -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 ®istrar) 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 */ |
Loading…
Reference in new issue