2023-02-01 15:23:51 +00:00
|
|
|
/************************************************************//**
|
|
|
|
*
|
|
|
|
* @file: graphics_internal.h
|
|
|
|
* @author: Martin Fouilleul
|
|
|
|
* @date: 23/01/2023
|
|
|
|
* @revision:
|
|
|
|
*
|
|
|
|
*****************************************************************/
|
|
|
|
#ifndef __GRAPHICS_INTERNAL_H_
|
|
|
|
#define __GRAPHICS_INTERNAL_H_
|
|
|
|
|
|
|
|
#include"graphics.h"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2023-02-20 15:49:44 +00:00
|
|
|
//---------------------------------------------------------------
|
2023-02-25 14:23:15 +00:00
|
|
|
// surface interface
|
2023-02-20 15:49:44 +00:00
|
|
|
//---------------------------------------------------------------
|
2023-02-01 15:23:51 +00:00
|
|
|
typedef struct mg_surface_data mg_surface_data;
|
|
|
|
|
|
|
|
typedef void (*mg_surface_destroy_proc)(mg_surface_data* surface);
|
|
|
|
typedef void (*mg_surface_prepare_proc)(mg_surface_data* surface);
|
|
|
|
typedef void (*mg_surface_present_proc)(mg_surface_data* surface);
|
2023-02-08 10:49:00 +00:00
|
|
|
typedef void (*mg_surface_swap_interval_proc)(mg_surface_data* surface, int swap);
|
2023-02-08 17:22:54 +00:00
|
|
|
typedef vec2 (*mg_surface_contents_scaling_proc)(mg_surface_data* surface);
|
2023-02-01 15:23:51 +00:00
|
|
|
typedef mp_rect (*mg_surface_get_frame_proc)(mg_surface_data* surface);
|
|
|
|
typedef void (*mg_surface_set_frame_proc)(mg_surface_data* surface, mp_rect frame);
|
|
|
|
typedef bool (*mg_surface_get_hidden_proc)(mg_surface_data* surface);
|
|
|
|
typedef void (*mg_surface_set_hidden_proc)(mg_surface_data* surface, bool hidden);
|
|
|
|
|
|
|
|
typedef struct mg_surface_data
|
|
|
|
{
|
|
|
|
mg_backend_id backend;
|
|
|
|
|
|
|
|
mg_surface_destroy_proc destroy;
|
|
|
|
mg_surface_prepare_proc prepare;
|
|
|
|
mg_surface_present_proc present;
|
2023-02-08 10:49:00 +00:00
|
|
|
mg_surface_swap_interval_proc swapInterval;
|
2023-02-08 17:22:54 +00:00
|
|
|
mg_surface_contents_scaling_proc contentsScaling;
|
2023-02-01 15:23:51 +00:00
|
|
|
mg_surface_get_frame_proc getFrame;
|
|
|
|
mg_surface_set_frame_proc setFrame;
|
|
|
|
mg_surface_get_hidden_proc getHidden;
|
|
|
|
mg_surface_set_hidden_proc setHidden;
|
|
|
|
|
|
|
|
} mg_surface_data;
|
|
|
|
|
|
|
|
mg_surface mg_surface_alloc_handle(mg_surface_data* surface);
|
|
|
|
mg_surface_data* mg_surface_data_from_handle(mg_surface handle);
|
|
|
|
|
|
|
|
//---------------------------------------------------------------
|
2023-02-25 14:23:15 +00:00
|
|
|
// canvas backend interface
|
2023-02-01 15:23:51 +00:00
|
|
|
//---------------------------------------------------------------
|
|
|
|
typedef struct mg_image_data
|
|
|
|
{
|
|
|
|
list_elt listElt;
|
|
|
|
u32 generation;
|
2023-02-23 16:07:41 +00:00
|
|
|
vec2 size;
|
2023-02-01 15:23:51 +00:00
|
|
|
|
|
|
|
} mg_image_data;
|
|
|
|
|
|
|
|
typedef struct mg_vertex_layout
|
|
|
|
{
|
|
|
|
u32 maxVertexCount;
|
|
|
|
u32 maxIndexCount;
|
|
|
|
|
|
|
|
char* posBuffer;
|
|
|
|
u32 posStride;
|
|
|
|
|
|
|
|
char* cubicBuffer;
|
|
|
|
u32 cubicStride;
|
|
|
|
|
2023-02-24 17:50:46 +00:00
|
|
|
char* uvTransformBuffer;
|
|
|
|
u32 uvTransformStride;
|
2023-02-01 15:23:51 +00:00
|
|
|
|
|
|
|
char* colorBuffer;
|
|
|
|
u32 colorStride;
|
|
|
|
|
2023-02-09 15:14:15 +00:00
|
|
|
char* shapeIndexBuffer;
|
|
|
|
u32 shapeIndexStride;
|
2023-02-01 15:23:51 +00:00
|
|
|
|
|
|
|
char* clipBuffer;
|
|
|
|
u32 clipStride;
|
|
|
|
|
|
|
|
char* indexBuffer;
|
|
|
|
u32 indexStride;
|
|
|
|
|
|
|
|
} mg_vertex_layout;
|
|
|
|
|
|
|
|
typedef struct mg_canvas_backend mg_canvas_backend;
|
|
|
|
|
|
|
|
typedef void (*mg_canvas_backend_destroy_proc)(mg_canvas_backend* backend);
|
2023-02-02 17:57:57 +00:00
|
|
|
typedef void (*mg_canvas_backend_begin_proc)(mg_canvas_backend* backend);
|
|
|
|
typedef void (*mg_canvas_backend_end_proc)(mg_canvas_backend* backend);
|
|
|
|
typedef void (*mg_canvas_backend_clear_proc)(mg_canvas_backend* backend, mg_color clearColor);
|
2023-02-27 18:25:41 +00:00
|
|
|
typedef void (*mg_canvas_backend_draw_batch_proc)(mg_canvas_backend* backend,
|
|
|
|
mg_image_data* imageData,
|
|
|
|
u32 vertexCount,
|
|
|
|
u32 shapeCount,
|
|
|
|
u32 indexCount);
|
2023-02-23 16:07:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
typedef mg_image_data* (*mg_canvas_backend_image_create_proc)(mg_canvas_backend* backend, vec2 size);
|
|
|
|
typedef void (*mg_canvas_backend_image_destroy_proc)(mg_canvas_backend* backend, mg_image_data* image);
|
2023-02-27 18:25:41 +00:00
|
|
|
typedef void (*mg_canvas_backend_image_upload_region_proc)(mg_canvas_backend* backend,
|
|
|
|
mg_image_data* image,
|
|
|
|
mp_rect region,
|
|
|
|
u8* pixels);
|
2023-02-01 15:23:51 +00:00
|
|
|
|
|
|
|
typedef struct mg_canvas_backend
|
|
|
|
{
|
|
|
|
mg_vertex_layout vertexLayout;
|
|
|
|
|
|
|
|
mg_canvas_backend_destroy_proc destroy;
|
2023-02-02 17:57:57 +00:00
|
|
|
mg_canvas_backend_begin_proc begin;
|
|
|
|
mg_canvas_backend_end_proc end;
|
|
|
|
mg_canvas_backend_clear_proc clear;
|
|
|
|
mg_canvas_backend_draw_batch_proc drawBatch;
|
2023-02-01 15:23:51 +00:00
|
|
|
|
2023-02-23 16:07:41 +00:00
|
|
|
mg_canvas_backend_image_create_proc imageCreate;
|
|
|
|
mg_canvas_backend_image_destroy_proc imageDestroy;
|
|
|
|
mg_canvas_backend_image_upload_region_proc imageUploadRegion;
|
|
|
|
} mg_canvas_backend;
|
2023-02-01 15:23:51 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
} // extern "C"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif //__GRAPHICS_INTERNAL_H_
|