Mesa (master): util: add util_framebuffer_min_size

Keith Whitwell keithw at kemper.freedesktop.org
Mon Jun 7 15:35:43 UTC 2010


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

Author: Keith Whitwell <keithw at vmware.com>
Date:   Thu May 27 15:48:38 2010 +0100

util: add util_framebuffer_min_size

---

 src/gallium/auxiliary/util/u_framebuffer.c |   35 ++++++++++++++++++++++++++++
 src/gallium/auxiliary/util/u_framebuffer.h |    5 ++++
 2 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_framebuffer.c b/src/gallium/auxiliary/util/u_framebuffer.c
index bdac12d..768ae9c 100644
--- a/src/gallium/auxiliary/util/u_framebuffer.c
+++ b/src/gallium/auxiliary/util/u_framebuffer.c
@@ -109,3 +109,38 @@ util_unreference_framebuffer_state(struct pipe_framebuffer_state *fb)
    fb->width = fb->height = 0;
    fb->nr_cbufs = 0;
 }
+
+
+/* Where multiple sizes are allowed for framebuffer surfaces, find the
+ * minimum width and height of all bound surfaces.
+ */
+boolean
+util_framebuffer_min_size(const struct pipe_framebuffer_state *fb,
+                          unsigned *width,
+                          unsigned *height)
+{
+   unsigned w = ~0;
+   unsigned h = ~0;
+   unsigned i;
+
+   for (i = 0; i < fb->nr_cbufs; i++) {
+      w = MIN2(w, fb->cbufs[i]->width);
+      h = MIN2(h, fb->cbufs[i]->height);
+   }
+
+   if (fb->zsbuf) {
+      w = MIN2(w, fb->zsbuf->width);
+      h = MIN2(h, fb->zsbuf->height);
+   }
+
+   if (w == ~0) {
+      *width = 0;
+      *height = 0;
+      return FALSE;
+   }
+   else {
+      *width = w;
+      *height = h;
+      return TRUE;
+   }
+}
diff --git a/src/gallium/auxiliary/util/u_framebuffer.h b/src/gallium/auxiliary/util/u_framebuffer.h
index adf1254..e7dc1e9 100644
--- a/src/gallium/auxiliary/util/u_framebuffer.h
+++ b/src/gallium/auxiliary/util/u_framebuffer.h
@@ -46,4 +46,9 @@ extern void
 util_unreference_framebuffer_state(struct pipe_framebuffer_state *fb);
 
 
+extern boolean
+util_framebuffer_min_size(const struct pipe_framebuffer_state *fb,
+                          unsigned *width,
+                          unsigned *height);
+
 #endif /* U_FRAMEBUFFER_H */




More information about the mesa-commit mailing list