summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/drivers/dri/common')
-rw-r--r--src/mesa/drivers/dri/common/depthtmp.h11
-rw-r--r--src/mesa/drivers/dri/common/spantmp.h18
-rw-r--r--src/mesa/drivers/dri/common/spantmp2.h35
-rw-r--r--src/mesa/drivers/dri/common/spantmp_common.h81
-rw-r--r--src/mesa/drivers/dri/common/stenciltmp.h16
5 files changed, 106 insertions, 55 deletions
diff --git a/src/mesa/drivers/dri/common/depthtmp.h b/src/mesa/drivers/dri/common/depthtmp.h
index bea4ea38d54..1875d157b4c 100644
--- a/src/mesa/drivers/dri/common/depthtmp.h
+++ b/src/mesa/drivers/dri/common/depthtmp.h
@@ -7,25 +7,20 @@
*/
+#include "spantmp_common.h"
+
#ifndef DBG
#define DBG 0
#endif
-
#ifndef HAVE_HW_DEPTH_SPANS
#define HAVE_HW_DEPTH_SPANS 0
#endif
+
#ifndef HAVE_HW_DEPTH_PIXELS
#define HAVE_HW_DEPTH_PIXELS 0
#endif
-#ifndef HW_READ_LOCK
-#define HW_READ_LOCK() HW_LOCK()
-#endif
-#ifndef HW_READ_UNLOCK
-#define HW_READ_UNLOCK() HW_UNLOCK()
-#endif
-
static void TAG(WriteDepthSpan)( GLcontext *ctx,
struct gl_renderbuffer *rb,
GLuint n, GLint x, GLint y,
diff --git a/src/mesa/drivers/dri/common/spantmp.h b/src/mesa/drivers/dri/common/spantmp.h
index b15bbb25776..f726e83053d 100644
--- a/src/mesa/drivers/dri/common/spantmp.h
+++ b/src/mesa/drivers/dri/common/spantmp.h
@@ -27,26 +27,12 @@
* Gareth Hughes <[email protected]>
*/
+#include "spantmp_common.h"
+
#ifndef DBG
#define DBG 0
#endif
-#ifndef HW_WRITE_LOCK
-#define HW_WRITE_LOCK() HW_LOCK()
-#endif
-
-#ifndef HW_WRITE_UNLOCK
-#define HW_WRITE_UNLOCK() HW_UNLOCK()
-#endif
-
-#ifndef HW_READ_LOCK
-#define HW_READ_LOCK() HW_LOCK()
-#endif
-
-#ifndef HW_READ_UNLOCK
-#define HW_READ_UNLOCK() HW_UNLOCK()
-#endif
-
#ifndef HW_READ_CLIPLOOP
#define HW_READ_CLIPLOOP() HW_CLIPLOOP()
#endif
diff --git a/src/mesa/drivers/dri/common/spantmp2.h b/src/mesa/drivers/dri/common/spantmp2.h
index b2b31863090..1a20a45970a 100644
--- a/src/mesa/drivers/dri/common/spantmp2.h
+++ b/src/mesa/drivers/dri/common/spantmp2.h
@@ -34,27 +34,12 @@
*/
#include "colormac.h"
+#include "spantmp_common.h"
#ifndef DBG
#define DBG 0
#endif
-#ifndef HW_WRITE_LOCK
-#define HW_WRITE_LOCK() HW_LOCK()
-#endif
-
-#ifndef HW_WRITE_UNLOCK
-#define HW_WRITE_UNLOCK() HW_UNLOCK()
-#endif
-
-#ifndef HW_READ_LOCK
-#define HW_READ_LOCK() HW_LOCK()
-#endif
-
-#ifndef HW_READ_UNLOCK
-#define HW_READ_UNLOCK() HW_UNLOCK()
-#endif
-
#ifndef HW_READ_CLIPLOOP
#define HW_READ_CLIPLOOP() HW_CLIPLOOP()
#endif
@@ -65,6 +50,14 @@
#if (SPANTMP_PIXEL_FMT == GL_RGB) && (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_SHORT_5_6_5)
+#ifndef GET_SRC_PTR
+#define GET_SRC_PTR(_x, _y) (read_buf + (_x) * 2 + (_y) * pitch)
+#endif
+
+#ifndef GET_DST_PTR
+#define GET_DST_PTR(_x, _y) ( buf + (_x) * 2 + (_y) * pitch)
+#endif
+
#define INIT_MONO_PIXEL(p, color) \
p = PACK_COLOR_565( color[0], color[1], color[2] )
@@ -92,9 +85,17 @@
#elif (SPANTMP_PIXEL_FMT == GL_BGRA) && (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_INT_8_8_8_8_REV)
+#ifndef GET_SRC_PTR
+#define GET_SRC_PTR(_x, _y) (read_buf + (_x) * 4 + (_y) * pitch)
+#endif
+
+#ifndef GET_DST_PTR
+#define GET_DST_PTR(_x, _y) ( buf + (_x) * 4 + (_y) * pitch)
+#endif
+
# define INIT_MONO_PIXEL(p, color) \
p = PACK_COLOR_8888(color[3], color[0], color[1], color[2])
-
+
# define WRITE_RGBA(_x, _y, r, g, b, a) \
do { \
GLuint * _p = (GLuint *) GET_DST_PTR(_x, _y); \
diff --git a/src/mesa/drivers/dri/common/spantmp_common.h b/src/mesa/drivers/dri/common/spantmp_common.h
new file mode 100644
index 00000000000..a4509a569d5
--- /dev/null
+++ b/src/mesa/drivers/dri/common/spantmp_common.h
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2000-2001 VA Linux Systems, Inc.
+ * (C) Copyright IBM Corporation 2004
+ * 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
+ * on 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
+ * VA LINUX SYSTEM, IBM AND/OR THEIR 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.
+ */
+
+/**
+ * \file spantmp_common.h
+ *
+ * common macros for span read / write functions to be used in the depth,
+ * stencil and pixel span templates.
+ */
+
+#ifndef HW_WRITE_LOCK
+#define HW_WRITE_LOCK() HW_LOCK()
+#endif
+
+#ifndef HW_WRITE_UNLOCK
+#define HW_WRITE_UNLOCK() HW_UNLOCK()
+#endif
+
+#ifndef HW_READ_LOCK
+#define HW_READ_LOCK() HW_LOCK()
+#endif
+
+#ifndef HW_READ_UNLOCK
+#define HW_READ_UNLOCK() HW_UNLOCK()
+#endif
+
+#ifndef HW_CLIPLOOP
+#define HW_CLIPLOOP() \
+ do { \
+ int _nc = dPriv->numClipRects; \
+ while ( _nc-- ) { \
+ int minx = dPriv->pClipRects[_nc].x1 - dPriv->x; \
+ int miny = dPriv->pClipRects[_nc].y1 - dPriv->y; \
+ int maxx = dPriv->pClipRects[_nc].x2 - dPriv->x; \
+ int maxy = dPriv->pClipRects[_nc].y2 - dPriv->y;
+#endif
+
+#ifndef HW_ENDCLIPLOOP
+#define HW_ENDCLIPLOOP() \
+ } \
+ } while (0)
+#endif
+
+#ifndef CLIPPIXEL
+#define CLIPPIXEL( _x, _y ) \
+ ((_x >= minx) && (_x < maxx) && (_y >= miny) && (_y < maxy))
+#endif
+
+#ifndef CLIPSPAN
+#define CLIPSPAN( _x, _y, _n, _x1, _n1, _i ) \
+ if ( _y < miny || _y >= maxy /*|| _x + n < minx || _x >=maxx*/ ) { \
+ _n1 = 0, _x1 = x; \
+ } else { \
+ _n1 = _n; \
+ _x1 = _x; \
+ if ( _x1 < minx ) _i += (minx-_x1), n1 -= (minx-_x1), _x1 = minx; \
+ if ( _x1 + _n1 >= maxx ) n1 -= (_x1 + n1 - maxx); \
+ }
+#endif
diff --git a/src/mesa/drivers/dri/common/stenciltmp.h b/src/mesa/drivers/dri/common/stenciltmp.h
index ffcb1a4c1ee..dccab0660d4 100644
--- a/src/mesa/drivers/dri/common/stenciltmp.h
+++ b/src/mesa/drivers/dri/common/stenciltmp.h
@@ -1,23 +1,11 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/common/stenciltmp.h,v 1.3 2001/03/21 16:14:20 dawes Exp $ */
+#include "spantmp_common.h"
+
#ifndef DBG
#define DBG 0
#endif
-#ifndef HW_WRITE_LOCK
-#define HW_WRITE_LOCK() HW_LOCK()
-#endif
-#ifndef HW_WRITE_UNLOCK
-#define HW_WRITE_UNLOCK() HW_UNLOCK()
-#endif
-
-#ifndef HW_READ_LOCK
-#define HW_READ_LOCK() HW_LOCK()
-#endif
-#ifndef HW_READ_UNLOCK
-#define HW_READ_UNLOCK() HW_UNLOCK()
-#endif
-
static void TAG(WriteStencilSpan)( GLcontext *ctx,
struct gl_renderbuffer *rb,
GLuint n, GLint x, GLint y,