summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2014-03-13 23:12:27 -0700
committerEric Anholt <eric@anholt.net>2014-03-26 12:58:40 -0700
commit0ca7223742e9ec0594203b3a99b11441730cca1a (patch)
tree0e56df653da5f85258ef608203badf7c82785ce9
parent209d004469391420130262059af43a813b2c07d7 (diff)
glamor: Add helper functions to walk pixmap tiling
This adds a few helper functions to make pixmap fbo access symmetrical between the single fbo and tiled cases. Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Eric Anholt <eric@anholt.net> Signed-off-by: Eric Anholt <eric@anholt.net>
-rw-r--r--glamor/glamor_priv.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index 22b561dd4..ed2c767dc 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -471,6 +471,52 @@ typedef struct glamor_pixmap_private {
};
} glamor_pixmap_private;
+static inline glamor_pixmap_fbo *
+glamor_pixmap_fbo_at(glamor_pixmap_private *priv, int x, int y)
+{
+ if (priv->type == GLAMOR_TEXTURE_LARGE) {
+ assert(x < priv->large.block_wcnt);
+ assert(y < priv->large.block_hcnt);
+ return priv->large.fbo_array[y * priv->large.block_wcnt + x];
+ }
+ assert (x == 0);
+ assert (y == 0);
+ return priv->base.fbo;
+}
+
+static inline BoxPtr
+glamor_pixmap_box_at(glamor_pixmap_private *priv, int x, int y)
+{
+ if (priv->type == GLAMOR_TEXTURE_LARGE) {
+ assert(x < priv->large.block_wcnt);
+ assert(y < priv->large.block_hcnt);
+ return &priv->large.box_array[y * priv->large.block_wcnt + x];
+ }
+ assert (x == 0);
+ assert (y == 0);
+ return &priv->base.box;
+}
+
+static inline int
+glamor_pixmap_wcnt(glamor_pixmap_private *priv)
+{
+ if (priv->type == GLAMOR_TEXTURE_LARGE)
+ return priv->large.block_wcnt;
+ return 1;
+}
+
+static inline int
+glamor_pixmap_hcnt(glamor_pixmap_private *priv)
+{
+ if (priv->type == GLAMOR_TEXTURE_LARGE)
+ return priv->large.block_hcnt;
+ return 1;
+}
+
+#define glamor_pixmap_loop(priv, x, y) \
+ for (y = 0; y < glamor_pixmap_hcnt(priv); y++) \
+ for (x = 0; x < glamor_pixmap_wcnt(priv); x++)
+
/*
* Pixmap dynamic status, used by dynamic upload feature.
*