Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nx-libs
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dimbor
nx-libs
Commits
55a9311f
Commit
55a9311f
authored
Oct 10, 2011
by
Reinhard Tartler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Imported nx-X11-3.3.0-5.tar.gz
Summary: Imported nx-X11-3.3.0-5.tar.gz Keywords: Imported nx-X11-3.3.0-5.tar.gz into Git repository
parent
aefdef62
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
930 additions
and
0 deletions
+930
-0
CHANGELOG
nx-X11/CHANGELOG
+8
-0
CHANGELOG.NX.original
nx-X11/CHANGELOG.NX.original
+8
-0
fbtrap.c
nx-X11/programs/Xserver/fb/fbtrap.c
+3
-0
fbtrap.c.NX.original
nx-X11/programs/Xserver/fb/fbtrap.c.NX.original
+242
-0
fbtrap.c.X.original
nx-X11/programs/Xserver/fb/fbtrap.c.X.original
+239
-0
utils.c
nx-X11/programs/Xserver/os/utils.c
+13
-0
utils.c.NX.original
nx-X11/programs/Xserver/os/utils.c.NX.original
+13
-0
renderedge.c
nx-X11/programs/Xserver/render/renderedge.c
+1
-0
renderedge.c.NX.original
nx-X11/programs/Xserver/render/renderedge.c.NX.original
+202
-0
renderedge.c.X.original
nx-X11/programs/Xserver/render/renderedge.c.X.original
+201
-0
No files found.
nx-X11/CHANGELOG
View file @
55a9311f
ChangeLog:
nx-X11-3.3.0-5
- Fixed TR01G02163. Signals need to be blocked before the call to
fork() in the Popen() utility.
- Fixed TR01G02164. Trapezoid data need to be validated before use.
This issue was the same of CVE-2007-2437.
nx-X11-3.3.0-4
- Enabled the code resetting the Xlib buffer if an IO error occured.
...
...
nx-X11/CHANGELOG.NX.original
View file @
55a9311f
ChangeLog:
nx-X11-3.3.0-5
- Fixed TR01G02163. Signals need to be blocked before the call to
fork() in the Popen() utility.
- Fixed TR01G02164. Trapezoid data need to be validated before use.
This issue was the same of CVE-2007-2437.
nx-X11-3.3.0-4
- Enabled the code resetting the Xlib buffer if an IO error occured.
...
...
nx-X11/programs/Xserver/fb/fbtrap.c
View file @
55a9311f
...
...
@@ -115,6 +115,9 @@ fbRasterizeTrapezoid (PicturePtr pPicture,
RenderEdge
l
,
r
;
xFixed
t
,
b
;
if
(
!
xTrapezoidValid
(
trap
))
return
;
fbGetDrawable
(
pPicture
->
pDrawable
,
buf
,
stride
,
bpp
,
pxoff
,
pyoff
);
width
=
pPicture
->
pDrawable
->
width
;
...
...
nx-X11/programs/Xserver/fb/fbtrap.c.NX.original
0 → 100644
View file @
55a9311f
/*
* $Id: fbtrap.c,v 1.5 2005/07/03 07:01:23 daniels Exp $
*
* Copyright © 2004 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include "fb.h"
#ifdef RENDER
#include "picturestr.h"
#include "mipict.h"
#include "renderedge.h"
#include "fbpict.h"
void
fbAddTraps (PicturePtr pPicture,
INT16 x_off,
INT16 y_off,
int ntrap,
xTrap *traps)
{
FbBits *buf;
int bpp;
int width;
int stride;
int height;
int pxoff, pyoff;
xFixed x_off_fixed;
xFixed y_off_fixed;
RenderEdge l, r;
xFixed t, b;
fbGetDrawable (pPicture->pDrawable, buf, stride, bpp, pxoff, pyoff);
width = pPicture->pDrawable->width;
height = pPicture->pDrawable->height;
x_off += pxoff;
y_off += pyoff;
x_off_fixed = IntToxFixed(y_off);
y_off_fixed = IntToxFixed(y_off);
while (ntrap--)
{
t = traps->top.y + y_off_fixed;
if (t < 0)
t = 0;
t = RenderSampleCeilY (t, bpp);
b = traps->bot.y + y_off_fixed;
if (xFixedToInt (b) >= height)
b = IntToxFixed (height) - 1;
b = RenderSampleFloorY (b, bpp);
if (b >= t)
{
/* initialize edge walkers */
RenderEdgeInit (&l, bpp, t,
traps->top.l + x_off_fixed,
traps->top.y + y_off_fixed,
traps->bot.l + x_off_fixed,
traps->bot.y + y_off_fixed);
RenderEdgeInit (&r, bpp, t,
traps->top.r + x_off_fixed,
traps->top.y + y_off_fixed,
traps->bot.r + x_off_fixed,
traps->bot.y + y_off_fixed);
fbRasterizeEdges (buf, bpp, width, stride, &l, &r, t, b);
}
traps++;
}
}
void
fbRasterizeTrapezoid (PicturePtr pPicture,
xTrapezoid *trap,
int x_off,
int y_off)
{
FbBits *buf;
int bpp;
int width;
int stride;
int height;
int pxoff, pyoff;
xFixed x_off_fixed;
xFixed y_off_fixed;
RenderEdge l, r;
xFixed t, b;
if (!xTrapezoidValid (trap))
return;
fbGetDrawable (pPicture->pDrawable, buf, stride, bpp, pxoff, pyoff);
width = pPicture->pDrawable->width;
height = pPicture->pDrawable->height;
x_off += pxoff;
y_off += pyoff;
x_off_fixed = IntToxFixed(x_off);
y_off_fixed = IntToxFixed(y_off);
t = trap->top + y_off_fixed;
if (t < 0)
t = 0;
t = RenderSampleCeilY (t, bpp);
b = trap->bottom + y_off_fixed;
if (xFixedToInt (b) >= height)
b = IntToxFixed (height) - 1;
b = RenderSampleFloorY (b, bpp);
if (b >= t)
{
/* initialize edge walkers */
RenderLineFixedEdgeInit (&l, bpp, t, &trap->left, x_off, y_off);
RenderLineFixedEdgeInit (&r, bpp, t, &trap->right, x_off, y_off);
fbRasterizeEdges (buf, bpp, width, stride, &l, &r, t, b);
}
}
static int
_GreaterY (xPointFixed *a, xPointFixed *b)
{
if (a->y == b->y)
return a->x > b->x;
return a->y > b->y;
}
/*
* Note that the definition of this function is a bit odd because
* of the X coordinate space (y increasing downwards).
*/
static int
_Clockwise (xPointFixed *ref, xPointFixed *a, xPointFixed *b)
{
xPointFixed ad, bd;
ad.x = a->x - ref->x;
ad.y = a->y - ref->y;
bd.x = b->x - ref->x;
bd.y = b->y - ref->y;
return ((xFixed_32_32) bd.y * ad.x - (xFixed_32_32) ad.y * bd.x) < 0;
}
/* FIXME -- this could be made more efficient */
void
fbAddTriangles (PicturePtr pPicture,
INT16 x_off,
INT16 y_off,
int ntri,
xTriangle *tris)
{
xPointFixed *top, *left, *right, *tmp;
xTrapezoid trap;
for (; ntri; ntri--, tris++)
{
top = &tris->p1;
left = &tris->p2;
right = &tris->p3;
if (_GreaterY (top, left)) {
tmp = left; left = top; top = tmp;
}
if (_GreaterY (top, right)) {
tmp = right; right = top; top = tmp;
}
if (_Clockwise (top, right, left)) {
tmp = right; right = left; left = tmp;
}
/*
* Two cases:
*
* + +
* / \ / \
* / \ / \
* / + + \
* / -- -- \
* / -- -- \
* / --- --- \
* +-- --+
*/
trap.top = top->y;
trap.left.p1 = *top;
trap.left.p2 = *left;
trap.right.p1 = *top;
trap.right.p2 = *right;
if (right->y < left->y)
trap.bottom = right->y;
else
trap.bottom = left->y;
fbRasterizeTrapezoid (pPicture, &trap, x_off, y_off);
if (right->y < left->y)
{
trap.top = right->y;
trap.bottom = left->y;
trap.right.p1 = *right;
trap.right.p2 = *left;
}
else
{
trap.top = left->y;
trap.bottom = right->y;
trap.left.p1 = *left;
trap.left.p2 = *right;
}
fbRasterizeTrapezoid (pPicture, &trap, x_off, y_off);
}
}
#endif /* RENDER */
nx-X11/programs/Xserver/fb/fbtrap.c.X.original
0 → 100644
View file @
55a9311f
/*
* $Id: fbtrap.c,v 1.5 2005/07/03 07:01:23 daniels Exp $
*
* Copyright © 2004 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include "fb.h"
#ifdef RENDER
#include "picturestr.h"
#include "mipict.h"
#include "renderedge.h"
#include "fbpict.h"
void
fbAddTraps (PicturePtr pPicture,
INT16 x_off,
INT16 y_off,
int ntrap,
xTrap *traps)
{
FbBits *buf;
int bpp;
int width;
int stride;
int height;
int pxoff, pyoff;
xFixed x_off_fixed;
xFixed y_off_fixed;
RenderEdge l, r;
xFixed t, b;
fbGetDrawable (pPicture->pDrawable, buf, stride, bpp, pxoff, pyoff);
width = pPicture->pDrawable->width;
height = pPicture->pDrawable->height;
x_off += pxoff;
y_off += pyoff;
x_off_fixed = IntToxFixed(y_off);
y_off_fixed = IntToxFixed(y_off);
while (ntrap--)
{
t = traps->top.y + y_off_fixed;
if (t < 0)
t = 0;
t = RenderSampleCeilY (t, bpp);
b = traps->bot.y + y_off_fixed;
if (xFixedToInt (b) >= height)
b = IntToxFixed (height) - 1;
b = RenderSampleFloorY (b, bpp);
if (b >= t)
{
/* initialize edge walkers */
RenderEdgeInit (&l, bpp, t,
traps->top.l + x_off_fixed,
traps->top.y + y_off_fixed,
traps->bot.l + x_off_fixed,
traps->bot.y + y_off_fixed);
RenderEdgeInit (&r, bpp, t,
traps->top.r + x_off_fixed,
traps->top.y + y_off_fixed,
traps->bot.r + x_off_fixed,
traps->bot.y + y_off_fixed);
fbRasterizeEdges (buf, bpp, width, stride, &l, &r, t, b);
}
traps++;
}
}
void
fbRasterizeTrapezoid (PicturePtr pPicture,
xTrapezoid *trap,
int x_off,
int y_off)
{
FbBits *buf;
int bpp;
int width;
int stride;
int height;
int pxoff, pyoff;
xFixed x_off_fixed;
xFixed y_off_fixed;
RenderEdge l, r;
xFixed t, b;
fbGetDrawable (pPicture->pDrawable, buf, stride, bpp, pxoff, pyoff);
width = pPicture->pDrawable->width;
height = pPicture->pDrawable->height;
x_off += pxoff;
y_off += pyoff;
x_off_fixed = IntToxFixed(x_off);
y_off_fixed = IntToxFixed(y_off);
t = trap->top + y_off_fixed;
if (t < 0)
t = 0;
t = RenderSampleCeilY (t, bpp);
b = trap->bottom + y_off_fixed;
if (xFixedToInt (b) >= height)
b = IntToxFixed (height) - 1;
b = RenderSampleFloorY (b, bpp);
if (b >= t)
{
/* initialize edge walkers */
RenderLineFixedEdgeInit (&l, bpp, t, &trap->left, x_off, y_off);
RenderLineFixedEdgeInit (&r, bpp, t, &trap->right, x_off, y_off);
fbRasterizeEdges (buf, bpp, width, stride, &l, &r, t, b);
}
}
static int
_GreaterY (xPointFixed *a, xPointFixed *b)
{
if (a->y == b->y)
return a->x > b->x;
return a->y > b->y;
}
/*
* Note that the definition of this function is a bit odd because
* of the X coordinate space (y increasing downwards).
*/
static int
_Clockwise (xPointFixed *ref, xPointFixed *a, xPointFixed *b)
{
xPointFixed ad, bd;
ad.x = a->x - ref->x;
ad.y = a->y - ref->y;
bd.x = b->x - ref->x;
bd.y = b->y - ref->y;
return ((xFixed_32_32) bd.y * ad.x - (xFixed_32_32) ad.y * bd.x) < 0;
}
/* FIXME -- this could be made more efficient */
void
fbAddTriangles (PicturePtr pPicture,
INT16 x_off,
INT16 y_off,
int ntri,
xTriangle *tris)
{
xPointFixed *top, *left, *right, *tmp;
xTrapezoid trap;
for (; ntri; ntri--, tris++)
{
top = &tris->p1;
left = &tris->p2;
right = &tris->p3;
if (_GreaterY (top, left)) {
tmp = left; left = top; top = tmp;
}
if (_GreaterY (top, right)) {
tmp = right; right = top; top = tmp;
}
if (_Clockwise (top, right, left)) {
tmp = right; right = left; left = tmp;
}
/*
* Two cases:
*
* + +
* / \ / \
* / \ / \
* / + + \
* / -- -- \
* / -- -- \
* / --- --- \
* +-- --+
*/
trap.top = top->y;
trap.left.p1 = *top;
trap.left.p2 = *left;
trap.right.p1 = *top;
trap.right.p2 = *right;
if (right->y < left->y)
trap.bottom = right->y;
else
trap.bottom = left->y;
fbRasterizeTrapezoid (pPicture, &trap, x_off, y_off);
if (right->y < left->y)
{
trap.top = right->y;
trap.bottom = left->y;
trap.right.p1 = *right;
trap.right.p2 = *left;
}
else
{
trap.top = left->y;
trap.bottom = right->y;
trap.left.p1 = *left;
trap.left.p2 = *right;
}
fbRasterizeTrapezoid (pPicture, &trap, x_off, y_off);
}
}
#endif /* RENDER */
nx-X11/programs/Xserver/os/utils.c
View file @
55a9311f
...
...
@@ -1847,12 +1847,19 @@ Popen(char *command, char *type)
if
(
OsVendorStartRedirectErrorFProc
!=
NULL
)
{
OsVendorStartRedirectErrorFProc
();
}
OsBlockSignals
();
#endif
switch
(
pid
=
fork
())
{
case
-
1
:
/* error */
close
(
pdes
[
0
]);
close
(
pdes
[
1
]);
xfree
(
cur
);
#ifdef NX_TRANS_EXIT
if
(
OsVendorEndRedirectErrorFProc
!=
NULL
)
{
OsVendorEndRedirectErrorFProc
();
}
OsReleaseSignals
();
#endif
return
NULL
;
case
0
:
/* child */
if
(
setgid
(
getgid
())
==
-
1
)
...
...
@@ -1917,12 +1924,18 @@ Popen(char *command, char *type)
#endif
#ifdef NX_TRANS_EXIT
OsReleaseSignals
();
#endif
execl
(
"/bin/sh"
,
"sh"
,
"-c"
,
command
,
(
char
*
)
NULL
);
_exit
(
127
);
}
#ifndef NX_TRANS_EXIT
/* Avoid EINTR during stdio calls */
OsBlockSignals
();
#endif
/* parent */
if
(
*
type
==
'r'
)
{
...
...
nx-X11/programs/Xserver/os/utils.c.NX.original
View file @
55a9311f
...
...
@@ -1847,12 +1847,19 @@ Popen(char *command, char *type)
if (OsVendorStartRedirectErrorFProc != NULL) {
OsVendorStartRedirectErrorFProc();
}
OsBlockSignals ();
#endif
switch (pid = fork()) {
case -1: /* error */
close(pdes[0]);
close(pdes[1]);
xfree(cur);
#ifdef NX_TRANS_EXIT
if (OsVendorEndRedirectErrorFProc != NULL) {
OsVendorEndRedirectErrorFProc();
}
OsReleaseSignals ();
#endif
return NULL;
case 0: /* child */
if (setgid(getgid()) == -1)
...
...
@@ -1917,12 +1924,18 @@ Popen(char *command, char *type)
#endif
#ifdef NX_TRANS_EXIT
OsReleaseSignals ();
#endif
execl("/bin/sh", "sh", "-c", command, (char *)NULL);
_exit(127);
}
#ifndef NX_TRANS_EXIT
/* Avoid EINTR during stdio calls */
OsBlockSignals ();
#endif
/* parent */
if (*type == 'r') {
...
...
nx-X11/programs/Xserver/render/renderedge.c
View file @
55a9311f
...
...
@@ -143,6 +143,7 @@ RenderEdgeInit (RenderEdge *e,
dx
=
x_bot
-
x_top
;
dy
=
y_bot
-
y_top
;
e
->
dy
=
dy
;
e
->
dx
=
0
;
if
(
dy
)
{
if
(
dx
>=
0
)
...
...
nx-X11/programs/Xserver/render/renderedge.c.NX.original
0 → 100644
View file @
55a9311f
/*
* $Id: renderedge.c,v 1.4 2005/07/03 07:02:08 daniels Exp $
*
* Copyright © 2004 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include "renderedge.h"
/*
* Compute the smallest value no less than y which is on a
* grid row
*/
xFixed
RenderSampleCeilY (xFixed y, int n)
{
xFixed f = xFixedFrac(y);
xFixed i = xFixedFloor(y);
f = ((f + Y_FRAC_FIRST(n)) / STEP_Y_SMALL(n)) * STEP_Y_SMALL(n) + Y_FRAC_FIRST(n);
if (f > Y_FRAC_LAST(n))
{
f = Y_FRAC_FIRST(n);
i += xFixed1;
}
return (i | f);
}
#define _div(a,b) ((a) >= 0 ? (a) / (b) : -((-(a) + (b) - 1) / (b)))
/*
* Compute the largest value no greater than y which is on a
* grid row
*/
xFixed
RenderSampleFloorY (xFixed y, int n)
{
xFixed f = xFixedFrac(y);
xFixed i = xFixedFloor (y);
f = _div(f - Y_FRAC_FIRST(n), STEP_Y_SMALL(n)) * STEP_Y_SMALL(n) + Y_FRAC_FIRST(n);
if (f < Y_FRAC_FIRST(n))
{
f = Y_FRAC_LAST(n);
i -= xFixed1;
}
return (i | f);
}
/*
* Step an edge by any amount (including negative values)
*/
void
RenderEdgeStep (RenderEdge *e, int n)
{
xFixed_48_16 ne;
e->x += n * e->stepx;
ne = e->e + n * (xFixed_48_16) e->dx;
if (n >= 0)
{
if (ne > 0)
{
int nx = (ne + e->dy - 1) / e->dy;
e->e = ne - nx * (xFixed_48_16) e->dy;
e->x += nx * e->signdx;
}
}
else
{
if (ne <= -e->dy)
{
int nx = (-ne) / e->dy;
e->e = ne + nx * (xFixed_48_16) e->dy;
e->x -= nx * e->signdx;
}
}
}
/*
* A private routine to initialize the multi-step
* elements of an edge structure
*/
static void
_RenderEdgeMultiInit (RenderEdge *e, int n, xFixed *stepx_p, xFixed *dx_p)
{
xFixed stepx;
xFixed_48_16 ne;
ne = n * (xFixed_48_16) e->dx;
stepx = n * e->stepx;
if (ne > 0)
{
int nx = ne / e->dy;
ne -= nx * e->dy;
stepx += nx * e->signdx;
}
*dx_p = ne;
*stepx_p = stepx;
}
/*
* Initialize one edge structure given the line endpoints and a
* starting y value
*/
void
RenderEdgeInit (RenderEdge *e,
int n,
xFixed y_start,
xFixed x_top,
xFixed y_top,
xFixed x_bot,
xFixed y_bot)
{
xFixed dx, dy;
e->x = x_top;
e->e = 0;
dx = x_bot - x_top;
dy = y_bot - y_top;
e->dy = dy;
e->dx = 0;
if (dy)
{
if (dx >= 0)
{
e->signdx = 1;
e->stepx = dx / dy;
e->dx = dx % dy;
e->e = -dy;
}
else
{
e->signdx = -1;
e->stepx = -(-dx / dy);
e->dx = -dx % dy;
e->e = 0;
}
_RenderEdgeMultiInit (e, STEP_Y_SMALL(n), &e->stepx_small, &e->dx_small);
_RenderEdgeMultiInit (e, STEP_Y_BIG(n), &e->stepx_big, &e->dx_big);
}
RenderEdgeStep (e, y_start - y_top);
}
/*
* Initialize one edge structure given a line, starting y value
* and a pixel offset for the line
*/
void
RenderLineFixedEdgeInit (RenderEdge *e,
int n,
xFixed y,
xLineFixed *line,
int x_off,
int y_off)
{
xFixed x_off_fixed = IntToxFixed(x_off);
xFixed y_off_fixed = IntToxFixed(y_off);
xPointFixed *top, *bot;
if (line->p1.y <= line->p2.y)
{
top = &line->p1;
bot = &line->p2;
}
else
{
top = &line->p2;
bot = &line->p1;
}
RenderEdgeInit (e, n, y,
top->x + x_off_fixed,
top->y + y_off_fixed,
bot->x + x_off_fixed,
bot->y + y_off_fixed);
}
nx-X11/programs/Xserver/render/renderedge.c.X.original
0 → 100644
View file @
55a9311f
/*
* $Id: renderedge.c,v 1.4 2005/07/03 07:02:08 daniels Exp $
*
* Copyright © 2004 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include "renderedge.h"
/*
* Compute the smallest value no less than y which is on a
* grid row
*/
xFixed
RenderSampleCeilY (xFixed y, int n)
{
xFixed f = xFixedFrac(y);
xFixed i = xFixedFloor(y);
f = ((f + Y_FRAC_FIRST(n)) / STEP_Y_SMALL(n)) * STEP_Y_SMALL(n) + Y_FRAC_FIRST(n);
if (f > Y_FRAC_LAST(n))
{
f = Y_FRAC_FIRST(n);
i += xFixed1;
}
return (i | f);
}
#define _div(a,b) ((a) >= 0 ? (a) / (b) : -((-(a) + (b) - 1) / (b)))
/*
* Compute the largest value no greater than y which is on a
* grid row
*/
xFixed
RenderSampleFloorY (xFixed y, int n)
{
xFixed f = xFixedFrac(y);
xFixed i = xFixedFloor (y);
f = _div(f - Y_FRAC_FIRST(n), STEP_Y_SMALL(n)) * STEP_Y_SMALL(n) + Y_FRAC_FIRST(n);
if (f < Y_FRAC_FIRST(n))
{
f = Y_FRAC_LAST(n);
i -= xFixed1;
}
return (i | f);
}
/*
* Step an edge by any amount (including negative values)
*/
void
RenderEdgeStep (RenderEdge *e, int n)
{
xFixed_48_16 ne;
e->x += n * e->stepx;
ne = e->e + n * (xFixed_48_16) e->dx;
if (n >= 0)
{
if (ne > 0)
{
int nx = (ne + e->dy - 1) / e->dy;
e->e = ne - nx * (xFixed_48_16) e->dy;
e->x += nx * e->signdx;
}
}
else
{
if (ne <= -e->dy)
{
int nx = (-ne) / e->dy;
e->e = ne + nx * (xFixed_48_16) e->dy;
e->x -= nx * e->signdx;
}
}
}
/*
* A private routine to initialize the multi-step
* elements of an edge structure
*/
static void
_RenderEdgeMultiInit (RenderEdge *e, int n, xFixed *stepx_p, xFixed *dx_p)
{
xFixed stepx;
xFixed_48_16 ne;
ne = n * (xFixed_48_16) e->dx;
stepx = n * e->stepx;
if (ne > 0)
{
int nx = ne / e->dy;
ne -= nx * e->dy;
stepx += nx * e->signdx;
}
*dx_p = ne;
*stepx_p = stepx;
}
/*
* Initialize one edge structure given the line endpoints and a
* starting y value
*/
void
RenderEdgeInit (RenderEdge *e,
int n,
xFixed y_start,
xFixed x_top,
xFixed y_top,
xFixed x_bot,
xFixed y_bot)
{
xFixed dx, dy;
e->x = x_top;
e->e = 0;
dx = x_bot - x_top;
dy = y_bot - y_top;
e->dy = dy;
if (dy)
{
if (dx >= 0)
{
e->signdx = 1;
e->stepx = dx / dy;
e->dx = dx % dy;
e->e = -dy;
}
else
{
e->signdx = -1;
e->stepx = -(-dx / dy);
e->dx = -dx % dy;
e->e = 0;
}
_RenderEdgeMultiInit (e, STEP_Y_SMALL(n), &e->stepx_small, &e->dx_small);
_RenderEdgeMultiInit (e, STEP_Y_BIG(n), &e->stepx_big, &e->dx_big);
}
RenderEdgeStep (e, y_start - y_top);
}
/*
* Initialize one edge structure given a line, starting y value
* and a pixel offset for the line
*/
void
RenderLineFixedEdgeInit (RenderEdge *e,
int n,
xFixed y,
xLineFixed *line,
int x_off,
int y_off)
{
xFixed x_off_fixed = IntToxFixed(x_off);
xFixed y_off_fixed = IntToxFixed(y_off);
xPointFixed *top, *bot;
if (line->p1.y <= line->p2.y)
{
top = &line->p1;
bot = &line->p2;
}
else
{
top = &line->p2;
bot = &line->p1;
}
RenderEdgeInit (e, n, y,
top->x + x_off_fixed,
top->y + y_off_fixed,
bot->x + x_off_fixed,
bot->y + y_off_fixed);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment