VirtualBox

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

最後變更 在這個檔案從67129是 51223,由 vboxsync 提交於 11 年 前

Additions/x11/x11include: added header files for X.Org Server 1.0 and 1.1.

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

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