diff --git a/src/app/app.h b/src/app/app.h index 55ff91f..367f116 100644 --- a/src/app/app.h +++ b/src/app/app.h @@ -316,9 +316,6 @@ ORCA_API void oc_set_cursor(oc_mouse_cursor cursor); ORCA_API void oc_pump_events(f64 timeout); ORCA_API oc_event* oc_next_event(oc_arena* arena); -typedef void (*oc_live_resize_callback)(oc_event event, void* data); -ORCA_API void oc_set_live_resize_callback(oc_live_resize_callback callback, void* data); - ORCA_API oc_key_code oc_scancode_to_keycode(oc_scan_code scanCode); //-------------------------------------------------------------------- diff --git a/src/app/app_internal.h b/src/app/app_internal.h index b6d0477..f3fbd48 100644 --- a/src/app/app_internal.h +++ b/src/app/app_internal.h @@ -73,9 +73,6 @@ typedef struct oc_app oc_window_data windowPool[OC_APP_MAX_WINDOWS]; oc_list windowFreeList; - oc_live_resize_callback liveResizeCallback; - void* liveResizeData; - oc_scan_code scanCodes[OC_SCANCODE_COUNT]; // native virtual key code to oc_scan_code oc_key_code keyMap[OC_SCANCODE_COUNT]; // oc_scan_code to oc_key_code, as per current keyboard layout diff --git a/src/app/osx_app.m b/src/app/osx_app.m index 3018776..fa38cb5 100644 --- a/src/app/osx_app.m +++ b/src/app/osx_app.m @@ -687,11 +687,6 @@ void oc_install_keyboard_layout_listener() event.move.content.w = contentRect.size.width; event.move.content.h = contentRect.size.height; - if(oc_appData.liveResizeCallback) - { - oc_appData.liveResizeCallback(event, oc_appData.liveResizeData); - } - //TODO: also ensure we don't overflow the queue during live resize... oc_queue_event(&event); } @@ -1874,12 +1869,6 @@ void oc_surface_init_for_window(oc_surface_data* surface, oc_window_data* window // Events handling //-------------------------------------------------------------------- -void oc_set_live_resize_callback(oc_live_resize_callback callback, void* data) -{ - oc_appData.liveResizeCallback = callback; - oc_appData.liveResizeData = data; -} - void oc_pump_events(f64 timeout) { @autoreleasepool diff --git a/src/graphics/graphics.h b/src/graphics/graphics.h index fadae40..64a854c 100644 --- a/src/graphics/graphics.h +++ b/src/graphics/graphics.h @@ -134,8 +134,6 @@ ORCA_API void oc_surface_send_to_back(oc_surface surface); //DOC: puts surface //------------------------------------------------------------------------------------------ #if !defined(OC_PLATFORM_ORCA) || !OC_PLATFORM_ORCA -typedef void (*oc_vsync_callback)(void* data); - ORCA_API void oc_vsync_init(void); ORCA_API void oc_vsync_wait(oc_window window); diff --git a/src/platform/platform_memory.h b/src/platform/platform_memory.h index b27620f..f35ba4f 100644 --- a/src/platform/platform_memory.h +++ b/src/platform/platform_memory.h @@ -1,9 +1,9 @@ -/************************************************************************* -* +/************************************************************************* +* * Orca * Copyright 2023 Martin Fouilleul and the Orca project contributors * See LICENSE.txt for licensing information -* +* **************************************************************************/ #ifndef __PLATFORM_MEMORY_H_ #define __PLATFORM_MEMORY_H_ @@ -12,28 +12,27 @@ #include "util/typedefs.h" #ifdef __cplusplus -extern "C" -{ +extern "C" { #endif - //-------------------------------------------------------------------------------- - //NOTE(martin): base allocator - //-------------------------------------------------------------------------------- - typedef struct oc_base_allocator oc_base_allocator; +//-------------------------------------------------------------------------------- +//NOTE(martin): base allocator +//-------------------------------------------------------------------------------- +typedef struct oc_base_allocator oc_base_allocator; - typedef void* (*oc_mem_reserve_function)(oc_base_allocator* context, u64 size); - typedef void (*oc_mem_modify_function)(oc_base_allocator* context, void* ptr, u64 size); +typedef void* (*oc_mem_reserve_proc)(oc_base_allocator* context, u64 size); +typedef void (*oc_mem_modify_proc)(oc_base_allocator* context, void* ptr, u64 size); - typedef struct oc_base_allocator - { - oc_mem_reserve_function reserve; - oc_mem_modify_function commit; - oc_mem_modify_function decommit; - oc_mem_modify_function release; +typedef struct oc_base_allocator +{ + oc_mem_reserve_proc reserve; + oc_mem_modify_proc commit; + oc_mem_modify_proc decommit; + oc_mem_modify_proc release; - } oc_base_allocator; +} oc_base_allocator; - ORCA_API oc_base_allocator* oc_base_allocator_default(); +ORCA_API oc_base_allocator* oc_base_allocator_default(); #define oc_base_reserve(base, size) base->reserve(base, size) #define oc_base_commit(base, ptr, size) base->commit(base, ptr, size) @@ -48,9 +47,9 @@ extern "C" #define oc_malloc_type(type) ((type*)malloc(sizeof(type))) #define oc_malloc_array(type, count) ((type*)malloc(sizeof(type) * count)) - //-------------------------------------------------------------------------------- - //NOTE(martin): memset / memcpy - //-------------------------------------------------------------------------------- +//-------------------------------------------------------------------------------- +//NOTE(martin): memset / memcpy +//-------------------------------------------------------------------------------- #include diff --git a/src/platform/platform_thread.h b/src/platform/platform_thread.h index d4b1b5a..453069e 100644 --- a/src/platform/platform_thread.h +++ b/src/platform/platform_thread.h @@ -18,74 +18,73 @@ #endif #ifdef __cplusplus -extern "C" -{ +extern "C" { #endif // __cplusplus - //--------------------------------------------------------------- - // Platform Thread API - //--------------------------------------------------------------- +//--------------------------------------------------------------- +// Platform Thread API +//--------------------------------------------------------------- - enum - { - OC_THREAD_NAME_MAX_SIZE = 64, // including null terminator - }; +enum +{ + OC_THREAD_NAME_MAX_SIZE = 64, // including null terminator +}; - typedef struct oc_thread oc_thread; +typedef struct oc_thread oc_thread; - typedef i32 (*oc_thread_start_function)(void* userPointer); +typedef i32 (*oc_thread_start_proc)(void* userPointer); - ORCA_API oc_thread* oc_thread_create(oc_thread_start_function start, void* userPointer); - ORCA_API oc_thread* oc_thread_create_with_name(oc_thread_start_function start, void* userPointer, oc_str8 name); - ORCA_API oc_str8 oc_thread_get_name(oc_thread* thread); - ORCA_API u64 oc_thread_unique_id(oc_thread* thread); - ORCA_API u64 oc_thread_self_id(); - ORCA_API int oc_thread_signal(oc_thread* thread, int sig); - ORCA_API int oc_thread_join(oc_thread* thread, i64* exitCode); - ORCA_API int oc_thread_detach(oc_thread* thread); +ORCA_API oc_thread* oc_thread_create(oc_thread_start_proc start, void* userPointer); +ORCA_API oc_thread* oc_thread_create_with_name(oc_thread_start_proc start, void* userPointer, oc_str8 name); +ORCA_API oc_str8 oc_thread_get_name(oc_thread* thread); +ORCA_API u64 oc_thread_unique_id(oc_thread* thread); +ORCA_API u64 oc_thread_self_id(); +ORCA_API int oc_thread_signal(oc_thread* thread, int sig); +ORCA_API int oc_thread_join(oc_thread* thread, i64* exitCode); +ORCA_API int oc_thread_detach(oc_thread* thread); - //--------------------------------------------------------------- - // Platform Mutex API - //--------------------------------------------------------------- +//--------------------------------------------------------------- +// Platform Mutex API +//--------------------------------------------------------------- - typedef struct oc_mutex oc_mutex; +typedef struct oc_mutex oc_mutex; - ORCA_API oc_mutex* oc_mutex_create(); - ORCA_API int oc_mutex_destroy(oc_mutex* mutex); - ORCA_API int oc_mutex_lock(oc_mutex* mutex); - ORCA_API int oc_mutex_unlock(oc_mutex* mutex); +ORCA_API oc_mutex* oc_mutex_create(); +ORCA_API int oc_mutex_destroy(oc_mutex* mutex); +ORCA_API int oc_mutex_lock(oc_mutex* mutex); +ORCA_API int oc_mutex_unlock(oc_mutex* mutex); - //--------------------------------------------------------------- - // Lightweight ticket mutex API - //--------------------------------------------------------------- +//--------------------------------------------------------------- +// Lightweight ticket mutex API +//--------------------------------------------------------------- - typedef struct oc_ticket - { - volatile _Atomic(u64) nextTicket; - volatile _Atomic(u64) serving; - } oc_ticket; +typedef struct oc_ticket +{ + volatile _Atomic(u64) nextTicket; + volatile _Atomic(u64) serving; +} oc_ticket; - ORCA_API void oc_ticket_init(oc_ticket* mutex); - ORCA_API void oc_ticket_lock(oc_ticket* mutex); - ORCA_API void oc_ticket_unlock(oc_ticket* mutex); +ORCA_API void oc_ticket_init(oc_ticket* mutex); +ORCA_API void oc_ticket_lock(oc_ticket* mutex); +ORCA_API void oc_ticket_unlock(oc_ticket* mutex); - //--------------------------------------------------------------- - // Platform condition variable API - //--------------------------------------------------------------- +//--------------------------------------------------------------- +// Platform condition variable API +//--------------------------------------------------------------- - typedef struct oc_condition oc_condition; +typedef struct oc_condition oc_condition; - ORCA_API oc_condition* oc_condition_create(); - ORCA_API int oc_condition_destroy(oc_condition* cond); - ORCA_API int oc_condition_wait(oc_condition* cond, oc_mutex* mutex); - ORCA_API int oc_condition_timedwait(oc_condition* cond, oc_mutex* mutex, f64 seconds); - ORCA_API int oc_condition_signal(oc_condition* cond); - ORCA_API int oc_condition_broadcast(oc_condition* cond); +ORCA_API oc_condition* oc_condition_create(); +ORCA_API int oc_condition_destroy(oc_condition* cond); +ORCA_API int oc_condition_wait(oc_condition* cond, oc_mutex* mutex); +ORCA_API int oc_condition_timedwait(oc_condition* cond, oc_mutex* mutex, f64 seconds); +ORCA_API int oc_condition_signal(oc_condition* cond); +ORCA_API int oc_condition_broadcast(oc_condition* cond); - //--------------------------------------------------------------- - // Putting threads to sleep - //--------------------------------------------------------------- - ORCA_API void oc_sleep_nano(u64 nanoseconds); // sleep for a given number of nanoseconds +//--------------------------------------------------------------- +// Putting threads to sleep +//--------------------------------------------------------------- +ORCA_API void oc_sleep_nano(u64 nanoseconds); // sleep for a given number of nanoseconds #ifdef __cplusplus } // extern "C" diff --git a/src/platform/posix_thread.c b/src/platform/posix_thread.c index 16e29ca..d47b2e9 100644 --- a/src/platform/posix_thread.c +++ b/src/platform/posix_thread.c @@ -18,7 +18,7 @@ struct oc_thread { bool valid; pthread_t pthread; - oc_thread_start_function start; + oc_thread_start_proc start; void* userPointer; oc_str8 name; char nameBuffer[OC_THREAD_NAME_MAX_SIZE]; @@ -35,7 +35,7 @@ static void* oc_thread_bootstrap(void* data) return ((void*)(ptrdiff_t)exitCode); } -oc_thread* oc_thread_create_with_name(oc_thread_start_function start, void* userPointer, oc_str8 name) +oc_thread* oc_thread_create_with_name(oc_thread_start_proc start, void* userPointer, oc_str8 name) { oc_thread* thread = (oc_thread*)malloc(sizeof(oc_thread)); if(!thread) @@ -69,7 +69,7 @@ oc_thread* oc_thread_create_with_name(oc_thread_start_function start, void* user } } -oc_thread* oc_thread_create(oc_thread_start_function start, void* userPointer) +oc_thread* oc_thread_create(oc_thread_start_proc start, void* userPointer) { return (oc_thread_create_with_name(start, userPointer, (oc_str8){ 0 })); } diff --git a/src/platform/win32_thread.c b/src/platform/win32_thread.c index 59ed947..adf885c 100644 --- a/src/platform/win32_thread.c +++ b/src/platform/win32_thread.c @@ -5,7 +5,7 @@ * See LICENSE.txt for licensing information * **************************************************************************/ -#include //INFINITY +#include //INFINITY #include #include #include // PostMessage @@ -14,7 +14,7 @@ struct oc_thread { - oc_thread_start_function start; + oc_thread_start_proc start; HANDLE handle; DWORD threadId; void* userPointer; @@ -29,7 +29,7 @@ static DWORD WINAPI oc_thread_bootstrap(LPVOID lpParameter) return (exitCode); } -oc_thread* oc_thread_create_with_name(oc_thread_start_function start, void* userPointer, oc_str8 name) +oc_thread* oc_thread_create_with_name(oc_thread_start_proc start, void* userPointer, oc_str8 name) { oc_thread* thread = (oc_thread*)malloc(sizeof(oc_thread)); thread->start = start; @@ -75,7 +75,7 @@ oc_thread* oc_thread_create_with_name(oc_thread_start_function start, void* user return (thread); } -oc_thread* oc_thread_create(oc_thread_start_function start, void* userPointer) +oc_thread* oc_thread_create(oc_thread_start_proc start, void* userPointer) { return (oc_thread_create_with_name(start, userPointer, (oc_str8){ 0 })); }