|
| 1 | +--- a/src/wpeframework/renderer-backend.cpp |
| 2 | ++++ b/src/wpeframework/renderer-backend.cpp |
| 3 | +@@ -34,6 +34,17 @@ |
| 4 | + #include <string> |
| 5 | + #include <string.h> |
| 6 | + |
| 7 | ++#ifdef __cplusplus |
| 8 | ++extern "C" { |
| 9 | ++#endif |
| 10 | ++#ifndef _GNU_SOURCE |
| 11 | ++#define _GNU_SOURCE |
| 12 | ++#endif |
| 13 | ++#include <dlfcn.h> |
| 14 | ++#ifdef __cplusplus |
| 15 | ++} |
| 16 | ++#endif |
| 17 | ++ |
| 18 | + namespace WPEFramework { |
| 19 | + |
| 20 | + struct EGLTarget : public IPC::Client::Handler { |
| 21 | +@@ -179,10 +190,100 @@ |
| 22 | + // frame_will_render |
| 23 | + [](void* data) |
| 24 | + { |
| 25 | ++ constexpr char const * const _lib = "libcompositorclient.so"; |
| 26 | ++ |
| 27 | ++ { |
| 28 | ++ constexpr char const * const _func = "WillRenderEGLTargetFor"; |
| 29 | ++ |
| 30 | ++ void * _sym = dlsym (RTLD_NEXT, _func); |
| 31 | ++ |
| 32 | ++ if (_sym != nullptr && data != nullptr) { |
| 33 | ++ Dl_info _info; |
| 34 | ++ |
| 35 | ++ /* char * */dlerror (); |
| 36 | ++ |
| 37 | ++ if (dladdr (_sym, &_info) == 0) { |
| 38 | ++ // Error |
| 39 | ++ fprintf (stderr, "Unable to verify %s exist in %s.\n", _func, _lib); |
| 40 | ++ } |
| 41 | ++ else { |
| 42 | ++ std::string _str (_info.dli_fname); |
| 43 | ++ |
| 44 | ++ if (_str.rfind(_lib) != std::string::npos) { |
| 45 | ++ // Found in library _lib |
| 46 | ++ |
| 47 | ++ reinterpret_cast < bool (*) (EGLNativeWindowType) > (_sym) ( static_cast < WPEFramework::EGLTarget* > (data) -> Native() ); |
| 48 | ++ } |
| 49 | ++ else { |
| 50 | ++ // Different library |
| 51 | ++ fprintf (stderr, "%s not found in %s.\n", _func, _lib); |
| 52 | ++ } |
| 53 | ++ } |
| 54 | ++ } |
| 55 | ++ } |
| 56 | ++ |
| 57 | ++ { |
| 58 | ++ constexpr char const * const _func = "SetEGLTarget"; |
| 59 | ++ |
| 60 | ++ void * _sym = dlsym (RTLD_NEXT, _func); |
| 61 | ++ |
| 62 | ++ if (_sym != nullptr && data != nullptr) { |
| 63 | ++ Dl_info _info; |
| 64 | ++ |
| 65 | ++ /* char * */dlerror (); |
| 66 | ++ |
| 67 | ++ if (dladdr (_sym, &_info) == 0) { |
| 68 | ++ // Error |
| 69 | ++ fprintf (stderr, "Unable to verify %s exist in %s.\n", _func, _lib); |
| 70 | ++ } |
| 71 | ++ else { |
| 72 | ++ std::string _str (_info.dli_fname); |
| 73 | ++ |
| 74 | ++ if (_str.rfind(_lib) != std::string::npos) { |
| 75 | ++ // Found in library _lib |
| 76 | ++ |
| 77 | ++ reinterpret_cast < bool (*) () > (_sym) (); |
| 78 | ++ } |
| 79 | ++ else { |
| 80 | ++ // Different library |
| 81 | ++ fprintf (stderr, "%s not found in %s.\n", _func, _lib); |
| 82 | ++ } |
| 83 | ++ } |
| 84 | ++ } |
| 85 | ++ } |
| 86 | + }, |
| 87 | + // frame_rendered |
| 88 | + [](void* data) |
| 89 | + { |
| 90 | ++ constexpr char const * const _lib = "libcompositorclient.so"; |
| 91 | ++ constexpr char const * const _func = "RenderedEGLTarget"; |
| 92 | ++ |
| 93 | ++ void * _sym = dlsym (RTLD_NEXT, _func); |
| 94 | ++ |
| 95 | ++ if (_sym != nullptr && data != nullptr) { |
| 96 | ++ Dl_info _info; |
| 97 | ++ |
| 98 | ++ /* char * */dlerror (); |
| 99 | ++ |
| 100 | ++ if (dladdr (_sym, &_info) == 0) { |
| 101 | ++ // Error |
| 102 | ++ fprintf (stderr, "Unable to verify %s exist in %s.\n", _func, _lib); |
| 103 | ++ } |
| 104 | ++ else { |
| 105 | ++ std::string _str (_info.dli_fname); |
| 106 | ++ |
| 107 | ++ if (_str.rfind(_lib) != std::string::npos) { |
| 108 | ++ // Found in library _lib |
| 109 | ++ |
| 110 | ++ reinterpret_cast < bool (*) () > (_sym) (); |
| 111 | ++ } |
| 112 | ++ else { |
| 113 | ++ // Different library |
| 114 | ++ fprintf (stderr, "%s not found in %s.\n", _func, _lib); |
| 115 | ++ } |
| 116 | ++ } |
| 117 | ++ } |
| 118 | ++ |
| 119 | + WPEFramework::EGLTarget& target (*static_cast<WPEFramework::EGLTarget*>(data)); |
| 120 | + |
| 121 | + /* bool */ target.display.vSyncCallback (); |
0 commit comments