VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/x11include/xorg-server-1.3.0.0/fbedgeimp.h@ 33428

Last change on this file since 33428 was 25078, checked in by vboxsync, 15 years ago

Additions/x11/x11include: exported and set eol-style on new headers

  • Property svn:eol-style set to native
File size: 3.1 KB
Line 
1/*
2 * $Id$
3 *
4 * Copyright © 2004 Keith Packard
5 *
6 * Permission to use, copy, modify, distribute, and sell this software and its
7 * documentation for any purpose is hereby granted without fee, provided that
8 * the above copyright notice appear in all copies and that both that
9 * copyright notice and this permission notice appear in supporting
10 * documentation, and that the name of Keith Packard not be used in
11 * advertising or publicity pertaining to distribution of the software without
12 * specific, written prior permission. Keith Packard makes no
13 * representations about the suitability of this software for any purpose. It
14 * is provided "as is" without express or implied warranty.
15 *
16 * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18 * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
20 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
21 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22 * PERFORMANCE OF THIS SOFTWARE.
23 */
24
25#ifdef HAVE_DIX_CONFIG_H
26#include <dix-config.h>
27#endif
28
29#ifndef rasterizeSpan
30#endif
31
32static void
33rasterizeEdges (FbBits *buf,
34 int width,
35 int stride,
36 RenderEdge *l,
37 RenderEdge *r,
38 xFixed t,
39 xFixed b)
40{
41 xFixed y = t;
42 FbBits *line;
43
44 line = buf + xFixedToInt (y) * stride;
45
46 for (;;)
47 {
48 xFixed lx, rx;
49 int lxi, rxi;
50
51 /* clip X */
52 lx = l->x;
53 if (lx < 0)
54 lx = 0;
55 rx = r->x;
56 if (xFixedToInt (rx) >= width)
57 rx = IntToxFixed (width);
58
59 /* Skip empty (or backwards) sections */
60 if (rx > lx)
61 {
62
63 /* Find pixel bounds for span */
64 lxi = xFixedToInt (lx);
65 rxi = xFixedToInt (rx);
66
67#if N_BITS == 1
68 {
69 FbBits *a = line;
70 FbBits startmask, endmask;
71 int nmiddle;
72 int width = rxi - lxi;
73 int x = lxi;
74
75 a += x >> FB_SHIFT;
76 x &= FB_MASK;
77
78 FbMaskBits (x, width, startmask, nmiddle, endmask);
79 if (startmask)
80 *a++ |= startmask;
81 while (nmiddle--)
82 *a++ = FB_ALLONES;
83 if (endmask)
84 *a |= endmask;
85 }
86#else
87 {
88 DefineAlpha(line,lxi);
89 int lxs, rxs;
90
91 /* Sample coverage for edge pixels */
92 lxs = RenderSamplesX (lx, N_BITS);
93 rxs = RenderSamplesX (rx, N_BITS);
94
95 /* Add coverage across row */
96 if (lxi == rxi)
97 {
98 AddAlpha (rxs - lxs);
99 }
100 else
101 {
102 int xi;
103
104 AddAlpha (N_X_FRAC(N_BITS) - lxs);
105 StepAlpha;
106 for (xi = lxi + 1; xi < rxi; xi++)
107 {
108 AddAlpha (N_X_FRAC(N_BITS));
109 StepAlpha;
110 }
111 /* Do not add in a 0 alpha here. This check is necessary
112 * to avoid a buffer overrun when rx is exactly on a pixel
113 * boundary.
114 */
115 if (rxs != 0)
116 AddAlpha (rxs);
117 }
118 }
119#endif
120 }
121
122 if (y == b)
123 break;
124
125#if N_BITS > 1
126 if (xFixedFrac (y) != Y_FRAC_LAST(N_BITS))
127 {
128 RenderEdgeStepSmall (l);
129 RenderEdgeStepSmall (r);
130 y += STEP_Y_SMALL(N_BITS);
131 }
132 else
133#endif
134 {
135 RenderEdgeStepBig (l);
136 RenderEdgeStepBig (r);
137 y += STEP_Y_BIG(N_BITS);
138 line += stride;
139 }
140 }
141}
142
143#undef rasterizeSpan
Note: See TracBrowser for help on using the repository browser.

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