VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/x11include/xorg-server-1.12.0/miscanfill.h@ 40349

最後變更 在這個檔案從40349是 40349,由 vboxsync 提交於 13 年 前

Additions/xorg: support X.Org Server 1.12.

  • 屬性 svn:eol-style 設為 native
檔案大小: 4.8 KB
 
1/*
2
3Copyright 1987, 1998 The Open Group
4
5Permission to use, copy, modify, distribute, and sell this software and its
6documentation for any purpose is hereby granted without fee, provided that
7the above copyright notice appear in all copies and that both that
8copyright notice and this permission notice appear in supporting
9documentation.
10
11The above copyright notice and this permission notice shall be included
12in all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
18OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20OTHER DEALINGS IN THE SOFTWARE.
21
22Except as contained in this notice, the name of The Open Group shall
23not be used in advertising or otherwise to promote the sale, use or
24other dealings in this Software without prior written authorization
25from The Open Group.
26
27*/
28
29
30#ifdef HAVE_DIX_CONFIG_H
31#include <dix-config.h>
32#endif
33
34#ifndef SCANFILLINCLUDED
35#define SCANFILLINCLUDED
36/*
37 * scanfill.h
38 *
39 * Written by Brian Kelleher; Jan 1985
40 *
41 * This file contains a few macros to help track
42 * the edge of a filled object. The object is assumed
43 * to be filled in scanline order, and thus the
44 * algorithm used is an extension of Bresenham's line
45 * drawing algorithm which assumes that y is always the
46 * major axis.
47 * Since these pieces of code are the same for any filled shape,
48 * it is more convenient to gather the library in one
49 * place, but since these pieces of code are also in
50 * the inner loops of output primitives, procedure call
51 * overhead is out of the question.
52 * See the author for a derivation if needed.
53 */
54
55
56
57/*
58 * In scan converting polygons, we want to choose those pixels
59 * which are inside the polygon. Thus, we add .5 to the starting
60 * x coordinate for both left and right edges. Now we choose the
61 * first pixel which is inside the pgon for the left edge and the
62 * first pixel which is outside the pgon for the right edge.
63 * Draw the left pixel, but not the right.
64 *
65 * How to add .5 to the starting x coordinate:
66 * If the edge is moving to the right, then subtract dy from the
67 * error term from the general form of the algorithm.
68 * If the edge is moving to the left, then add dy to the error term.
69 *
70 * The reason for the difference between edges moving to the left
71 * and edges moving to the right is simple: If an edge is moving
72 * to the right, then we want the algorithm to flip immediately.
73 * If it is moving to the left, then we don't want it to flip until
74 * we traverse an entire pixel.
75 */
76#define BRESINITPGON(dy, x1, x2, xStart, d, m, m1, incr1, incr2) { \
77 int dx; /* local storage */ \
78\
79 /* \
80 * if the edge is horizontal, then it is ignored \
81 * and assumed not to be processed. Otherwise, do this stuff. \
82 */ \
83 if ((dy) != 0) { \
84 xStart = (x1); \
85 dx = (x2) - xStart; \
86 if (dx < 0) { \
87 m = dx / (dy); \
88 m1 = m - 1; \
89 incr1 = -2 * dx + 2 * (dy) * m1; \
90 incr2 = -2 * dx + 2 * (dy) * m; \
91 d = 2 * m * (dy) - 2 * dx - 2 * (dy); \
92 } else { \
93 m = dx / (dy); \
94 m1 = m + 1; \
95 incr1 = 2 * dx - 2 * (dy) * m1; \
96 incr2 = 2 * dx - 2 * (dy) * m; \
97 d = -2 * m * (dy) + 2 * dx; \
98 } \
99 } \
100}
101
102
103#define BRESINCRPGON(d, minval, m, m1, incr1, incr2) { \
104 if (m1 > 0) { \
105 if (d > 0) { \
106 minval += m1; \
107 d += incr1; \
108 } \
109 else { \
110 minval += m; \
111 d += incr2; \
112 } \
113 } else {\
114 if (d >= 0) { \
115 minval += m1; \
116 d += incr1; \
117 } \
118 else { \
119 minval += m; \
120 d += incr2; \
121 } \
122 } \
123}
124
125
126
127/*
128 * This structure contains all of the information needed
129 * to run the bresenham algorithm.
130 * The variables may be hardcoded into the declarations
131 * instead of using this structure to make use of
132 * register declarations.
133 */
134typedef struct {
135 int minor; /* minor axis */
136 int d; /* decision variable */
137 int m, m1; /* slope and slope+1 */
138 int incr1, incr2; /* error increments */
139} BRESINFO;
140
141
142#define BRESINITPGONSTRUCT(dmaj, min1, min2, bres) \
143 BRESINITPGON(dmaj, min1, min2, bres.minor, bres.d, \
144 bres.m, bres.m1, bres.incr1, bres.incr2)
145
146#define BRESINCRPGONSTRUCT(bres) \
147 BRESINCRPGON(bres.d, bres.minor, bres.m, bres.m1, bres.incr1, bres.incr2)
148
149
150#endif
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette