summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp65
1 files changed, 50 insertions, 15 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 77a405a..f5ffbea 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -74,6 +74,7 @@ Main_RenderUI(ImGuiIO io, ImVec4 clear_color, SDL_Window *window)
static bool32
Main_InputTest(project_data *File, project_state *State, memory *Memory, sorted_file Sorted, ui *UI, SDL_Window *window, GLuint textureID)
{
+ uint64 InputStart = SDL_GetPerformanceCounter();
ImGuiIO& io = ImGui::GetIO();
SDL_Event event = {};
int test = 0;
@@ -171,6 +172,10 @@ Main_InputTest(project_data *File, project_state *State, memory *Memory, sorted_
test += 1;
if (State->UpdateScreen)
test = 0;
+
+ uint64 InputTime = SDL_GetPerformanceCounter() - InputStart;
+ printf("OURUI: %.2lu\n", InputTime);
+
return test;
}
@@ -291,6 +296,7 @@ Render_SortKeyframes(project_data *File, project_state *State, memory *Memory,
static void
GL_Test(const ImDrawList* parent_list, const ImDrawCmd* cmd)
{
+ uint64 PerfStart = SDL_GetPerformanceCounter();
gl_viewport_data *RenderData = (gl_viewport_data *)cmd->UserCallbackData;
gl_effect_layer MSBuffer = {};
@@ -350,13 +356,22 @@ GL_Test(const ImDrawList* parent_list, const ImDrawCmd* cmd)
glBindFramebuffer(GL_READ_FRAMEBUFFER, MSBuffer.FramebufferObject);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
// The multisample framebuffer allows us to conveniently clip to the comp bounds.
- ImVec2 MinPos(RenderData->UIPos.x, A[3] - RenderData->UIPos.y - RenderData->UIZoom.y);
- ImVec2 MaxPos = MinPos + RenderData->UIZoom;
- glBlitFramebuffer(MinPos.x, MinPos.y, MaxPos.x, MaxPos.y,
- MinPos.x, MinPos.y, MaxPos.x, MaxPos.y,
- GL_COLOR_BUFFER_BIT, GL_LINEAR);
+ if (RenderData->ViewportDisplay == 1) {
+ ImVec2 MinPos(RenderData->UIPos.x, A[3] - RenderData->UIPos.y - RenderData->UIZoom.y);
+ ImVec2 MaxPos = MinPos + RenderData->UIZoom;
+ glBlitFramebuffer(MinPos.x, MinPos.y, MaxPos.x, MaxPos.y,
+ MinPos.x, MinPos.y, MaxPos.x, MaxPos.y,
+ GL_COLOR_BUFFER_BIT, GL_LINEAR);
+ } else {
+ // TODO(fox): fix this?
+ glBlitFramebuffer(RenderData->ViewportMin.x, RenderData->ViewportMin.y - 50, RenderData->ViewportMax.x, RenderData->ViewportMax.y,
+ RenderData->ViewportMin.x, RenderData->ViewportMin.y - 50, RenderData->ViewportMax.x, RenderData->ViewportMax.y,
+ GL_COLOR_BUFFER_BIT, GL_LINEAR);
+ }
GL_DeleteHWBuffer(&MSBuffer);
+ uint64 PerfEnd = SDL_GetPerformanceCounter() - PerfStart;
+ printf("OPENGL: %.2lu\n", PerfEnd);
}
// TODO(fox): We have five functions that essentially do this same precomp loop
@@ -465,17 +480,19 @@ LayerIterate_SelectionAct(project_state *State, memory *Memory, uint32 CompIndex
Assert(Layer->Block_Composition_Index == CompIndex);
int Width = 0, Height = 0;
Layer_GetDimensions(Memory, Layer, &Width, &Height);
- if (Layer->IsPrecomp && (Layer->IsSelected & 0x03)) {
+ if (Layer->IsPrecomp && (Layer->IsSelected & 0x03 || State->SelectionMode == 1)) {
// only like 20% sure how this works...
layer_transforms NewExtraT = Layer_GetTransforms(Layer);
v2 NewCenter = T_CompPosToLayerPos(NewExtraT, Comp->Width, Comp->Height, Width, Height, Center.x, Center.y);
NewExtraT.rotation = ExtraT.rotation - NewExtraT.rotation;
NewExtraT.scale = ExtraT.scale / NewExtraT.scale;
LayerIndex = LayerIterate_SelectionAct(State, Memory, Layer->Block_Source_Index, NewExtraT, NewCenter, SortedCompArray, SortedLayerArray, SelectionCount, SelectedLayerIndex, SelectedPrecompIndex, BelowOnly);
- if (LayerIndex != -1) {
+ if (LayerIndex == -2) {
+ return -2;
+ } else if (LayerIndex != -1) {
Layer->IsSelected = 0x02;
return LayerIndex;
- }
+ }
}
v2 Position = State->Interact_Transform.Position;
real32 Rad = (ExtraT.rotation * (PI / 180));
@@ -484,16 +501,22 @@ LayerIterate_SelectionAct(project_state *State, memory *Memory, uint32 CompIndex
Position = XAxis + YAxis;
layer_transforms T = Layer_GetTransforms(Layer);
v2 UV = T_CompUVToLayerUV(T, Comp->Width, Comp->Height, Width, Height, Center / V2(Comp->Width, Comp->Height));
- if (UV.x <= 1.0f && UV.x >= 0.0f && UV.y <= 1.0f && UV.y >= 0.0f && !(Layer->IsSelected & 0x01) && !Layer->IsLocked)
+ if (UV.x <= 1.0f && UV.x >= 0.0f && UV.y <= 1.0f && UV.y >= 0.0f && !Layer->IsLocked)
{
- if (!BelowOnly && SelectionCount == 1) {
- if (i < SelectedLayerIndex || SelectedPrecompIndex != CompIndex) {
+ if (!(Layer->IsSelected & 0x01)) {
+ if (!BelowOnly && SelectionCount == 1) {
+ if (i < SelectedLayerIndex || SelectedPrecompIndex != CompIndex) {
+ LayerIndex = Index_Physical;
+ break;
+ }
+ } else {
LayerIndex = Index_Physical;
break;
}
- } else {
- LayerIndex = Index_Physical;
- break;
+ } else if (Layer->IsSelected & 0x01 && BelowOnly) {
+ Layer->IsSelected = 0x00;
+ State->Interact_Transform = {};
+ return -2;
}
}
}
@@ -621,10 +644,16 @@ Render_UI(project_data *File, project_state *State, memory *Memory, ui *UI, ImDr
RenderData->LayerCount++;
PointBuffer += sizeof(gl_data);
+ int RenderFlags = 0;
int Visibility = ShapeOpt.Visibility;
+ if (Visibility == 0 || Visibility == 2)
+ RenderFlags |= gl_renderflag_fill;
+ if (Visibility == 1 || Visibility == 2)
+ RenderFlags |= gl_renderflag_stroke;
+
*GL_Data = { 0, Data_Stroke, StrokeCount, ShapeOpt.StrokeCol,
Data_Fill, NumberOfVerts, ShapeOpt.FillCol,
- T, Shape->Width, Shape->Height, Visibility };
+ T, Shape->Width, Shape->Height, RenderFlags };
} else if (Layer->IsPrecomp) {
layer_transforms NewExtraT = Layer_GetTransforms(Layer);
@@ -1322,7 +1351,9 @@ int main(int argc, char *argv[]) {
// TODO(fox): Do the same thing with the timeline and viewport to
// reduce wasted rendering further; for now I am at least pausing all
// UI when no inputs happen.
+ uint64 InputStart = SDL_GetPerformanceCounter();
State->UpdateScreen += Main_InputTest(File, State, &Memory, Sorted, &File->UI, window, textureID);
+ uint64 InputTime = SDL_GetPerformanceCounter() - InputStart;
if (State->IsPlaying) {
block_composition *MainComp = (block_composition *)Memory_Block_AddressAtIndex(&Memory, F_Precomps, File->PrincipalCompIndex);
@@ -1423,6 +1454,7 @@ int main(int argc, char *argv[]) {
// frames, but we'd have to make sure the pop order stays the same in all scenarios.
Assert(Debug.ScratchState == 0);
+ uint64 RenderStart = SDL_GetPerformanceCounter();
bool32 UpdateScreen = 0;
if (State->IsPlaying && State->HotFramePerf > 1 && FullyCached) {
uint64 RenderTime = SDL_GetPerformanceCounter() - State->HotFramePerf;
@@ -1439,6 +1471,7 @@ int main(int argc, char *argv[]) {
UpdateScreen = 1;
}
}
+ uint64 RenderTime = SDL_GetPerformanceCounter() - RenderStart;
if (State->HotFramePerf == 1) {
State->HotFramePerf = SDL_GetPerformanceCounter();
@@ -1459,6 +1492,8 @@ int main(int argc, char *argv[]) {
if (TargetMS > FrameMS)
SDL_Delay((uint64)(TargetMS - FrameMS));
}
+ printf("TOTAL: %.2lu, (%.2f ms) - INPUTS: %.2lu - RENDERING: %.2lu\n", PerfTime, FrameMS, InputTime, RenderTime);
+ // printf("TOTAL: %.2lu, (%.2f ms) - RENDERING: %.2lu\n", PerfTime, FrameMS, PerfTime);
}
for (int i = 0; i < 7; i++) {