src/ascension/context.h

changeset 66
8297afa1c29c
parent 65
9c44c55d327a
     1.1 --- a/src/ascension/context.h	Thu Apr 18 22:53:55 2024 +0200
     1.2 +++ b/src/ascension/context.h	Fri Apr 19 22:28:29 2024 +0200
     1.3 @@ -52,11 +52,9 @@
     1.4      CxBuffer error_buffer;
     1.5      AscInput input;
     1.6      AscWindow windows[ASC_MAX_WINDOWS];
     1.7 -    // TODO: rework how fonts are cached
     1.8 -    AscFont fonts[ASC_MAX_FONTS];
     1.9 +    AscFont active_font;
    1.10      unsigned char fonts_loaded;
    1.11      unsigned char active_window;
    1.12 -    unsigned char active_font;
    1.13      asc_col4i ink;
    1.14      uint64_t frame_nanos;
    1.15      uint64_t total_nanos;
    1.16 @@ -69,24 +67,23 @@
    1.17   * The currently active font.
    1.18   * @see asc_font()
    1.19   */
    1.20 -#define asc_active_font \
    1.21 -    (&asc_context.fonts[asc_context.active_font])
    1.22 +#define asc_active_font asc_context.active_font
    1.23  
    1.24 +#ifdef NDEBUG
    1.25  /**
    1.26   * The currently active window in the context.
    1.27   * @see asc_window_activate()
    1.28   */
    1.29  #define asc_active_window \
    1.30      (&asc_context.windows[asc_context.active_window])
    1.31 -
    1.32 -static inline bool asc_assert_active_window() {
    1.33 -    if (asc_context.active_window < ASC_MAX_WINDOWS) {
    1.34 -        return true;
    1.35 -    } else {
    1.36 -        asc_error("A graphics operation was performed without active window");
    1.37 -        return false;
    1.38 -    }
    1.39 -}
    1.40 +#else
    1.41 +/**
    1.42 + * The currently active window in the context.
    1.43 + * @see asc_window_activate()
    1.44 + */
    1.45 +#define asc_active_window asc_active_window_assert()
    1.46 +AscWindow *asc_active_window_assert(void);
    1.47 +#endif // NDEBUG
    1.48  
    1.49  void asc_context_initialize(void);
    1.50  void asc_context_destroy(void);

mercurial