From 2af0ddbcf5cf32e4f6e8e1e3993a1aca0c409c90 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 30 Oct 2013 17:22:02 +0100 Subject: add initial, untested opentrack-api.dll Signed-off-by: Stanislaw Halik --- opentrack-api/opentrack-guts.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 opentrack-api/opentrack-guts.h (limited to 'opentrack-api/opentrack-guts.h') diff --git a/opentrack-api/opentrack-guts.h b/opentrack-api/opentrack-guts.h new file mode 100644 index 00000000..1061d75d --- /dev/null +++ b/opentrack-api/opentrack-guts.h @@ -0,0 +1,40 @@ +#pragma once + +#include "ftnoir_tracker_base/ftnoir_tracker_base.h" +#include "facetracknoir/global-settings.h" +#include +#include +#include +#include +#include +#include +#include +#include + +typedef ITracker* opentrack_tracker; + +class opentrack_meta { +public: + Metadata* meta; + QString path; + DynamicLibrary* lib; + + opentrack_meta(Metadata* meta, QString& path, DynamicLibrary* lib) : + meta(meta), path(path), lib(lib) + {} + ~opentrack_meta() + { + delete meta; + delete lib; + } +}; + +typedef class opentrack_ctx { +public: + QDir dir; + char** list; + QList meta_list; + QFrame fake_frame; + opentrack_ctx(QDir& dir); + ~opentrack_ctx(); +} *opentrack; -- cgit v1.2.3 From 4501ea093dadd3c44e88da9901eff683b0a91614 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 30 Oct 2013 17:47:38 +0100 Subject: add visibility modifiers for GNU C --- opentrack-api/opentrack-guts.h | 10 ++++++++-- opentrack-api/opentrack.h | 20 +++++++++++++------- 2 files changed, 21 insertions(+), 9 deletions(-) (limited to 'opentrack-api/opentrack-guts.h') diff --git a/opentrack-api/opentrack-guts.h b/opentrack-api/opentrack-guts.h index 1061d75d..3f8806cc 100644 --- a/opentrack-api/opentrack-guts.h +++ b/opentrack-api/opentrack-guts.h @@ -11,9 +11,15 @@ #include #include +#ifdef __GNUC__ +# define OPENTRACK_HIDDEN __attribute__((visibility ("hidden"))) +#else +# define OPENTRACK_HIDDEN +#endif + typedef ITracker* opentrack_tracker; -class opentrack_meta { +class OPENTRACK_HIDDEN opentrack_meta { public: Metadata* meta; QString path; @@ -29,7 +35,7 @@ public: } }; -typedef class opentrack_ctx { +typedef class OPENTRACK_HIDDEN opentrack_ctx { public: QDir dir; char** list; diff --git a/opentrack-api/opentrack.h b/opentrack-api/opentrack.h index 8d28b5b8..95339d08 100644 --- a/opentrack-api/opentrack.h +++ b/opentrack-api/opentrack.h @@ -25,6 +25,12 @@ typedef opentrack_opaque_tracker* opentrack_tracker; # endif #endif +#ifdef __GNUC__ +# define OPENTRACK_VISIBLE __attribute__((visibility ("default"))) +#else +# define OPENTRACK_VISIBLE +#endif + /* for `opentrack_tracker_tick', individual headpose elts */ #ifndef IN_OPENTRACK enum opentrack_dof { @@ -38,20 +44,20 @@ enum opentrack_dof { }; #endif -opentrack opentrack_make_ctx(const char* dir); -void opentrack_finalize_ctx(opentrack self); +opentrack OPENTRACK_VISIBLE opentrack_make_ctx(const char* dir); +void OPENTRACK_VISIBLE opentrack_finalize_ctx(opentrack self); /* no need to free the return value; invalid to modify it */ -const char** opentrack_enum_trackers(opentrack self); +const char** OPENTRACK_VISIBLE opentrack_enum_trackers(opentrack self); /* * don't `opentrack_tracker_tick an unstarted tracker, it's invalid to do so * it's also invalid to start a finalized tracker */ -opentrack_tracker opentrack_make_tracker(opentrack ctx, const char* name); -void opentrack_tracker_start(opentrack self, opentrack_tracker tracker); -int opentrack_tracker_tick(opentrack_tracker tracker, double* headpose); -void opentrack_finalize_tracker(opentrack_tracker tracker); +opentrack_tracker OPENTRACK_VISIBLE opentrack_make_tracker(opentrack ctx, const char* name); +void OPENTRACK_VISIBLE opentrack_tracker_start(opentrack self, opentrack_tracker tracker); +int OPENTRACK_VISIBLE opentrack_tracker_tick(opentrack_tracker tracker, double* headpose); +void OPENTRACK_VISIBLE opentrack_finalize_tracker(opentrack_tracker tracker); #ifdef __cplusplus } #endif -- cgit v1.2.3 From 95f7e4c5b9608c550d008c662dc41fa049a6b725 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 30 Oct 2013 18:24:51 +0100 Subject: clean up the visibility mess in a messiest way possible Signed-off-by: Stanislaw Halik --- CMakeLists.txt | 13 ++++++++----- facetracknoir/global-settings.cpp | 12 ++++++++++++ facetracknoir/global-settings.h | 15 +++++++++++++++ opentrack-api/context.cpp | 15 +++++++++++---- opentrack-api/opentrack-guts.h | 24 +++++++++++++----------- opentrack-api/opentrack.h | 7 ++++++- 6 files changed, 65 insertions(+), 21 deletions(-) (limited to 'opentrack-api/opentrack-guts.h') diff --git a/CMakeLists.txt b/CMakeLists.txt index 239cafb5..1aafaa16 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -154,8 +154,8 @@ else() endif() # main app -file(GLOB opentrack-lib-c "opentrack-api/*.cpp") -file(GLOB opentrack-lib-h "opentrack-api/*.h") +file(GLOB opentrack-lib-c "opentrack-api/*.cpp" "facetracknoir/global-settings.cpp") +file(GLOB opentrack-lib-h "opentrack-api/*.h" "facetracknoir/global-settings.h") file(GLOB opentrack-bin-c "facetracknoir/*.cpp" "facetracknoir/*.rc") file(GLOB opentrack-bin-h "facetracknoir/*.h") @@ -614,9 +614,12 @@ configure_file("${CMAKE_SOURCE_DIR}/opentrack-version.h" "${CMAKE_BINARY_DIR}/op add_library(opentrack-api SHARED ${opentrack-lib-c} ${opentrack-lib-h} ${opentrack-lib-moc}) target_link_libraries(opentrack-api ${MY_QT_LIBS}) -if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) - SET_TARGET_PROPERTIES(opentrack-api - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/opentrack-api/gnuc-version-script.txt") +if(CMAKE_COMPILER_IS_GNUCXX) + SET_TARGET_PROPERTIES(opentrack-api PROPERTIES + LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/opentrack-api/gnuc-version-script.txt" + COMPILE_FLAGS "-fvisibility=protected -fvisibility-inlines-hidden" + COMPILE_DEFINITIONS IN_OPENTRACK_API + ) endif() set_target_properties(opentrack PROPERTIES COMPILE_DEFINITIONS OPENTRACK_VERSION=\"${OPENTRACK__COMMIT}\") diff --git a/facetracknoir/global-settings.cpp b/facetracknoir/global-settings.cpp index b198f327..42646742 100644 --- a/facetracknoir/global-settings.cpp +++ b/facetracknoir/global-settings.cpp @@ -4,6 +4,12 @@ # include #endif +#ifdef IN_OPENTRACK_API +# ifdef __GNUC__ +# pragma GCC visibility push(protected) +# endif +#endif + SelectedLibraries* Libraries = NULL; SelectedLibraries::~SelectedLibraries() @@ -128,3 +134,9 @@ DynamicLibrary::~DynamicLibrary() (void) dlclose(handle); #endif } + +#ifdef IN_OPENTRACK_API +# ifdef __GNUC__ +# pragma GCC visibility pop +# endif +#endif diff --git a/facetracknoir/global-settings.h b/facetracknoir/global-settings.h index b2a54e20..ea36abac 100644 --- a/facetracknoir/global-settings.h +++ b/facetracknoir/global-settings.h @@ -12,6 +12,14 @@ # define MAYBE_STDCALL_UNDERSCORE "" #endif +#include + +#ifdef IN_OPENTRACK_API +# ifdef __GNUC__ +# pragma GCC visibility push(protected) +# endif +#endif + #include #include #include @@ -83,3 +91,10 @@ public: virtual DynamicLibrary* current_filter() = 0; virtual QFrame* get_video_widget() = 0; }; + + +#ifdef IN_OPENTRACK_API +# ifdef __GNUC__ +# pragma GCC visibility pop +# endif +#endif diff --git a/opentrack-api/context.cpp b/opentrack-api/context.cpp index 100acf5c..1fdf6713 100644 --- a/opentrack-api/context.cpp +++ b/opentrack-api/context.cpp @@ -17,7 +17,10 @@ # define LIB_PREFIX "lib" #endif -// shamelessly copied from core +#ifdef __GNUC__ +# pragma GCC visibility push(protected) +#endif + static Metadata* get_metadata(DynamicLibrary* lib, QString& longName, QIcon& icon) { Metadata* meta; @@ -89,20 +92,24 @@ opentrack_ctx::~opentrack_ctx() extern "C" { -const char** OPENTRACK_EXPORT opentrack_enum_trackers(opentrack ctx) +const char** opentrack_enum_trackers(opentrack ctx) { return const_cast(ctx->list); } -opentrack OPENTRACK_EXPORT opentrack_make_ctx(const char *dir) +opentrack opentrack_make_ctx(const char *dir) { QDir d(dir); return new opentrack_ctx(d); } -void OPENTRACK_EXPORT opentrack_finalize_ctx(opentrack foo) +void opentrack_finalize_ctx(opentrack foo) { delete foo; } } + +#ifdef __GNUC__ +# pragma GCC visibility pop +#endif diff --git a/opentrack-api/opentrack-guts.h b/opentrack-api/opentrack-guts.h index 3f8806cc..01463cfc 100644 --- a/opentrack-api/opentrack-guts.h +++ b/opentrack-api/opentrack-guts.h @@ -1,8 +1,9 @@ #pragma once -#include "ftnoir_tracker_base/ftnoir_tracker_base.h" -#include "facetracknoir/global-settings.h" -#include +#ifdef __GNUC__ +# pragma GCC visibility push(protected) +#endif + #include #include #include @@ -10,16 +11,13 @@ #include #include #include - -#ifdef __GNUC__ -# define OPENTRACK_HIDDEN __attribute__((visibility ("hidden"))) -#else -# define OPENTRACK_HIDDEN -#endif +#include +#include "ftnoir_tracker_base/ftnoir_tracker_base.h" +#include "facetracknoir/global-settings.h" typedef ITracker* opentrack_tracker; -class OPENTRACK_HIDDEN opentrack_meta { +class opentrack_meta { public: Metadata* meta; QString path; @@ -35,7 +33,7 @@ public: } }; -typedef class OPENTRACK_HIDDEN opentrack_ctx { +typedef class opentrack_ctx { public: QDir dir; char** list; @@ -44,3 +42,7 @@ public: opentrack_ctx(QDir& dir); ~opentrack_ctx(); } *opentrack; + +#ifdef __GNUC__ +# pragma GCC visibility pop +#endif diff --git a/opentrack-api/opentrack.h b/opentrack-api/opentrack.h index 8d28b5b8..1c8fcee5 100644 --- a/opentrack-api/opentrack.h +++ b/opentrack-api/opentrack.h @@ -15,7 +15,11 @@ typedef opentrack_opaque_tracker* opentrack_tracker; # ifdef _WIN32 # define OPENTRACK_EXPORT __declspec(dllexport) # else -# define OPENTRACK_EXPORT +# ifdef __GNUC__ +# define OPENTRACK_EXPORT __attribute__((visibility ("default"))) +# else +# define OPENTRACK_EXPORT +# endif # endif #else # ifdef _WIN32 @@ -55,3 +59,4 @@ void opentrack_finalize_tracker(opentrack_tracker tracker); #ifdef __cplusplus } #endif + -- cgit v1.2.3 From 5eb570d1608e2071c0d01412925ac43768770624 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 30 Oct 2013 18:40:06 +0100 Subject: end this foolishness, a linker script is more than enough Signed-off-by: Stanislaw Halik --- facetracknoir/global-settings.cpp | 12 ------------ facetracknoir/global-settings.h | 13 ------------- opentrack-api/context.cpp | 7 ------- opentrack-api/opentrack-guts.h | 8 -------- 4 files changed, 40 deletions(-) (limited to 'opentrack-api/opentrack-guts.h') diff --git a/facetracknoir/global-settings.cpp b/facetracknoir/global-settings.cpp index 42646742..b198f327 100644 --- a/facetracknoir/global-settings.cpp +++ b/facetracknoir/global-settings.cpp @@ -4,12 +4,6 @@ # include #endif -#ifdef IN_OPENTRACK_API -# ifdef __GNUC__ -# pragma GCC visibility push(protected) -# endif -#endif - SelectedLibraries* Libraries = NULL; SelectedLibraries::~SelectedLibraries() @@ -134,9 +128,3 @@ DynamicLibrary::~DynamicLibrary() (void) dlclose(handle); #endif } - -#ifdef IN_OPENTRACK_API -# ifdef __GNUC__ -# pragma GCC visibility pop -# endif -#endif diff --git a/facetracknoir/global-settings.h b/facetracknoir/global-settings.h index ea36abac..3e24bf74 100644 --- a/facetracknoir/global-settings.h +++ b/facetracknoir/global-settings.h @@ -14,12 +14,6 @@ #include -#ifdef IN_OPENTRACK_API -# ifdef __GNUC__ -# pragma GCC visibility push(protected) -# endif -#endif - #include #include #include @@ -91,10 +85,3 @@ public: virtual DynamicLibrary* current_filter() = 0; virtual QFrame* get_video_widget() = 0; }; - - -#ifdef IN_OPENTRACK_API -# ifdef __GNUC__ -# pragma GCC visibility pop -# endif -#endif diff --git a/opentrack-api/context.cpp b/opentrack-api/context.cpp index 1fdf6713..003377ce 100644 --- a/opentrack-api/context.cpp +++ b/opentrack-api/context.cpp @@ -17,10 +17,6 @@ # define LIB_PREFIX "lib" #endif -#ifdef __GNUC__ -# pragma GCC visibility push(protected) -#endif - static Metadata* get_metadata(DynamicLibrary* lib, QString& longName, QIcon& icon) { Metadata* meta; @@ -110,6 +106,3 @@ void opentrack_finalize_ctx(opentrack foo) } -#ifdef __GNUC__ -# pragma GCC visibility pop -#endif diff --git a/opentrack-api/opentrack-guts.h b/opentrack-api/opentrack-guts.h index 01463cfc..b9c3878b 100644 --- a/opentrack-api/opentrack-guts.h +++ b/opentrack-api/opentrack-guts.h @@ -1,9 +1,5 @@ #pragma once -#ifdef __GNUC__ -# pragma GCC visibility push(protected) -#endif - #include #include #include @@ -42,7 +38,3 @@ public: opentrack_ctx(QDir& dir); ~opentrack_ctx(); } *opentrack; - -#ifdef __GNUC__ -# pragma GCC visibility pop -#endif -- cgit v1.2.3 From 657cf32cb57257556c26f702e9e09b0edb15f350 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 30 Oct 2013 23:09:36 +0100 Subject: make standalone libopentrack-api.so work --- opentrack-api/context.cpp | 20 +++++++++++--------- opentrack-api/opentrack-guts.h | 27 +++++++++++++++++---------- opentrack-api/opentrack.h | 6 +++--- opentrack-api/trackers.cpp | 9 +++++---- 4 files changed, 36 insertions(+), 26 deletions(-) (limited to 'opentrack-api/opentrack-guts.h') diff --git a/opentrack-api/context.cpp b/opentrack-api/context.cpp index 9b8aa718..e0fd5357 100644 --- a/opentrack-api/context.cpp +++ b/opentrack-api/context.cpp @@ -27,10 +27,12 @@ static Metadata* get_metadata(DynamicLibrary* lib, QString& longName, QIcon& ico return meta; } -static QList list_files(QDir& dir, QString filter) +static QList list_files(QString filter) { QList ret; - QStringList filenames = dir.entryList( QStringList() << (LIB_PREFIX + filter + ("*." SONAME)), QDir::Files, QDir::Name ); + QStringList filenames = QDir((qApp->applicationDirPath())).entryList( + QStringList() << (LIB_PREFIX + filter + ("*." SONAME)), + QDir::Files, QDir::Name ); for ( int i = 0; i < filenames.size(); i++) { QIcon icon; QString long_name; @@ -49,7 +51,7 @@ static QList list_files(QDir& dir, QString filter) if (str.size() > prefix.size() + suffix.size() && str.startsWith(prefix) && str.endsWith(suffix)) { auto str2 = str.mid(prefix.size(), str.size() - prefix.size() - suffix.size()); - opentrack_meta item(meta, str2, lib); + opentrack_meta item(str2, lib); ret.push_back(item); } } @@ -57,9 +59,10 @@ static QList list_files(QDir& dir, QString filter) return ret; } -opentrack_ctx::opentrack_ctx(QDir& dir) : - dir(dir), - meta_list(list_files(dir, "opentrack-tracker-")) +opentrack_ctx::opentrack_ctx(int argc, char** argv, void* window_parent) : + app(argc, argv), + meta_list(list_files("opentrack-tracker-")), + fake_frame(window_parent) { const int count = meta_list.size(); list = new char*[count + 1]; @@ -93,10 +96,9 @@ const char** opentrack_enum_trackers(opentrack ctx) return const_cast(ctx->list); } -opentrack opentrack_make_ctx(const char *dir) +opentrack opentrack_make_ctx(int argc, char** argv, void* window_parent) { - QDir d(dir); - return new opentrack_ctx(d); + return new opentrack_ctx(argc, argv, window_parent); } void opentrack_finalize_ctx(opentrack foo) diff --git a/opentrack-api/opentrack-guts.h b/opentrack-api/opentrack-guts.h index b9c3878b..fd94ea34 100644 --- a/opentrack-api/opentrack-guts.h +++ b/opentrack-api/opentrack-guts.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include @@ -8,33 +9,39 @@ #include #include #include +#include #include "ftnoir_tracker_base/ftnoir_tracker_base.h" #include "facetracknoir/global-settings.h" +#include typedef ITracker* opentrack_tracker; class opentrack_meta { public: - Metadata* meta; QString path; - DynamicLibrary* lib; + std::shared_ptr lib; - opentrack_meta(Metadata* meta, QString& path, DynamicLibrary* lib) : - meta(meta), path(path), lib(lib) + opentrack_meta(QString& path, DynamicLibrary* lib) : + path(path), lib(lib) {} - ~opentrack_meta() +}; + +class MyFrame : public QFrame { + Q_OBJECT +public: + MyFrame(void* parent) { - delete meta; - delete lib; + create((WId) parent); } + explicit MyFrame() {} }; typedef class opentrack_ctx { public: - QDir dir; + QApplication app; char** list; QList meta_list; - QFrame fake_frame; - opentrack_ctx(QDir& dir); + MyFrame fake_frame; + opentrack_ctx(int argc, char** argv, void* window_parent); ~opentrack_ctx(); } *opentrack; diff --git a/opentrack-api/opentrack.h b/opentrack-api/opentrack.h index 1c8fcee5..63136abc 100644 --- a/opentrack-api/opentrack.h +++ b/opentrack-api/opentrack.h @@ -6,9 +6,9 @@ extern "C" { #ifndef IN_OPENTRACK /* opaque pointers, forward definitions */ struct opentrack_opaque_ctx; -typedef opentrack_opaque_ctx* opentrack; +typedef struct opentrack_opaque_ctx* opentrack; struct opentrack_opaque_tracker; -typedef opentrack_opaque_tracker* opentrack_tracker; +typedef struct opentrack_opaque_tracker* opentrack_tracker; #endif #ifdef IN_OPENTRACK @@ -42,7 +42,7 @@ enum opentrack_dof { }; #endif -opentrack opentrack_make_ctx(const char* dir); +opentrack opentrack_make_ctx(int argc, char** argv, void* window_parent); void opentrack_finalize_ctx(opentrack self); /* no need to free the return value; invalid to modify it */ diff --git a/opentrack-api/trackers.cpp b/opentrack-api/trackers.cpp index 2527017b..0f698e4c 100644 --- a/opentrack-api/trackers.cpp +++ b/opentrack-api/trackers.cpp @@ -5,13 +5,12 @@ extern "C" { opentrack_tracker OPENTRACK_EXPORT opentrack_make_tracker(opentrack ctx, const char* name) { - QString n(name); for (int i = 0; i < ctx->meta_list.size(); i++) { - auto meta = ctx->meta_list[i]; + auto meta = ctx->meta_list.at(i); if (ctx->meta_list.at(i).path == name) { - ITracker* foo = reinterpret_cast(meta.lib->Constructor()); + ITracker* foo = static_cast(meta.lib->Constructor()); return foo; } } @@ -32,7 +31,9 @@ void OPENTRACK_EXPORT opentrack_tracker_start(opentrack self, opentrack_tracker int OPENTRACK_EXPORT opentrack_tracker_tick(opentrack_tracker tracker, double* headpose) { - return tracker->GiveHeadPoseData(headpose); + int ret = tracker->GiveHeadPoseData(headpose); + QApplication::processEvents(0, 5); + return ret; } } -- cgit v1.2.3 From 1882ed8c0dfacf9994201e6ca99635d067d32e46 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 31 Oct 2013 17:10:11 +0100 Subject: api: add a mode where video frame isn't visible at all Signed-off-by: Stanislaw Halik --- opentrack-api/opentrack-guts.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'opentrack-api/opentrack-guts.h') diff --git a/opentrack-api/opentrack-guts.h b/opentrack-api/opentrack-guts.h index fd94ea34..db897edc 100644 --- a/opentrack-api/opentrack-guts.h +++ b/opentrack-api/opentrack-guts.h @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -31,7 +32,15 @@ class MyFrame : public QFrame { public: MyFrame(void* parent) { - create((WId) parent); + if (parent == (void*) -1) + { + show(); + setVisible(false); + } + else + { + create((WId) parent); + } } explicit MyFrame() {} }; -- cgit v1.2.3 From 4e8de273fe765a8a3fedaebd654cb74752bc4663 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 31 Oct 2013 17:18:36 +0100 Subject: api: prevent focus lossage, hopefully --- opentrack-api/opentrack-guts.h | 1 + 1 file changed, 1 insertion(+) (limited to 'opentrack-api/opentrack-guts.h') diff --git a/opentrack-api/opentrack-guts.h b/opentrack-api/opentrack-guts.h index db897edc..c8e3309a 100644 --- a/opentrack-api/opentrack-guts.h +++ b/opentrack-api/opentrack-guts.h @@ -36,6 +36,7 @@ public: { show(); setVisible(false); + hide(); } else { -- cgit v1.2.3