mirror of
https://github.com/brl/mutter.git
synced 2024-11-23 00:20:42 -05:00
cogl-texture-2d-sliced: Fix the foreach callback for waste textures
When converting the virtual coordinates of the underlying texture for a slice to virtual coordinates for the whole texture it was using the size and offset of the intersection as the size of the child texture. This would be incorrect if the texture contains waste or the texture coordinates are not the default. Instead the sliced foreach function now passes the CoglSpan to the callback instead of the intersection. http://bugzilla.clutter-project.org/show_bug.cgi?id=2398
This commit is contained in:
parent
3203c2382f
commit
3bd20acfb4
@ -59,10 +59,8 @@ static const CoglTextureVtable cogl_texture_2d_sliced_vtable;
|
|||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
CoglTexture2DSliced *tex;
|
CoglTexture2DSliced *tex;
|
||||||
float x_intersect_start;
|
CoglSpan *x_span;
|
||||||
float x_intersect_end;
|
CoglSpan *y_span;
|
||||||
float y_intersect_start;
|
|
||||||
float y_intersect_end;
|
|
||||||
|
|
||||||
CoglTextureSliceCallback callback;
|
CoglTextureSliceCallback callback;
|
||||||
void *user_data;
|
void *user_data;
|
||||||
@ -81,18 +79,14 @@ _cogl_texture_2d_sliced_foreach_cb (CoglHandle handle,
|
|||||||
|
|
||||||
/* Convert the virtual coordinates of the texture slice back to
|
/* Convert the virtual coordinates of the texture slice back to
|
||||||
coordinates in the space of the outer texture */
|
coordinates in the space of the outer texture */
|
||||||
virtual_coords_out[0] = (virtual_coords_in[0] *
|
virtual_coords_out[0] = (virtual_coords_in[0] * data->x_span->size +
|
||||||
(data->x_intersect_end - data->x_intersect_start) +
|
data->x_span->start) / data->tex->width;
|
||||||
data->x_intersect_start) / data->tex->width;
|
virtual_coords_out[1] = (virtual_coords_in[1] * data->y_span->size +
|
||||||
virtual_coords_out[1] = (virtual_coords_in[1] *
|
data->y_span->start) / data->tex->height;
|
||||||
(data->y_intersect_end - data->y_intersect_start) +
|
virtual_coords_out[2] = (virtual_coords_in[2] * data->x_span->size +
|
||||||
data->y_intersect_start) / data->tex->height;
|
data->x_span->start) / data->tex->width;
|
||||||
virtual_coords_out[2] = (virtual_coords_in[2] *
|
virtual_coords_out[3] = (virtual_coords_in[3] * data->y_span->size +
|
||||||
(data->x_intersect_end - data->x_intersect_start) +
|
data->y_span->start) / data->tex->height;
|
||||||
data->x_intersect_start) / data->tex->width;
|
|
||||||
virtual_coords_out[3] = (virtual_coords_in[3] *
|
|
||||||
(data->y_intersect_end - data->y_intersect_start) +
|
|
||||||
data->y_intersect_start) / data->tex->height;
|
|
||||||
|
|
||||||
data->callback (data->tex,
|
data->callback (data->tex,
|
||||||
gl_handle,
|
gl_handle,
|
||||||
@ -151,30 +145,31 @@ _cogl_texture_2d_sliced_foreach_sub_texture_in_region (
|
|||||||
!_cogl_span_iter_end (&iter_y);
|
!_cogl_span_iter_end (&iter_y);
|
||||||
_cogl_span_iter_next (&iter_y))
|
_cogl_span_iter_next (&iter_y))
|
||||||
{
|
{
|
||||||
|
float y_intersect_start = iter_y.intersect_start;
|
||||||
|
float y_intersect_end = iter_y.intersect_end;
|
||||||
float slice_ty1;
|
float slice_ty1;
|
||||||
float slice_ty2;
|
float slice_ty2;
|
||||||
|
|
||||||
data.y_intersect_start = iter_y.intersect_start;
|
|
||||||
data.y_intersect_end = iter_y.intersect_end;
|
|
||||||
|
|
||||||
/* Discard slices out of rectangle early */
|
/* Discard slices out of rectangle early */
|
||||||
if (!iter_y.intersects)
|
if (!iter_y.intersects)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (iter_y.flipped)
|
if (iter_y.flipped)
|
||||||
{
|
{
|
||||||
data.y_intersect_start = iter_y.intersect_end;
|
y_intersect_start = iter_y.intersect_end;
|
||||||
data.y_intersect_end = iter_y.intersect_start;
|
y_intersect_end = iter_y.intersect_start;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Localize slice texture coordinates */
|
/* Localize slice texture coordinates */
|
||||||
slice_ty1 = data.y_intersect_start - iter_y.pos;
|
slice_ty1 = y_intersect_start - iter_y.pos;
|
||||||
slice_ty2 = data.y_intersect_end - iter_y.pos;
|
slice_ty2 = y_intersect_end - iter_y.pos;
|
||||||
|
|
||||||
/* Normalize slice texture coordinates */
|
/* Normalize slice texture coordinates */
|
||||||
slice_ty1 /= iter_y.span->size;
|
slice_ty1 /= iter_y.span->size;
|
||||||
slice_ty2 /= iter_y.span->size;
|
slice_ty2 /= iter_y.span->size;
|
||||||
|
|
||||||
|
data.y_span = iter_y.span;
|
||||||
|
|
||||||
/* Iterate the x axis of the virtual rectangle */
|
/* Iterate the x axis of the virtual rectangle */
|
||||||
for (_cogl_span_iter_begin (&iter_x,
|
for (_cogl_span_iter_begin (&iter_x,
|
||||||
tex_2ds->slice_x_spans,
|
tex_2ds->slice_x_spans,
|
||||||
@ -184,31 +179,32 @@ _cogl_texture_2d_sliced_foreach_sub_texture_in_region (
|
|||||||
!_cogl_span_iter_end (&iter_x);
|
!_cogl_span_iter_end (&iter_x);
|
||||||
_cogl_span_iter_next (&iter_x))
|
_cogl_span_iter_next (&iter_x))
|
||||||
{
|
{
|
||||||
|
float x_intersect_start = iter_x.intersect_start;
|
||||||
|
float x_intersect_end = iter_x.intersect_end;
|
||||||
float slice_tx1;
|
float slice_tx1;
|
||||||
float slice_tx2;
|
float slice_tx2;
|
||||||
CoglHandle slice_tex;
|
CoglHandle slice_tex;
|
||||||
|
|
||||||
data.x_intersect_start = iter_x.intersect_start;
|
|
||||||
data.x_intersect_end = iter_x.intersect_end;
|
|
||||||
|
|
||||||
/* Discard slices out of rectangle early */
|
/* Discard slices out of rectangle early */
|
||||||
if (!iter_x.intersects)
|
if (!iter_x.intersects)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (iter_x.flipped)
|
if (iter_x.flipped)
|
||||||
{
|
{
|
||||||
data.x_intersect_start = iter_x.intersect_end;
|
x_intersect_start = iter_x.intersect_end;
|
||||||
data.x_intersect_end = iter_x.intersect_start;
|
x_intersect_end = iter_x.intersect_start;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Localize slice texture coordinates */
|
/* Localize slice texture coordinates */
|
||||||
slice_tx1 = data.x_intersect_start - iter_x.pos;
|
slice_tx1 = x_intersect_start - iter_x.pos;
|
||||||
slice_tx2 = data.x_intersect_end - iter_x.pos;
|
slice_tx2 = x_intersect_end - iter_x.pos;
|
||||||
|
|
||||||
/* Normalize slice texture coordinates */
|
/* Normalize slice texture coordinates */
|
||||||
slice_tx1 /= iter_x.span->size;
|
slice_tx1 /= iter_x.span->size;
|
||||||
slice_tx2 /= iter_x.span->size;
|
slice_tx2 /= iter_x.span->size;
|
||||||
|
|
||||||
|
data.x_span = iter_x.span;
|
||||||
|
|
||||||
/* Pluck out the cogl texture for this slice */
|
/* Pluck out the cogl texture for this slice */
|
||||||
slice_tex = g_array_index (tex_2ds->slice_textures, CoglHandle,
|
slice_tex = g_array_index (tex_2ds->slice_textures, CoglHandle,
|
||||||
iter_y.index * iter_x.array->len +
|
iter_y.index * iter_x.array->len +
|
||||||
|
Loading…
Reference in New Issue
Block a user