Skip to content

Commit

Permalink
Split context in software & hardware contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeclerck authored Mar 22, 2023
1 parent 0a47246 commit 381484b
Show file tree
Hide file tree
Showing 30 changed files with 2,199 additions and 575 deletions.
15 changes: 10 additions & 5 deletions src/configure.ml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,16 @@ let () =
(foreign_stubs
(language c)
(names config util unicode point rect list hashtable event
gdi_keyboard gdi_backend gdi_target gdi_window gdi_context
qtz_keyboard qtz_backend qtz_target qtz_window qtz_context
x11_keysym x11_keyboard x11_backend x11_target x11_window x11_context
wl_backend wl_target wl_window wl_context
window pixmap image_interpolation filters context transform draw_instr
gdi_keyboard gdi_backend gdi_target gdi_window
gdi_sw_context gdi_hw_context
qtz_keyboard qtz_backend qtz_target qtz_window
qtz_sw_context qtz_hw_context
x11_keysym x11_keyboard x11_backend x11_target x11_window
x11_sw_context x11_hw_context
wl_backend wl_target wl_window
wl_sw_context wl_hw_context
window pixmap image_interpolation filters transform draw_instr
sw_context hw_context context
font_desc gdi_font qtz_font unx_font font
gdi_impexp qtz_impexp unx_impexp impexp
path arc path2d polygon polygonize
Expand Down
15 changes: 10 additions & 5 deletions src/dune.inc
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@
(foreign_stubs
(language c)
(names config util unicode point rect list hashtable event
gdi_keyboard gdi_backend gdi_target gdi_window gdi_context
qtz_keyboard qtz_backend qtz_target qtz_window qtz_context
x11_keysym x11_keyboard x11_backend x11_target x11_window x11_context
wl_backend wl_target wl_window wl_context
window pixmap image_interpolation filters context transform draw_instr
gdi_keyboard gdi_backend gdi_target gdi_window
gdi_sw_context gdi_hw_context
qtz_keyboard qtz_backend qtz_target qtz_window
qtz_sw_context qtz_hw_context
x11_keysym x11_keyboard x11_backend x11_target x11_window
x11_sw_context x11_hw_context
wl_backend wl_target wl_window
wl_sw_context wl_hw_context
window pixmap image_interpolation filters transform draw_instr
sw_context hw_context context
font_desc gdi_font qtz_font unx_font font
gdi_impexp qtz_impexp unx_impexp impexp
path arc path2d polygon polygonize
Expand Down
22 changes: 16 additions & 6 deletions src/implem/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@
/* */
/**************************************************************************/

#include <stdbool.h>
#include <assert.h>

#include "config.h"

static impl_type_t impl_type = IMPL_NONE;
static impl_type_t
_impl_type = IMPL_NONE;

void
set_impl_type(
impl_type_t it)
{
assert(it != IMPL_CANVAS);
#ifndef HAS_GDI
assert(it != IMPL_GDI);
#endif
Expand All @@ -31,17 +32,26 @@ set_impl_type(
#ifndef HAS_WAYLAND
assert(it != IMPL_WAYLAND);
#endif
impl_type = it;
_impl_type = it;
}

impl_type_t
get_impl_type()
get_impl_type(
void)
{
return impl_type;
return _impl_type;
}

bool
has_hardware_accel(
void)
{
return false;
}

os_type_t
get_os_type()
get_os_type(
void)
{
#if defined(_WIN32) || defined(_WIN64)
return OS_WIN32;
Expand Down
36 changes: 28 additions & 8 deletions src/implem/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ typedef enum os_type_t {

typedef enum impl_type_t {
IMPL_NONE = 0,
IMPL_CANVAS = 1,
IMPL_GDI = 2,
IMPL_QUARTZ = 3,
IMPL_X11 = 4,
IMPL_WAYLAND = 5
IMPL_GDI = 1,
IMPL_QUARTZ = 2,
IMPL_X11 = 3,
IMPL_WAYLAND = 4
} impl_type_t;

#define switch_IMPL() switch (get_impl_type())
Expand Down Expand Up @@ -59,9 +58,30 @@ typedef enum impl_type_t {
#define default_fail() default: assert(!"Missing implementation"); break
#define default_ignore() default: break

void set_impl_type(impl_type_t it);
impl_type_t get_impl_type();
#ifdef HAS_ACCEL
#define switch_ACCEL() switch (has_hardware_accel())
#define case_HW(s) case true: { s; } break
#define case_SW(s) case false: { s; } break
#else
#define switch_ACCEL()
#define case_HW(s)
#define case_SW(s) s
#endif

void
set_impl_type(
impl_type_t it);

impl_type_t
get_impl_type(
void);

bool
has_hardware_accel(
void);

os_type_t get_os_type();
os_type_t
get_os_type(
void);

#endif /* __CONFIG_H */
Loading

0 comments on commit 381484b

Please sign in to comment.