Introduce a new approach that discriminate coordinates in points and pixels. Now all the logic from the Lua side and in rencache is to always use points. The coordinates are converted to pixels only within the renderer, in the file renderer.c. In this way the application logic does not need to care about the scaling of the retina displays. For non-retina display the scaling between points and pixels is equal to one so nothing will change. There is nevertheless a change that leak into the Lua side. The subpixel coordinates are in sub-pixel, not sub-points so they are scaled by the retina scaling factor. But no change in the code is required because the subpixel scaling factor take into account the retina scaling, when present. Because the retina scaling factor is not know when the application starts but only when a window is actually available we introduce a mechanism to render the font with a given scaling factor only from the renderer when they are needed. We use therefore FontDesc to describe the font information but without actually rasterizing the font at a given scale.
18 lines
540 B
C
18 lines
540 B
C
#ifndef RENCACHE_H
|
|
#define RENCACHE_H
|
|
|
|
#include <stdbool.h>
|
|
#include "renderer.h"
|
|
|
|
void rencache_show_debug(bool enable);
|
|
void rencache_free_font(FontDesc *font_desc);
|
|
void rencache_set_clip_rect(RenRect rect);
|
|
void rencache_draw_rect(RenRect rect, RenColor color);
|
|
int rencache_draw_text(FontDesc *font_desc, const char *text, int x, int y, RenColor color,
|
|
bool draw_subpixel, CPReplaceTable *replacements, RenColor replace_color);
|
|
void rencache_invalidate(void);
|
|
void rencache_begin_frame(void);
|
|
void rencache_end_frame(void);
|
|
|
|
#endif
|