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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
|
static int32
LayerIterate_TestSelection(project_state *State, memory *Memory, uint32 PrincipalIndex, layer_transforms ExtraT, v2 Center,
sorted_comp_array *SortedCompArray, sorted_layer_array *SortedLayerArray, bool32 BelowOnly);
// TODO(fox);: Incorporate sorting for non-continuous shapes.
static uint32
Bezier_Shape_Sort(memory *Memory, shape_layer *Shape, bezier_point *PointData,
project_state *State, layer_transforms T, int Width, int Height,
int CompWidth, int CompHeight, real32 Radius, bool32 Interact);
static bezier_point *
Bezier_LookupAddress(memory *Memory, uint16 *Block_Bezier_Index, uint16 Index, bool32 AssertExists = 1);
static bezier_point *
Bezier_LookupAddress(memory *Memory, property_channel *Property, uint16 Index, bool32 AssertExists = 1);
static void
Bezier_Interact_Evaluate(project_state *State, bezier_point *PointAddress, v2 *Pos, real32 GraphZoomHeight = 1, real32 Y_Increment = 1);
static void
Bezier_Add(memory *Memory, memory_table_list TableName, uint16 *Block_Bezier_Index, uint16 *Block_Bezier_Count,
uint16 *PointCount, bezier_point PointData);
static void
Bezier_Add(memory *Memory, memory_table_list TableName, property_channel *Property, bezier_point PointData, uint16 *ArrayLocation);
// return all points
static void Bezier_CubicCalcPointsCasteljauStep(void *Data, uint32 Size, uint32 *Increment, real32 x1, real32 y1, real32 x2, real32 y2, real32 x3, real32 y3, real32 x4, real32 y4, real32 tess_tol, int level);
void * Bezier_CubicCalcPoints(v2 p1, v2 p2, v2 p3, v2 p4, void *Data, uint32 Size);
v2 Bezier_LineDist(v2 a, v2 b, v2 p);
v2 Bezier_LineClosestPoint(v2 a, v2 b, v2 p);
// The ratio here is just the dot product divided by the squared length.
v2 Bezier_LineClosestPointR(v2 a, v2 b, v2 p, real32 *ratio);
static void Bezier_CubicBoxCasteljauStep(v2 Min, v2 Max, v2 *p_closest, v2 *p_last, real32 *p_closest_dist2,
real32 x1, real32 y1, real32 x2, real32 y2, real32 x3, real32 y3, real32 x4, real32 y4, real32 tess_tol, int level);
static void
Bezier_BoxTest(v2 p1, v2 p2, v2 p3, v2 p4, v2 Min, v2 Max, v2 *p_closest);
real32 Bezier_CubicRatioOfPoint(v2 p1, v2 p2, v2 p3, v2 p4, v2 p);
// finds the min/max bounds of the curve
static void Bezier_CubicMinMaxCasteljauStep(v2 *p_min, v2 *p_max, real32 x1, real32 y1, real32 x2, real32 y2, real32 x3, real32 y3, real32 x4, real32 y4, real32 tess_tol, int level);
real32 Bezier_CubicRatioOfPoint(v2 p1, v2 p2, v2 p3, v2 p4, v2 p);
static bool32
File_Open(project_data *File, project_state *State, memory *Memory, char *Filename);
static bool32
IO_Save(project_data *File, project_state *State, memory *Memory, char *Filename);
static void
File_SaveAs(project_data *File, project_state *State, memory *Memory, char *Filename);
static void
Playhead_Increment(int32 *Frame_Current, int32 Frame_Start, int32 Frame_End, int32 Increment);
static uint16
Source_Generate_Blank(project_data *File, project_state *State, memory *Memory, uint16 Width, uint16 Height, uint16 BytesPerPixel);
static void
Source_Delete(project_data *File, memory *Memory, uint32 Index);
static int16
Source_Generate(project_data *File, project_state *State, memory *Memory, void *TempString);
static void
Property_AddKeyframe(memory *Memory, memory_table_list TableName, property_channel *Property, int Frame, uint16 *ArrayLocation);
static block_composition *
Precomp_Init(project_data *File, memory *Memory, block_composition *DupeComp = NULL);
static uint32
Effect_Init(project_state *State, memory *Memory, uint32 EffectEntryIndex, int EffectCount);
static void
Effect_Add(project_data *File, project_state *State, memory *Memory, uint32 EffectEntryIndex);
void Source_DeselectAll(project_data *File, memory *Memory);
// NOTE(fox);: This won't work with precomps!
void Clipboard_Paste(project_data *File, project_state *State, memory *Memory, sorted_comp_array *SortedCompStart, sorted_layer_array *SortedLayerStart, uint16 *SortedKeyframeArray);
void Clipboard_Store(project_data *File, project_state *State, memory *Memory, sorted_comp_array *SortedCompStart, sorted_layer_array *SortedLayerStart, sorted_property_array *SortedPropertyStart, uint16 *SortedKeyframeArray);
void Property_MinMax_X(memory *Memory, project_state *State, property_channel *Property,
uint16 *ArrayLocation, real32 *Min, real32 *Max);
void Property_MinMax_Y(memory *Memory, project_state *State, property_channel *Property,
sorted_property_array *PropertyStart, real32 *Min, real32 *Max, bool32 Evaluate = 1);
inline property_channel *
Effect_Property(memory *Memory, block_effect *Effect, int Offset);
inline v2 Effect_V2(memory *Memory, block_effect *Effect, int Offset);
// TODO(fox);: Merge with other sorting code.
void Effect_Curves_Sort(memory *Memory, block_effect *Effect, uint16 *SortedPointStart, uint16 Which);
static void
Interact_Evaluate_Layer(memory *Memory, project_state *State, uint16 Layer_Index_Physical, sorted_comp_array SortedCompStart, sorted_layer_array *SortedLayerStart,
int32 *Frame_Start, int32 *Frame_End, int *Frame_Offset);
void File_DeselectAllKeyframes(project_data *File, project_state *State, memory *Memory,
sorted_comp_array *SortedCompArray, sorted_layer_array *SortedLayerArray,
sorted_property_array *SortedPropertyStart, uint16 *SortedKeyframeArray);
static void
Project_Layer_Delete(project_data *File, project_state *State, memory *Memory);
static bool32
Property_IsGraphSelected(memory *Memory, property_channel *Property, uint16 *ArrayLocation);
static void
Project_Layer_Duplicate(project_data *File, project_state *State, memory *Memory,
sorted_comp_array *SortedCompArray, sorted_layer_array *SortedLayerArray, v2 Offset, bool32 FakeOnly, bool32 NewPrecomp);
static void
Project_ShapeLayer_New(project_data *File, project_state *State, memory *Memory);
static void
Project_PaintLayer_New(project_data *File, project_state *State, memory *Memory);
void Source_UICreateButton(project_data *File, project_state *State, memory *Memory);
void Precomp_UIDuplicate(project_data *File, project_state *State, memory *Memory, uint16 CompIndex,
sorted_comp_array SortedCompStart, sorted_layer_array *SortedLayerStart);
void Precomp_UIDelete(project_data *File, project_state *State, memory *Memory, uint16 CompIndex,
sorted_comp_array SortedCompStart, sorted_layer_array *SortedLayerStart);
void Precomp_UICreateButton(project_data *File, project_state *State, memory *Memory, uint16 CompIndex,
sorted_comp_array SortedCompStart, sorted_layer_array *SortedLayerStart);
// TODO(fox);: Make separate full-size bitmap that gets scaled on the GPU instead of this
static void
State_BindBrushTexture(memory *Memory, brush_state *Brush, uint32 BytesPerPixel);
static void
Brush_CalcBitmapAlphaFromSize(memory *Memory, brush_state *Brush, uint32 BytesPerPixel);
// Imported bitmaps are stored in linear, and all ops are also done in linear.
static void
Bitmap_SRGBToLinear(void *Buffer, uint16 Width, uint16 Height, uint16 BytesPerPixel, bool32 ToLinear);
static void
Brush_Info(brush_info *B, brush_state *Brush, block_source *Source, void *SourceBuffer, v2 LayerPos, v4 Color);
void Bitmap_SwapData(uint8 *Address_0, uint8 *Address_1, uint64 Size, uint16 BytesPerPixel);
static void
PaintTest(brush_info B, void *CacheBuffer, rectangle RenderRegion);
static void
RenderQueue_AddBrush(project_state *State, v2 LayerPos);
static void
RenderQueue_AddBlit(project_state *State);
static void
Effect_GaussianBlur(real32 *Data, int Width, int Height, int BytesPerPixel, void *EffectBitmapAddress, uint16 ShaderProgram);
static void
Effect_Curves_Init(block_effect *Effect, property_channel *Property);
static void
Effect_Levels(real32 *Data, int Width, int Height, int BytesPerPixel, void *EffectBitmapAddress, uint16 ShaderProgram);
static void
Effect_Curves(real32 *Data, int Width, int Height, int BytesPerPixel, void *EffectBitmapAddress, uint16 ShaderProgram);
static void
Effect_EndEntry(project_state *State);
static void
Effect_AddProperty_Real(project_state *State, char *Name, real32 DefaultValue, real32 MinVal = -999999, real32 MaxVal = 999999, property_display_type DisplayType = property_display_type_standard);
static void
Effect_AddProperty_Col(project_state *State, char *Name, v4 DefaultValue);
static void
Effect_AddProperty_Blendmode(project_state *State, char *Name, blend_mode DefaultValue);
static header_effect*
Effect_EntryFromID(project_state *State, char *ID);
static void
Effect_InitEntries(project_state *State);
void Effect_GL_DrawColor(int Width, int Height, int BytesPerPixel, void *EffectBitmapAddress,
uint16 ShaderProgram, v4 Color);
void Effect_GL_GaussianBlur(int Width, int Height, int BytesPerPixel, void *EffectBitmapAddress,
uint16 ShaderProgram, real32 Radius);
void Effect_GL_Levels(int Width, int Height, int BytesPerPixel, void *EffectBitmapAddress,
uint16 ShaderProgram, real32 Min, real32 Mid, real32 Max, v4 ColMin, v4 ColMid, v4 ColMax);
static void
CurvesSolver(real32 *LUT, v2 Point_P1, v2 Point_P2, v2 m1, v2 m2, int i);
static void
Effect_Software_Curves(int Width, int Height, int BytesPerPixel, void *EffectBitmapAddress, v2 *PointData, real32 PointCount, v4 PointCount_Col);
bool32 AV_TryFrame(av_info *AV, AVCodecContext *CodecContext, int32 *err, bool32 *EndOfFile, int StreamIndex = -1);
// Widgets not involving drawing UI.
static v2 ImGui_ScreenPointToCompUV(ImVec2 ViewportMin, ImVec2 CompPos, ImVec2 CompZoom, ImVec2 MousePos);
static void ImGui_WarpMouseFinish(project_state *State, ImVec2 MousePos);
static ImVec2 ImGui_Brush_CalcMousePos(project_state *State, ImGuiIO &io, ImVec2 MouseDelta, int32 i, real32 DeltaDistance, real32 DeltaSlope);
static bool32 ImGui_TestBoxSelection_Point(ImVec2 Pos, ImGuiIO &io, bool32 *Test);
static void
Layer_TestBoxSelect(memory *Memory, project_state *State, ui *UI, sorted_comp_array *SortedCompArray, sorted_layer_array *SortedLayerArray,
uint16 PrincipalIndex, layer_transforms ExtraT, v2 MinPos, v2 MaxPos);
static void
Sort_OffsetDupes(memory *Memory, sorted_layer_array *SortedLayerStart, block_layer *StartLayer, sorted_layer_array *StartSortEntry,
int i, int FauxIncrement, int LayerCount, int Mode);
void AV_IsFileSupported(char *filename, bool32 *IsVideo, bool32 *HasAudio);
void AV_Dealloc(av_info *AV);
void AV_InitStream(av_stream_info *Stream);
// The duration isn't always reported in AVStream, but seeking towards the end
// and advancing until we hit EOF seems to be accurate.
void AV_GetDuration(av_info *AV, av_stream_info *Stream, uint64 *Duration, real32 *SecondCount);
void AV_Init(block_source *Source, av_info *AV, memory *Memory);
uint32 AV_AudioTest(av_info *AV, void *Data, uint32 Size, real32 FPS, int32 InitialFrameToSeek);
void AV_SeekAudio(av_info *AV, real32 FPS, int32 FrameToSeek);
void AV_LoadVideoFrame(memory *Memory, block_source *Source, av_info *AV, int32 FrameToSeek, void *Buffer);
void
GL_GenAndBindTexture(GLuint *GLTexture, int Width, int Height, int BytesPerPixel, void *BufferAddress);
static void
GL_BindDefaultVertexArrays();
void
GL_InitHWBuffer(gl_effect_layer *Test);
void
GL_DeleteHWBuffer(gl_effect_layer *Test);
void
GL_UpdateTexture(gl_effect_layer *Test, void *Data, uint16 Width, uint16 Height, uint16 BytesPerPixel, bool32 Multisample);
static uint16
Effect_GL_InitShader(const char *FragmentShaderEffectSource);
static void
ImGui_WarpMouse(project_state *State, ImVec2 MousePos, ImVec2 Min, ImVec2 Max, int Direction = 3);
static bool32
ImGui_TestBoxSelection_Point(ImVec2 Pos, ImGuiIO &io, bool32 *Test);
static void
ImGui_ColorPanel(project_data *File, project_state *State, ui *UI, memory *Memory, ImGuiIO io);
static void
ImGui_KeybindUI(project_data *File, project_state *State, ui *UI, memory *Memory, ImGuiIO io);
static void
ImGui_Popups(project_data *File, project_state *State, ui *UI, memory *Memory, ImGuiIO io);
static void
ImGui_ProcessInputs(project_data *File, project_state *State, ui *UI, memory *Memory, ImGuiIO io, sorted_file Sorted);
static void
ImGui_Menu(project_data *File, project_state *State, ui *UI, memory *Memory, ImGuiIO io);
static void
ImGui_EffectsPanel(project_data *File, project_state *State, memory *Memory, ui *UI, ImGuiIO io);
static void
ImGui_DebugRenderQueue(project_state *State);
static void
ImGui_DebugUndoTree(memory *Memory, project_state *State);
static void
ImGui_Properties_Slider(project_state *State, memory *Memory, property_channel *Property, ImGuiIO &io, ImVec2 WindowMinAbs, ImVec2 WindowMaxAbs, memory_table_list Table);
static void
ImGui_Properties_CurvesUI(project_state *State, memory *Memory, ImGuiIO io, block_effect *Effect, property_channel *PropertyStart, uint16 *SortedPointStart);
static void
ImGui_SD_Prompt(project_data *File, project_state *State, ui *UI, memory *Memory, ImGuiIO io,
sorted_comp_array *SortedCompArray, sorted_layer_array *SortedLayerArray);
static void
ImGui_Timeline_HorizontalIncrementDraw(project_state *State, ui *UI, ImDrawList *draw_list, ImVec2 TimelineSizeWithBorder, ImVec2 TimelineAbsolutePos, block_composition MainComp,
ImVec2 TimelineZoomSize, ImVec2 TimelineMoveSize);
static void
ImGui_Timeline(project_data *File, project_state *State, memory *Memory, ui *UI, ImGuiIO io,
sorted_comp_array *SortedCompArray, sorted_layer_array *SortedLayerArray, sorted_property_array *SortedPropertyStart, uint16 *SortedKeyframeArray);
static void
ImGui_Viewport_ShapeUI(project_state *State, memory *Memory, ui *UI, ImGuiIO &io, block_layer *Layer, int Width, int Height, shape_layer *Shape, block_composition *MainComp, ImDrawList *draw_list);
static void
ImGui_Viewport_BrushUI(project_state *State, memory *Memory, ImVec2 ViewportMin, ImVec2 ViewportMax, ImVec2 CompZoom, ImGuiIO io, uint16 Width, uint16 Height);
static void
ImGui_Viewport_TransformUI(project_data *File, project_state *State, memory *Memory, ui *UI, ImGuiIO &io, ImDrawList *draw_list,
interact_transform *Interact, ImVec2 ViewportMin, uint32 CompWidth, uint32 CompHeight, uint16 *SortedKeyframeArray);
static void
ImGui_Viewport_SelectedLayerUI(project_state *State, memory *Memory, ui *UI, ImGuiIO &io, ImDrawList *draw_list, block_composition *MainComp, uint32 CompIndex, block_layer *ParentLayer[4], uint32 Recursions, v2 *Min, v2 *Max,
sorted_comp_array *SortedCompArray, sorted_layer_array *SortedLayerArray);
static void
ImGui_Viewport(project_data *File, project_state *State, ui *UI, memory *Memory, ImGuiIO io, GLuint textureID,
sorted_comp_array *SortedCompArray, sorted_layer_array *SortedLayerArray, sorted_property_array *SortedPropertyStart, uint16 *SortedKeyframeArray);
static void
IO_ReadFromStream(void *Address, uint64 SizeToRead, SDL_RWops *File);
// lots of cleanup...
static void
Layer_Delete(project_data *File, project_state *State, memory *Memory, uint32 Index);
static int
Layer_GetTopOffset(project_data *File, memory *Memory);
static void
Layer_ToggleChannel(project_data *File, memory *Memory, int32 a);
static void
Layer_Select(memory *Memory, project_state *State, int32 i);
static void
Layer_Select_RecurseUp(memory *Memory, project_state *State, int32 i, int16 RecursionIdx[MAX_PRECOMP_RECURSIONS], uint32 Recursions);
static void
Layer_Select_Traverse(uint16 PrincipalCompIndex, memory *Memory, project_state *State, int32 IndexToFind, sorted_comp_array *SortedCompArray, sorted_layer_array *SortedLayerArray,
int16 RecursionIdx[MAX_PRECOMP_RECURSIONS], int32 *Recursions);
static void
Layer_GetDimensions(memory *Memory, block_layer *Layer, int *Width, int *Height);
static v2
Layer_TraverseForPoint(project_data *File, project_state *State, memory *Memory, v2 PrincipalCompUV, sorted_comp_array *SortedCompArray, sorted_layer_array *SortedLayerArray, uint16 LayerIndex);
static bool32
Shape_TestBoxSelect(v2 Min, v2 Max, bezier_point *BezierPointData, uint32 BezierCount);
static int32
LayerIterate_TestSelection(project_state *State, memory *Memory, uint32 PrincipalIndex, layer_transforms ExtraT, v2 Center,
sorted_comp_array *SortedCompArray, sorted_layer_array *SortedLayerArray, bool32 BelowOnly);
static bool32
Transform_TestBox(block_layer *Layer, uint32 Width, uint32 Height, v2 Min, v2 Max);
static void
Layer_RecursiveDeselect(memory *Memory, sorted_comp_array *SortedCompArray, sorted_layer_array *SortedLayerArray, uint16 TargetIndex, uint16 PrincipalIndex);
static bool32
Main_InputTest(project_data *File, project_state *State, memory *Memory, sorted_file Sorted, ui *UI, SDL_Window *window, GLuint textureID);
static void
Render_Main(project_data *File, project_state *State, memory *Memory, sorted_file Sorted, ui *UI, SDL_Window *window, GLuint textureID,
void *Data, void *OutputBuffer, render_type RenderType, rectangle RenderRegion);
static void
Layer_UpdateAllKeyframes(project_data *File, project_state *State, memory *Memory, block_layer *Layer, uint16 Index_Physical,
sorted_property_array *SortedProperty, uint16 *SortedKeyframe, uint16 Frame_Current);
static av_info *
AV_Retrieve(project_state *State, memory *Memory, uint32 SourceIndex);
struct gl_data;
struct gl_viewport_data;
static void
GL_Test(const ImDrawList* parent_list, const ImDrawCmd* cmd);
static void
Render_Paint(project_data *File, project_state *State, memory *Memory, sorted_file Sorted, ui *UI, SDL_Window *window, GLuint textureID, ImGuiIO io, v2 LayerPos);
static void
Render_Blit(project_data *File, project_state *State, memory *Memory, sorted_file Sorted, ui *UI, SDL_Window *window, GLuint textureID, ImGuiIO io, v2 LayerPos);
static void
Main_Renderer(project_data *File, project_state *State, memory *Memory, sorted_file Sorted, ui *UI, SDL_Window *window, GLuint textureID, ImGuiIO io);
static uint32
Memory_Block_AllocateNew(memory *Memory, memory_table_list TableName);
static void *
Memory_Block_AddressAtIndex(memory *Memory, memory_table_list TableName, uint32 Index, bool32 AssertExists = 1);
static uint16
Memory_Block_LazyIndexAtAddress(memory *Memory, memory_table_list TableName, void *Address);
static void *
Memory_Block_AllocateAddress(memory *Memory, memory_table_list TableName);
// IMPORTANT(fox);: All block data structs have to start with a uint8 Occupied variable!
static bool32
Block_Loop(memory *Memory, memory_table_list TableName, uint32 TotalCount, int *HasIncremented, int *CurrentCount, int *Index);
static bool32
Block_Loop(memory *Memory, property_channel *Property, uint32 TotalCount, int *HasIncremented, int *CurrentCount, int *Index);
static uint32
Memory_Block_PrincipalBitmap_AllocateNew(project_data *File, project_state *State, memory *Memory);
static uint32
Memory_Block_Bitmap_AllocateNew(project_state *State, memory *Memory, cache_entry Entry, uint64 NewSize);
static void
Memory_Cache_Purge(project_data *File, project_state *State, memory *Memory, int32 SingleFrame = -1);
static cache_entry *
Memory_Cache_Search(project_state *State, memory *Memory, cache_entry_type Type, uint32 TypeInfo, uint32 TypeInfo_Sub);
static void *
Memory_Block_Bitmap_AddressAtIndex(memory *Memory, uint32 Index);
static void *
Memory_AddressAtOffset(memory *Memory, memory_table_list TableName, uint64 Offset);
void Memory_Copy(uint8 *Address_Write, uint8 *Address_Read, uint64 Size);
void Memory_Fill(uint8 *Address_Write, uint8 *Address_Read, uint64 WriteSize, uint64 ReadSize);
void Arbitrary_Zero(uint8 *Address_Write, uint64 Size);
void Arbitrary_SwapData(memory *Memory, uint8 *Address_0, uint8 *Address_1, uint64 Size);
static void *
Memory_PushScratch(memory *Memory, uint64 Size);
static void
Memory_PopScratch(memory *Memory, uint64 Size);
static void
Arbitrary_ShiftData(uint8 *Address_Start, uint8 *Address_End, uint64 ShiftAmount, int32 Direction);
static uint64
Data_Compress(memory *Memory, void *DataSource, uint64 DataSize, void *DataBuffer, uint64 DataBufferSize, int CompressionLevel);
static void
Data_Decompress(memory *Memory, void *CompressedLocation, uint64 CompressedSize, void *BitmapLocation, uint64 ExpectedSize);
static uint32
NVG_FlattenPath(memory *Memory, shape_layer *Shape, shape_options ShapeOpt, nvg_point *PointData,
project_state *State, layer_transforms T, int Width, int Height,
int CompWidth, int CompHeight, bool32 Interact, v2 *Min, v2 *Max, bool32 IsConcave);
static real32 *
NVG_Point(real32 *StrokeData, real32 x, real32 y, real32 u, real32 v);
static void NVG_ChooseBevel(int bevel, nvg_point *p0, nvg_point *p1, float w,
float* x0, float* y0, float* x1, float* y1);
static real32 * NVG_RoundCap(nvg_point * Point, real32 *StrokeData,
float dx, float dy, float w, int ncap,
float u0, float u1, int Mode);
static real32 * NVG_ButtCap(nvg_point *Point, real32 *StrokeData,
float dx, float dy, float w, float d,
float u0, float u1, int Mode);
static void
NVG_ExpandFill(void *Memory, int NumberOfVerts, nvg_point *PointData, real32 *FillData);
static v2
T_CompUVToLayerUV(layer_transforms T, uint32 FileWidth, uint32 FileHeight, uint32 SourceWidth, uint32 SourceHeight, v2 CompUV);
static v2
T_CompPosToLayerPos(layer_transforms T, uint32 FileWidth, uint32 FileHeight, uint32 SourceWidth, uint32 SourceHeight, real32 X, real32 Y);
static layer_transforms
Transform_TestInteracts(project_state *State, block_layer *Layer, sorted_layer_array SortEntry, layer_transforms T);
static layer_transforms
Transform_Add(layer_transforms T, layer_transforms ExtraT, real32 Width, real32 Height);
static uint8 *
Render_UI(project_data *File, project_state *State, memory *Memory, ui *UI, ImDrawList *draw_list, uint8 *PointBuffer, gl_viewport_data *RenderData,
sorted_comp_array *SortedCompArray, sorted_layer_array *SortedLayerArray, layer_transforms ExtraT,
sorted_property_array *SortedPropertyStart, uint16 *SortedKeyframeArray, uint32 CompIndex, int32 Frame_Current);
static v2
Transform_ScreenSpaceToLocal(layer_transforms T, uint32 FileWidth, uint32 FileHeight, uint32 SourceWidth, uint32 SourceHeight,
ImVec2 CompPos, ImVec2 CompZoom, ImVec2 ViewportMin, ImVec2 Point);
// Transform given data based on state's Interact data.
static void
Transform_ApplyInteractive(interact_transform Interact, real32 *OutputX, real32 *OutputY, real32 *OutputRotation, real32 *OutputScale);
static void
LayerIterate(project_state *State, memory *Memory, uint32 CompIndex, layer_transforms ExtraT, v2 Center,
sorted_comp_array *SortedCompArray, sorted_layer_array *SortedLayerArray);
static void
Transform_IterateOuterBounds(block_layer *Layer, uint32 Width, uint32 Height, real32 *MinX, real32 *MinY, real32 *MaxX, real32 *MaxY);
static void
Transform_Recurse(project_state *State, memory *Memory, block_composition *MainComp, uint32 CompIndex, block_layer *ParentLayer[4], uint32 Recursions,
sorted_comp_array *SortedCompArray, sorted_layer_array *SortedLayerArray,
real32 *MinX, real32 *MinY, real32 *MaxX, real32 *MaxY);
inline void
ImGui_DrawCenteredRect(ImDrawList *draw_list, ImVec2 Point, real32 Width, uint32 col);
static bool32
Layer_TestForPoint(memory *Memory, project_state *State, ui *UI, sorted_comp_array *SortedCompArray, sorted_layer_array *SortedLayerArray, uint16 CompIndex, v2 CompPos, layer_transforms ExtraT);
static v2
TransformPoint(layer_transforms T, real32 Width, real32 Height, v2 Point);
static layer_transforms
Transform_Inverse(layer_transforms T);
static ImVec2
Layer_LocalToScreenSpace(project_state *State, memory *Memory, block_layer *Layer, ui *UI, uint32 PrincipalCompIndex, v2 Point);
static void
Renderer_Start(void *Data, void *OutputBuffer, render_type RenderType, rectangle RenderRegion);
static void
Renderer_Check(bool32 *Test, render_type RenderType);
static void
Fallback_RenderLayer(transform_info T, void *OutputBuffer, rectangle RenderRegion);
inline uint16 *
Property_GetSortedArray(uint16 *SortedKeyframeArray, int i, int h);
static sorted_layer_array *
Sorted_GetLayerStart(sorted_layer_array *LayerArrayStart, sorted_comp_array *SortedCompStart, uint32 TargetComp);
static void
Layer_Sort_CheckPrev(memory *Memory, int i, int Direction, sorted_layer_array *SortedLayerStart, sorted_comp_array SortedCompStart, int *EntriesPassed, sorted_layer_array *LayerEntry, bool32 AltMethod);
void LayerProperty_SortAll(project_data *File, project_state *State, memory *Memory, sorted_layer_array *LayerArrayStart,
sorted_comp_array *CompStart, sorted_property_array *SortedPropertyStart, uint16 *SortedKeyframeArray,
uint32 CompCount);
static void
TempSource_SortAll(project_data *File, project_state *State, memory *Memory, uint16 *SourceArrayStart, uint16 *TempSourceCount);
static sorted_file
File_Sort_Push(project_data *File, project_state *State, memory *Memory);
static void
File_Sort_Pop(memory *Memory, uint64 Layer_SortSize, uint64 Property_SortSize, uint64 Source_SortSize);
#if STABLE
struct curl_data;
static size_t dumbcurlcallback(void *data, size_t size, size_t nmemb, void *userp);
static void
SD_JSONToSource(project_data *File, project_state *State, memory *Memory, void *JSONResponse, int Height, int Width);
static void
SD_ParseProgress(project_state *State, char *JSONInfo);
static void
SD_AssembleJSON(sd_state *SD, char *JSONPayload, void *Base64Bitmap = NULL);
struct curl_state;
static void
Curl_Free(curl_state *Handle);
static void
Curl_StopAll(project_state *State, curl_state *ProgHandle, curl_state *MainHandle);
static int
Curl_Check(curl_state *Handle);
static void
Curl_Prog_Init(curl_state *C, void *OutputData);
static void
Curl_Main(project_data *File, project_state *State, memory *Memory, curl_state *MainHandle, curl_state *ProgHandle);
#endif
static void
CopyStrings(void *Dest, void *Data);
static uint16
String_AddToFile(memory *Memory, char *Char, bool32 NoUndo = 1);
static bool32
String_Compare(char *String1, char *String2, uint32 Length);
static uint32
String_Length(char *Char);
static void
String_Copy(char *String1, char *String2, uint32 Length);
static void
String_Append(char *String1, char *String2, uint32 Length);
static void
String_PathToLayerName(char *Path, char *Dest);
static int
TestThread(void *ptr);
static bool32
Threading_IsActive(render_type RenderType);
static void
Threading_BitmapOp(void *Data, void *OutputBuffer, render_type RenderType, rectangle InitialRenderRegion);
static uint64
History_GetActionSize(history_entry_list *History, int i);
void History_Entry_Commit(memory *Memory, char *Name);
void History_Entry_End(memory *Memory);
static void History_Action_Shift(memory *Memory, memory_table_list TableName,
void *Address0, void *Address1, uint64 Amount, int16 Direction);
static void History_Action_Block_Swap(memory *Memory, memory_table_list TableName, void *Address_Data);
static void History_Action_Swap(memory *Memory, memory_table_list TableName, uint64 Size, void *Address_Data);
|