mirror of
https://github.com/brl/mutter.git
synced 2024-12-24 12:02:04 +00:00
Fix some failures from the fixed-to-float script in cogl-texture
The script converted calls to COGL_FIXED_MUL(x,y) to (x*y). However this fails for cases like this: COGL_FIXED_MUL(a + b, c) which become (a + b * c) The meaning of this is of course different because multiplication has a higher precedence than addition. This was causing breakages in cogl_texture_quad_sw when the vertex coordinates are not in increasing order. This was the case in test-backface-culling when NPOTs are not available.
This commit is contained in:
parent
047161ea96
commit
634cdeab1f
@ -2072,8 +2072,8 @@ _cogl_texture_quad_sw (CoglTexture *tex,
|
|||||||
tw = (float)(tex->bitmap.width);
|
tw = (float)(tex->bitmap.width);
|
||||||
th = (float)(tex->bitmap.height);
|
th = (float)(tex->bitmap.height);
|
||||||
|
|
||||||
tqx = (x2 - x1 / (tw * (tx2 - tx1)));
|
tqx = (x2 - x1) / (tw * (tx2 - tx1));
|
||||||
tqy = (y2 - y1 / (th * (ty2 - ty1)));
|
tqy = (y2 - y1) / (th * (ty2 - ty1));
|
||||||
|
|
||||||
/* Integral texture coordinate for first tile */
|
/* Integral texture coordinate for first tile */
|
||||||
first_tx = (float)(floorf (tx1));
|
first_tx = (float)(floorf (tx1));
|
||||||
@ -2088,8 +2088,8 @@ _cogl_texture_quad_sw (CoglTexture *tex,
|
|||||||
ty2 = (ty2 * th);
|
ty2 = (ty2 * th);
|
||||||
|
|
||||||
/* Quad coordinate of the first tile */
|
/* Quad coordinate of the first tile */
|
||||||
first_qx = x1 - (tx1 - first_tx * tqx);
|
first_qx = x1 - (tx1 - first_tx) * tqx;
|
||||||
first_qy = y1 - (ty1 - first_ty * tqy);
|
first_qy = y1 - (ty1 - first_ty) * tqy;
|
||||||
|
|
||||||
|
|
||||||
/* Iterate until whole quad height covered */
|
/* Iterate until whole quad height covered */
|
||||||
@ -2102,11 +2102,9 @@ _cogl_texture_quad_sw (CoglTexture *tex,
|
|||||||
if (!iter_y.intersects) continue;
|
if (!iter_y.intersects) continue;
|
||||||
|
|
||||||
/* Span-quad intersection in quad coordinates */
|
/* Span-quad intersection in quad coordinates */
|
||||||
slice_qy1 = first_qy +
|
slice_qy1 = first_qy + (iter_y.intersect_start - first_ty) * tqy;
|
||||||
(iter_y.intersect_start - first_ty * tqy);
|
|
||||||
|
|
||||||
slice_qy2 = first_qy +
|
slice_qy2 = first_qy + (iter_y.intersect_end - first_ty) * tqy;
|
||||||
(iter_y.intersect_end - first_ty * tqy);
|
|
||||||
|
|
||||||
/* Localize slice texture coordinates */
|
/* Localize slice texture coordinates */
|
||||||
slice_ty1 = iter_y.intersect_start - iter_y.pos;
|
slice_ty1 = iter_y.intersect_start - iter_y.pos;
|
||||||
@ -2130,11 +2128,9 @@ _cogl_texture_quad_sw (CoglTexture *tex,
|
|||||||
if (!iter_x.intersects) continue;
|
if (!iter_x.intersects) continue;
|
||||||
|
|
||||||
/* Span-quad intersection in quad coordinates */
|
/* Span-quad intersection in quad coordinates */
|
||||||
slice_qx1 = first_qx +
|
slice_qx1 = first_qx + (iter_x.intersect_start - first_tx) * tqx;
|
||||||
(iter_x.intersect_start - first_tx * tqx);
|
|
||||||
|
|
||||||
slice_qx2 = first_qx +
|
slice_qx2 = first_qx + (iter_x.intersect_end - first_tx) * tqx;
|
||||||
(iter_x.intersect_end - first_tx * tqx);
|
|
||||||
|
|
||||||
/* Localize slice texture coordinates */
|
/* Localize slice texture coordinates */
|
||||||
slice_tx1 = iter_x.intersect_start - iter_x.pos;
|
slice_tx1 = iter_x.intersect_start - iter_x.pos;
|
||||||
|
@ -2202,8 +2202,8 @@ _cogl_texture_quad_sw (CoglTexture *tex,
|
|||||||
tw = (float)(tex->bitmap.width);
|
tw = (float)(tex->bitmap.width);
|
||||||
th = (float)(tex->bitmap.height);
|
th = (float)(tex->bitmap.height);
|
||||||
|
|
||||||
tqx = (x2 - x1 / (tw * (tx2 - tx1)));
|
tqx = (x2 - x1) / (tw * (tx2 - tx1));
|
||||||
tqy = (y2 - y1 / (th * (ty2 - ty1)));
|
tqy = (y2 - y1) / (th * (ty2 - ty1));
|
||||||
|
|
||||||
/* Integral texture coordinate for first tile */
|
/* Integral texture coordinate for first tile */
|
||||||
first_tx = (float)(floorf (tx1));
|
first_tx = (float)(floorf (tx1));
|
||||||
@ -2218,8 +2218,8 @@ _cogl_texture_quad_sw (CoglTexture *tex,
|
|||||||
ty2 = (ty2 * th);
|
ty2 = (ty2 * th);
|
||||||
|
|
||||||
/* Quad coordinate of the first tile */
|
/* Quad coordinate of the first tile */
|
||||||
first_qx = x1 - (tx1 - first_tx * tqx);
|
first_qx = x1 - (tx1 - first_tx) * tqx;
|
||||||
first_qy = y1 - (ty1 - first_ty * tqy);
|
first_qy = y1 - (ty1 - first_ty) * tqy;
|
||||||
|
|
||||||
|
|
||||||
/* Iterate until whole quad height covered */
|
/* Iterate until whole quad height covered */
|
||||||
@ -2232,11 +2232,9 @@ _cogl_texture_quad_sw (CoglTexture *tex,
|
|||||||
if (!iter_y.intersects) continue;
|
if (!iter_y.intersects) continue;
|
||||||
|
|
||||||
/* Span-quad intersection in quad coordinates */
|
/* Span-quad intersection in quad coordinates */
|
||||||
slice_qy1 = first_qy +
|
slice_qy1 = first_qy + (iter_y.intersect_start - first_ty) * tqy;
|
||||||
(iter_y.intersect_start - first_ty * tqy);
|
|
||||||
|
|
||||||
slice_qy2 = first_qy +
|
slice_qy2 = first_qy + (iter_y.intersect_end - first_ty) * tqy;
|
||||||
(iter_y.intersect_end - first_ty * tqy);
|
|
||||||
|
|
||||||
/* Localize slice texture coordinates */
|
/* Localize slice texture coordinates */
|
||||||
slice_ty1 = iter_y.intersect_start - iter_y.pos;
|
slice_ty1 = iter_y.intersect_start - iter_y.pos;
|
||||||
@ -2257,11 +2255,9 @@ _cogl_texture_quad_sw (CoglTexture *tex,
|
|||||||
if (!iter_x.intersects) continue;
|
if (!iter_x.intersects) continue;
|
||||||
|
|
||||||
/* Span-quad intersection in quad coordinates */
|
/* Span-quad intersection in quad coordinates */
|
||||||
slice_qx1 = first_qx +
|
slice_qx1 = first_qx + (iter_x.intersect_start - first_tx) * tqx;
|
||||||
(iter_x.intersect_start - first_tx * tqx);
|
|
||||||
|
|
||||||
slice_qx2 = first_qx +
|
slice_qx2 = first_qx + (iter_x.intersect_end - first_tx) * tqx;
|
||||||
(iter_x.intersect_end - first_tx * tqx);
|
|
||||||
|
|
||||||
/* Localize slice texture coordinates */
|
/* Localize slice texture coordinates */
|
||||||
slice_tx1 = iter_x.intersect_start - iter_x.pos;
|
slice_tx1 = iter_x.intersect_start - iter_x.pos;
|
||||||
|
Loading…
Reference in New Issue
Block a user