Tizen 2.0 Release
[profile/ivi/osmesa.git] / src / mesa / drivers / dri / common / spantmp_common.h
1 /*
2  * Copyright 2000-2001 VA Linux Systems, Inc.
3  * (C) Copyright IBM Corporation 2004
4  * All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * on the rights to use, copy, modify, merge, publish, distribute, sub
10  * license, and/or sell copies of the Software, and to permit persons to whom
11  * the Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice (including the next
14  * paragraph) shall be included in all copies or substantial portions of the
15  * Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
20  * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
21  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
23  * USE OR OTHER DEALINGS IN THE SOFTWARE.
24  */
25
26 /**
27  * \file spantmp_common.h
28  *
29  * common macros for span read / write functions to be used in the depth,
30  * stencil and pixel span templates.
31  */
32
33 #ifndef HW_WRITE_LOCK
34 #define HW_WRITE_LOCK()         HW_LOCK()
35 #endif
36
37 #ifndef HW_WRITE_UNLOCK
38 #define HW_WRITE_UNLOCK()       HW_UNLOCK()
39 #endif
40
41 #ifndef HW_READ_LOCK
42 #define HW_READ_LOCK()          HW_LOCK()
43 #endif
44
45 #ifndef HW_READ_UNLOCK
46 #define HW_READ_UNLOCK()        HW_UNLOCK()
47 #endif
48
49 #ifndef HW_CLIPLOOP
50 #define HW_CLIPLOOP()                                                   \
51    do {                                                                 \
52       int _nc = dPriv->numClipRects;                                    \
53       while ( _nc-- ) {                                                 \
54          int minx = dPriv->pClipRects[_nc].x1 - dPriv->x;               \
55          int miny = dPriv->pClipRects[_nc].y1 - dPriv->y;               \
56          int maxx = dPriv->pClipRects[_nc].x2 - dPriv->x;               \
57          int maxy = dPriv->pClipRects[_nc].y2 - dPriv->y;
58 #endif
59
60 #ifndef HW_ENDCLIPLOOP
61 #define HW_ENDCLIPLOOP()                                                \
62       }                                                                 \
63    } while (0)
64 #endif
65
66 #ifndef CLIPPIXEL
67 #define CLIPPIXEL( _x, _y )                                             \
68    ((_x >= minx) && (_x < maxx) && (_y >= miny) && (_y < maxy))
69 #endif
70
71 #ifndef CLIPSPAN
72 #define CLIPSPAN( _x, _y, _n, _x1, _n1, _i )                            \
73    if ( _y < miny || _y >= maxy /*|| _x + n < minx || _x >=maxx*/ ) {   \
74       _n1 = 0, _x1 = x;                                                 \
75    } else {                                                             \
76       _n1 = _n;                                                         \
77       _x1 = _x;                                                         \
78       if ( _x1 < minx ) _i += (minx-_x1), n1 -= (minx-_x1), _x1 = minx; \
79       if ( _x1 + _n1 >= maxx ) n1 -= (_x1 + n1 - maxx);                 \
80    }
81 #endif