[gtk/matthiasc/for-master: 5/6] ngl: Be consistent about padding
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master: 5/6] ngl: Be consistent about padding
- Date: Sun, 16 May 2021 02:23:53 +0000 (UTC)
commit 81e02064656ca937936b4eca292ec880e0598a3e
Author: Matthias Clasen <mclasen redhat com>
Date: Sat May 15 08:58:50 2021 -0400
ngl: Be consistent about padding
Make gsk_ngl_texture_library_pack always return
the position including the padding. And compute
texture coordinates accurately in all cases (we
were fudging the padding for standalone textures.
gsk/ngl/gskngltexturelibrary.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
---
diff --git a/gsk/ngl/gskngltexturelibrary.c b/gsk/ngl/gskngltexturelibrary.c
index 1e87fc6a6a..6e4eb62d4e 100644
--- a/gsk/ngl/gskngltexturelibrary.c
+++ b/gsk/ngl/gskngltexturelibrary.c
@@ -377,10 +377,10 @@ gsk_ngl_texture_library_pack (GskNglTextureLibrary *self,
entry->atlas = atlas;
entry->is_atlased = TRUE;
- entry->area.x = (float)(packed_x + padding) / atlas->width;
- entry->area.y = (float)(packed_y + padding) / atlas->height;
- entry->area.x2 = entry->area.x + (float)width / atlas->width;
- entry->area.y2 = entry->area.y + (float)height / atlas->height;
+ entry->area.x = (packed_x + padding) / (float)atlas->width;
+ entry->area.y = (packed_y + padding) / (float)atlas->height;
+ entry->area.x2 = (packed_x + padding + width) / (float)atlas->width;
+ entry->area.y2 = (packed_y + padding + height) / (float)atlas->height;
*out_packed_x = packed_x;
*out_packed_y = packed_y;
@@ -394,13 +394,13 @@ gsk_ngl_texture_library_pack (GskNglTextureLibrary *self,
entry->texture = texture;
entry->is_atlased = FALSE;
entry->accessed = TRUE;
- entry->area.x = 0.0f;
- entry->area.y = 0.0f;
- entry->area.x2 = 1.0f;
- entry->area.y2 = 1.0f;
+ entry->area.x = padding / (float) (padding + width + padding);
+ entry->area.y = padding / (float) (padding + height + padding);
+ entry->area.x2 = (padding + width) / (float) (padding + width + padding);
+ entry->area.y2 = (padding + height) / (float) (padding + height + padding);
- *out_packed_x = padding;
- *out_packed_y = padding;
+ *out_packed_x = 0;
+ *out_packed_y = 0;
}
g_hash_table_insert (self->hash_table, key, entry);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]