[Mesa-dev] [PATCH 7/8] mesa: add viewport() helper

Samuel Pitoiset samuel.pitoiset at gmail.com
Thu Jun 22 14:36:29 UTC 2017


Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
 src/mesa/main/viewport.c | 40 +++++++++++++++++++++++-----------------
 1 file changed, 23 insertions(+), 17 deletions(-)

diff --git a/src/mesa/main/viewport.c b/src/mesa/main/viewport.c
index 867c35054b9..254b4aedd8e 100644
--- a/src/mesa/main/viewport.c
+++ b/src/mesa/main/viewport.c
@@ -85,6 +85,28 @@ struct gl_depthrange_inputs {
    GLdouble Near, Far;          /**< Depth buffer range */
 };
 
+static void
+viewport(struct gl_context *ctx, GLint x, GLint y, GLsizei width,
+         GLsizei height)
+{
+   /* The GL_ARB_viewport_array spec says:
+    *
+    *     "Viewport sets the parameters for all viewports to the same values
+    *     and is equivalent (assuming no errors are generated) to:
+    *
+    *     for (uint i = 0; i < MAX_VIEWPORTS; i++)
+    *         ViewportIndexedf(i, 1, (float)x, (float)y, (float)w, (float)h);"
+    *
+    * Set all of the viewports supported by the implementation, but only
+    * signal the driver once at the end.
+    */
+   for (unsigned i = 0; i < ctx->Const.MaxViewports; i++)
+      set_viewport_no_notify(ctx, i, x, y, width, height);
+
+   if (ctx->Driver.Viewport)
+      ctx->Driver.Viewport(ctx);
+}
+
 /**
  * Set the viewport.
  * \sa Called via glViewport() or display list execution.
@@ -95,7 +117,6 @@ struct gl_depthrange_inputs {
 void GLAPIENTRY
 _mesa_Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
 {
-   unsigned i;
    GET_CURRENT_CONTEXT(ctx);
 
    if (MESA_VERBOSE & VERBOSE_API)
@@ -107,22 +128,7 @@ _mesa_Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
       return;
    }
 
-   /* The GL_ARB_viewport_array spec says:
-    *
-    *     "Viewport sets the parameters for all viewports to the same values
-    *     and is equivalent (assuming no errors are generated) to:
-    *
-    *     for (uint i = 0; i < MAX_VIEWPORTS; i++)
-    *         ViewportIndexedf(i, 1, (float)x, (float)y, (float)w, (float)h);"
-    *
-    * Set all of the viewports supported by the implementation, but only
-    * signal the driver once at the end.
-    */
-   for (i = 0; i < ctx->Const.MaxViewports; i++)
-      set_viewport_no_notify(ctx, i, x, y, width, height);
-
-   if (ctx->Driver.Viewport)
-      ctx->Driver.Viewport(ctx);
+   viewport(ctx, x, y, width, height);
 }
 
 
-- 
2.13.1



More information about the mesa-dev mailing list