1 extern "C" { 2 #include "host-common/goldfish_pipe.h" 3 #include "virtio-gpu-gfxstream-renderer.h" 4 #include "virgl_hw.h" 5 } // extern "C" 6 7 enum BackendFlags { 8 GFXSTREAM_BACKEND_FLAGS_NO_VK_BIT = 1 << 0, 9 GFXSTREAM_BACKEND_FLAGS_EGL2EGL_BIT = 1 << 1, 10 }; 11 12 struct gfxstream_callbacks { 13 /* Metrics callbacks */ 14 void (*add_instant_event)(int64_t event_code); 15 void (*add_instant_event_with_descriptor)(int64_t event_code, int64_t descriptor); 16 void (*add_instant_event_with_metric)(int64_t event_code, int64_t metric_value); 17 void (*set_annotation)(const char* key, const char* value); 18 void (*abort)(); 19 }; 20 21 extern "C" VG_EXPORT void gfxstream_backend_init( 22 uint32_t display_width, 23 uint32_t display_height, 24 uint32_t display_type, 25 void* renderer_cookie, 26 int renderer_flags, 27 struct virgl_renderer_callbacks* virglrenderer_callbacks, 28 struct gfxstream_callbacks* gfxstreamcallbacks); 29 30 extern "C" VG_EXPORT void gfxstream_backend_setup_window( 31 void* native_window_handle, 32 int32_t window_x, 33 int32_t window_y, 34 int32_t window_width, 35 int32_t window_height, 36 int32_t fb_width, 37 int32_t fb_height); 38 39 extern "C" VG_EXPORT void gfxstream_backend_teardown(void); 40 41 // Get the gfxstream backend render information. 42 // example: 43 // /* Get the render string size */ 44 // size_t size = 0 45 // gfxstream_backend_getrender(nullptr, 0, &size); 46 // 47 // /* add extra space for '\0' */ 48 // char * buf = malloc(size + 1); 49 // 50 // /* Get the result render string */ 51 // gfxstream_backend_getrender(buf, size+1, nullptr); 52 // 53 // if bufSize is less or equal the render string length, only bufSize-1 char copied. 54 extern "C" VG_EXPORT void gfxstream_backend_getrender( 55 char* buf, 56 size_t bufSize, 57 size_t* size); 58