Some of the copies were buggy.
}
-static void
-copy_rect(ubyte * dst,
- unsigned cpp,
- unsigned dst_pitch,
- unsigned dst_x,
- unsigned dst_y,
- unsigned width,
- unsigned height,
- const ubyte *src,
- unsigned src_pitch,
- unsigned src_x,
- unsigned src_y)
-{
- unsigned i;
-
- dst_pitch *= cpp;
- src_pitch *= cpp;
- dst += dst_x * cpp;
- src += src_x * cpp;
- dst += dst_y * dst_pitch;
- src += src_y * dst_pitch;
- width *= cpp;
-
- if (width == dst_pitch && width == src_pitch)
- memcpy(dst, src, height * width);
- else {
- for (i = 0; i < height; i++) {
- memcpy(dst, src, width);
- dst += dst_pitch;
- src += src_pitch;
- }
- }
-}
-
-
/* Upload data to a rectangular sub-region. Lots of choices how to do this:
*
* - memcpy by span to current destination
const void *src, unsigned src_pitch,
unsigned srcx, unsigned srcy, unsigned width, unsigned height)
{
- copy_rect(pipe_surface_map(dst),
- dst->cpp, dst->pitch,
- dstx, dsty, width, height, src, src_pitch, srcx, srcy);
+ pipe_copy_rect(pipe_surface_map(dst),
+ dst->cpp, dst->pitch,
+ dstx, dsty, width, height, src, src_pitch, srcx, srcy);
pipe_surface_unmap(dst);
}
assert( dst->cpp == src->cpp );
if (0) {
- copy_rect(pipe_surface_map(dst),
- dst->cpp,
- dst->pitch,
- dstx, dsty,
- width, height,
- pipe_surface_map(src),
- src->pitch,
- srcx, srcy);
+ pipe_copy_rect(pipe_surface_map(dst),
+ dst->cpp,
+ dst->pitch,
+ dstx, dsty,
+ width, height,
+ pipe_surface_map(src),
+ src->pitch,
+ srcx, srcy);
pipe_surface_unmap(src);
pipe_surface_unmap(dst);
}
-static void
-copy_rect(ubyte * dst,
- unsigned cpp,
- unsigned dst_pitch,
- unsigned dst_x,
- unsigned dst_y,
- unsigned width,
- unsigned height,
- const ubyte *src,
- unsigned src_pitch,
- unsigned src_x,
- unsigned src_y)
-{
- unsigned i;
-
- dst_pitch *= cpp;
- src_pitch *= cpp;
- dst += dst_x * cpp;
- src += src_x * cpp;
- dst += dst_y * dst_pitch;
- src += src_y * dst_pitch;
- width *= cpp;
-
- if (width == dst_pitch && width == src_pitch)
- memcpy(dst, src, height * width);
- else {
- for (i = 0; i < height; i++) {
- memcpy(dst, src, width);
- dst += dst_pitch;
- src += src_pitch;
- }
- }
-}
-
/* Upload data to a rectangular sub-region. Lots of choices how to do this:
*
* - memcpy by span to current destination
const void *src, unsigned src_pitch,
unsigned srcx, unsigned srcy, unsigned width, unsigned height)
{
- copy_rect(pipe_surface_map(dst) + dst->offset,
- dst->cpp, dst->pitch,
- dstx, dsty, width, height, src, src_pitch, srcx, srcy);
+ pipe_copy_rect(pipe_surface_map(dst) + dst->offset,
+ dst->cpp, dst->pitch,
+ dstx, dsty, width, height, src, src_pitch, srcx, srcy);
pipe_surface_unmap(dst);
}
assert(dst->cpp == src->cpp);
if (0) {
- copy_rect(pipe_surface_map(dst) + dst->offset,
- dst->cpp,
- dst->pitch,
- dstx, dsty,
- width, height,
- pipe_surface_map(src) + src->offset,
- src->pitch,
- srcx, srcy);
+ pipe_copy_rect(pipe_surface_map(dst) + dst->offset,
+ dst->cpp,
+ dst->pitch,
+ dstx, dsty,
+ width, height,
+ pipe_surface_map(src) + src->offset,
+ src->pitch,
+ srcx, srcy);
pipe_surface_unmap(src);
pipe_surface_unmap(dst);
*/
extern void _mesa_printf(const char *str, ...);
+
+/* util/p_util.c
+ */
+extern void pipe_copy_rect(ubyte * dst, unsigned cpp, unsigned dst_pitch,
+ unsigned dst_x, unsigned dst_y, unsigned width,
+ unsigned height, const ubyte * src,
+ unsigned src_pitch, unsigned src_x, unsigned src_y);
+
+
#endif
}
-/**
- * Copy 2D rect from one place to another.
- * Position and sizes are in pixels.
- */
-static void
-copy_rect(ubyte * dst,
- unsigned cpp,
- unsigned dst_pitch,
- unsigned dst_x,
- unsigned dst_y,
- unsigned width,
- unsigned height,
- const ubyte * src,
- unsigned src_pitch,
- unsigned src_x,
- unsigned src_y)
-{
- unsigned i;
-
- dst_pitch *= cpp;
- src_pitch *= cpp;
- dst += dst_x * cpp;
- src += src_x * cpp;
- dst += dst_y * dst_pitch;
- src += src_y * src_pitch;
- width *= cpp;
-
- if (width == dst_pitch && width == src_pitch)
- memcpy(dst, src, height * width);
- else {
- for (i = 0; i < height; i++) {
- memcpy(dst, src, width);
- dst += dst_pitch;
- src += src_pitch;
- }
- }
-}
-
-
/* Upload data to a rectangular sub-region. Lots of choices how to do this:
*
* - memcpy by span to current destination
const void *src, unsigned src_pitch,
unsigned srcx, unsigned srcy, unsigned width, unsigned height)
{
- copy_rect(pipe_surface_map(dst),
- dst->cpp,
- dst->pitch,
- dstx, dsty, width, height, src, src_pitch, srcx, srcy);
+ pipe_copy_rect(pipe_surface_map(dst),
+ dst->cpp,
+ dst->pitch,
+ dstx, dsty, width, height, src, src_pitch, srcx, srcy);
pipe_surface_unmap(dst);
}
{
assert( dst->cpp == src->cpp );
- copy_rect(pipe_surface_map(dst),
- dst->cpp,
- dst->pitch,
- dstx, dsty,
- width, height,
- pipe_surface_map(src),
- src->pitch,
- srcx, srcy);
+ pipe_copy_rect(pipe_surface_map(dst),
+ dst->cpp,
+ dst->pitch,
+ dstx, dsty,
+ width, height,
+ pipe_surface_map(src),
+ src->pitch,
+ srcx, srcy);
pipe_surface_unmap(src);
pipe_surface_unmap(dst);
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/**
+ * Miscellaneous utility functions.
+ */
+
+
+#include "pipe/p_defines.h"
+#include "pipe/p_util.h"
+
+
+/**
+ * Copy 2D rect from one place to another.
+ * Position and sizes are in pixels.
+ */
+void
+pipe_copy_rect(ubyte * dst,
+ unsigned cpp,
+ unsigned dst_pitch,
+ unsigned dst_x,
+ unsigned dst_y,
+ unsigned width,
+ unsigned height,
+ const ubyte * src,
+ unsigned src_pitch,
+ unsigned src_x,
+ unsigned src_y)
+{
+ unsigned i;
+
+ dst_pitch *= cpp;
+ src_pitch *= cpp;
+ dst += dst_x * cpp;
+ src += src_x * cpp;
+ dst += dst_y * dst_pitch;
+ src += src_y * src_pitch;
+ width *= cpp;
+
+ if (width == dst_pitch && width == src_pitch)
+ memcpy(dst, src, height * width);
+ else {
+ for (i = 0; i < height; i++) {
+ memcpy(dst, src, width);
+ dst += dst_pitch;
+ src += src_pitch;
+ }
+ }
+}
pipe/cso_cache/cso_cache.c
PIPEUTIL_SOURCES = \
- pipe/util/p_tile.c
+ pipe/util/p_tile.c \
+ pipe/util/p_util.c
STATETRACKER_SOURCES = \
state_tracker/st_atom.c \