summaryrefslogtreecommitdiff
path: root/src/gallium/include/pipe/p_format.h
diff options
context:
space:
mode:
authorJosé Fonseca <jrfonseca@tungstengraphics.com>2008-06-27 19:37:56 +0900
committerJosé Fonseca <jrfonseca@tungstengraphics.com>2008-06-27 19:37:56 +0900
commit4ddd65967915ca4846f2831bc676c878a29dae4a (patch)
treef2c66e355d5e9ea6f80531f995ccc25166d06fc3 /src/gallium/include/pipe/p_format.h
parent05cfb4c4b84b4e3119112c381ceffc583a4ef5fe (diff)
gallium: Drop pipe_texture->cpp and pipe_surface->cpp.
The chars-per-pixel concept falls apart with compressed and yuv images, where more than one pixel are coded in a single data block.
Diffstat (limited to 'src/gallium/include/pipe/p_format.h')
-rw-r--r--src/gallium/include/pipe/p_format.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/gallium/include/pipe/p_format.h b/src/gallium/include/pipe/p_format.h
index d973fb357b..a2c6155d01 100644
--- a/src/gallium/include/pipe/p_format.h
+++ b/src/gallium/include/pipe/p_format.h
@@ -501,6 +501,47 @@ pf_get_block(enum pipe_format format, struct pipe_format_block *block)
}
}
+static INLINE unsigned
+pf_get_nblocksx(const struct pipe_format_block *block, unsigned x)
+{
+ return (x + block->width - 1)/block->width;
+}
+
+static INLINE unsigned
+pf_get_nblocksy(const struct pipe_format_block *block, unsigned y)
+{
+ return (y + block->height - 1)/block->height;
+}
+
+static INLINE unsigned
+pf_get_nblocks(const struct pipe_format_block *block, unsigned width, unsigned height)
+{
+ return pf_get_nblocksx(block, width)*pf_get_nblocksy(block, height);
+}
+
+static INLINE void
+pipe_rect_to_blocks(const struct pipe_format_block *block,
+ unsigned *width, unsigned *height,
+ unsigned *src_x, unsigned *src_y,
+ unsigned *dst_x, unsigned *dst_y)
+{
+ assert(block->size > 0);
+ assert(block->width > 0);
+ assert(block->height > 0);
+ if(width)
+ *width = pf_get_nblocksx(block, *width);
+ if(height)
+ *height = pf_get_nblocksy(block, *height);
+ if(src_x)
+ *src_x /= block->width;
+ if(src_y)
+ *src_y /= block->height;
+ if(dst_x)
+ *dst_x /= block->width;
+ if(dst_y)
+ *dst_y /= block->height;
+}
+
#ifdef __cplusplus
}
#endif