diff options
-rw-r--r-- | bezier.cpp | 50 | ||||
-rwxr-xr-x | build.sh | 5 | ||||
-rw-r--r-- | createcalls.cpp | 48 | ||||
-rw-r--r-- | defines.h | 1 | ||||
-rw-r--r-- | effects.cpp | 4 | ||||
-rw-r--r-- | ffmpeg_backend.cpp | 5 | ||||
-rw-r--r-- | layer.cpp | 14 | ||||
-rw-r--r-- | memory.cpp | 11 | ||||
-rw-r--r-- | my_imgui_widgets.cpp | 16 | ||||
-rw-r--r-- | my_math.h | 1 | ||||
-rw-r--r-- | prenderer.cpp | 28 | ||||
-rw-r--r-- | ui.cpp | 17 |
12 files changed, 76 insertions, 124 deletions
@@ -155,3 +155,53 @@ void Bezier_CubicCalcPoints(v2 p1, v2 p2, v2 p3, v2 p4, void *Data, uint32 *Incr void *Pointer = Data; Bezier_CubicCalcPointsCasteljauStep(Pointer, Increment, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, p4.x, p4.y, tess_tol, 0); } + +// These functions will become more generalized as shapes are added. + +static void +Mask_AddPointToLine(mask *Mask, uint16 Index, v2 Pos) +{ + for (int i = Mask->NumberOfPoints - 1; i > Index; i--) { + Mask->Point[i+1] = Mask->Point[i]; + } + mask_point *PointToAdd = &Mask->Point[Index+1]; + PointToAdd->Pos = Pos; + Mask->NumberOfPoints++; +} + +static void +Mask_PushPoint(mask *Mask, v2 Pos) +{ + mask_point *PointToAdd = &Mask->Point[Mask->NumberOfPoints]; + PointToAdd->Pos = Pos; + Mask->NumberOfPoints++; +} + +static void +Mask_AddPointToCurve(mask *Mask, uint16 Index, real32 ratio) +{ + mask_point *Point0 = &Mask->Point[Index]; + mask_point *Point1 = &Mask->Point[Index+1]; + + v2 Point0_Pos_Right = Point0->Pos + Point0->TangentRight; + v2 Point1_Pos_Left = Point1->Pos + Point1->TangentLeft; + v2 Handle0_Half = Line_RatioToPoint(Point0->Pos, Point0_Pos_Right, ratio); + v2 Handle1_Half = Line_RatioToPoint(Point1_Pos_Left, Point1->Pos, ratio); + v2 Top_Half = Line_RatioToPoint(Point0_Pos_Right, Point1_Pos_Left, ratio); + v2 NewHandleLeft = Line_RatioToPoint(Handle0_Half, Top_Half, ratio); + v2 NewHandleRight = Line_RatioToPoint(Top_Half, Handle1_Half, ratio); + v2 NewPos = Line_RatioToPoint(NewHandleLeft, NewHandleRight, ratio); + + Point0->TangentRight = -(Point0->Pos - Handle0_Half); + Point1->TangentLeft = -(Point1->Pos - Handle1_Half); + + for (int i = Mask->NumberOfPoints - 1; i > Index; i--) { + Mask->Point[i+1] = Mask->Point[i]; + } + mask_point *PointToAdd = &Mask->Point[Index+1]; + + PointToAdd->Pos = NewPos; + PointToAdd->TangentLeft = -(NewPos - NewHandleLeft); + PointToAdd->TangentRight = -(NewPos - NewHandleRight); + Mask->NumberOfPoints++; +} @@ -5,9 +5,10 @@ WINDOWS=0 WARNING_FLAGS=" -Wall -Wextra \ -Wno-unused-function -Wno-unused-variable -Wno-unused-parameter -Wno-unused-but-set-variable \ - -Wno-missing-field-initializers -Wno-sign-compare -Wno-write-strings -Wno-unused-but-set-parameter \ - -Wno-missing-braces -Wno-format-security + -Wno-missing-field-initializers -Wno-sign-compare -Wno-unused-but-set-parameter \ + -Wno-missing-braces -Wno-format-security \ -fno-exceptions -Wno-strict-aliasing \ + -Wno-write-strings -DDEBUG=1 -DARM=0 -DTHREADED=1 \ " diff --git a/createcalls.cpp b/createcalls.cpp index 89d881b..633a37a 100644 --- a/createcalls.cpp +++ b/createcalls.cpp @@ -384,54 +384,6 @@ Layer_ScreenSpaceToLocal(project_layer *Layer, ui *UI, comp_buffer CompBuffer, I } static void -Mask_AddPointToLine(mask *Mask, uint16 Index, v2 Pos) -{ - for (int i = Mask->NumberOfPoints - 1; i > Index; i--) { - Mask->Point[i+1] = Mask->Point[i]; - } - mask_point *PointToAdd = &Mask->Point[Index+1]; - PointToAdd->Pos = Pos; - Mask->NumberOfPoints++; -} - -static void -Mask_PushPoint(mask *Mask, v2 Pos) -{ - mask_point *PointToAdd = &Mask->Point[Mask->NumberOfPoints]; - PointToAdd->Pos = Pos; - Mask->NumberOfPoints++; -} - -static void -Mask_AddPointToCurve(mask *Mask, uint16 Index, real32 ratio) -{ - mask_point *Point0 = &Mask->Point[Index]; - mask_point *Point1 = &Mask->Point[Index+1]; - - v2 Point0_Pos_Right = Point0->Pos + Point0->TangentRight; - v2 Point1_Pos_Left = Point1->Pos + Point1->TangentLeft; - v2 Handle0_Half = Line_RatioToPoint(Point0->Pos, Point0_Pos_Right, ratio); - v2 Handle1_Half = Line_RatioToPoint(Point1_Pos_Left, Point1->Pos, ratio); - v2 Top_Half = Line_RatioToPoint(Point0_Pos_Right, Point1_Pos_Left, ratio); - v2 NewHandleLeft = Line_RatioToPoint(Handle0_Half, Top_Half, ratio); - v2 NewHandleRight = Line_RatioToPoint(Top_Half, Handle1_Half, ratio); - v2 NewPos = Line_RatioToPoint(NewHandleLeft, NewHandleRight, ratio); - - Point0->TangentRight = -(Point0->Pos - Handle0_Half); - Point1->TangentLeft = -(Point1->Pos - Handle1_Half); - - for (int i = Mask->NumberOfPoints - 1; i > Index; i--) { - Mask->Point[i+1] = Mask->Point[i]; - } - mask_point *PointToAdd = &Mask->Point[Index+1]; - - PointToAdd->Pos = NewPos; - PointToAdd->TangentLeft = -(NewPos - NewHandleLeft); - PointToAdd->TangentRight = -(NewPos - NewHandleRight); - Mask->NumberOfPoints++; -} - -static void LoadTestFootage(project_data *File, project_state *State, memory *Memory) { if (!Source_Generate(File, Memory, "../asset/24.mp4")) @@ -1,4 +1,3 @@ -#define SwitchBool(Bool) if((Bool)) {(Bool) = 0;} else {(Bool) = 1;} #define AmountOf(Array) sizeof((Array)) / sizeof((Array)[1]) typedef int8_t int8; diff --git a/effects.cpp b/effects.cpp index 67f0887..b15b0fb 100644 --- a/effects.cpp +++ b/effects.cpp @@ -8,14 +8,11 @@ DrawColor(source *Source, layer_bitmap_info *BitmapInfo, memory *Memory, propert __m256 ZeroPointFive = _mm256_set1_ps(0.5); __m256 One = _mm256_set1_ps(1); __m256 Two = _mm256_set1_ps(2); - __m256 Four = _mm256_set1_ps(4); __m256 Fraction255 = _mm256_set1_ps(1/255.0f); __m256 Real255 = _mm256_set1_ps(255); - __m256i Zero = _mm256_set1_epi8(0); __m256i FF = _mm256_set1_epi32(0xFF); - __m256i Int255 = _mm256_set1_epi8((uint8)255); __m256 Alpha = _mm256_set1_ps(FloatColor.a); __m256 AlphaInv = _mm256_set1_ps(1.0f - FloatColor.a); @@ -47,7 +44,6 @@ DrawColor(source *Source, layer_bitmap_info *BitmapInfo, memory *Memory, propert __m256 G_Dest = _mm256_mul_ps(_mm256_cvtepi32_ps(_mm256_and_si256(_mm256_srli_epi32(DestPixel, 8), FF)), Fraction255); __m256 B_Dest = _mm256_mul_ps(_mm256_cvtepi32_ps(_mm256_and_si256(_mm256_srli_epi32(DestPixel, 16), FF)), Fraction255); __m256i A_Out = _mm256_and_si256(_mm256_srli_epi32(DestPixel, 24), FF); - __m256 A_Dest = _mm256_mul_ps(_mm256_cvtepi32_ps(A_Out), Fraction255); __m256 R_Blend = _mm256_setzero_ps(); __m256 G_Blend = _mm256_setzero_ps(); diff --git a/ffmpeg_backend.cpp b/ffmpeg_backend.cpp index bece065..b3d5be8 100644 --- a/ffmpeg_backend.cpp +++ b/ffmpeg_backend.cpp @@ -114,7 +114,7 @@ void AV_Init(source *Source, layer_bitmap_info *BitmapInfo, memory *Memory) Assert(0); } - for (int i = 0; i < AV->FileFormatContext->nb_streams; i++) + for (uint32 i = 0; i < AV->FileFormatContext->nb_streams; i++) { AVCodecParameters *LocalCodecParameters = NULL; LocalCodecParameters = AV->FileFormatContext->streams[i]->codecpar; @@ -223,9 +223,6 @@ cached_bitmap * AV_LoadVideoFrame(source *Source, layer_bitmap_info *BitmapInfo, } Assert(Source->Info.AvgPTSPerFrame); - int p = 0; - int i = 0; - int32 FrameToSeek = TimelineFrame - BitmapInfo->FrameOffset; if (*CurrentlyRenderedFrame == FrameToSeek || FrameToSeek < 0) return 0; @@ -71,15 +71,15 @@ TransformsInteract(project_data *File, project_state *State, ui *UI, transforms_ for (int i = 0; i < State->NumberOfSelectedLayers; i++) { uint16 Index = List.LayerIndex[i]; if (Mode == sliding_position) { - SwitchBool(File->Layer[Index]->x.IsToggled) - SwitchBool(File->Layer[Index]->y.IsToggled) + File->Layer[Index]->x.IsToggled ^= 1; + File->Layer[Index]->y.IsToggled ^= 1; } else if (Mode == sliding_anchorpoint) { - SwitchBool(File->Layer[Index]->ax.IsToggled) - SwitchBool(File->Layer[Index]->ay.IsToggled) + File->Layer[Index]->ax.IsToggled ^= 1; + File->Layer[Index]->ay.IsToggled ^= 1; } else if (Mode == sliding_rotation) { - SwitchBool(File->Layer[Index]->rotation.IsToggled) + File->Layer[Index]->rotation.IsToggled ^= 1; } else if (Mode == sliding_scale) { - SwitchBool(File->Layer[Index]->scale.IsToggled) + File->Layer[Index]->scale.IsToggled ^= 1; } } } else if (UI->FocusedWindow == focus_viewport) { @@ -150,7 +150,7 @@ MoveLayersByIncrement(project_data *File, project_state *State, int16 Increment) while (c > 0) { if (Index+c == State->MostRecentlySelectedLayer) State->MostRecentlySelectedLayer += Increment; - project_layer Temp = *File->Layer[Index+c]; + // project_layer Temp = *File->Layer[Index+c]; *File->Layer[Index+c] = *File->Layer[Index + c - 1]; c--; } @@ -57,12 +57,11 @@ Memory_RollingBitmap(memory *Memory, source *Source, uint32 FrameToSeek) uint16 Width = Source->Info.Width; uint16 Height = Source->Info.Height; uint16 BytesPerPixel = Source->Info.BytesPerPixel; - int32 Pitch = Width*BytesPerPixel; memory_table *Table = &Memory->Slot[B_LoadedBitmaps]; // First check whether we'd run over the buffer at the current - // position, and reset it if so. + // position, and reset the position if so. uint64 Size = Bitmap_CalcTotalBytes(Width, Height, BytesPerPixel); if (Table->CurrentPosition + Size > Table->Size) { Table->CurrentPosition = 0; @@ -71,6 +70,8 @@ Memory_RollingBitmap(memory *Memory, source *Source, uint32 FrameToSeek) cached_bitmap *Bitmap = &Memory->Bitmap[Table->PointerIndex]; + // If there are no pointers in front of us, we don't have to free any space + // and just need to increment the number of pointers. if (Table->PointerIndex != Table->NumberOfPointers) { // Next, if there's a pointer in front of the current position, // check whether it's far away enough so that the size fits. @@ -78,7 +79,7 @@ Memory_RollingBitmap(memory *Memory, source *Source, uint32 FrameToSeek) if (Bitmap->Data) { uint64 BytesBetween = (uint8 *)Bitmap->Data - ((uint8 *)Table->Address + Table->CurrentPosition); if (BytesBetween > Size) { - int16 StopAt = Table->NumberOfPointers - 1; + uint32 StopAt = Table->NumberOfPointers - 1; while (StopAt > Table->PointerIndex - 1) { Memory->Bitmap[StopAt + 1] = Memory->Bitmap[StopAt]; StopAt--; @@ -102,7 +103,7 @@ Memory_RollingBitmap(memory *Memory, source *Source, uint32 FrameToSeek) void *Data2 = Memory->Bitmap[Table->PointerIndex+1].Data; uint64 BytesBetween = (uint8 *)Data2 - (uint8 *)AddressStart; if (BytesBetween < Size) { - int16 StopAt = Table->PointerIndex; + uint32 StopAt = Table->PointerIndex; while (StopAt < Table->NumberOfPointers - 1) { Memory->Bitmap[StopAt] = Memory->Bitmap[StopAt + 1]; StopAt++; @@ -121,8 +122,6 @@ Memory_RollingBitmap(memory *Memory, source *Source, uint32 FrameToSeek) } } } else { - // Increment the total number of pointers if the PointerIndex is ahead - // of the amount of pointers. Table->NumberOfPointers++; } Bitmap->Data = AllocateMemory(Memory, Size, B_LoadedBitmaps); diff --git a/my_imgui_widgets.cpp b/my_imgui_widgets.cpp index 656804d..4a4427c 100644 --- a/my_imgui_widgets.cpp +++ b/my_imgui_widgets.cpp @@ -210,7 +210,7 @@ ImGui_PropertiesPanel(project_data *File, project_state *State, ui *UI, memory * else ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetColorU32(ImGuiCol_Button)); if (ImGui::Button("V")) { - SwitchBool(Effect->IsActive); + Effect->IsActive ^= 1; State->UpdateFrame = true; } ImGui::SameLine(); @@ -418,10 +418,10 @@ ImGui_Viewport(project_data File, project_state *State, ui *UI, comp_buffer Comp draw_list->AddNgon(Point0_ScreenPos, 10, col, 8, 5.0f); - // draw_list->AddNgon(Point0_ScreenPos_Left, 10, col, 8, 5.0f); - // draw_list->AddNgon(Point0_ScreenPos_Right, 10, col, 8, 5.0f); - // draw_list->AddLine(Point0_ScreenPos, Point0_ScreenPos_Left, col, 2.0f); - // draw_list->AddLine(Point0_ScreenPos, Point0_ScreenPos_Right, col, 2.0f); + draw_list->AddNgon(Point0_ScreenPos_Left, 10, col, 8, 5.0f); + draw_list->AddNgon(Point0_ScreenPos_Right, 10, col, 8, 5.0f); + draw_list->AddLine(Point0_ScreenPos, Point0_ScreenPos_Left, col, 2.0f); + draw_list->AddLine(Point0_ScreenPos, Point0_ScreenPos_Right, col, 2.0f); int max = 1; @@ -1005,7 +1005,7 @@ ImGui_Timeline(project_data *File, project_state *State, memory *Memory, ui *UI, ManualKeyframeInsertF(Property, Memory, File->CurrentFrame, Property->CurrentValue.f); ImGui::SameLine(); if (ImGui::Button("G")) { - SwitchBool(Property->IsGraphToggled); + Property->IsGraphToggled ^= 1; // TODO(fox): Make system to init things like these automatically? if (!Property->GraphLength) { Property->GraphLength = 150; @@ -1492,7 +1492,7 @@ ImGui_ProcessInputs(project_data *File, project_state *State, comp_buffer *CompB if (io.KeyShift) { State->RerouteEffects = true; } else { - SwitchBool(State->IsPlaying); + State->IsPlaying ^= 1; } } @@ -1540,7 +1540,7 @@ ImGui_ProcessInputs(project_data *File, project_state *State, comp_buffer *CompB #if DEBUG if (ImGui::IsKeyPressed(ImGuiKey_W)) { - SwitchBool(Debug.ToggleWindow); + Debug.ToggleWindow ^= 1; } #endif @@ -685,7 +685,6 @@ Uint32ToNormalizedCol(uint32 LayerPixel) inline real32 Uint32ToNormalizedBW(uint32 LayerPixel) { - uint8 A2 = (LayerPixel >> 24); uint8 R2 = (LayerPixel >> 16); uint8 G2 = (LayerPixel >> 8); uint8 B2 = (LayerPixel >> 0); diff --git a/prenderer.cpp b/prenderer.cpp index 940cb0a..a93fa90 100644 --- a/prenderer.cpp +++ b/prenderer.cpp @@ -18,8 +18,6 @@ CheckQueue(render_queue RenderInfo, uint16 Index); static void CalculateAnchorOffset(project_layer *Layer, real32 Value, uint16 Dir) { - v2 Result = {}; - transform_info TransformInfo; source *Source = Layer->Source; real32 Rad = (Layer->rotation.CurrentValue.f * (PI / 180)); @@ -136,7 +134,7 @@ static void QueueCurrentFrame(project_data *File, comp_buffer *CompBuffer, project_state *State) { IsRendering = true; - render_queue RenderInfo = {File, State, CompBuffer}; + // render_queue RenderInfo = {File, State, CompBuffer}; for (int16 i = 0; i < File->NumberOfLayers; i++) { @@ -401,25 +399,16 @@ AVX2_RenderLayer(transform_info T, comp_buffer *Buffer, rectangle RenderRegion) __m256 One = _mm256_set1_ps(1); __m256 Two = _mm256_set1_ps(2); __m256 Zero = _mm256_set1_ps(0); - // __m256 UMin = _mm256_set1_ps(0.0f - (1 / T.LayerWidth)); - // __m256 VMin = _mm256_set1_ps(0.0f - (1 / T.LayerHeight)); - // __m256 UMax = _mm256_set1_ps(1.0f + (1 / T.LayerWidth)); - __m256 VMax = _mm256_set1_ps(1.0f - (1 / T.LayerHeight)); __m256 ZeroPoint25 = _mm256_set1_ps(0.25); __m256 ZeroPointFive = _mm256_set1_ps(0.5); - __m256i Zeroi = _mm256_set1_epi32(0); __m256i Onei = _mm256_set1_epi32(1); __m256 Four = _mm256_set1_ps(4); - __m256 Sixteen = _mm256_set1_ps(16); __m256i FF = _mm256_set1_epi32(0xFF); - __m256i Full = _mm256_set1_epi32(0xFFFFFFFF); __m256i BottomTwoBits = _mm256_set1_epi32(0x03); __m256i Fouri = _mm256_set1_epi32(4); __m256i Sixteeni = _mm256_set1_epi32(16); - __m256i SixtyFouri = _mm256_set1_epi32(64); __m256 Real255 = _mm256_set1_ps(255.0f); - __m256i Int255 = _mm256_set1_epi32(255); __m256 Norm255 = _mm256_set1_ps(1/255.0f); // __m256i White = _mm256_setr_epi32(0xFFFFFFFF, 0, 0, 0, 0xFFFFFFFF, 0, 0, 0); // __m256i White2 = _mm256_set1_epi32(0xFFFFFFFF); @@ -523,8 +512,7 @@ AVX2_RenderLayer(transform_info T, comp_buffer *Buffer, rectangle RenderRegion) __m256i TexXIntPlusOne = _mm256_add_epi32(TexXInt, _mm256_and_si256(_mm256_cmpgt_epi32(LayerWidthMinusOne, TexXInt), Onei)); __m256i TexYInt = _mm256_cvttps_epi32(TexYFull); __m256i TexYIntPlusOne = _mm256_add_epi32(TexYInt, _mm256_and_si256(_mm256_cmpgt_epi32(LayerHeightMinusOne, TexYInt), Onei)); - if (T.LayerWidth == 50 && _mm256_cvtsi256_si32(TexYIntPlusOne) == 49) - int pp = 0; + // NOTE(fox): The comparison is for when we're on the last pixel of the texel. __m256 TexX = _mm256_sub_ps(TexXFull, _mm256_cvtepi32_ps(TexXInt)); @@ -793,16 +781,13 @@ SSE2_RenderLayer(transform_info T, comp_buffer *Buffer, rectangle RenderRegion) __m128 Two = _mm_set1_ps(2); __m128 Zero = _mm_set1_ps(0); __m128 ZeroPointFive = _mm_set1_ps(0.5); - __m128i Zeroi = _mm_set1_epi32(0); __m128i Onei = _mm_set1_epi32(1); __m128 Four = _mm_set1_ps(4); - __m128 Sixteen = _mm_set1_ps(16); __m128i FF = _mm_set1_epi32(0xFF); __m128i BottomTwoBits = _mm_set1_epi32(0x03); __m128i Fouri = _mm_set1_epi32(4); __m128i Sixteeni = _mm_set1_epi32(16); __m128 Reg255 = _mm_set1_ps(255.0f); - __m128i Int255 = _mm_set1_epi32(255); __m128 Norm255 = _mm_set1_ps(1/255.0f); // NOTE(fox): Each loop operates on 4 pixels, 4 horizontal by 1 vertical. @@ -1122,9 +1107,6 @@ Fallback_RenderLayer(transform_info T, comp_buffer *Buffer, rectangle RenderRegi uint16 WidthP, HeightP; Bitmap_CalcPackedDimensions(Buffer->Width, Buffer->Height, &WidthP, &HeightP); - uint8 *Row = ((uint8 *)Buffer->PackedBuffer + WidthP*Buffer->BytesPerPixel*(int16)(LayerBounds.Min.y) ); - - uint32 Channel = (T.LayerWidth * T.LayerHeight); real32 Normalized255 = 1 / 255.0f; for (int16 Y = LayerBounds.Min.y; Y < LayerBounds.Max.y; Y++) @@ -1149,12 +1131,6 @@ Fallback_RenderLayer(transform_info T, comp_buffer *Buffer, rectangle RenderRegi uint32 TexYInt = (uint32)TexYFull; real32 TexY = TexYFull - TexYInt; - if(T.LayerWidth == 50) - real32 pp = 0; - - if(TexYInt > 47 && T.LayerWidth == 50) - real32 pp = 0; - real32 TexXInv = 1 - TexX; real32 TexYInv = 1 - TexY; real32 TexBothXInv = TexXInv * TexY; @@ -1,17 +0,0 @@ -static void -InteractProperty(int16 Index, project_data *File, project_state *State, bool32 Ended, real32 Value, memory *Memory, cache_pool *Cache) -{ - for (int r = 0; r < State->NumberOfSelectedLayers; r++) { - keyframe *Keyframe = InsertKeyframeAtFrame(&File->LayerPTR[State->SelectedLayerIndex[r]]->Property[Index], *State, File->CurrentFrame, Memory, Cache); - Keyframe->Value.f += Value; - } - // Cache->Interact = Active; - // Cache->InteractIndex = State->SelectedLayerIndex[0]; - if (Ended) - { - State->TranslateScaleRotate = 0; - Cache->Interact = Clear; - } - State->UpdateFrame = true; - // Cache->Frame[File->CurrentFrame].Cached = false; -} |