Skip to content

Commit 6b4477c

Browse files
committed
Merge branch 'master' into port_changes_from_qr_plus
# Conflicts: # android/build.gradle # android/gradle/wrapper/gradle-wrapper.properties # android/src/main/AndroidManifest.xml # example/android/app/build.gradle # example/android/build.gradle # example/android/gradle/wrapper/gradle-wrapper.properties # lib/src/qr_code_scanner.dart # pubspec.yaml
2 parents 807356b + 5af7a54 commit 6b4477c

7 files changed

Lines changed: 410 additions & 0 deletions

File tree

lib/src/web/flutter_qr_web.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,12 @@ class QRViewControllerWeb implements QRViewController {
385385
// TODO: implement scanInvert
386386
throw UnimplementedError();
387387
}
388+
389+
@override
390+
bool get isIntegrationTesting => false;
391+
392+
@override
393+
String get linuxDevice => throw UnimplementedError();
388394
}
389395

390396
Widget createWebQrView(

linux/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
flutter/ephemeral

linux/CMakeLists.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
cmake_minimum_required(VERSION 3.10)
2+
set(PROJECT_NAME "qr_code_scanner")
3+
project(${PROJECT_NAME} LANGUAGES CXX)
4+
5+
# This value is used when generating builds using this plugin, so it must
6+
# not be changed
7+
set(PLUGIN_NAME "qr_code_scanner_plugin")
8+
9+
add_library(${PLUGIN_NAME} SHARED
10+
"qr_code_scanner_plugin.cc"
11+
)
12+
apply_standard_settings(${PLUGIN_NAME})
13+
set_target_properties(${PLUGIN_NAME} PROPERTIES
14+
CXX_VISIBILITY_PRESET hidden)
15+
target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL)
16+
target_include_directories(${PLUGIN_NAME} INTERFACE
17+
"${CMAKE_CURRENT_SOURCE_DIR}/include")
18+
target_link_libraries(${PLUGIN_NAME} PRIVATE flutter)
19+
target_link_libraries(${PLUGIN_NAME} PRIVATE PkgConfig::GTK)
20+
target_link_libraries(${PLUGIN_NAME} PRIVATE zbar)
21+
22+
# List of absolute paths to libraries that should be bundled with the plugin
23+
set(qr_code_scanner_bundled_libraries
24+
""
25+
PARENT_SCOPE
26+
)

