-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Labels
Description
Improved drawRect method implementation for unfilled rectangles
The new implementation for unfilled rectangles in the drawRect method offers better control and clarity:
Each edge of the rectangle is now drawn explicitly, improving precision.
The use of a constant thickness enhances maintainability.
However, there's a potential optimization opportunity:
Consider creating a single DrawCmd for the entire unfilled rectangle instead of four separate commands. This could improve performance, especially when drawing many unfilled rectangles. Here's a potential approach:
if (!filled) {
DrawCmd *drawCmd = alloc();
drawCmd->NumVertices = 8; // 4 corners, each used twice
drawCmd->Vertices = new RenderVert[drawCmd->NumVertices];
// ... set up vertices for all four corners ...
drawCmd->NumIndices = 8; // 4 lines, 2 indices each
drawCmd->Indices = new ui16[drawCmd->NumIndices];
// ... set up indices to draw 4 lines ...
drawCmd->PrimType = PrimitiveType::LineList;
mDrawCmdArray.add(drawCmd);
}
This approach would reduce memory allocations and draw calls, potentially improving performance.