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
d94f4727
Commit
d94f4727
authored
Sep 06, 2019
by
Ulrich Sibiller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Drawable.c: code simplifications / scope improvements
parent
0133d461
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
112 additions
and
244 deletions
+112
-244
Drawable.c
nx-X11/programs/Xserver/hw/nxagent/Drawable.c
+112
-244
No files found.
nx-X11/programs/Xserver/hw/nxagent/Drawable.c
View file @
d94f4727
...
...
@@ -122,12 +122,8 @@ int nxagentSkipImage = 0;
static
int
nxagentTooManyImageData
(
void
)
{
unsigned
int
r
;
unsigned
int
limit
;
limit
=
nxagentOption
(
ImageRateLimit
);
r
=
nxagentGetDataRate
()
/
1000
;
unsigned
int
limit
=
nxagentOption
(
ImageRateLimit
);
unsigned
int
r
=
nxagentGetDataRate
()
/
1000
;
#ifdef TEST
if
(
r
>
limit
)
...
...
@@ -141,8 +137,6 @@ static int nxagentTooManyImageData(void)
int
nxagentSynchronizeDrawable
(
DrawablePtr
pDrawable
,
int
wait
,
unsigned
int
breakMask
,
WindowPtr
owner
)
{
int
result
;
pDrawable
=
nxagentSplitDrawable
(
pDrawable
);
if
(
nxagentLosslessTrap
==
0
)
...
...
@@ -170,7 +164,7 @@ int nxagentSynchronizeDrawable(DrawablePtr pDrawable, int wait, unsigned int bre
nxagentSplitTrap
=
1
;
result
=
nxagentSynchronizeDrawableData
(
pDrawable
,
breakMask
,
owner
);
int
result
=
nxagentSynchronizeDrawableData
(
pDrawable
,
breakMask
,
owner
);
nxagentSplitTrap
=
0
;
...
...
@@ -182,7 +176,6 @@ int nxagentSynchronizeDrawable(DrawablePtr pDrawable, int wait, unsigned int bre
}
#ifdef TEST
if
(
nxagentDrawableStatus
(
pDrawable
)
==
Synchronized
)
{
fprintf
(
stderr
,
"nxagentSynchronizeDrawable: Drawable %s [%p] with id [%ld] now synchronized.
\n
"
,
...
...
@@ -193,7 +186,6 @@ int nxagentSynchronizeDrawable(DrawablePtr pDrawable, int wait, unsigned int bre
fprintf
(
stderr
,
"nxagentSynchronizeDrawable: Drawable %s [%p] with id [%ld] not fully synchronized.
\n
"
,
nxagentDrawableType
(
pDrawable
),
(
void
*
)
pDrawable
,
pDrawable
->
id
);
}
#endif
return
result
;
...
...
@@ -201,31 +193,27 @@ int nxagentSynchronizeDrawable(DrawablePtr pDrawable, int wait, unsigned int bre
int
nxagentSynchronizeDrawableData
(
DrawablePtr
pDrawable
,
unsigned
int
breakMask
,
WindowPtr
owner
)
{
int
width
,
height
,
depth
,
length
;
unsigned
int
leftPad
,
format
;
char
*
data
=
NULL
;
DrawablePtr
pSrcDrawable
;
GCPtr
pGC
;
int
success
;
if
(
pDrawable
->
type
==
DRAWABLE_PIXMAP
)
{
leftPad
=
0
;
GCPtr
pGC
;
unsigned
int
leftPad
=
0
;
width
=
pDrawable
->
width
;
height
=
pDrawable
->
height
;
depth
=
pDrawable
->
depth
;
int
width
=
pDrawable
->
width
;
int
height
=
pDrawable
->
height
;
int
depth
=
pDrawable
->
depth
;
#ifdef TEST
fprintf
(
stderr
,
"nxagentSynchronizeDrawableData: Synchronizing drawable (%s) with geometry [%d][%d][%d].
\n
"
,
nxagentDrawableType
(
pDrawable
),
width
,
height
,
depth
);
#endif
format
=
(
depth
==
1
)
?
XYPixmap
:
ZPixmap
;
unsigned
int
format
=
(
depth
==
1
)
?
XYPixmap
:
ZPixmap
;
length
=
nxagentImageLength
(
width
,
height
,
format
,
leftPad
,
depth
);
int
length
=
nxagentImageLength
(
width
,
height
,
format
,
leftPad
,
depth
);
if
((
data
=
malloc
(
length
))
==
NULL
)
{
...
...
@@ -238,7 +226,7 @@ int nxagentSynchronizeDrawableData(DrawablePtr pDrawable, unsigned int breakMask
goto
nxagentSynchronizeDrawableDataEnd
;
}
pSrcDrawable
=
(
pDrawable
->
type
==
DRAWABLE_PIXMAP
?
DrawablePtr
pSrcDrawable
=
(
pDrawable
->
type
==
DRAWABLE_PIXMAP
?
((
DrawablePtr
)
nxagentVirtualPixmap
((
PixmapPtr
)
pDrawable
))
:
pDrawable
);
...
...
@@ -369,47 +357,20 @@ nxagentSynchronizeDrawableDataEnd:
int
nxagentSynchronizeRegion
(
DrawablePtr
pDrawable
,
RegionPtr
pRegion
,
unsigned
int
breakMask
,
WindowPtr
owner
)
{
GCPtr
pGC
;
DrawablePtr
pSrcDrawable
;
BoxPtr
pBox
;
RegionPtr
clipRegion
;
RegionRec
tileRegion
;
RegionRec
exposeRegion
;
BoxRec
box
;
BoxRec
tileBox
;
int
leftPad
=
0
;
int
success
=
0
;
char
*
data
=
NULL
;
GCPtr
pGC
=
NULL
;
RegionPtr
clipRegion
=
NullRegion
;
#ifdef COLLECTED_UPDATES
RegionRec
collectedUpdates
;
#endif
char
*
data
;
int
nBox
;
int
x
,
y
;
int
w
,
h
;
int
extentWidth
,
extentHeight
;
int
tileWidth
,
tileHeight
;
int
length
,
format
,
leftPad
;
int
i
;
int
saveTrap
;
int
success
;
int
useStoredBitmap
;
unsigned
long
now
;
unsigned
long
elapsedTime
;
leftPad
=
0
;
success
=
0
;
data
=
NULL
;
pGC
=
NULL
;
clipRegion
=
NullRegion
;
#ifdef COLLECTED_UPDATES
RegionInit
(
&
collectedUpdates
,
NullBox
,
1
);
#endif
RegionRec
exposeRegion
;
RegionInit
(
&
exposeRegion
,
NullBox
,
1
);
if
(
nxagentDrawableBitmap
(
pDrawable
)
!=
NullPixmap
&&
...
...
@@ -429,7 +390,7 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned
* full drawable.
*/
useStoredBitmap
=
(
nxagentDrawableBitmap
(
pDrawable
)
!=
NullPixmap
&&
pRegion
==
NullRegion
);
int
useStoredBitmap
=
(
nxagentDrawableBitmap
(
pDrawable
)
!=
NullPixmap
&&
pRegion
==
NullRegion
);
if
(
useStoredBitmap
!=
0
)
{
...
...
@@ -570,7 +531,7 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned
nxagentDrawableType
(
pDrawable
),
(
void
*
)
pDrawable
);
#endif
saveTrap
=
nxagentGCTrap
;
int
saveTrap
=
nxagentGCTrap
;
nxagentGCTrap
=
0
;
...
...
@@ -609,6 +570,7 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned
* huge window it had to result in a failed data memory allocation.
*/
int
w
,
h
,
extentWidth
,
extentHeight
,
tileWidth
,
tileHeight
;
extentWidth
=
clipRegion
->
extents
.
x2
-
clipRegion
->
extents
.
x1
;
extentHeight
=
clipRegion
->
extents
.
y2
-
clipRegion
->
extents
.
y1
;
...
...
@@ -619,6 +581,7 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned
fprintf
(
stderr
,
"nxagentSynchronizeRegion: Using tiles of size [%dx%d].
\n
"
,
tileWidth
,
tileHeight
);
#endif
int
length
,
format
;
data
=
nxagentAllocateImageData
(
w
,
h
,
pDrawable
->
depth
,
&
length
,
&
format
);
if
(
data
==
NULL
)
...
...
@@ -646,17 +609,17 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned
#ifndef USE_OPTIMIZED_BOXES
pBox
=
RegionRects
(
clipRegion
);
BoxPtr
pBox
=
RegionRects
(
clipRegion
);
#else
pBox
=
nxagentGetOptimizedRegionBoxes
(
clipRegion
);
BoxPtr
pBox
=
nxagentGetOptimizedRegionBoxes
(
clipRegion
);
#endif
/* USE_OPTIMIZED_BOXES */
nBox
=
RegionNumRects
(
clipRegion
);
int
nBox
=
RegionNumRects
(
clipRegion
);
now
=
GetTimeInMillis
();
unsigned
long
now
=
GetTimeInMillis
();
nxagentSynchronization
.
abort
=
0
;
...
...
@@ -664,7 +627,7 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned
* Going to split the updated region into small blocks.
*/
for
(
i
=
0
;
i
<
nBox
;
i
++
)
for
(
i
nt
i
=
0
;
i
<
nBox
;
i
++
)
{
#ifdef USE_OPTIMIZED_BOXES
...
...
@@ -676,13 +639,13 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned
#endif
box
=
pBox
[
i
];
BoxRec
box
=
pBox
[
i
];
for
(
y
=
box
.
y1
;
y
<
box
.
y2
;
y
+=
h
)
for
(
int
y
=
box
.
y1
;
y
<
box
.
y2
;
y
+=
h
)
{
h
=
min
(
box
.
y2
-
y
,
tileHeight
);
for
(
x
=
box
.
x1
;
x
<
box
.
x2
;
x
+=
w
)
for
(
int
x
=
box
.
x1
;
x
<
box
.
x2
;
x
+=
w
)
{
w
=
min
(
box
.
x2
-
x
,
tileWidth
);
...
...
@@ -713,7 +676,7 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned
* DeferTimeout milliseconds.
*/
elapsedTime
=
GetTimeInMillis
()
-
now
;
unsigned
long
elapsedTime
=
GetTimeInMillis
()
-
now
;
if
(
elapsedTime
>
nxagentOption
(
DeferTimeout
))
{
...
...
@@ -762,10 +725,7 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned
goto
nxagentSynchronizeRegionStop
;
}
tileBox
.
x1
=
x
;
tileBox
.
y1
=
y
;
tileBox
.
x2
=
x
+
w
;
tileBox
.
y2
=
y
+
h
;
BoxRec
tileBox
=
{.
x1
=
x
,
.
y1
=
y
,
.
x2
=
x
+
w
,
.
y2
=
y
+
h
};
#ifdef DEBUG
fprintf
(
stderr
,
"nxagentSynchronizeRegion: Going to synchronize tile [%d,%d,%d,%d].
\n
"
,
...
...
@@ -778,6 +738,7 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned
* Going to unmark the synchronized region.
*/
RegionRec
tileRegion
;
RegionInit
(
&
tileRegion
,
&
tileBox
,
1
);
RegionUnion
(
&
exposeRegion
,
&
exposeRegion
,
&
tileRegion
);
...
...
@@ -806,11 +767,9 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned
if
(
nxagentDrawableStatus
(
pDrawable
)
==
NotSynchronized
)
{
char
*
cmpData
;
int
cmpLength
,
cmpFormat
;
cmpData
=
nxagentAllocateImageData
(
w
,
h
,
pDrawable
->
depth
,
&
cmpLength
,
&
cmpFormat
);
c
har
*
c
mpData
=
nxagentAllocateImageData
(
w
,
h
,
pDrawable
->
depth
,
&
cmpLength
,
&
cmpFormat
);
if
(
cmpData
!=
NULL
)
{
...
...
@@ -877,16 +836,11 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned
(
nxagentOption
(
XRatio
)
!=
DONT_SCALE
||
nxagentOption
(
YRatio
)
!=
DONT_SCALE
))
{
int
scaledx
;
int
scaledy
;
int
scaledw
;
int
scaledh
;
scaledx
=
nxagentScale
(
x
,
nxagentOption
(
XRatio
));
scaledy
=
nxagentScale
(
y
,
nxagentOption
(
YRatio
));
int
scaledx
=
nxagentScale
(
x
,
nxagentOption
(
XRatio
));
int
scaledy
=
nxagentScale
(
y
,
nxagentOption
(
YRatio
));
scaledw
=
nxagentScale
(
x
+
w
,
nxagentOption
(
XRatio
))
-
scaledx
;
scaledh
=
nxagentScale
(
y
+
h
,
nxagentOption
(
YRatio
))
-
scaledy
;
int
scaledw
=
nxagentScale
(
x
+
w
,
nxagentOption
(
XRatio
))
-
scaledx
;
int
scaledh
=
nxagentScale
(
y
+
h
,
nxagentOption
(
YRatio
))
-
scaledy
;
XClearArea
(
nxagentDisplay
,
nxagentWindow
(
owner
),
scaledx
,
scaledy
,
scaledw
,
scaledh
,
0
);
}
...
...
@@ -969,14 +923,12 @@ nxagentSynchronizeRegionStop:
nxagentIsCorruptedBackground
((
PixmapPtr
)
pDrawable
)
==
1
&&
RegionNil
(
&
exposeRegion
)
==
0
)
{
struct
nxagentExposeBackground
eb
;
int
i
;
eb
.
pBackground
=
(
PixmapPtr
)
pDrawable
;
eb
.
pExpose
=
&
exposeRegion
;
struct
nxagentExposeBackground
eb
=
{
.
pBackground
=
(
PixmapPtr
)
pDrawable
,
.
pExpose
=
&
exposeRegion
,
};
for
(
i
=
0
;
i
<
MAXCLIENTS
;
i
++
)
for
(
i
nt
i
=
0
;
i
<
MAXCLIENTS
;
i
++
)
{
if
(
clients
[
i
]
!=
NULL
)
{
...
...
@@ -995,27 +947,22 @@ nxagentSynchronizeRegionStop:
RegionValidate
(
&
collectedUpdates
,
&
overlap
);
for
(
i
=
0
;
i
<
RegionNumRects
(
&
collectedUpdates
);
i
++
)
for
(
i
nt
i
=
0
;
i
<
RegionNumRects
(
&
collectedUpdates
);
i
++
)
{
x
=
RegionRects
(
&
collectedUpdates
)[
i
].
x1
;
y
=
RegionRects
(
&
collectedUpdates
)[
i
].
y1
;
w
=
RegionRects
(
&
collectedUpdates
)[
i
].
x2
-
RegionRects
(
&
collectedUpdates
)[
i
].
x1
;
h
=
RegionRects
(
&
collectedUpdates
)[
i
].
y2
-
RegionRects
(
&
collectedUpdates
)[
i
].
y1
;
int
x
=
RegionRects
(
&
collectedUpdates
)[
i
].
x1
;
int
y
=
RegionRects
(
&
collectedUpdates
)[
i
].
y1
;
int
w
=
RegionRects
(
&
collectedUpdates
)[
i
].
x2
-
RegionRects
(
&
collectedUpdates
)[
i
].
x1
;
int
h
=
RegionRects
(
&
collectedUpdates
)[
i
].
y2
-
RegionRects
(
&
collectedUpdates
)[
i
].
y1
;
if
(
nxagentOption
(
Shadow
)
==
1
&&
(
nxagentOption
(
XRatio
)
!=
DONT_SCALE
||
nxagentOption
(
YRatio
)
!=
DONT_SCALE
))
{
int
scaledx
;
int
scaledy
;
int
scaledw
;
int
scaledh
;
scaledx
=
nxagentScale
(
x
,
nxagentOption
(
XRatio
));
scaledy
=
nxagentScale
(
y
,
nxagentOption
(
YRatio
));
int
scaledx
=
nxagentScale
(
x
,
nxagentOption
(
XRatio
));
int
scaledy
=
nxagentScale
(
y
,
nxagentOption
(
YRatio
));
scaledw
=
nxagentScale
(
x
+
w
,
nxagentOption
(
XRatio
))
-
scaledx
;
scaledh
=
nxagentScale
(
y
+
h
,
nxagentOption
(
YRatio
))
-
scaledy
;
int
scaledw
=
nxagentScale
(
x
+
w
,
nxagentOption
(
XRatio
))
-
scaledx
;
int
scaledh
=
nxagentScale
(
y
+
h
,
nxagentOption
(
YRatio
))
-
scaledy
;
XClearArea
(
nxagentDisplay
,
nxagentWindow
(
owner
),
scaledx
,
scaledy
,
scaledw
,
scaledh
,
0
);
}
...
...
@@ -1050,8 +997,6 @@ nxagentSynchronizeRegionFree:
void
nxagentSynchronizeBox
(
DrawablePtr
pDrawable
,
BoxPtr
pBox
,
unsigned
int
breakMask
)
{
RegionPtr
pRegion
;
if
(
nxagentDrawableStatus
(
pDrawable
)
==
Synchronized
)
{
#ifdef TEST
...
...
@@ -1078,7 +1023,7 @@ void nxagentSynchronizeBox(DrawablePtr pDrawable, BoxPtr pBox, unsigned int brea
pBox
->
x1
,
pBox
->
y1
,
pBox
->
x2
,
pBox
->
y2
);
#endif
pRegion
=
nxagentCreateRegion
(
pDrawable
,
NULL
,
pBox
->
x1
,
pBox
->
y1
,
RegionPtr
pRegion
=
nxagentCreateRegion
(
pDrawable
,
NULL
,
pBox
->
x1
,
pBox
->
y1
,
pBox
->
x2
-
pBox
->
x1
,
pBox
->
y2
-
pBox
->
y1
);
...
...
@@ -1282,10 +1227,6 @@ FIXME: This condition sounds only as a complication, as the break
void
nxagentSynchronizationLoop
(
unsigned
int
mask
)
{
unsigned
int
breakMask
;
int
doRoundRobin
;
/*
FIXME: All drawables should be set as synchronized and never marked as
corrupted while the display is down.
...
...
@@ -1325,7 +1266,7 @@ FIXME: All drawables should be set as synchronized and never marked as
"blocking [%d].
\n
"
,
nxagentCongestion
,
nxagentBlocking
);
#endif
breakMask
=
mask
;
unsigned
int
breakMask
=
mask
;
/*
* The resource counter can be reset if we have not aborted the
...
...
@@ -1333,7 +1274,7 @@ FIXME: All drawables should be set as synchronized and never marked as
* round-robin and if the bitmaps are all synchronized.
*/
doRoundRobin
=
(
nxagentSynchronization
.
pDrawable
!=
NULL
);
int
doRoundRobin
=
(
nxagentSynchronization
.
pDrawable
!=
NULL
);
nxagentSynchronization
.
abort
=
0
;
...
...
@@ -1471,15 +1412,8 @@ FIXME: All drawables should be set as synchronized and never marked as
RegionPtr
nxagentCreateRegion
(
DrawablePtr
pDrawable
,
GCPtr
pGC
,
int
x
,
int
y
,
int
width
,
int
height
)
{
RegionPtr
pRegion
;
BoxRec
box
;
box
.
x1
=
x
;
box
.
y1
=
y
;
box
.
x2
=
x
+
width
;
box
.
y2
=
y
+
height
;
pRegion
=
RegionCreate
(
&
box
,
1
);
BoxRec
box
=
{.
x1
=
x
,
.
y1
=
y
,
.
x2
=
x
+
width
,
.
y2
=
y
+
height
};
RegionPtr
pRegion
=
RegionCreate
(
&
box
,
1
);
/*
* Clipping the region.
...
...
@@ -1487,22 +1421,17 @@ RegionPtr nxagentCreateRegion(DrawablePtr pDrawable, GCPtr pGC, int x, int y,
if
(
pDrawable
->
type
==
DRAWABLE_PIXMAP
)
{
BoxRec
tmpBox
;
RegionRec
tmpRegion
;
/*
* The region created doesn't need to be clipped
*
if it has the
pixmap dimensions.
* The region created doesn't need to be clipped
if it has the
* pixmap dimensions.
*/
if
(
x
!=
0
||
y
!=
0
||
width
!=
pDrawable
->
width
||
height
!=
pDrawable
->
height
)
{
tmpBox
.
x1
=
0
;
tmpBox
.
y1
=
0
;
tmpBox
.
x2
=
pDrawable
->
width
;
tmpBox
.
y2
=
pDrawable
->
height
;
BoxRec
tmpBox
=
{.
x1
=
0
,
.
y1
=
0
,
.
x2
=
pDrawable
->
width
,
.
y2
=
pDrawable
->
height
};
RegionRec
tmpRegion
;
RegionInit
(
&
tmpRegion
,
&
tmpBox
,
1
);
...
...
@@ -1582,11 +1511,6 @@ RegionPtr nxagentCreateRegion(DrawablePtr pDrawable, GCPtr pGC, int x, int y,
void
nxagentMarkCorruptedRegion
(
DrawablePtr
pDrawable
,
RegionPtr
pRegion
)
{
int
x
;
int
y
;
int
width
;
int
height
;
if
(
pRegion
!=
NullRegion
&&
RegionNil
(
pRegion
)
==
1
)
{
#ifdef TEST
...
...
@@ -1615,11 +1539,11 @@ void nxagentMarkCorruptedRegion(DrawablePtr pDrawable, RegionPtr pRegion)
if
(
pRegion
==
NullRegion
)
{
x
=
0
;
y
=
0
;
int
x
=
0
;
int
y
=
0
;
width
=
pDrawable
->
width
;
height
=
pDrawable
->
height
;
int
width
=
pDrawable
->
width
;
int
height
=
pDrawable
->
height
;
#ifdef TEST
fprintf
(
stderr
,
"nxagentMarkCorruptedRegion: Fully invalidating %s [%p] with "
...
...
@@ -1661,8 +1585,6 @@ void nxagentMarkCorruptedRegion(DrawablePtr pDrawable, RegionPtr pRegion)
void
nxagentUnmarkCorruptedRegion
(
DrawablePtr
pDrawable
,
RegionPtr
pRegion
)
{
int
oldStatus
;
if
(
pRegion
!=
NullRegion
&&
RegionNil
(
pRegion
)
==
1
)
{
#ifdef TEST
...
...
@@ -1673,7 +1595,7 @@ void nxagentUnmarkCorruptedRegion(DrawablePtr pDrawable, RegionPtr pRegion)
return
;
}
oldStatus
=
nxagentDrawableStatus
(
pDrawable
);
int
oldStatus
=
nxagentDrawableStatus
(
pDrawable
);
if
(
oldStatus
==
Synchronized
)
{
...
...
@@ -1829,20 +1751,11 @@ void nxagentMoveCorruptedRegion(WindowPtr pWin, unsigned int mask)
BoxPtr
nxagentGetOptimizedRegionBoxes
(
RegionPtr
pRegion
)
{
BoxPtr
pBox
;
BoxRec
boxExtents
;
int
nBox
;
int
i
,
j
;
#ifdef DEBUG
int
nBoxOptim
;
#endif
pBox
=
RegionRects
(
pRegion
);
BoxPtr
pBox
=
RegionRects
(
pRegion
);
nBox
=
RegionNumRects
(
pRegion
);
int
nBox
=
RegionNumRects
(
pRegion
);
#ifdef TEST
fprintf
(
stderr
,
"nxagentGetOptimizedRegionBoxes: Going to optimize region at [%p] with [%d] rects.
\n
"
,
...
...
@@ -1855,7 +1768,7 @@ BoxPtr nxagentGetOptimizedRegionBoxes(RegionPtr pRegion)
}
#ifdef DEBUG
nBoxOptim
=
nBox
;
int
nBoxOptim
=
nBox
;
#endif
/*
...
...
@@ -1863,7 +1776,7 @@ BoxPtr nxagentGetOptimizedRegionBoxes(RegionPtr pRegion)
* their overlapping vertex as rule.
*/
for
(
i
=
0
;
i
<
nBox
;
i
++
)
for
(
i
nt
i
=
0
;
i
<
nBox
;
i
++
)
{
/*
* If the coordinates are (0,0) the box has been already merged,
...
...
@@ -1891,7 +1804,7 @@ BoxPtr nxagentGetOptimizedRegionBoxes(RegionPtr pRegion)
boxExtents
.
y2
=
pBox
[
i
].
y2
;
for
(
j
=
i
+
1
;
j
<
nBox
;
j
++
)
for
(
int
j
=
i
+
1
;
j
<
nBox
;
j
++
)
{
if
(
pBox
[
j
].
x1
==
0
&&
pBox
[
j
].
y1
==
0
&&
pBox
[
j
].
x2
==
0
&&
pBox
[
j
].
y2
==
0
)
...
...
@@ -1994,7 +1907,7 @@ BoxPtr nxagentGetOptimizedRegionBoxes(RegionPtr pRegion)
* partial- ly overlapping boxes.
*/
for
(
i
=
0
;
i
<
nBox
;
i
++
)
for
(
i
nt
i
=
0
;
i
<
nBox
;
i
++
)
{
if
(
pBox
[
i
].
x1
==
0
&&
pBox
[
i
].
y1
==
0
&&
pBox
[
i
].
x2
==
0
&&
pBox
[
i
].
y2
==
0
)
...
...
@@ -2012,7 +1925,7 @@ BoxPtr nxagentGetOptimizedRegionBoxes(RegionPtr pRegion)
boxExtents
.
x2
=
pBox
[
i
].
x2
;
boxExtents
.
y2
=
pBox
[
i
].
y2
;
for
(
j
=
i
+
1
;
j
<
nBox
;
j
++
)
for
(
int
j
=
i
+
1
;
j
<
nBox
;
j
++
)
{
if
(
pBox
[
j
].
x1
==
0
&&
pBox
[
j
].
y1
==
0
&&
pBox
[
j
].
x2
==
0
&&
pBox
[
j
].
y2
==
0
)
...
...
@@ -2063,19 +1976,14 @@ BoxPtr nxagentGetOptimizedRegionBoxes(RegionPtr pRegion)
unsigned
long
nxagentGetColor
(
DrawablePtr
pDrawable
,
int
xPixel
,
int
yPixel
)
{
XImage
*
ximage
;
Visual
*
pVisual
;
char
*
data
;
int
depth
,
format
,
length
;
int
leftPad
=
0
;
unsigned
long
pixel
;
depth
=
pDrawable
->
depth
;
format
=
(
depth
==
1
)
?
XYPixmap
:
ZPixmap
;
length
=
nxagentImageLength
(
1
,
1
,
format
,
leftPad
,
depth
);
int
depth
=
pDrawable
->
depth
;
int
format
=
(
depth
==
1
)
?
XYPixmap
:
ZPixmap
;
int
length
=
nxagentImageLength
(
1
,
1
,
format
,
leftPad
,
depth
);
if
((
data
=
malloc
(
length
))
==
NULL
)
char
*
data
=
malloc
(
length
);
if
(
data
==
NULL
)
{
#ifdef WARNING
fprintf
(
stderr
,
"nxagentGetColor: WARNING! Failed to allocate memory for the operation.
\n
"
);
...
...
@@ -2084,7 +1992,7 @@ unsigned long nxagentGetColor(DrawablePtr pDrawable, int xPixel, int yPixel)
return
-
1
;
}
pVisual
=
nxagentImageVisual
(
pDrawable
,
depth
);
Visual
*
pVisual
=
nxagentImageVisual
(
pDrawable
,
depth
);
if
(
pVisual
==
NULL
)
{
...
...
@@ -2097,7 +2005,7 @@ unsigned long nxagentGetColor(DrawablePtr pDrawable, int xPixel, int yPixel)
fbGetImage
(
pDrawable
,
xPixel
,
yPixel
,
1
,
1
,
format
,
AllPlanes
,
data
);
ximage
=
XCreateImage
(
nxagentDisplay
,
pVisual
,
depth
,
format
,
leftPad
,
(
char
*
)
data
,
XImage
*
ximage
=
XCreateImage
(
nxagentDisplay
,
pVisual
,
depth
,
format
,
leftPad
,
(
char
*
)
data
,
1
,
1
,
BitmapPad
(
nxagentDisplay
),
nxagentImagePad
(
1
,
format
,
leftPad
,
1
));
...
...
@@ -2112,7 +2020,7 @@ unsigned long nxagentGetColor(DrawablePtr pDrawable, int xPixel, int yPixel)
return
-
1
;
}
pixel
=
XGetPixel
(
ximage
,
0
,
0
);
unsigned
long
pixel
=
XGetPixel
(
ximage
,
0
,
0
);
XDestroyImage
(
ximage
);
...
...
@@ -2126,8 +2034,6 @@ unsigned long nxagentGetColor(DrawablePtr pDrawable, int xPixel, int yPixel)
unsigned
long
nxagentGetRegionColor
(
DrawablePtr
pDrawable
,
RegionPtr
pRegion
)
{
int
xPicker
,
yPicker
;
if
(
RegionNil
(
pRegion
)
==
1
)
{
return
nxagentGetDrawableColor
(
pDrawable
);
...
...
@@ -2138,14 +2044,14 @@ unsigned long nxagentGetRegionColor(DrawablePtr pDrawable, RegionPtr pRegion)
* bottom right corner of corrupted region extents.
*/
xPicker
=
pRegion
->
extents
.
x2
+
1
;
int
xPicker
=
pRegion
->
extents
.
x2
+
1
;
if
(
xPicker
>
pDrawable
->
width
)
{
xPicker
=
pDrawable
->
width
;
}
yPicker
=
pRegion
->
extents
.
y2
+
1
;
int
yPicker
=
pRegion
->
extents
.
y2
+
1
;
if
(
yPicker
>
pDrawable
->
height
)
{
...
...
@@ -2157,29 +2063,17 @@ unsigned long nxagentGetRegionColor(DrawablePtr pDrawable, RegionPtr pRegion)
unsigned
long
nxagentGetDrawableColor
(
DrawablePtr
pDrawable
)
{
int
xPicker
,
yPicker
;
/*
* The pixel used to determine the color of a drawable is at
* coordinates (x + width - 4, y + 4).
*/
xPicker
=
pDrawable
->
width
-
4
;
yPicker
=
4
;
return
nxagentGetColor
(
pDrawable
,
xPicker
,
yPicker
);
return
nxagentGetColor
(
pDrawable
,
pDrawable
->
width
-
4
,
4
);
}
void
nxagentClearRegion
(
DrawablePtr
pDrawable
,
RegionPtr
pRegion
)
{
WindowPtr
pWin
;
BoxPtr
pBox
;
unsigned
long
color
;
unsigned
long
backupPixel
=
0
;
int
nBox
,
i
;
int
restore
;
#ifdef DEBUG
static
int
nBoxCleared
;
...
...
@@ -2203,9 +2097,9 @@ void nxagentClearRegion(DrawablePtr pDrawable, RegionPtr pRegion)
return
;
}
pWin
=
(
WindowPtr
)
pDrawable
;
WindowPtr
pWin
=
(
WindowPtr
)
pDrawable
;
restore
=
0
;
int
restore
=
0
;
/*
* If the window has already a background, we can hope it will be
...
...
@@ -2227,7 +2121,7 @@ void nxagentClearRegion(DrawablePtr pDrawable, RegionPtr pRegion)
backupPixel
=
pWin
->
background
.
pixel
;
color
=
nxagentGetDrawableColor
((
DrawablePtr
)
pWin
);
unsigned
long
color
=
nxagentGetDrawableColor
((
DrawablePtr
)
pWin
);
if
(
color
==
-
1
)
{
...
...
@@ -2247,11 +2141,11 @@ void nxagentClearRegion(DrawablePtr pDrawable, RegionPtr pRegion)
restore
=
1
;
}
pBox
=
nxagentGetOptimizedRegionBoxes
(
pRegion
);
BoxPtr
pBox
=
nxagentGetOptimizedRegionBoxes
(
pRegion
);
nBox
=
RegionNumRects
(
pRegion
);
int
nBox
=
RegionNumRects
(
pRegion
);
for
(
i
=
0
;
i
<
nBox
;
i
++
)
for
(
i
nt
i
=
0
;
i
<
nBox
;
i
++
)
{
if
(
pBox
[
i
].
x1
==
0
&&
pBox
[
i
].
y1
==
0
&&
pBox
[
i
].
x2
==
0
&&
pBox
[
i
].
y2
==
0
)
...
...
@@ -2284,21 +2178,14 @@ void nxagentClearRegion(DrawablePtr pDrawable, RegionPtr pRegion)
void
nxagentFillRemoteRegion
(
DrawablePtr
pDrawable
,
RegionPtr
pRegion
)
{
GCPtr
pGC
;
BoxPtr
pBox
;
XRectangle
*
pRects
;
int
nrects
;
int
i
;
if
(
RegionNil
(
pRegion
)
==
1
)
{
return
;
}
pGC
=
nxagentGetGraphicContext
(
pDrawable
);
GCPtr
pGC
=
nxagentGetGraphicContext
(
pDrawable
);
nrects
=
RegionNumRects
(
pRegion
);
int
nrects
=
RegionNumRects
(
pRegion
);
#ifdef TEST
fprintf
(
stderr
,
"nxagentFillRemoteRegion: Going to fill remote region [%d,%d,%d,%d] rects [%d] with color [%lu].
\n
"
,
...
...
@@ -2315,11 +2202,10 @@ void nxagentFillRemoteRegion(DrawablePtr pDrawable, RegionPtr pRegion)
}
else
{
pBox
=
RegionRects
(
pRegion
);
pRects
=
malloc
(
nrects
*
sizeof
(
XRectangle
));
BoxPtr
pBox
=
RegionRects
(
pRegion
);
XRectangle
*
pRects
=
malloc
(
nrects
*
sizeof
(
XRectangle
));
for
(
i
=
0
;
i
<
nrects
;
i
++
)
for
(
i
nt
i
=
0
;
i
<
nrects
;
i
++
)
{
pRects
[
i
].
x
=
pBox
[
i
].
x1
;
pRects
[
i
].
y
=
pBox
[
i
].
y1
;
...
...
@@ -2373,20 +2259,14 @@ int nxagentDestroyCorruptedBackgroundResource(void * p, XID id)
void
nxagentPointsToDirtyRegion
(
DrawablePtr
pDrawable
,
int
mode
,
int
nPoints
,
xPoint
*
pPoints
)
{
RegionPtr
pRegion
;
RegionRec
tmpRegion
;
BoxRec
box
,
extents
;
xPoint
*
xp
;
int
np
;
np
=
nPoints
;
xp
=
pPoints
;
pRegion
=
RegionCreate
(
NullBox
,
1
);
RegionPtr
pRegion
=
RegionCreate
(
NullBox
,
1
);
int
np
=
nPoints
;
while
(
np
--
)
{
BoxRec
box
;
xPoint
*
xp
=
pPoints
;
if
(
CoordModePrevious
)
{
box
.
x1
=
box
.
x2
=
(
xp
-
1
)
->
x
+
xp
->
x
;
...
...
@@ -2408,6 +2288,7 @@ void nxagentPointsToDirtyRegion(DrawablePtr pDrawable, int mode,
* this loop could become less expensive.
*/
RegionRec
tmpRegion
;
RegionInit
(
&
tmpRegion
,
&
box
,
1
);
RegionUnion
(
pRegion
,
pRegion
,
&
tmpRegion
);
...
...
@@ -2417,7 +2298,7 @@ void nxagentPointsToDirtyRegion(DrawablePtr pDrawable, int mode,
xp
++
;
}
extents
=
*
RegionExtents
(
pRegion
);
BoxRec
extents
=
*
RegionExtents
(
pRegion
);
RegionReset
(
pRegion
,
&
extents
);
...
...
@@ -2557,14 +2438,9 @@ void nxagentRegionsOnScreen(void)
void
nxagentCreateDrawableBitmap
(
DrawablePtr
pDrawable
)
{
PixmapPtr
pBitmap
;
GCPtr
pGC
=
NULL
;
RegionPtr
pClipRegion
=
NullRegion
;
int
x
,
y
;
int
w
,
h
;
int
saveTrap
;
#ifdef TEST
fprintf
(
stderr
,
"nxagentCreateDrawableBitmap: Creating synchronization bitmap for [%s] at [%p].
\n
"
,
nxagentDrawableType
(
pDrawable
),
(
void
*
)
pDrawable
);
...
...
@@ -2574,7 +2450,7 @@ void nxagentCreateDrawableBitmap(DrawablePtr pDrawable)
* The bitmap is created only in the nxagent.
*/
saveTrap
=
nxagentGCTrap
;
int
saveTrap
=
nxagentGCTrap
;
nxagentGCTrap
=
1
;
...
...
@@ -2631,6 +2507,7 @@ void nxagentCreateDrawableBitmap(DrawablePtr pDrawable)
* window, because the pixmap creation would fail.
*/
PixmapPtr
pBitmap
;
pBitmap
=
nxagentCreatePixmap
(
pDrawable
->
pScreen
,
pDrawable
->
width
,
pDrawable
->
height
,
pDrawable
->
depth
,
0
);
if
(
pBitmap
==
NULL
)
...
...
@@ -2646,10 +2523,10 @@ void nxagentCreateDrawableBitmap(DrawablePtr pDrawable)
ValidateGC
((
DrawablePtr
)
pBitmap
,
pGC
);
x
=
pClipRegion
->
extents
.
x1
;
y
=
pClipRegion
->
extents
.
y1
;
w
=
pClipRegion
->
extents
.
x2
-
pClipRegion
->
extents
.
x1
;
h
=
pClipRegion
->
extents
.
y2
-
pClipRegion
->
extents
.
y1
;
int
x
=
pClipRegion
->
extents
.
x1
;
int
y
=
pClipRegion
->
extents
.
y1
;
int
w
=
pClipRegion
->
extents
.
x2
-
pClipRegion
->
extents
.
x1
;
int
h
=
pClipRegion
->
extents
.
y2
-
pClipRegion
->
extents
.
y1
;
nxagentCopyArea
(
pDrawable
,
(
DrawablePtr
)
pBitmap
,
pGC
,
x
,
y
,
w
,
h
,
x
,
y
);
...
...
@@ -3086,7 +2963,6 @@ nxagentSendBackgroundExposeEnd:
void
nxagentExposeBackgroundPredicate
(
void
*
p0
,
XID
x1
,
void
*
p2
)
{
WindowPtr
pWin
=
(
WindowPtr
)
p0
;
WindowPtr
pParent
;
struct
nxagentExposeBackground
*
pPair
=
p2
;
...
...
@@ -3112,7 +2988,7 @@ void nxagentExposeBackgroundPredicate(void *p0, XID x1, void *p2)
(
void
*
)
pWin
);
#endif
pParent
=
pWin
->
parent
;
WindowPtr
pParent
=
pWin
->
parent
;
while
(
pParent
!=
NULL
)
{
...
...
@@ -3140,21 +3016,14 @@ void nxagentExposeBackgroundPredicate(void *p0, XID x1, void *p2)
int
nxagentClipAndSendClearExpose
(
WindowPtr
pWin
,
void
*
ptr
)
{
RegionPtr
exposeRgn
;
RegionPtr
remoteExposeRgn
;
#ifdef DEBUG
BoxRec
box
;
#endif
remoteExposeRgn
=
(
RegionRec
*
)
ptr
;
RegionPtr
remoteExposeRgn
=
(
RegionRec
*
)
ptr
;
if
(
nxagentWindowPriv
(
pWin
)
->
deferredBackgroundExpose
==
1
)
{
exposeRgn
=
RegionCreate
(
NULL
,
1
);
RegionPtr
exposeRgn
=
RegionCreate
(
NULL
,
1
);
#ifdef DEBUG
box
=
*
RegionExtents
(
remoteExposeRgn
);
BoxRec
box
=
*
RegionExtents
(
remoteExposeRgn
);
fprintf
(
stderr
,
"nxagentClipAndSendClearExpose: Background expose extents: [%d,%d,%d,%d].
\n
"
,
box
.
x1
,
box
.
y1
,
box
.
x2
,
box
.
y2
);
...
...
@@ -3230,4 +3099,3 @@ void nxagentSendDeferredBackgroundExposures(void)
RegionEmpty
(
nxagentDeferredBackgroundExposures
);
}
}
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