mesa: add viewport() helper
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 22 Jun 2017 13:26:32 +0000 (15:26 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 23 Jun 2017 07:26:43 +0000 (09:26 +0200)
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/mesa/main/viewport.c

index af453fd259edc6feaecc7fdd47013ea9637fb7f0..b18168a4d43bece8a7693a5bcba8248aa6abbdbd 100644 (file)
@@ -85,6 +85,32 @@ 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) {
+      /* Many drivers will use this call to check for window size changes
+       * and reallocate the z/stencil/accum/etc buffers if needed.
+       */
+      ctx->Driver.Viewport(ctx);
+   }
+}
+
 /**
  * Set the viewport.
  * \sa Called via glViewport() or display list execution.
@@ -95,7 +121,6 @@ struct gl_depthrange_inputs {
 void GLAPIENTRY
 _mesa_Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
 {
-   unsigned i;
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
 
@@ -108,26 +133,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) {
-      /* Many drivers will use this call to check for window size changes
-       * and reallocate the z/stencil/accum/etc buffers if needed.
-       */
-      ctx->Driver.Viewport(ctx);
-   }
+   viewport(ctx, x, y, width, height);
 }