summaryrefslogtreecommitdiff
path: root/functions.h
blob: d4a4cfaecd18bc4df60741de15148b982a320b11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// static bool32 AV_IsFileSupported(char *filename, bool32 *IsVideo);

static void Arbitrary_WriteInto(uint8 *Address_Read, uint8 *Address_Write, uint64 Size);
static void Arbitrary_Zero(uint8 *Address_Write, uint64 Size);
static void Arbitrary_SwapData(memory *Memory, uint8 *Address_0, uint8 *Address_1, uint64 Size);
static void Arbitrary_ShiftData(uint8 *Address_Start, uint8 *Address_End, uint64 ShiftAmount, int32 Direction);

static v2 T_CompUVToLayerUV(layer_transforms T, uint32 FileWidth, uint32 FileHeight, uint32 SourceWidth, uint32 SourceHeight, v2 CompUV);

static void Interact_Transform_Begin(project_data *File, memory *Memory, project_state *State, ImVec2 OGPos);

static v2           Transform_ScreenSpaceToLocal(layer_transforms T, uint32 FileWidth, uint32 FileHeight, uint32 SourceWidth, uint32 SourceHeight, ui UI, ImVec2 ViewportMin, ImVec2 Point);
static ImVec2 Layer_LocalToScreenSpace(project_state *State, block_layer *Layer, ui *UI, real32 SourceWidth, real32 SourceHeight, real32 CompWidth, real32 CompHeight, v2 Point);

static void Transform_ApplyInteractive(interact_transform Interact, real32 *OutputX, real32 *OutputY, real32 *OutputRotation, real32 *OutputScale);

static layer_transforms Layer_GetTransforms(block_layer *Layer);
void GL_GenAndBindTexture(GLuint *GLTexture, int Width, int Height, int BytesPerPixel, void *BufferAddress);

static real32 Bezier_SolveYForX(v2 Point_P0, v2 Point_P1, v2 Point_P2, v2 Point_P3, real32 X);
# if 0

// Buffer management

static void * Layer_AllocateBitmap(memory *Memory, uint16 Width, uint16 Height, uint16 BytesPerPixel); //
static project_layer * Layer_Init(project_data *File, memory *Memory); // Initializes a layer's name and properties. Add a source manually.


static void Bitmap_CalcPackedDimensions(uint16 Width, uint16 Height, uint16 *WidthP, uint16 *HeightP); // Returns the dimensions a packed bitmap should be in memory.
static void Bitmap_ConvertPacking(void *Buffer, void *DestBuffer, uint16 Width, uint16 Height, uint16 BytesPerPixel, uint16 Which);
static void Bitmap_CalcHistogram(void *Data, void *Input, uint16 BytesPerPixel, uint64 TotalBytes);
static uint16 Bitmap_CalcByteOffset(uint16 BytesPerPixel); // Returns the amount of bytes a loop goes through depending on the InstructionMode.
static uint64 Bitmap_CalcTotalBytes(uint16 Width, uint16 Height, uint16 BytesPerPixel); // Returns the total amount of bytes a bitmap takes up.
static uint64 Bitmap_CalcUnpackedBytes(uint16 Width, uint16 Height, uint16 BytesPerPixel);

static bool32 Source_Generate(project_data *File, project_state *State, memory *Memory, void *Path); // Fills out source info if the source is a supported file.

// Libav (ffmpeg) backend for decoding video

static void AV_Init(char *filename, source *Source, memory *Memory); // Initializes all internal structs and calculates average PTS.
static cached_bitmap * AV_LoadVideoFrame(source *Source, memory *Memory, int32 TimelineFrame); // Loads video frame at TimelineFrame.

static cached_bitmap * Cache_CheckBitmap(source *Source, layer_bitmap_info *BitmapInfo, memory *Memory, int32 TimelineFrame);

// OpenGL

static void GL_UpdateTexture(gl_effect_layer *Test, void *Data, uint16 Width, uint16 Height, bool32 Multisample);
static void GL_RasterizeShape(project_layer *Layer, mask *Mask);

static v2 Line_RatioToPoint(v2 a, v2 b, float ratio);
static v2 ImGui_ScreenPointToCompUV(ImVec2 ViewportMin, ImVec2 CompPos, ImVec2 CompZoom, ImVec2 MousePos);

void Bezier_CubicCalcPoints(v2 p1, v2 p2, v2 p3, v2 p4, void *Data, uint32 *Increment);

static void Mask_TriangulateAndRasterize(memory *Memory, project_layer *Layer, mask *Mask);


static void History_Undo(memory *Memory);
static void History_Redo(memory *Memory);

static void History_Entry_Commit(memory *Memory, action_entry_type Type, char *Name);
static void History_Entry_End(memory *Memory);
static void History_Entry_SetPointer(memory *Memory, void *Data);

static void History_Action_Change(memory *Memory, void *DataLocation, void *OriginalData, void *NewData, action_type ActionChange);
static void History_Action_Change_SwapBool(memory *Memory, bool32 *Bool);
static void History_Action_Change_V2(memory *Memory, v2 *DataAddress, v2 *OriginalData, v2 *NewData);
static void History_Action_Change_Increment(memory *Memory, void *Data, action_type);
static void History_Action_Change_Decrement(memory *Memory, void *Data, action_type);
static void History_Action_Shift(memory *Memory, action_type ActionChange, void *DataAddress, int16 Direction, int16 Index);
static void History_Action_Shift_2(memory *Memory, void *StartingAddress, uint32 Size, uint16 NumberOf,  int16 Direction, int16 Index);
static void History_Action_StoreData(memory *Memory, void *DataAddress, uint64 ByteSize);
static void History_Action_Undo(memory *Memory);
static void History_Action_Redo(memory *Memory);

#if ARM
static void NEON_RenderLayer(transform_info T, comp_buffer *Buffer, rectangle RenderRegion);
#else
static void AVX2_RenderLayer(transform_info TransformInfo, comp_buffer *Buffer, rectangle RenderRegion);
static void SSE2_RenderLayer(transform_info TransformInfo, comp_buffer *Buffer, rectangle RenderRegion);
#endif
static void Fallback_RenderLayer(transform_info TransformInfo, comp_buffer *Buffer, rectangle RenderRegion);
static void PushRect(rectangle RenderRegion);
static bool32 CheckQueue(render_queue RenderInfo, uint16 Index);

// Effects

static void Effect_DrawColor(source *Source, layer_bitmap_info *BitmapInfo, memory *Memory, property_channel Property[]);
static void Effect_Levels(source *Source, layer_bitmap_info *BitmapInfo, memory *Memory, property_channel Property[]);
static void Effect_GaussianBlur(source *Source, layer_bitmap_info *BitmapInfo, memory *Memory, property_channel Property[]);
#endif