diff options
author | Brian <[email protected]> | 2007-05-24 16:48:38 -0600 |
---|---|---|
committer | Brian <[email protected]> | 2007-05-24 16:48:38 -0600 |
commit | 9267341bd01900bc78700928e5836d0f52572e38 (patch) | |
tree | bcb67472bb05739b6cab9468f48ce518a4124539 | |
parent | 3bf0fd60905d18cc6fef7845d68e0c5b530f531b (diff) |
scissor depends on glScissor() and framebuffer size
-rw-r--r-- | src/mesa/softpipe/state_tracker/st_atom_scissor.c | 37 |
1 files 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 |