linux/flutter/CMakeLists.txt

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# This file controls Flutter-level build steps. It should not be edited.
2+
cmake_minimum_required(VERSION 3.10)
3+
4+
set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
5+
6+
# Configuration provided via flutter tool.
7+
include(${EPHEMERAL_DIR}/generated_config.cmake)
8+
9+
# TODO: Move the rest of this into files in ephemeral. See
10+
# https://github.com/flutter/flutter/issues/57146.
11+
12+
# Serves the same purpose as list(TRANSFORM ... PREPEND ...),
13+
# which isn't available in 3.10.
14+
function(list_prepend LIST_NAME PREFIX)
15+
set(NEW_LIST "")
16+
foreach(element ${${LIST_NAME}})
17+
list(APPEND NEW_LIST "${PREFIX}${element}")
18+
endforeach(element)
19+
set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE)
20+
endfunction()
21+
22+
# === Flutter Library ===
23+
# System-level dependencies.
24+
find_package(PkgConfig REQUIRED)
25+
pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
26+
pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0)
27+
pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0)
28+
29+
set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so")
30+
31+
# Published to parent scope for install step.
32+
set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
33+
set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
34+
set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
35+
set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE)
36+
37+
list(APPEND FLUTTER_LIBRARY_HEADERS
38+
"fl_basic_message_channel.h"
39+
"fl_binary_codec.h"
40+
"fl_binary_messenger.h"
41+
"fl_dart_project.h"
42+
"fl_engine.h"
43+
"fl_json_message_codec.h"
44+
"fl_json_method_codec.h"
45+
"fl_message_codec.h"
46+
"fl_method_call.h"
47+
"fl_method_channel.h"
48+
"fl_method_codec.h"
49+
"fl_method_response.h"
50+
"fl_plugin_registrar.h"
51+
"fl_plugin_registry.h"
52+
"fl_standard_message_codec.h"
53+
"fl_standard_method_codec.h"
54+
"fl_string_codec.h"
55+
"fl_value.h"
56+
"fl_view.h"
57+
"flutter_linux.h"
58+
)
59+
list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/")
60+
add_library(flutter INTERFACE)
61+
target_include_directories(flutter INTERFACE
62+
"${EPHEMERAL_DIR}"
63+
)
64+
target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}")
65+
target_link_libraries(flutter INTERFACE
66+
PkgConfig::GTK
67+
PkgConfig::GLIB
68+
PkgConfig::GIO
69+
)
70+
add_dependencies(flutter flutter_assemble)
71+
72+
# === Flutter tool backend ===
73+
# _phony_ is a non-existent file to force this command to run every time,
74+
# since currently there's no way to get a full input/output list from the
75+
# flutter tool.
76+
add_custom_command(
77+
OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
78+
${CMAKE_CURRENT_BINARY_DIR}/_phony_
79+
COMMAND ${CMAKE_COMMAND} -E env
80+
${FLUTTER_TOOL_ENVIRONMENT}
81+
"${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh"
82+
${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE}
83+
VERBATIM
84+
)
85+
add_custom_target(flutter_assemble DEPENDS
86+
"${FLUTTER_LIBRARY}"
87+
${FLUTTER_LIBRARY_HEADERS}
88+
)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#ifndef FLUTTER_PLUGIN_QR_CODE_SCANNER_PLUGIN_H_
2+
#define FLUTTER_PLUGIN_QR_CODE_SCANNER_PLUGIN_H_
3+
4+
#include <flutter_linux/flutter_linux.h>
5+
6+
G_BEGIN_DECLS
7+
8+
#ifdef FLUTTER_PLUGIN_IMPL
9+
#define FLUTTER_PLUGIN_EXPORT __attribute__((visibility("default")))
10+
#else
11+
#define FLUTTER_PLUGIN_EXPORT
12+
#endif
13+
14+
typedef struct _QrCodeScannerPlugin QrCodeScannerPlugin;
15+
typedef struct {
16+
GObjectClass parent_class;
17+
} QrCodeScannerPluginClass;
18+
19+
FLUTTER_PLUGIN_EXPORT GType qr_code_scanner_plugin_get_type();
20+
21+
FLUTTER_PLUGIN_EXPORT void qr_code_scanner_plugin_register_with_registrar(
22+
FlPluginRegistrar* registrar);
23+
24+
G_END_DECLS
25+
#endif // FLUTTER_PLUGIN_QR_CODE_SCANNER_PLUGIN_H_
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#include <flutter_linux/flutter_linux.h>
2+
3+
struct _VideoOutletClass {
4+
FlPixelBufferTextureClass parent_class;
5+
};
6+
7+
struct VideoOutletPrivate {
8+
int64_t texture_id = 0;
9+
uint8_t *buffer = nullptr;
10+
int32_t video_width = 0;
11+
int32_t video_height = 0;
12+
};
13+
14+
G_DECLARE_DERIVABLE_TYPE(VideoOutlet, video_outlet, QR_CODE_SCANNER, VIDEO_OUTLET,
15+
FlPixelBufferTexture)
16+
17+
G_DEFINE_TYPE_WITH_CODE(VideoOutlet, video_outlet,
18+
fl_pixel_buffer_texture_get_type(),
19+
G_ADD_PRIVATE(VideoOutlet))
20+
21+
static gboolean video_outlet_copy_pixels(FlPixelBufferTexture *texture,
22+
const uint8_t **out_buffer,
23+
uint32_t *width, uint32_t *height,
24+
GError **error) {
25+
auto video_outlet_private =
26+
(VideoOutletPrivate *) video_outlet_get_instance_private(
27+
QR_CODE_SCANNER_VIDEO_OUTLET(texture));
28+
*out_buffer = video_outlet_private->buffer;
29+
*width = video_outlet_private->video_width;
30+
*height = video_outlet_private->video_height;
31+
return TRUE;
32+
}
33+
34+
static VideoOutlet *video_outlet_new() {
35+
return QR_CODE_SCANNER_VIDEO_OUTLET(g_object_new(video_outlet_get_type(), nullptr));
36+
}
37+
38+
static void video_outlet_class_init(VideoOutletClass *klass) {
39+
FL_PIXEL_BUFFER_TEXTURE_CLASS(klass)->copy_pixels = video_outlet_copy_pixels;
40+
}
41+
42+
static void video_outlet_init(VideoOutlet *self) {}

0 commit comments

Comments
 (0)