Mesa (master): mesa: add scissor() and scissor_array() helpers

Samuel Pitoiset hakzsam at kemper.freedesktop.org
Wed Jun 7 07:11:36 UTC 2017


Module: Mesa
Branch: master
Commit: e2524a21cb7846c36d2b01ed402f2de428654d52
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e2524a21cb7846c36d2b01ed402f2de428654d52

Author: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Date:   Tue Jun  6 21:58:28 2017 +0200

mesa: add scissor() and scissor_array() helpers

Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>

---

 src/mesa/main/scissor.c | 55 +++++++++++++++++++++++++++++++------------------
 1 file changed, 35 insertions(+), 20 deletions(-)

diff --git a/src/mesa/main/scissor.c b/src/mesa/main/scissor.c
index 5cf02168bd..50d01a4692 100644
--- a/src/mesa/main/scissor.c
+++ b/src/mesa/main/scissor.c
@@ -55,22 +55,10 @@ set_scissor_no_notify(struct gl_context *ctx, unsigned idx,
    ctx->Scissor.ScissorArray[idx].Height = height;
 }
 
-/**
- * Called via glScissor
- */
-void GLAPIENTRY
-_mesa_Scissor( GLint x, GLint y, GLsizei width, GLsizei height )
+static void
+scissor(struct gl_context *ctx, GLint x, GLint y, GLsizei width, GLsizei height)
 {
    unsigned i;
-   GET_CURRENT_CONTEXT(ctx);
-
-   if (MESA_VERBOSE & VERBOSE_API)
-      _mesa_debug(ctx, "glScissor %d %d %d %d\n", x, y, width, height);
-
-   if (width < 0 || height < 0) {
-      _mesa_error( ctx, GL_INVALID_VALUE, "glScissor" );
-      return;
-   }
 
    /* The GL_ARB_viewport_array spec says:
     *
@@ -91,6 +79,25 @@ _mesa_Scissor( GLint x, GLint y, GLsizei width, GLsizei height )
       ctx->Driver.Scissor(ctx);
 }
 
+/**
+ * Called via glScissor
+ */
+void GLAPIENTRY
+_mesa_Scissor(GLint x, GLint y, GLsizei width, GLsizei height)
+{
+   GET_CURRENT_CONTEXT(ctx);
+
+   if (MESA_VERBOSE & VERBOSE_API)
+      _mesa_debug(ctx, "glScissor %d %d %d %d\n", x, y, width, height);
+
+   if (width < 0 || height < 0) {
+      _mesa_error( ctx, GL_INVALID_VALUE, "glScissor" );
+      return;
+   }
+
+   scissor(ctx, x, y, width, height);
+}
+
 
 /**
  * Define the scissor box.
@@ -115,6 +122,19 @@ _mesa_set_scissor(struct gl_context *ctx, unsigned idx,
       ctx->Driver.Scissor(ctx);
 }
 
+static void
+scissor_array(struct gl_context *ctx, GLuint first, GLsizei count,
+              struct gl_scissor_rect *rect)
+{
+   for (GLsizei i = 0; i < count; i++) {
+      set_scissor_no_notify(ctx, i + first, rect[i].X, rect[i].Y,
+                            rect[i].Width, rect[i].Height);
+   }
+
+   if (ctx->Driver.Scissor)
+      ctx->Driver.Scissor(ctx);
+}
+
 /**
  * Define count scissor boxes starting at index.
  *
@@ -150,12 +170,7 @@ _mesa_ScissorArrayv(GLuint first, GLsizei count, const GLint *v)
       }
    }
 
-   for (i = 0; i < count; i++)
-      set_scissor_no_notify(ctx, i + first,
-                            p[i].X, p[i].Y, p[i].Width, p[i].Height);
-
-   if (ctx->Driver.Scissor)
-      ctx->Driver.Scissor(ctx);
+   scissor_array(ctx, first, count, p);
 }
 
 /**




More information about the mesa-commit mailing list