float range_max = 1.0;
float flip = -1.0;
boolean degenerate = FALSE;
+ boolean invertY = FALSE;
enum pipe_error ret;
float fb_width = svga->curr.framebuffer.width;
fx = viewport->scale[0] * 1.0 + viewport->translate[0];
}
- if (fh < 0) {
- prescale.scale[1] *= -1.0;
- prescale.translate[1] += -fh;
+ if (fh < 0.0) {
+ prescale.translate[1] = fh - 1 + fy * 2;
fh = -fh;
- fy = flip * viewport->scale[1] * 1.0 + viewport->translate[1];
+ fy -= fh;
+ prescale.scale[1] = -1.0;
+ invertY = TRUE;
}
if (fx < 0) {
}
if (fy < 0) {
- prescale.translate[1] += fy;
+ if (invertY) {
+ prescale.translate[1] -= fy;
+ }
+ else {
+ prescale.translate[1] += fy;
+ }
prescale.scale[1] *= fh / (fh + fy);
fh += fy;
fy = 0;
if (fy + fh > fb_height) {
prescale.scale[1] *= fh / (fb_height - fy);
- prescale.translate[1] -= fy * (fh / (fb_height - fy));
- prescale.translate[1] += fy;
+ if (invertY) {
+ float in = fb_height - fy; /* number of vp pixels inside view */
+ float out = fy + fh - fb_height; /* number of vp pixels out of view */
+ prescale.translate[1] += fy * out / in;
+ }
+ else {
+ prescale.translate[1] -= fy * (fh / (fb_height - fy));
+ prescale.translate[1] += fy;
+ }
fh = fb_height - fy;
}
break;
}
+ if (invertY)
+ adjust_y = -adjust_y;
+
prescale.translate[0] += adjust_x;
prescale.translate[1] += adjust_y;
prescale.translate[2] = 0.5; /* D3D clip space */