spans: Represent spans with floating point precision

Instead of using integers to represent spans we now use floats instead.
This means we are no longer forced to iterate using non-normalized
coordinates so we should hopefully be able to avoid numerous redundant
unnormalize/normalize steps when using the spans api.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
This commit is contained in:
Robert Bragg 2011-10-23 20:20:49 +01:00
parent c7098e417d
commit c11036cd13
3 changed files with 10 additions and 11 deletions

View File

@ -38,8 +38,7 @@ _cogl_span_iter_update (CoglSpanIter *iter)
iter->span = &g_array_index (iter->array, CoglSpan, iter->index); iter->span = &g_array_index (iter->array, CoglSpan, iter->index);
/* Offset next position by span size */ /* Offset next position by span size */
iter->next_pos = iter->pos + iter->next_pos = iter->pos + iter->span->size - iter->span->waste;
(float)(iter->span->size - iter->span->waste);
/* Check if span intersects the area to cover */ /* Check if span intersects the area to cover */
if (iter->next_pos <= iter->cover_start || if (iter->next_pos <= iter->cover_start ||

View File

@ -28,9 +28,9 @@
typedef struct _CoglSpan typedef struct _CoglSpan
{ {
int start; float start;
int size; float size;
int waste; float waste;
} CoglSpan; } CoglSpan;
typedef struct _CoglSpanIter typedef struct _CoglSpanIter

View File

@ -246,8 +246,8 @@ _cogl_texture_2d_sliced_set_waste (CoglTexture2DSliced *tex_2ds,
{ {
src = (bmp_data + ((src_y + (int) y_iter->intersect_start - dst_y) * src = (bmp_data + ((src_y + (int) y_iter->intersect_start - dst_y) *
bmp_rowstride) + bmp_rowstride) +
(src_x + x_span->start + x_span->size - (src_x + (int)x_span->start + (int)x_span->size -
x_span->waste - dst_x - 1) * bpp); (int)x_span->waste - dst_x - 1) * bpp);
dst = waste_buf; dst = waste_buf;
@ -295,8 +295,8 @@ _cogl_texture_2d_sliced_set_waste (CoglTexture2DSliced *tex_2ds,
src = (bmp_data + ((src_x + (int) x_iter->intersect_start - dst_x) * src = (bmp_data + ((src_x + (int) x_iter->intersect_start - dst_x) *
bpp) + bpp) +
(src_y + y_span->start + y_span->size - y_span->waste (src_y + (int)y_span->start + (int)y_span->size -
- dst_y - 1) * bmp_rowstride); (int)y_span->waste - dst_y - 1) * bmp_rowstride);
dst = waste_buf; dst = waste_buf;
@ -790,8 +790,8 @@ _cogl_texture_2d_sliced_slices_create (CoglContext *ctx,
COGL_NOTE (SLICING, "CREATE SLICE (%d,%d)\tsize (%d,%d)", COGL_NOTE (SLICING, "CREATE SLICE (%d,%d)\tsize (%d,%d)",
x, y, x, y,
x_span->size - x_span->waste, (int)(x_span->size - x_span->waste),
y_span->size - y_span->waste); (int)(y_span->size - y_span->waste));
slice_textures[y * n_x_slices + x] = slice_textures[y * n_x_slices + x] =
cogl_texture_2d_new_with_size (ctx, x_span->size, y_span->size, cogl_texture_2d_new_with_size (ctx, x_span->size, y_span->size,