[Mesa-dev] [PATCH 12/18] mesa: Add scissor entry points for viewport_array

Courtney Goeltzenleuchter courtney at lunarg.com
Wed Nov 20 14:59:28 PST 2013


Signed-off-by: Courtney Goeltzenleuchter <courtney at LunarG.com>
---
 src/mesa/main/scissor.c | 113 ++++++++++++++++++++++++++++++++++++++++++++++++
 src/mesa/main/scissor.h |   8 ++++
 2 files changed, 121 insertions(+)

diff --git a/src/mesa/main/scissor.c b/src/mesa/main/scissor.c
index 3187ab1..580558e 100644
--- a/src/mesa/main/scissor.c
+++ b/src/mesa/main/scissor.c
@@ -91,6 +91,119 @@ _mesa_set_scissori(struct gl_context *ctx, GLuint index,
                           ctx->Scissor.ScissorArray[index].Width, ctx->Scissor.ScissorArray[index].Height);
 }
 
+/**
+ * Define count scissor boxes starting at index.
+ *
+ * \param index  index of first scissor records to set
+ * \param count  number of scissor records to set
+ * \param x, y   pointer to array of struct gl_scissor_rects
+ *
+ * \sa glScissorArrayv().
+ *
+ * Verifies the parameters and call _mesa_set_scissori to do the work.
+ */
+void GLAPIENTRY
+_mesa_ScissorArrayv(GLuint first, GLsizei count, const GLint * v)
+{
+   GLuint i;
+   struct gl_scissor_rect *p = (struct gl_scissor_rect *) v;
+   GET_CURRENT_CONTEXT(ctx);
+
+   if ((first + count) >= ctx->Const.MaxViewports) {
+      _mesa_error(ctx, GL_INVALID_VALUE,
+                  "glScissorArrayv: first (%d) + count (%d) >= MaxViewports (%d)",
+                  first, count, ctx->Const.MaxViewports);
+      return;
+   }
+
+   /* Verify width & height */
+   for (i = 0; i < count; i++) {
+      if (p[i].Width < 0 || p[i].Height < 0) {
+         _mesa_error(ctx, GL_INVALID_VALUE,
+                     "glScissorArrayv: index (%d) width or height < 0 (%d, %d)",
+                     i, p[i].Width, p[i].Height);
+      }
+   }
+
+   for (i = 0; i < count; i++)
+      _mesa_set_scissori(ctx, i + first, p[i].X, p[i].Y, p[i].Width, p[i].Height);
+
+}
+
+/**
+ * Define the scissor box.
+ *
+ * \param index  index of scissor records to set
+ * \param x, y   coordinates of the scissor box lower-left corner.
+ * \param width  width of the scissor box.
+ * \param height height of the scissor box.
+ *
+ * \sa glScissorIndexed().
+ *
+ * Verifies the parameters call _mesa_set_scissori to do the work.
+ */
+void GLAPIENTRY
+_mesa_ScissorIndexed(GLuint index, GLint left, GLint bottom,
+                     GLsizei width, GLsizei height)
+{
+   GET_CURRENT_CONTEXT(ctx);
+
+   if (MESA_VERBOSE & VERBOSE_API)
+      _mesa_debug(ctx, "glScissorIndexed(%d, %d, %d, %d, %d)\n", index,
+                  left, bottom, width, height);
+
+   if (width < 0 || height < 0) {
+         _mesa_error(ctx, GL_INVALID_VALUE,
+                     "glScissorIndexed: index (%d) width or height < 0 (%d, %d)",
+                     index, width, height);
+      }
+
+   if (index >= ctx->Const.MaxViewports) {
+      _mesa_error(ctx, GL_INVALID_VALUE,
+                  "glScissorIndexed: index (%d) >= MaxViewports (%d)",
+                  index, ctx->Const.MaxViewports);
+      return;
+   }
+
+   _mesa_set_scissori(ctx, index, left, bottom, width, height);
+}
+
+/**
+ * Define the scissor box.
+ *
+ * \param x, y coordinates of the scissor box lower-left corner.
+ * \param width width of the scissor box.
+ * \param height height of the scissor box.
+ *
+ * \sa glScissor().
+ *
+ * Verifies the parameters call _mesa_set_scissori to do the work.
+ */
+void GLAPIENTRY
+_mesa_ScissorIndexedv(GLuint index, const GLint * v)
+{
+   struct gl_scissor_rect *p = (struct gl_scissor_rect *) v;
+   GET_CURRENT_CONTEXT(ctx);
+
+   if (MESA_VERBOSE & VERBOSE_API)
+      _mesa_debug(ctx, "glScissorIndexedv(%d, %d, %d, %d, %d)\n", index,
+                  p->X, p->Y, p->Width, p->Height);
+
+   if (p->Width < 0 || p->Height < 0) {
+         _mesa_error(ctx, GL_INVALID_VALUE,
+                     "glScissorIndexedv: index (%d) width or height < 0 (%d, %d)",
+                     index, p->Width, p->Height);
+      }
+
+   if (index >= ctx->Const.MaxViewports) {
+      _mesa_error(ctx, GL_INVALID_VALUE,
+                  "glScissorIndexedv: index (%d) >= MaxViewports (%d)",
+                  index, ctx->Const.MaxViewports);
+      return;
+   }
+
+   _mesa_set_scissori(ctx, index, p->X, p->Y, p->Width, p->Height);
+}
 
 /**
  * Initialize the context's scissor state.
diff --git a/src/mesa/main/scissor.h b/src/mesa/main/scissor.h
index f8aca2c..68f644f 100644
--- a/src/mesa/main/scissor.h
+++ b/src/mesa/main/scissor.h
@@ -34,6 +34,14 @@ struct gl_context;
 extern void GLAPIENTRY
 _mesa_Scissor( GLint x, GLint y, GLsizei width, GLsizei height );
 
+extern void GLAPIENTRY
+_mesa_ScissorArrayv(GLuint first, GLsizei count, const GLint * v);
+
+extern void GLAPIENTRY
+_mesa_ScissorIndexed(GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height);
+
+extern void GLAPIENTRY
+_mesa_ScissorIndexedv(GLuint index, const GLint * v);
 
 extern void
 _mesa_set_scissori(struct gl_context *ctx, GLuint index,
-- 
1.8.1.2



More information about the mesa-dev mailing list