2023-03-28 11:09:48 +00:00
|
|
|
/************************************************************//**
|
|
|
|
*
|
|
|
|
* @file: mtl_renderer.h
|
|
|
|
* @author: Martin Fouilleul
|
|
|
|
* @date: 01/08/2022
|
|
|
|
* @revision:
|
|
|
|
*
|
|
|
|
*****************************************************************/
|
|
|
|
#ifndef __MTL_RENDERER_H_
|
|
|
|
#define __MTL_RENDERER_H_
|
|
|
|
|
|
|
|
#include<simd/simd.h>
|
|
|
|
|
|
|
|
typedef enum {
|
2023-03-28 15:58:23 +00:00
|
|
|
MG_MTL_FILL,
|
2023-04-04 17:02:53 +00:00
|
|
|
MG_MTL_STROKE,
|
2023-03-28 15:58:23 +00:00
|
|
|
} mg_mtl_cmd;
|
2023-03-28 11:09:48 +00:00
|
|
|
|
2023-03-28 15:58:23 +00:00
|
|
|
typedef struct mg_mtl_path
|
|
|
|
{
|
|
|
|
mg_mtl_cmd cmd;
|
|
|
|
vector_float4 color;
|
|
|
|
vector_float4 box;
|
|
|
|
|
|
|
|
} mg_mtl_path;
|
2023-03-28 11:09:48 +00:00
|
|
|
|
|
|
|
typedef enum {
|
2023-03-28 15:58:23 +00:00
|
|
|
MG_MTL_LINE = 1,
|
2023-03-30 13:58:46 +00:00
|
|
|
MG_MTL_QUADRATIC,
|
|
|
|
MG_MTL_CUBIC,
|
2023-03-28 15:58:23 +00:00
|
|
|
} mg_mtl_seg_kind;
|
2023-03-28 11:09:48 +00:00
|
|
|
|
|
|
|
typedef struct mg_mtl_path_elt
|
|
|
|
{
|
|
|
|
int pathIndex;
|
2023-04-07 08:15:37 +00:00
|
|
|
int localEltIndex;
|
2023-03-28 11:09:48 +00:00
|
|
|
mg_mtl_seg_kind kind;
|
|
|
|
vector_float2 p[4];
|
|
|
|
} mg_mtl_path_elt;
|
|
|
|
|
2023-03-28 15:58:23 +00:00
|
|
|
typedef enum {
|
|
|
|
MG_MTL_BL, // curve on bottom left
|
|
|
|
MG_MTL_BR, // curve on bottom right
|
|
|
|
MG_MTL_TL, // curve on top left
|
|
|
|
MG_MTL_TR // curve on top right
|
|
|
|
} mg_mtl_seg_config;
|
|
|
|
|
2023-03-28 11:09:48 +00:00
|
|
|
typedef struct mg_mtl_segment
|
|
|
|
{
|
2023-03-30 13:58:46 +00:00
|
|
|
mg_mtl_seg_kind kind;
|
2023-03-28 11:09:48 +00:00
|
|
|
int pathIndex;
|
|
|
|
mg_mtl_seg_config config; //TODO pack these
|
|
|
|
int windingIncrement;
|
|
|
|
vector_float4 box;
|
2023-04-07 08:15:37 +00:00
|
|
|
matrix_float3x3 hullMatrix;
|
2023-03-30 13:58:46 +00:00
|
|
|
matrix_float3x3 implicitMatrix;
|
2023-04-07 15:17:55 +00:00
|
|
|
float sign;
|
|
|
|
vector_float2 hullVertex;
|
2023-03-30 13:58:46 +00:00
|
|
|
int debugID;
|
|
|
|
|
2023-03-28 11:09:48 +00:00
|
|
|
} mg_mtl_segment;
|
|
|
|
|
2023-03-28 15:58:23 +00:00
|
|
|
typedef struct mg_mtl_path_queue
|
2023-03-28 11:09:48 +00:00
|
|
|
{
|
2023-03-28 15:58:23 +00:00
|
|
|
vector_int4 area;
|
|
|
|
int tileQueues;
|
|
|
|
} mg_mtl_path_queue;
|
2023-03-28 11:09:48 +00:00
|
|
|
|
2023-03-28 15:58:23 +00:00
|
|
|
#ifdef __METAL_VERSION__
|
|
|
|
using namespace metal;
|
|
|
|
#endif
|
|
|
|
|
2023-03-29 12:27:05 +00:00
|
|
|
typedef enum { MG_MTL_OP_START,
|
|
|
|
MG_MTL_OP_SEGMENT } mg_mtl_tile_op_kind;
|
2023-03-28 15:58:23 +00:00
|
|
|
|
|
|
|
typedef struct mg_mtl_tile_op
|
|
|
|
{
|
|
|
|
mg_mtl_tile_op_kind kind;
|
|
|
|
int index;
|
|
|
|
int next;
|
2023-03-29 12:27:05 +00:00
|
|
|
union
|
|
|
|
{
|
|
|
|
bool crossRight;
|
|
|
|
int windingOffset;
|
|
|
|
};
|
2023-03-30 14:41:41 +00:00
|
|
|
|
2023-03-28 15:58:23 +00:00
|
|
|
} mg_mtl_tile_op;
|
|
|
|
|
|
|
|
typedef struct mg_mtl_tile_queue
|
|
|
|
{
|
2023-03-29 12:27:05 +00:00
|
|
|
atomic_int windingOffset;
|
2023-03-28 15:58:23 +00:00
|
|
|
atomic_int first;
|
2023-03-29 12:27:05 +00:00
|
|
|
int last;
|
2023-03-28 11:09:48 +00:00
|
|
|
|
2023-03-28 15:58:23 +00:00
|
|
|
} mg_mtl_tile_queue;
|
2023-03-28 11:09:48 +00:00
|
|
|
|
|
|
|
#endif //__MTL_RENDERER_H_
|