From 7804c6a96d26c2e757d09f1864eb73fb81eb280f Mon Sep 17 00:00:00 2001 From: Fox Caminiti Date: Thu, 20 Oct 2022 20:45:37 -0400 Subject: precomp recursion! --- main.h | 205 +++++++++++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 155 insertions(+), 50 deletions(-) (limited to 'main.h') diff --git a/main.h b/main.h index 8e29917..9ccb19e 100644 --- a/main.h +++ b/main.h @@ -44,6 +44,30 @@ struct block_string { char Char[1024 - sizeof(uint8)]; }; +struct bitmap_cache_status +{ + uint32 Block_End; +}; + +enum cache_entry_type +{ + cache_entry_type_assert, + cache_entry_type_comp, + cache_entry_type_source, + cache_entry_type_layer, +}; + +struct cache_entry +{ + uint8 IsOccupied; + uint8 IsCached; + uint64 CycleTime; + uint32 Block_StartIndex; + enum cache_entry_type Type; + uint32 TypeInfo; + uint32 TypeInfo_Sub; +}; + enum interpolation_type { interpolation_type_linear, @@ -63,9 +87,76 @@ struct block_bezier { bezier_point Point[MAX_KEYFRAMES_PER_BLOCK]; }; +struct layer_bitmap_state { + // Image and video + bool32 ToUpdate = 1; + + // GL state + // gl_effect_layer Test; + // gl_effect_layer TestM; + + // Video state + int32 CurrentFrame = -1; // The last frame number rendered to the bitmap. -1 gurantees a load upon layer creation. + void *AVInfo; // Internal data containing current frame info +}; + struct render_state { - void *MainCompBuffer; + struct layer_bitmap_state Bitmap[MAX_LAYERS]; + cache_entry Entry[2048]; +}; + +enum focused_window +{ + focus_viewport, + focus_properties, + focus_timeline +}; + +struct sorted_comp_info +{ + uint32 LayerCount; + uint32 CurrentSortIndex; +}; + +struct sorted_layer +{ + uint16 Block_Layer_Index; +}; + +struct ui +{ + ImVec2 CompZoom; // In screen pixels, not percentage. + ImVec2 CompPos; + + // Under 1 is zoomed in! + ImVec2 TimelinePercentZoomed; + ImVec2 TimelinePercentOffset; + + bool32 BoxSelect; + ImVec2 DragDelta_Prev; // TODO(fox): Make native ImGui? + + focused_window FocusedWindow; // Convenience for adding window-specific hotkeys. + + v2 TempZoomRatio = V2(1, 1); + + int32 Warp_X = 0; + int32 Warp_Y = 0; + bool32 Warp_WantSetPos = false; + ImVec2 Warp_PositionToSet; + real32 Warp_PositionInitial; + int32 Warp_Direction; +}; + +struct pen_state { + bool32 IsActive; +}; + +enum interact_type +{ + interact_type_none, + interact_type_layer_move, + interact_type_layer_timeadjust }; struct project_state @@ -76,8 +167,9 @@ struct project_state render_state Render; + int32 Frame_Current; // tool Tool = tool_default; - // pen_state Pen = {}; + pen_state Pen = {}; bool32 IsRunning = 1; bool32 IsPlaying; @@ -85,9 +177,11 @@ struct project_state int16 MostRecentlySelectedLayer = -1; // selection_type RecentSelectionType = selection_none; - bool32 IsInteracting; - real32 InteractCache[6]; - // interact_type InteractType; + interact_type Interact_Active; + real32 Interact_Offset[4]; + void *Interact_Address; + + int32 Initializing = 3; int32 MsgTime; // currently in "frames" char *Msg; @@ -101,19 +195,22 @@ struct project_data uint8 Occupied; uint16 Layer_Count; uint16 Source_Count; + uint16 Comp_Count; uint16 PrincipalCompIndex; }; struct block_composition { uint8 Occupied; + + uint16 Name_String_Index; + uint16 Width; uint16 Height; uint16 FPS; uint16 BytesPerPixel; uint32 Frame_Count; - int32 Frame_Current; int32 Frame_Start; int32 Frame_End; }; @@ -128,7 +225,8 @@ struct block_source { uint8 Occupied; - uint16 Block_String_Index; + uint16 Path_String_Index; + uint16 Name_String_Index; // Image and video uint16 Width; uint16 Height; @@ -138,7 +236,7 @@ struct block_source real32 FPS; real32 AvgPTSPerFrame; // set by Libav - source_type SourceType; + source_type Type; }; struct property_header @@ -163,24 +261,12 @@ struct property_channel { bool32 IsToggled; }; -struct layer_bitmap_state { - // Image and video - bool32 ToUpdate = 1; - - // GL state - // gl_effect_layer Test; - // gl_effect_layer TestM; - - // Video state - int32 CurrentFrame = -1; // The last frame number rendered to the bitmap. -1 gurantees a load upon layer creation. - void *AVInfo; // Internal data containing current frame info -}; - struct block_layer { uint8 Occupied; + bool32 IsPrecomp; + uint16 Block_Source_Index; // also used for precomp uint16 Block_String_Index; - uint16 Block_Source_Index; uint16 Block_Composition_Index; uint16 Block_Mask_Index[MAX_EFFECTS]; @@ -208,14 +294,60 @@ struct block_layer { }; bool32 IsSelected; + bool32 IsVisible; + bool32 IsAdjustment; int32 Frame_Offset; int32 Frame_Start; int32 Frame_End; - uint32 LayerColor; + real32 Vertical_Offset; + real32 Vertical_Height = 1; + + real32 Col[3]; }; +struct render_byte_info { + uint32 MaskPixel; + uint32 ByteOffset; + uint32 Bits; + real32 Normalized; +}; + +struct transform_info { + real32 XAxisPX; + real32 XAxisPY; + real32 YAxisPX; + real32 YAxisPY; + + real32 LayerWidth; + real32 LayerHeight; + real32 LayerBytesPerPixel; + real32 LayerPitch; + render_byte_info LayerBits; + + real32 BufferWidth; + real32 BufferHeight; + real32 BufferBytesPerPixel; + real32 BufferPitch; + render_byte_info BufferBits; + + real32 LayerOpacity; + real32 OriginX; + real32 OriginY; + blend_mode BlendMode; + + bool32 IsAdjustment; + + rectangle ClipRect; + void *SourceBuffer; +}; + +struct render_entry { + void *RenderData; + void *OutputBuffer; + rectangle RenderRegion; +}; #if 0 @@ -247,25 +379,6 @@ struct comp_buffer { void *UnpackedBuffer; }; -struct transform_info { - real32 XAxisPX; - real32 XAxisPY; - real32 YAxisPX; - real32 YAxisPY; - real32 LayerWidth; - real32 LayerHeight; - uint32 FullLayerWidth; - uint32 FullLayerHeight; - real32 LayerOpacity; - blend_mode BlendMode; - real32 OriginX; - real32 OriginY; - uint32 BufferPitch; - uint32 LayerPitch; - rectangle ClipRect; - void *SourceBuffer; -}; - struct mask_point { v2 Pos; bool32 HandleBezier; @@ -318,14 +431,6 @@ struct pen_state { bool32 IsActive; }; -enum interact_type -{ - interact_type_keyframe_move, - interact_type_keyframe_rotate, - interact_type_keyframe_scale -} - - struct brush_tool { real32 Size; -- cgit v1.2.3