summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTuomas Virtanen <katajakasa@gmail.com>2018-06-23 01:38:02 +0300
committerTuomas Virtanen <katajakasa@gmail.com>2018-06-23 01:38:02 +0300
commit329de67ea44552c1d08e23203daee7e878ffd759 (patch)
tree56ce99ac70c1f28ecbd894728111672bdaa19c85 /src
parentcd1adb20d37af17195b8d4dc1f9ac761bf2f4c48 (diff)
Add borders between atlas items
Diffstat (limited to 'src')
-rw-r--r--src/internal/subtitle/kitatlas.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/internal/subtitle/kitatlas.c b/src/internal/subtitle/kitatlas.c
index a011989..34c88a8 100644
--- a/src/internal/subtitle/kitatlas.c
+++ b/src/internal/subtitle/kitatlas.c
@@ -115,7 +115,7 @@ int Kit_FindFreeAtlasSlot(Kit_TextureAtlas *atlas, Kit_TextureAtlasItem *item) {
total_reserved_h += shelf_h;
// If the item fits, check if the space is better than previous one
- if(item->surface->w <= (atlas->w - shelf_w) && item->surface->h <= shelf_h) {
+ if(item->surface->w <= (atlas->w - shelf_w) && (item->surface->h + atlas->border) <= shelf_h) {
if(shelf_h < best_shelf_h) {
best_shelf_h = shelf_h;
best_shelf_idx = shelf_idx;
@@ -130,21 +130,21 @@ int Kit_FindFreeAtlasSlot(Kit_TextureAtlas *atlas, Kit_TextureAtlasItem *item) {
item,
best_shelf_idx,
atlas->shelves[best_shelf_idx].count,
- atlas->shelves[best_shelf_idx].width,
+ atlas->shelves[best_shelf_idx].width + atlas->border,
best_shelf_y);
- atlas->shelves[best_shelf_idx].width += item->surface->w;
+ atlas->shelves[best_shelf_idx].width += item->surface->w + atlas->border;
atlas->shelves[best_shelf_idx].count += 1;
return 0;
} else if(total_remaining_h >= item->surface->h) {
- atlas->shelves[shelf_idx].width = item->surface->w;
- atlas->shelves[shelf_idx].height = item->surface->h;
+ atlas->shelves[shelf_idx].width = item->surface->w + atlas->border;
+ atlas->shelves[shelf_idx].height = item->surface->h + atlas->border;
atlas->shelves[shelf_idx].count = 1;
Kit_SetItemAllocation(
item,
shelf_idx,
0,
- 0,
- total_reserved_h);
+ atlas->border,
+ total_reserved_h + atlas->border);
return 0;
}