Skip to content

Commit

Permalink
[le_font_renderer] refactor le_resource
Browse files Browse the repository at this point in the history
update `font_renderer` to work with new le_img_resource_handle
  • Loading branch information
tgfrerer committed May 27, 2021
1 parent 23091aa commit 094e619
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
20 changes: 10 additions & 10 deletions modules/le_font_renderer/le_font_renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
#include "glm/vec4.hpp"

struct font_info_t {
le_font_o * font; // non-owning
le_resource_handle_t font_image;
le_resource_info_t font_atlas_info;
le_texture_handle font_image_sampler;
bool atlas_uploaded;
bool sampler_created;
le_font_o * font; // non-owning
le_img_resource_handle font_image;
le_resource_info_t font_atlas_info;
le_texture_handle font_image_sampler;
bool atlas_uploaded;
bool sampler_created;
};

struct le_font_renderer_o {
Expand Down Expand Up @@ -98,21 +98,21 @@ le_texture_handle le_font_renderer_get_font_image_sampler( le_font_renderer_o *s
}
}

// ----------| invariant: Image sampler has not been found, otherwise we'd have returned early.
// ----------| Invariant: Font has not been found, otherwise we'd have returned early.

return nullptr;
}

// ----------------------------------------------------------------------
le_resource_handle_t *le_font_renderer_get_font_image( le_font_renderer_o *self, le_font_o *font ) {
le_img_resource_handle le_font_renderer_get_font_image( le_font_renderer_o *self, le_font_o *font ) {

for ( auto &f : self->fonts_info ) {
if ( f.font == font ) {
return &f.font_image;
return f.font_image;
}
}

// ----------| invariant: Image sampler has not been found, otherwise we'd have returned early.
// ----------| Invariant: Font has not been found, otherwise we'd have returned early.

return nullptr;
}
Expand Down
9 changes: 5 additions & 4 deletions modules/le_font_renderer/le_font_renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ struct le_renderer_o;
struct le_render_module_o;
struct le_renderpass_o;
struct le_command_buffer_encoder_o;
struct le_resource_handle_t;
struct le_texture_handle_t;

LE_OPAQUE_HANDLE( le_img_resource_handle );
LE_OPAQUE_HANDLE( le_texture_handle );

// clang-format off
struct le_font_renderer_api {
Expand Down Expand Up @@ -39,8 +40,8 @@ struct le_font_renderer_api {

bool (*draw_string)( le_font_renderer_o* self, le_font_o* font, le_command_buffer_encoder_o* encoder, draw_string_info_t & info );

le_texture_handle_t * (* get_font_image_sampler )( le_font_renderer_o* self, le_font_o* font );
le_resource_handle_t * (* get_font_image )( le_font_renderer_o* self, le_font_o* font );
le_texture_handle (* get_font_image_sampler )( le_font_renderer_o* self, le_font_o* font );
le_img_resource_handle (* get_font_image )( le_font_renderer_o* self, le_font_o* font );

};

Expand Down

0 comments on commit 094e619

Please sign in to comment.