diff options
Diffstat (limited to 'src/nanovg.cpp')
-rw-r--r-- | src/nanovg.cpp | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/src/nanovg.cpp b/src/nanovg.cpp index 1fb59ee..22d8621 100644 --- a/src/nanovg.cpp +++ b/src/nanovg.cpp @@ -172,42 +172,28 @@ static real32 * NVG_ButtCap(nvg_point *Point, real32 *StrokeData, // NOTE(fox): We only have to care about winding if we want to do HW accelerated // shape subtraction with the stencil buffer (I think). -// All the extra inputs on the second line are for when we need to take -// interactive mode into account. Since undoing a transform requires knowledge -// of the shape's size (does it?), the code needs to be ran twice, controlled -// with the Interact bool. static uint32 NVG_FlattenPath(memory *Memory, shape_layer *Shape, nvg_point *PointData, project_state *State, layer_transforms T, int Width, int Height, int CompWidth, int CompHeight, bool32 Interact, v2 *Min, v2 *Max) { nvg_point *PointPlayhead = PointData; - for (int i = 0; i < Shape->Point_Count; i++) { - bezier_point *Point = Bezier_LookupAddress(Memory, Shape->Block_Bezier_Index, i, 1); + bezier_point *BezierPointData = (bezier_point *)Memory_PushScratch(Memory, sizeof(bezier_point) * 128); + uint32 BezierCount = Bezier_Shape_Sort(Memory, Shape, BezierPointData, + State, T, Width, Height, + CompWidth, CompHeight, Interact); + for (int i = 0; i < BezierCount; i++) { + bezier_point *Point = &BezierPointData[i]; if (i == 0 || Point->Type == interpolation_type_linear) { v2 Pos = Point->Pos[0]; - if (State->Interact_Active == interact_type_keyframe_move && Point->IsSelected && Interact != 0) { - Pos = TransformPoint(T, Width, Height, Pos); - Pos.x += State->Interact_Offset[0]; - Pos.y += State->Interact_Offset[1]; - Pos = T_CompPosToLayerPos(T, CompWidth, CompHeight, Width, Height, Pos.x, Pos.y); - } *(v2 *)PointPlayhead = Pos; if (Shape->IsClosed || (i != 0 && i != (Shape->Point_Count - 1))) { PointPlayhead->Flags |= NVG_PT_CORNER; } PointPlayhead++; } else if (Point->Type == interpolation_type_bezier) { - bezier_point *Point_1 = Bezier_LookupAddress(Memory, Shape->Block_Bezier_Index, i-1, 1); + bezier_point *Point_1 = &BezierPointData[i-1]; v2 Pos[2] = { Point_1->Pos[0], Point->Pos[0] }; - if (State->Interact_Active == interact_type_keyframe_move && Point->IsSelected && Width != 0) { - for (int i = 0; i < 2; i++) { - Pos[i] = TransformPoint(T, Width, Height, Pos[i]); - Pos[i].x += State->Interact_Offset[0]; - Pos[i].y += State->Interact_Offset[1]; - Pos[i] = T_CompPosToLayerPos(T, CompWidth, CompHeight, Width, Height, Pos[i].x, Pos[i].y); - } - } PointPlayhead = (nvg_point *)Bezier_CubicCalcPoints(Pos[0], Pos[0] + Point_1->Pos[1], Pos[1] + Point->Pos[2], Pos[1], PointPlayhead, sizeof(nvg_point)); // The point at the end is also returned, so we remove it. if (i != (Shape->Point_Count - 1)) @@ -216,6 +202,7 @@ NVG_FlattenPath(memory *Memory, shape_layer *Shape, nvg_point *PointData, Assert(0); } } + Memory_PopScratch(Memory, sizeof(bezier_point) * 128); int NumberOfVerts = PointPlayhead - PointData; nvg_point *Point = &PointData[NumberOfVerts - 1]; nvg_point *NextPoint = PointData; |