summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp215
1 files changed, 106 insertions, 109 deletions
diff --git a/src/main.cpp b/src/main.cpp
index fd56316..534460e 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -128,15 +128,15 @@ Main_InputTest(project_data *File, project_state *State, memory *Memory, sorted_
}
#endif
- ImGui_Viewport(File, State, UI, Memory, io, textureID, Sorted.CompArray, Sorted.LayerArray, Sorted.PropertyStart, Sorted.PropertyArray);
ImGui_Timeline(File, State, Memory, UI, io, Sorted.CompArray, Sorted.LayerArray, Sorted.PropertyStart, Sorted.PropertyArray);
+ ImGui_Viewport(File, State, UI, Memory, io, textureID, Sorted.CompArray, Sorted.LayerArray, Sorted.PropertyStart, Sorted.PropertyArray);
if (File->UI.Mode == 0) {
ImGui_EffectsPanel(File, State, Memory, UI, io);
} else {
}
ImGui_PropertiesPanel(File, State, UI, Memory, io, Sorted.CompArray, Sorted.LayerArray, Sorted.PropertyStart, Sorted.PropertyArray);
- ImGui_File(File, State, Memory, io, Sorted.CompArray, Sorted.LayerArray);
+ // ImGui_File(File, State, Memory, io, Sorted.CompArray, Sorted.LayerArray);
ImGui_ColorPanel(File, State, UI, Memory, io);
#if STABLE
@@ -274,61 +274,6 @@ Render_SortKeyframes(project_data *File, project_state *State, memory *Memory,
}
}
-/*
-struct render_entry_data
-{
- int LayerCount;
- int Width;
- int Height;
- int BytesPerPixel;
- blend_mode BlendMode;
-};
-
-struct render_layer_data
-{
- layer_transforms T;
- int Width;
- int Height;
- // AV-specific
- int BytesPerPixel;
- void *Buffer;
- // shape-specific
- void *Stroke_Data;
- uint32 Stroke_Count;
- v4 Stroke_Col;
- void *Fill_Data;
- uint32 Fill_Count;
- v4 Fill_Col;
-};
-*/
-
-struct gl_data
-{
- void *StrokeData;
- uint32 StrokeCount;
- v4 StrokeCol;
- void *FillData;
- uint32 FillCount;
- v4 FillCol;
- layer_transforms T;
- real32 Width;
- real32 Height;
- int RenderMode;
-};
-
-struct gl_viewport_data
-{
- ImVec2 ViewportSize;
- int Width;
- int Height;
- int BytesPerPixel;
- ImVec2 UIPos;
- ImVec2 UIZoom;
- real32 UIScale;
- gl_data *LayerEntry[MAX_LAYERS];
- int LayerCount;
-};
-
static void
GL_Test(const ImDrawList* parent_list, const ImDrawCmd* cmd)
{
@@ -346,13 +291,23 @@ GL_Test(const ImDrawList* parent_list, const ImDrawCmd* cmd)
glUseProgram(DefaultShaderProgram);
- // for (int i = 0; i < 1; i++) {
+ bool32 KeepStencil = false;
+
for (int i = 0; i < RenderData->LayerCount; i++) {
gl_data *Data = RenderData->LayerEntry[i];
- GL_RasterizeShape2(&MSBuffer, Data->StrokeData, Data->FillData, Data->StrokeCount, Data->FillCount,
- Data->T, RenderData->Width, RenderData->Height, RenderData->BytesPerPixel,
- Data->Width, Data->Height, Data->StrokeCol, Data->FillCol, Data->RenderMode, 0,
- RenderData->ViewportSize, RenderData->UIPos, RenderData->UIZoom);
+
+ if (Data->Type == 0) {
+ GL_RasterizeShape2(&MSBuffer, Data->StrokeData, Data->FillData, Data->StrokeCount, Data->FillCount,
+ Data->T, RenderData->Width, RenderData->Height, RenderData->BytesPerPixel,
+ Data->Width, Data->Height, Data->StrokeCol, Data->FillCol, Data->RenderMode, 0,
+ RenderData->ViewportSize, RenderData->UIPos, RenderData->UIZoom, KeepStencil);
+ } else {
+ // GL_BlitStencil(&MSBuffer, Data->StrokeData, Data->FillData, Data->StrokeCount, Data->FillCount,
+ // Data->T, RenderData->Width, RenderData->Height, RenderData->BytesPerPixel,
+ // Data->Width, Data->Height, Data->StrokeCol, Data->FillCol, Data->RenderMode, 0,
+ // RenderData->ViewportSize, RenderData->UIPos, RenderData->UIZoom);
+ // KeepStencil = true;
+ }
}
glBindFramebuffer(GL_READ_FRAMEBUFFER, MSBuffer.FramebufferObject);
@@ -368,14 +323,12 @@ GL_Test(const ImDrawList* parent_list, const ImDrawCmd* cmd)
}
static void
-Render_UI(project_data *File, project_state *State, memory *Memory, ui *UI, ImDrawList *draw_list,
- sorted_comp_array *SortedCompArray, sorted_layer_array *SortedLayerArray,
+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)
{
-
block_composition *Comp = (block_composition *)Memory_Block_AddressAtIndex(Memory, F_Precomps, CompIndex);
cache_entry *Entry_Main = Memory_Cache_Search(State, Memory, cache_entry_type_comp, CompIndex, Frame_Current);
- void *CompBuffer = Memory_Block_Bitmap_AddressAtIndex(Memory, Entry_Main->Block_StartIndex);
uint64 Size = Comp->Width * Comp->Height * Comp->BytesPerPixel;
sorted_comp_array *SortedCompStart = &SortedCompArray[CompIndex];
@@ -383,24 +336,51 @@ Render_UI(project_data *File, project_state *State, memory *Memory, ui *UI, ImDr
Render_SortKeyframes(File, State, Memory, SortedCompStart, SortedLayerStart, SortedCompArray, SortedLayerArray, SortedPropertyStart, SortedKeyframeArray, Frame_Current);
- uint8 *StartAddress = (uint8 *)Memory->Slot[B_PointData].Address;
- Arbitrary_Zero(StartAddress, Memory->Slot[B_PointData].Size);
-
-
- gl_viewport_data *RenderData = (gl_viewport_data *)StartAddress;
- StartAddress += sizeof(gl_viewport_data);
- *RenderData = { ImGui::GetMainViewport()->Size,
- Comp->Width, Comp->Height, Comp->BytesPerPixel,
- UI->CompPos, UI->CompZoom, UI->CompZoom.x / Comp->Width, {} };
-
int LayerCount = SortedCompStart->LayerCount + SortedCompStart->FakeLayerCount;
for (int i = 0; i < LayerCount; i++)
{
sorted_layer_array SortEntry = SortedLayerStart[i];
uint32 Index_Physical = SortEntry.Block_Layer_Index;
block_layer *Layer = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, Index_Physical);
- if (!Layer->IsShapeLayer) {
- continue;
+ if (Layer->IsPrecomp) {
+ *ExtraT = Layer_GetTransforms(Layer);
+ if (State->Interact_Active == interact_type_viewport_transform && Layer->IsSelected == 1) {
+ Transform_ApplyInteractive(State->Interact_Transform, &ExtraT->x, &ExtraT->y, &ExtraT->rotation, &ExtraT->scale);
+ }
+ if (State->Interact_Active == interact_type_viewport_transform_gizmo && Layer->IsSelected == 1) {
+ Transform_ApplyInteractive(State->Interact_Transform, &ExtraT->x, &ExtraT->y, &ExtraT->rotation, &ExtraT->scale);
+ }
+ if (State->Interact_Active == interact_type_viewport_slide && Layer->IsSelected == 1) {
+ Assert(0);
+ // Transform_ApplySlide((v2 *)&State->Interact_Offset[0], &T);
+ }
+ if (State->Interact_Active == interact_type_viewport_duplicate && SortEntry.IsFake) {
+ Assert(Layer->IsSelected);
+ ExtraT->x += State->Interact_Offset[0];
+ ExtraT->y += State->Interact_Offset[1];
+ }
+ gl_data *GL_Data = RenderData->LayerEntry[RenderData->LayerCount] = (gl_data *)PointBuffer;
+ RenderData->LayerCount++;
+ PointBuffer += sizeof(gl_data);
+ int Width = 0, Height = 0;
+ Layer_GetDimensions(Memory, Layer, &Width, &Height);
+ GL_Data->Type = 1;
+ GL_Data->T = *ExtraT;
+ GL_Data->Width = Width;
+ GL_Data->Height = Height;
+ GL_Data->FillData = PointBuffer;
+ real32 CompVerts[16] = { 0.f, 0.f, 0.f, 0.f,
+ 0.f, (real32)Height, 0.f, 0.f,
+ (real32)Width, (real32)Height, 0.f, 0.f,
+ (real32)Width, 0.f, 0.f, 0.f };
+ for (int a = 0; a < 16; a++) {
+ *(real32 *)PointBuffer = CompVerts[a];
+ PointBuffer += sizeof(real32);
+ }
+ GL_Data->FillCount = 4;
+ Render_UI(File, State, Memory, UI, draw_list, PointBuffer, RenderData,
+ SortedCompArray, SortedLayerArray, ExtraT,
+ SortedPropertyStart, SortedKeyframeArray, Layer->Block_Source_Index, Frame_Current);
}
int32 Frame_Start = Layer->Frame_Start;
int32 Frame_End = Layer->Frame_End;
@@ -414,9 +394,7 @@ Render_UI(project_data *File, project_state *State, memory *Memory, ui *UI, ImDr
if (Frame_Start_Abs <= Frame_Current &&
Frame_End_Abs > Frame_Current && Layer->IsVisible)
{
- shape_layer *Shape = &Layer->Shape;
- shape_options ShapeOpt = Layer->ShapeOpt;
- void *Data = StartAddress;
+ void *Data = PointBuffer;
layer_transforms T = Layer_GetTransforms(Layer);
if (State->Interact_Active == interact_type_viewport_transform && Layer->IsSelected == 1) {
@@ -426,6 +404,7 @@ Render_UI(project_data *File, project_state *State, memory *Memory, ui *UI, ImDr
Transform_ApplyInteractive(State->Interact_Transform, &T.x, &T.y, &T.rotation, &T.scale);
}
if (State->Interact_Active == interact_type_viewport_slide && Layer->IsSelected == 1) {
+ Assert(0);
// Transform_ApplySlide((v2 *)&State->Interact_Offset[0], &T);
}
if (State->Interact_Active == interact_type_viewport_duplicate && SortEntry.IsFake) {
@@ -433,39 +412,57 @@ Render_UI(project_data *File, project_state *State, memory *Memory, ui *UI, ImDr
T.x += State->Interact_Offset[0];
T.y += State->Interact_Offset[1];
}
+ if (ExtraT->scale != 0) {
+ T = Transform_Add(T, *ExtraT, Comp->Width, Comp->Height);
+ }
- v2 Min = {}, Max = {};
- uint32 NumberOfVerts = NVG_FlattenPath(Memory, Shape, ShapeOpt, (nvg_point *)Data,
- State, T, Shape->Width, Shape->Height, Comp->Width, Comp->Height, 1, &Min, &Max);
- StartAddress += NumberOfVerts * sizeof(nvg_point);
- void *Data_Stroke = StartAddress;
- uint32 StrokeCount = NVG_ExpandStroke(Memory, NumberOfVerts, ShapeOpt.StrokeWidth, ShapeOpt.LineCapType, ShapeOpt.LineJoinType, Shape->IsClosed, (nvg_point *)Data, (real32 *)Data_Stroke);
- StartAddress += StrokeCount * sizeof(real32) * 4;
- void *Data_Fill = StartAddress;
- NVG_ExpandFill(Memory, NumberOfVerts, (nvg_point *)Data, (real32 *)Data_Fill);
- StartAddress += NumberOfVerts * sizeof(real32) * 4;
-
- // zero to set the framebuffer to main
- gl_effect_layer TestL = {};
- void *EffectBitmapAddress = NULL;
-
- gl_data *GL_Data = RenderData->LayerEntry[RenderData->LayerCount] = (gl_data *)StartAddress;
- RenderData->LayerCount++;
- StartAddress += sizeof(gl_data);
-
- int Visibility = (ShapeOpt.StrokeWidth > 0.0f) ? ShapeOpt.Visibility : 1;
- *GL_Data = { Data_Stroke, StrokeCount, ShapeOpt.StrokeCol,
- Data_Fill, NumberOfVerts, ShapeOpt.FillCol,
- T, Shape->Width, Shape->Height, Visibility };
+ if (Layer->IsShapeLayer) {
+ shape_layer *Shape = &Layer->Shape;
+ shape_options ShapeOpt = Layer->ShapeOpt;
+ if (ShapeOpt.Visibility == 1 && ShapeOpt.StrokeWidth <= 0.0f)
+ continue;
+ v2 Min = {}, Max = {};
+ uint32 NumberOfVerts = NVG_FlattenPath(Memory, Shape, ShapeOpt, (nvg_point *)Data,
+ State, T, Shape->Width, Shape->Height, Comp->Width, Comp->Height, 1, &Min, &Max);
+ PointBuffer += NumberOfVerts * sizeof(nvg_point);
+ void *Data_Stroke = PointBuffer;
+ uint32 StrokeCount = NVG_ExpandStroke(Memory, NumberOfVerts, ShapeOpt.StrokeWidth, ShapeOpt.LineCapType, ShapeOpt.LineJoinType, Shape->IsClosed, (nvg_point *)Data, (real32 *)Data_Stroke);
+ PointBuffer += StrokeCount * sizeof(real32) * 4;
+ void *Data_Fill = PointBuffer;
+ NVG_ExpandFill(Memory, NumberOfVerts, (nvg_point *)Data, (real32 *)Data_Fill);
+ PointBuffer += NumberOfVerts * sizeof(real32) * 4;
+
+ // zero to set the framebuffer to main
+ gl_effect_layer TestL = {};
+ void *EffectBitmapAddress = NULL;
+
+ gl_data *GL_Data = RenderData->LayerEntry[RenderData->LayerCount] = (gl_data *)PointBuffer;
+ RenderData->LayerCount++;
+ PointBuffer += sizeof(gl_data);
+
+ int Visibility = ShapeOpt.Visibility;
+ *GL_Data = { 0, Data_Stroke, StrokeCount, ShapeOpt.StrokeCol,
+ Data_Fill, NumberOfVerts, ShapeOpt.FillCol,
+ T, Shape->Width, Shape->Height, Visibility };
+ } else if (!Layer->IsPrecomp) {
+ int Width = 0, Height = 0;
+ Layer_GetDimensions(Memory, Layer, &Width, &Height);
+
+ gl_data *GL_Data = RenderData->LayerEntry[RenderData->LayerCount] = (gl_data *)PointBuffer;
+ RenderData->LayerCount++;
+ PointBuffer += sizeof(gl_data);
+
+ GL_Data->Type = 1;
+ GL_Data->Width = Width;
+ GL_Data->Height = Height;
+ GL_Data->T = T;
+ } else {
+ }
}
}
- Assert((StartAddress - (uint8 *)Memory->Slot[B_PointData].Address) < Memory->Slot[B_PointData].Size);
-
- ImDrawCallback CustomRenderer = GL_Test;
- draw_list->AddCallback(CustomRenderer, (void *)RenderData);
+ Assert((PointBuffer - (uint8 *)Memory->Slot[B_PointData].Address) < Memory->Slot[B_PointData].Size);
- draw_list->AddCallback(ImDrawCallback_ResetRenderState, NULL);
}
static void *