diff --git a/milepost/src/gl_canvas.c b/milepost/src/gl_canvas.c index 50a81df..2c43bee 100644 --- a/milepost/src/gl_canvas.c +++ b/milepost/src/gl_canvas.c @@ -373,8 +373,14 @@ void mg_gl_canvas_encode_path(mg_gl_canvas_backend* backend, mg_primitive* primi path->textureID = -1; } - int nTilesX = ((path->box.z - path->box.x)*scale - 1) / MG_GL_TILE_SIZE + 1; - int nTilesY = ((path->box.w - path->box.y)*scale - 1) / MG_GL_TILE_SIZE + 1; + int firstTileX = path->box.x*scale / MG_GL_TILE_SIZE; + int firstTileY = path->box.y*scale / MG_GL_TILE_SIZE; + int lastTileX = path->box.z*scale / MG_GL_TILE_SIZE; + int lastTileY = path->box.w*scale / MG_GL_TILE_SIZE; + + int nTilesX = lastTileX - firstTileX + 1; + int nTilesY = lastTileY - firstTileY + 1; + backend->maxTileQueueCount += (nTilesX * nTilesY); } diff --git a/milepost/src/mtl_renderer.m b/milepost/src/mtl_renderer.m index 61de9db..11497cd 100644 --- a/milepost/src/mtl_renderer.m +++ b/milepost/src/mtl_renderer.m @@ -255,8 +255,14 @@ void mg_mtl_encode_path(mg_mtl_canvas_backend* backend, mg_primitive* primitive, } path->texture = backend->currentImageIndex; - int nTilesX = ((path->box.z - path->box.x)*scale - 1) / MG_MTL_TILE_SIZE + 1; - int nTilesY = ((path->box.w - path->box.y)*scale - 1) / MG_MTL_TILE_SIZE + 1; + int firstTileX = path->box.x*scale / MG_MTL_TILE_SIZE; + int firstTileY = path->box.y*scale / MG_MTL_TILE_SIZE; + int lastTileX = path->box.z*scale / MG_MTL_TILE_SIZE; + int lastTileY = path->box.w*scale / MG_MTL_TILE_SIZE; + + int nTilesX = lastTileX - firstTileX + 1; + int nTilesY = lastTileY - firstTileY + 1; + backend->maxTileQueueCount += (nTilesX * nTilesY); }