aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main/framebuffer.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2014-01-26 20:19:23 +0100
committermarha <marha@users.sourceforge.net>2014-01-26 20:19:23 +0100
commit5f455179ae4b279a82d99a7a3dabe61f58c42ad6 (patch)
treefdecec022cf1b8b782b90a64c14e374fa6d400cb /mesalib/src/mesa/main/framebuffer.c
parent78d84bd03c744b0ed420c450dd2807904ccaef21 (diff)
parent30af30b78075159fce477ae99cc72540133714d0 (diff)
downloadvcxsrv-5f455179ae4b279a82d99a7a3dabe61f58c42ad6.tar.gz
vcxsrv-5f455179ae4b279a82d99a7a3dabe61f58c42ad6.tar.bz2
vcxsrv-5f455179ae4b279a82d99a7a3dabe61f58c42ad6.zip
Merge remote-tracking branch 'origin/released'
* origin/released: xserver randrproto libxtrans fontconfig libxcb xcb-proto mesa git update 26 Jan 2014 Conflicts: X11/xtrans/Xtrans.c xorg-server/dix/dispatch.c xorg-server/os/xdmcp.c
Diffstat (limited to 'mesalib/src/mesa/main/framebuffer.c')
-rw-r--r--mesalib/src/mesa/main/framebuffer.c86
1 files changed, 57 insertions, 29 deletions
diff --git a/mesalib/src/mesa/main/framebuffer.c b/mesalib/src/mesa/main/framebuffer.c
index 2fad45880..bd8f4933f 100644
--- a/mesalib/src/mesa/main/framebuffer.c
+++ b/mesalib/src/mesa/main/framebuffer.c
@@ -357,6 +357,56 @@ update_framebuffer_size(struct gl_context *ctx, struct gl_framebuffer *fb)
/**
+ * Calculate the inclusive bounding box for the scissor of a specific viewport
+ *
+ * \param ctx GL context.
+ * \param buffer Framebuffer to be checked against
+ * \param idx Index of the desired viewport
+ * \param bbox Bounding box for the scissored viewport. Stored as xmin,
+ * xmax, ymin, ymax.
+ *
+ * \warning This function assumes that the framebuffer dimensions are up to
+ * date (e.g., update_framebuffer_size has been recently called on \c buffer).
+ *
+ * \sa _mesa_clip_to_region
+ */
+void
+_mesa_scissor_bounding_box(const struct gl_context *ctx,
+ const struct gl_framebuffer *buffer,
+ unsigned idx, int *bbox)
+{
+ bbox[0] = 0;
+ bbox[2] = 0;
+ bbox[1] = buffer->Width;
+ bbox[3] = buffer->Height;
+
+ if (ctx->Scissor.EnableFlags & (1u << idx)) {
+ if (ctx->Scissor.ScissorArray[idx].X > bbox[0]) {
+ bbox[0] = ctx->Scissor.ScissorArray[idx].X;
+ }
+ if (ctx->Scissor.ScissorArray[idx].Y > bbox[2]) {
+ bbox[2] = ctx->Scissor.ScissorArray[idx].Y;
+ }
+ if (ctx->Scissor.ScissorArray[idx].X + ctx->Scissor.ScissorArray[idx].Width < bbox[1]) {
+ bbox[1] = ctx->Scissor.ScissorArray[idx].X + ctx->Scissor.ScissorArray[idx].Width;
+ }
+ if (ctx->Scissor.ScissorArray[idx].Y + ctx->Scissor.ScissorArray[idx].Height < bbox[3]) {
+ bbox[3] = ctx->Scissor.ScissorArray[idx].Y + ctx->Scissor.ScissorArray[idx].Height;
+ }
+ /* finally, check for empty region */
+ if (bbox[0] > bbox[1]) {
+ bbox[0] = bbox[1];
+ }
+ if (bbox[2] > bbox[3]) {
+ bbox[2] = bbox[3];
+ }
+ }
+
+ ASSERT(bbox[0] <= bbox[1]);
+ ASSERT(bbox[2] <= bbox[3]);
+}
+
+/**
* Update the context's current drawing buffer's Xmin, Xmax, Ymin, Ymax fields.
* These values are computed from the buffer's width and height and
* the scissor box, if it's enabled.
@@ -366,6 +416,7 @@ void
_mesa_update_draw_buffer_bounds(struct gl_context *ctx)
{
struct gl_framebuffer *buffer = ctx->DrawBuffer;
+ int bbox[4];
if (!buffer)
return;
@@ -375,35 +426,12 @@ _mesa_update_draw_buffer_bounds(struct gl_context *ctx)
update_framebuffer_size(ctx, buffer);
}
- buffer->_Xmin = 0;
- buffer->_Ymin = 0;
- buffer->_Xmax = buffer->Width;
- buffer->_Ymax = buffer->Height;
-
- if (ctx->Scissor.Enabled) {
- if (ctx->Scissor.X > buffer->_Xmin) {
- buffer->_Xmin = ctx->Scissor.X;
- }
- if (ctx->Scissor.Y > buffer->_Ymin) {
- buffer->_Ymin = ctx->Scissor.Y;
- }
- if (ctx->Scissor.X + ctx->Scissor.Width < buffer->_Xmax) {
- buffer->_Xmax = ctx->Scissor.X + ctx->Scissor.Width;
- }
- if (ctx->Scissor.Y + ctx->Scissor.Height < buffer->_Ymax) {
- buffer->_Ymax = ctx->Scissor.Y + ctx->Scissor.Height;
- }
- /* finally, check for empty region */
- if (buffer->_Xmin > buffer->_Xmax) {
- buffer->_Xmin = buffer->_Xmax;
- }
- if (buffer->_Ymin > buffer->_Ymax) {
- buffer->_Ymin = buffer->_Ymax;
- }
- }
-
- ASSERT(buffer->_Xmin <= buffer->_Xmax);
- ASSERT(buffer->_Ymin <= buffer->_Ymax);
+ /* Default to the first scissor as that's always valid */
+ _mesa_scissor_bounding_box(ctx, buffer, 0, bbox);
+ buffer->_Xmin = bbox[0];
+ buffer->_Ymin = bbox[2];
+ buffer->_Xmax = bbox[1];
+ buffer->_Ymax = bbox[3];
}