Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@
MTLVC_ADD_VERTEX(TX1, TY1, DX1, DY1, 0); \
} while (0)

// Next define should exactly match to the amount
// of MTLVC_ADD_VERTEX in MTLVC_ADD_TRIANGLES
#define VERTS_FOR_A_QUAD 6

jboolean
MTLVertexCache_InitVertexCache()
{
Expand Down Expand Up @@ -219,7 +223,11 @@ void MTLVertexCache_FreeVertexCache()
J2dTraceLn1(J2D_TRACE_INFO, "MTLVertexCache_AddMaskQuad: %d",
maskCacheIndex);

if (maskCacheIndex >= MTLVC_MASK_CACHE_MAX_INDEX)
// MTLVC_ADD_TRIANGLES at the end of this function
// will place VERTS_FOR_A_QUAD vertexes to the vertex cache
// check free space and flush if needed.
if ((maskCacheIndex >= MTLVC_MASK_CACHE_MAX_INDEX) ||
((vertexCacheIndex + VERTS_FOR_A_QUAD) >= MTLVC_MAX_INDEX))
{
J2dTraceLn2(J2D_TRACE_INFO, "maskCacheIndex = %d, vertexCacheIndex = %d", maskCacheIndex, vertexCacheIndex);
MTLVertexCache_FlushVertexCache(mtlc);
Expand Down Expand Up @@ -305,7 +313,9 @@ void MTLVertexCache_FreeVertexCache()
{
J2dTraceLn(J2D_TRACE_INFO, "MTLVertexCache_AddGlyphQuad");

if (vertexCacheIndex >= MTLVC_MAX_INDEX)
// MTLVC_ADD_TRIANGLES adds VERTS_FOR_A_QUAD vertexes into Cache
// so need to check space for VERTS_FOR_A_QUAD elements
if ((vertexCacheIndex + VERTS_FOR_A_QUAD) >= MTLVC_MAX_INDEX)
{
J2dTraceLn2(J2D_TRACE_INFO, "maskCacheIndex = %d, vertexCacheIndex = %d", maskCacheIndex, vertexCacheIndex);
MTLVertexCache_FlushGlyphVertexCache();
Expand Down