From 9267341bd01900bc78700928e5836d0f52572e38 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 24 May 2007 16:48:38 -0600 Subject: [PATCH] scissor depends on glScissor() and framebuffer size --- .../softpipe/state_tracker/st_atom_scissor.c | 37 ++++++++++++++----- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/src/mesa/softpipe/state_tracker/st_atom_scissor.c b/src/mesa/softpipe/state_tracker/st_atom_scissor.c index 74f5cc1a2b4..105c2a6dd92 100644 --- a/src/mesa/softpipe/state_tracker/st_atom_scissor.c +++ b/src/mesa/softpipe/state_tracker/st_atom_scissor.c @@ -36,28 +36,47 @@ #include "st_atom.h" -/* scissor state +/** + * Scissor depends on the scissor box, and the framebuffer dimensions. */ -static void update_scissor( struct st_context *st ) +static void +update_scissor( struct st_context *st ) { struct softpipe_scissor_rect scissor; + const struct gl_framebuffer *fb = st->ctx->DrawBuffer; + + scissor.minx = 0; + scissor.miny = 0; + scissor.maxx = fb->Width; + scissor.maxy = fb->Height; + + if (st->ctx->Scissor.Enabled) { + if (st->ctx->Scissor.X > scissor.minx) + scissor.minx = st->ctx->Scissor.X; + if (st->ctx->Scissor.Y > scissor.miny) + scissor.miny = st->ctx->Scissor.Y; + + if (st->ctx->Scissor.X + st->ctx->Scissor.Width < scissor.maxx) + scissor.maxx = st->ctx->Scissor.X + st->ctx->Scissor.Width; + if (st->ctx->Scissor.Y + st->ctx->Scissor.Height < scissor.maxy) + scissor.maxy = st->ctx->Scissor.Y + st->ctx->Scissor.Height; + + /* check for null space */ + if (scissor.minx >= scissor.maxx || scissor.miny >= scissor.maxy) + scissor.minx = scissor.miny = scissor.maxx = scissor.maxy = 0; + } - scissor.minx = st->ctx->Scissor.X; - scissor.miny = st->ctx->Scissor.Y; - scissor.maxx = st->ctx->Scissor.X + st->ctx->Scissor.Width; - scissor.maxy = st->ctx->Scissor.Y + st->ctx->Scissor.Height; - if (memcmp(&scissor, &st->state.scissor, sizeof(scissor)) != 0) { /* state has changed */ st->state.scissor = scissor; /* struct copy */ - st->softpipe->set_scissor_rect(st->softpipe, &scissor); /* set new state */ + st->softpipe->set_scissor_rect(st->softpipe, &scissor); /* activate */ } } const struct st_tracked_state st_update_scissor = { .dirty = { - .mesa = (_NEW_SCISSOR), + .mesa = (_NEW_SCISSOR | _NEW_BUFFERS), .st = 0, }, .update = update_scissor -- 2.30.2