[Mesa-dev] [PATCH 11/37] mesa: Refactor viewport setting even more

Ian Romanick idr at freedesktop.org
Fri Jan 17 17:03:31 PST 2014


From: Ian Romanick <ian.d.romanick at intel.com>

Create an internal function that just writes data into the viewport.  In
future patches this will see more use because we only want to call
dd_function_table::Viewport once after setting all of the viewport
instead of once per viewport.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/mesa/main/viewport.c | 63 +++++++++++++++++++++++++++++-------------------
 1 file changed, 38 insertions(+), 25 deletions(-)

diff --git a/src/mesa/main/viewport.c b/src/mesa/main/viewport.c
index 2c81af7..ac891c8 100644
--- a/src/mesa/main/viewport.c
+++ b/src/mesa/main/viewport.c
@@ -34,6 +34,35 @@
 #include "mtypes.h"
 #include "viewport.h"
 
+static void
+set_viewport_no_notify(struct gl_context *ctx, unsigned idx, GLint x, GLint y,
+                       GLsizei width, GLsizei height)
+{
+   /* clamp width and height to the implementation dependent range */
+   width  = MIN2(width, (GLsizei) ctx->Const.MaxViewportWidth);
+   height = MIN2(height, (GLsizei) ctx->Const.MaxViewportHeight);
+
+   ctx->ViewportArray[idx].X = x;
+   ctx->ViewportArray[idx].Width = width;
+   ctx->ViewportArray[idx].Y = y;
+   ctx->ViewportArray[idx].Height = height;
+   ctx->NewState |= _NEW_VIEWPORT;
+
+#if 1
+   /* XXX remove this someday.  Currently the DRI drivers rely on
+    * the WindowMap matrix being up to date in the driver's Viewport
+    * and DepthRange functions.
+    */
+   _math_matrix_viewport(&ctx->ViewportArray[idx]._WindowMap,
+                         ctx->ViewportArray[idx].X,
+                         ctx->ViewportArray[idx].Y,
+                         ctx->ViewportArray[idx].Width,
+                         ctx->ViewportArray[idx].Height,
+                         ctx->ViewportArray[idx].Near,
+                         ctx->ViewportArray[idx].Far,
+                         ctx->DrawBuffer->_DepthMaxF);
+#endif
+}
 
 /**
  * Set the viewport.
@@ -57,7 +86,14 @@ _mesa_Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
       return;
    }
 
-   _mesa_set_viewport(ctx, 0, x, y, width, height);
+   set_viewport_no_notify(ctx, 0, 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);
+   }
 }
 
 
@@ -75,30 +111,7 @@ void
 _mesa_set_viewport(struct gl_context *ctx, unsigned idx, GLint x, GLint y,
                     GLsizei width, GLsizei height)
 {
-   /* clamp width and height to the implementation dependent range */
-   width  = MIN2(width, (GLsizei) ctx->Const.MaxViewportWidth);
-   height = MIN2(height, (GLsizei) ctx->Const.MaxViewportHeight);
-
-   ctx->ViewportArray[idx].X = x;
-   ctx->ViewportArray[idx].Width = width;
-   ctx->ViewportArray[idx].Y = y;
-   ctx->ViewportArray[idx].Height = height;
-   ctx->NewState |= _NEW_VIEWPORT;
-
-#if 1
-   /* XXX remove this someday.  Currently the DRI drivers rely on
-    * the WindowMap matrix being up to date in the driver's Viewport
-    * and DepthRange functions.
-    */
-   _math_matrix_viewport(&ctx->ViewportArray[idx]._WindowMap,
-                         ctx->ViewportArray[idx].X,
-                         ctx->ViewportArray[idx].Y,
-                         ctx->ViewportArray[idx].Width,
-                         ctx->ViewportArray[idx].Height,
-                         ctx->ViewportArray[idx].Near,
-                         ctx->ViewportArray[idx].Far,
-                         ctx->DrawBuffer->_DepthMaxF);
-#endif
+   set_viewport_no_notify(ctx, idx, x, y, width, height);
 
    if (ctx->Driver.Viewport) {
       /* Many drivers will use this call to check for window size changes
-- 
1.8.1.4



More information about the mesa-dev mailing list