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
9b1e2993
Commit
9b1e2993
authored
Oct 23, 2019
by
Ulrich Sibiller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Image.c: reformat comments
parent
24cb46d2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
149 additions
and
200 deletions
+149
-200
Image.c
nx-X11/programs/Xserver/hw/nxagent/Image.c
+149
-200
No files found.
nx-X11/programs/Xserver/hw/nxagent/Image.c
View file @
9b1e2993
...
@@ -59,9 +59,8 @@
...
@@ -59,9 +59,8 @@
#undef DUMP
#undef DUMP
/*
/*
* Don't pack the images having a width, a
* Don't pack the images having a width, a height or a data size
* height or a data size smaller or equal
* smaller or equal to these thresholds.
* to these thresholds.
*/
*/
#define IMAGE_PACK_WIDTH 2
#define IMAGE_PACK_WIDTH 2
...
@@ -69,16 +68,14 @@
...
@@ -69,16 +68,14 @@
#define IMAGE_PACK_LENGTH 512
#define IMAGE_PACK_LENGTH 512
/*
/*
* Compress the image with a lossless encoder
* Compress the image with a lossless encoder if the percentage of
* if the percentage of discrete pixels in the
* discrete pixels in the image is below this threshold.
* image is below this threshold.
*/
*/
#define IMAGE_UNIQUE_RATIO 10
#define IMAGE_UNIQUE_RATIO 10
/*
/*
* Preferred pack and split parameters we
* Preferred pack and split parameters we got from the NX transport.
* got from the NX transport.
*/
*/
int
nxagentPackLossless
=
-
1
;
int
nxagentPackLossless
=
-
1
;
...
@@ -94,8 +91,8 @@ int nxagentAlphaEnabled = 0;
...
@@ -94,8 +91,8 @@ int nxagentAlphaEnabled = 0;
int
nxagentAlphaCompat
=
0
;
int
nxagentAlphaCompat
=
0
;
/*
/*
* Used to reformat image when connecting to
* Used to reformat image when connecting to
displays having different
*
displays having different
byte order.
* byte order.
*/
*/
extern
void
nxagentBitOrderInvert
(
unsigned
char
*
,
int
);
extern
void
nxagentBitOrderInvert
(
unsigned
char
*
,
int
);
...
@@ -110,8 +107,7 @@ extern void nxagentFourByteSwap(register unsigned char *, register int);
...
@@ -110,8 +107,7 @@ extern void nxagentFourByteSwap(register unsigned char *, register int);
static
VisualID
nxagentUnpackVisualId
[
MAX_CONNECTIONS
];
static
VisualID
nxagentUnpackVisualId
[
MAX_CONNECTIONS
];
/*
/*
* Store the last alpha data set for the
* Store the last alpha data set for the client.
* client.
*/
*/
typedef
struct
_UnpackAlpha
typedef
struct
_UnpackAlpha
...
@@ -126,9 +122,8 @@ typedef UnpackAlphaRec *UnpackAlphaPtr;
...
@@ -126,9 +122,8 @@ typedef UnpackAlphaRec *UnpackAlphaPtr;
static
UnpackAlphaPtr
nxagentUnpackAlpha
[
MAX_CONNECTIONS
];
static
UnpackAlphaPtr
nxagentUnpackAlpha
[
MAX_CONNECTIONS
];
/*
/*
* Encode the imade alpha channel by using
* Encode the imade alpha channel by using a specific encoding,
* a specific encoding, separating it from
* separating it from the rest of the RGB data.
* the rest of the RGB data.
*/
*/
static
char
*
nxagentImageAlpha
(
XImage
*
ximage
);
static
char
*
nxagentImageAlpha
(
XImage
*
ximage
);
...
@@ -141,10 +136,9 @@ static void nxagentSetUnpackAlpha(DrawablePtr pDrawable, XImage *pImage, ClientP
...
@@ -141,10 +136,9 @@ static void nxagentSetUnpackAlpha(DrawablePtr pDrawable, XImage *pImage, ClientP
static
char
*
nxagentImageCopy
(
XImage
*
source
,
XImage
*
destination
);
static
char
*
nxagentImageCopy
(
XImage
*
source
,
XImage
*
destination
);
/*
/*
* Return true if the image can be cached.
* Return true if the image can be cached. Don't cache the images
* Don't cache the images packed with the
* packed with the bitmap method as the encoding is little more
* bitmap method as the encoding is little
* expensive than a copy.
* more expensive than a copy.
*/
*/
#define nxagentNeedCache(image, method) \
#define nxagentNeedCache(image, method) \
...
@@ -152,10 +146,8 @@ static char *nxagentImageCopy(XImage *source, XImage *destination);
...
@@ -152,10 +146,8 @@ static char *nxagentImageCopy(XImage *source, XImage *destination);
((method) != PACK_BITMAP_16M_COLORS)
((method) != PACK_BITMAP_16M_COLORS)
/*
/*
* With the bitmap encoding, if the image
* With the bitmap encoding, if the image is 32 bits-per-pixel the 4th
* is 32 bits-per-pixel the 4th byte is not
* byte is not transmitted, so we don't need to clean the image.
* transmitted, so we don't need to clean
* the image.
*/
*/
#define nxagentNeedClean(image, method) \
#define nxagentNeedClean(image, method) \
...
@@ -188,11 +180,10 @@ ImageStatisticsRec nxagentImageStatistics;
...
@@ -188,11 +180,10 @@ ImageStatisticsRec nxagentImageStatistics;
int
nxagentImageReformat
(
char
*
base
,
int
nbytes
,
int
bpp
,
int
order
)
int
nxagentImageReformat
(
char
*
base
,
int
nbytes
,
int
bpp
,
int
order
)
{
{
/*
/*
* This is used whenever we need to swap the image data.
* This is used whenever we need to swap the image data. If we got
* If we got an image from an X server having a different
* an image from an X server having a different endianness, we will
* endianness, we will need to reformat the image to match
* need to reformat the image to match our own image-order so that
* our own image-order so that ProcGetImage can return
* ProcGetImage can return the expected format to the client.
* the expected format to the client.
*/
*/
switch
(
bpp
)
switch
(
bpp
)
...
@@ -298,10 +289,9 @@ int nxagentImagePad(int width, int format, int leftPad, int depth)
...
@@ -298,10 +289,9 @@ int nxagentImagePad(int width, int format, int leftPad, int depth)
}
}
/*
/*
* Only copy the data, not the structure.
* Only copy the data, not the structure. The data pointed by the
* The data pointed by the destination is
* destination is lost. Used to clone two images that point to the
* lost. Used to clone two images that
* same data.
* point to the same data.
*/
*/
char
*
nxagentImageCopy
(
XImage
*
source
,
XImage
*
destination
)
char
*
nxagentImageCopy
(
XImage
*
source
,
XImage
*
destination
)
...
@@ -344,8 +334,7 @@ char *nxagentImageAlpha(XImage *image)
...
@@ -344,8 +334,7 @@ char *nxagentImageAlpha(XImage *image)
}
}
/*
/*
* The image is supposed to be in
* The image is supposed to be in server order.
* server order.
*/
*/
int
offset
=
(
image
->
byte_order
==
MSBFirst
)
?
0
:
3
;
int
offset
=
(
image
->
byte_order
==
MSBFirst
)
?
0
:
3
;
...
@@ -364,8 +353,7 @@ char *nxagentImageAlpha(XImage *image)
...
@@ -364,8 +353,7 @@ char *nxagentImageAlpha(XImage *image)
}
}
/*
/*
* Write down the image cache statistics
* Write down the image cache statistics to the buffer.
* to the buffer.
*/
*/
void
nxagentImageStatisticsHandler
(
char
**
buffer
,
int
type
)
void
nxagentImageStatisticsHandler
(
char
**
buffer
,
int
type
)
...
@@ -381,9 +369,8 @@ FIXME: Agent cache statistics have to be implemented.
...
@@ -381,9 +369,8 @@ FIXME: Agent cache statistics have to be implemented.
}
}
/*
/*
* This should be called only for drawables
* This should be called only for drawables having a depth of 32. In
* having a depth of 32. In the other cases,
* the other cases, it would only generate useless traffic.
* it would only generate useless traffic.
*/
*/
void
nxagentSetUnpackAlpha
(
DrawablePtr
pDrawable
,
XImage
*
pImage
,
ClientPtr
pClient
)
void
nxagentSetUnpackAlpha
(
DrawablePtr
pDrawable
,
XImage
*
pImage
,
ClientPtr
pClient
)
...
@@ -404,16 +391,15 @@ void nxagentSetUnpackAlpha(DrawablePtr pDrawable, XImage *pImage, ClientPtr pCli
...
@@ -404,16 +391,15 @@ void nxagentSetUnpackAlpha(DrawablePtr pDrawable, XImage *pImage, ClientPtr pCli
}
}
/*
/*
* If we are synchronizing the drawable, discard
* If we are synchronizing the drawable, discard any unpack alpha
* any unpack alpha stored for the client. The
* stored for the client. The alpha data, in fact, may be still
* alpha data, in fact, may be still traveling
* traveling and so we either wait until the end of the split or
* and so we either wait until the end of the
* send a fresh copy.
* split or send a fresh copy.
*/
*/
/*
/*
FIXME: Here the split trap is always set and so the caching of
FIXME: Here the split trap is always set and so the caching of
the
the alpha channel is useless. I remember we set the trap
alpha channel is useless. I remember we set the trap because of
because of
the cursor but why is it always set now?
the cursor but why is it always set now?
*/
*/
#ifdef DEBUG
#ifdef DEBUG
fprintf
(
stderr
,
"nxagentSetUnpackAlpha: Checking alpha channel for client [%d] with trap [%d].
\n
"
,
fprintf
(
stderr
,
"nxagentSetUnpackAlpha: Checking alpha channel for client [%d] with trap [%d].
\n
"
,
...
@@ -431,9 +417,8 @@ FIXME: Here the split trap is always set and so the caching of
...
@@ -431,9 +417,8 @@ FIXME: Here the split trap is always set and so the caching of
#endif
#endif
/*
/*
* Check if we are connected to a newer proxy
* Check if we are connected to a newer proxy version and so can
* version and so can send the alpha data in
* send the alpha data in compressed form.
* compressed form.
*/
*/
if
(
nxagentAlphaCompat
==
0
)
if
(
nxagentAlphaCompat
==
0
)
...
@@ -480,8 +465,7 @@ FIXME: Here the split trap is always set and so the caching of
...
@@ -480,8 +465,7 @@ FIXME: Here the split trap is always set and so the caching of
}
}
/*
/*
* The NX agent's implementation of the
* The NX agent's implementation of the X server's image functions.
* X server's image functions.
*/
*/
void
nxagentPutImage
(
DrawablePtr
pDrawable
,
GCPtr
pGC
,
int
depth
,
void
nxagentPutImage
(
DrawablePtr
pDrawable
,
GCPtr
pGC
,
int
depth
,
...
@@ -502,9 +486,8 @@ void nxagentPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth,
...
@@ -502,9 +486,8 @@ void nxagentPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth,
#endif
#endif
/*
/*
* If the display is down and there is not an
* If the display is down and there is not an nxagent attached,
* nxagent attached, sleep for a while but
* sleep for a while but still give a chance to the client to write
* still give a chance to the client to write
* to the framebuffer.
* to the framebuffer.
*/
*/
...
@@ -527,11 +510,11 @@ void nxagentPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth,
...
@@ -527,11 +510,11 @@ void nxagentPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth,
}
}
/*
/*
* This is of little use because clients usually write
* This is of little use because clients usually write
to windows
*
to windows only after an expose event, and, in the
*
only after an expose event, and, in the rare case they use a
*
rare case they use a direct put image to the window
*
direct put image to the window (for a media player it should be a
*
(for a media player it should be a necessity), they
*
necessity), they are likely to monitor the visibility of the
*
are likely to monitor the visibility of the
window.
* window.
*/
*/
if
(
nxagentOption
(
IgnoreVisibility
)
==
0
&&
pDrawable
->
type
==
DRAWABLE_WINDOW
&&
if
(
nxagentOption
(
IgnoreVisibility
)
==
0
&&
pDrawable
->
type
==
DRAWABLE_WINDOW
&&
...
@@ -548,9 +531,8 @@ void nxagentPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth,
...
@@ -548,9 +531,8 @@ void nxagentPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth,
}
}
/*
/*
* This is more interesting. Check if the operation
* This is more interesting. Check if the operation will produce a
* will produce a visible result based on the clip
* visible result based on the clip list of the window and the GC.
* list of the window and the GC.
*/
*/
pRegion
=
nxagentCreateRegion
(
pDrawable
,
pGC
,
dstX
,
dstY
,
dstWidth
,
dstHeight
);
pRegion
=
nxagentCreateRegion
(
pDrawable
,
pGC
,
dstX
,
dstY
,
dstWidth
,
dstHeight
);
...
@@ -607,9 +589,8 @@ FIXME: Should use these.
...
@@ -607,9 +589,8 @@ FIXME: Should use these.
}
}
/*
/*
* We are going to realize the operation
* We are going to realize the operation on the real display. Let's
* on the real display. Let's check if
* check if the link is down.
* the link is down.
*/
*/
if
(
NXDisplayError
(
nxagentDisplay
)
==
1
)
if
(
NXDisplayError
(
nxagentDisplay
)
==
1
)
...
@@ -618,13 +599,11 @@ FIXME: Should use these.
...
@@ -618,13 +599,11 @@ FIXME: Should use these.
}
}
/*
/*
* Mark the region as corrupted and skip the operation
* Mark the region as corrupted and skip the operation if we went
* if we went out of bandwidth. The drawable will be
* out of bandwidth. The drawable will be synchronized at later
* synchronized at later time. Don't do that if the
* time. Don't do that if the image is likely to be a shape or a
* image is likely to be a shape or a clip mask, if we
* clip mask, if we are here because we are actually synchronizing
* are here because we are actually synchronizing the
* the drawable or if the drawable's corrupted region is over-age.
* drawable or if the drawable's corrupted region is
* over-age.
*/
*/
if
(
NXAGENT_SHOULD_DEFER_PUTIMAGE
(
pDrawable
))
if
(
NXAGENT_SHOULD_DEFER_PUTIMAGE
(
pDrawable
))
...
@@ -676,8 +655,7 @@ FIXME: Should use these.
...
@@ -676,8 +655,7 @@ FIXME: Should use these.
#endif
#endif
/*
/*
* Check whether we need to enclose the
* Check whether we need to enclose the image in a split sequence.
* image in a split sequence.
*/
*/
/*
/*
FIXME: Should we disable the split with link LAN?
FIXME: Should we disable the split with link LAN?
...
@@ -689,12 +667,11 @@ FIXME: Should we disable the split with link LAN?
...
@@ -689,12 +667,11 @@ FIXME: Should we disable the split with link LAN?
split
=
(
nxagentOption
(
Streaming
)
==
1
&&
split
=
(
nxagentOption
(
Streaming
)
==
1
&&
nxagentOption
(
LinkType
)
!=
LINK_TYPE_NONE
nxagentOption
(
LinkType
)
!=
LINK_TYPE_NONE
/*
/*
FIXME: Do we stream the images from GLX or Xv? If we do that,
FIXME: Do we stream the images from GLX or Xv? If we do that, we
we should also write on the frame buffer, including the
should also write on the frame buffer, including the images put
images put on windows, to be able to reconstruct the
on windows, to be able to reconstruct the region that is out of
region that is out of sync. Surely we should not try to
sync. Surely we should not try to cache the GLX and Xv images
cache the GLX and Xv images in memory or save them in
in memory or save them in the image cache on disk.
the image cache on disk.
*/
*/
/*
/*
FIXME: Temporarily stream the GLX data.
FIXME: Temporarily stream the GLX data.
...
@@ -705,8 +682,7 @@ FIXME: Temporarily stream the GLX data.
...
@@ -705,8 +682,7 @@ FIXME: Temporarily stream the GLX data.
);
);
/*
/*
* Never split images whose depth
* Never split images whose depth is less than 15.
* is less than 15.
*/
*/
if
(
split
==
1
&&
(
nxagentSplitTrap
==
1
||
depth
<
15
))
if
(
split
==
1
&&
(
nxagentSplitTrap
==
1
||
depth
<
15
))
...
@@ -750,9 +726,8 @@ FIXME: Temporarily stream the GLX data.
...
@@ -750,9 +726,8 @@ FIXME: Temporarily stream the GLX data.
#endif
#endif
/*
/*
* If the image was originated by a GLX
* If the image was originated by a GLX or Xvideo request,
* or Xvideo request, temporarily disable
* temporarily disable the use of the cache.
* the use of the cache.
*/
*/
if
(
nxagentOption
(
LinkType
)
!=
LINK_TYPE_NONE
&&
if
(
nxagentOption
(
LinkType
)
!=
LINK_TYPE_NONE
&&
...
@@ -768,17 +743,15 @@ FIXME: Temporarily stream the GLX data.
...
@@ -768,17 +743,15 @@ FIXME: Temporarily stream the GLX data.
}
}
/*
/*
* Enclose the next messages in a split
* Enclose the next messages in a split sequence. The proxy will
* sequence. The proxy will tell us if
* tell us if the split took place.
* the split took place.
*/
*/
if
(
split
==
1
)
if
(
split
==
1
)
{
{
/*
/*
* If the drawable is already being split,
* If the drawable is already being split, expand the
* expand the region. Currently drawables
* region. Currently drawables can't have more than a single split
* can't have more than a single split
* region.
* region.
*/
*/
...
@@ -789,9 +762,8 @@ FIXME: Temporarily stream the GLX data.
...
@@ -789,9 +762,8 @@ FIXME: Temporarily stream the GLX data.
(
void
*
)
pDrawable
);
(
void
*
)
pDrawable
);
#endif
#endif
/*
/*
FIXME: Should probably intersect the region with
FIXME: Should probably intersect the region with the region being
the region being split to also invalidate
split to also invalidate the commits.
the commits.
*/
*/
nxagentMarkCorruptedRegion
(
pDrawable
,
pRegion
);
nxagentMarkCorruptedRegion
(
pDrawable
,
pRegion
);
...
@@ -800,9 +772,8 @@ FIXME: Should probably intersect the region with
...
@@ -800,9 +772,8 @@ FIXME: Should probably intersect the region with
else
else
{
{
/*
/*
* Assign a new resource to the drawable.
* Assign a new resource to the drawable. Will also assign the
* Will also assign the GC to use for the
* GC to use for the operation.
* operation.
*/
*/
resource
=
nxagentCreateSplit
(
pDrawable
,
&
pGC
);
resource
=
nxagentCreateSplit
(
pDrawable
,
&
pGC
);
...
@@ -824,12 +795,11 @@ FIXME: Should probably intersect the region with
...
@@ -824,12 +795,11 @@ FIXME: Should probably intersect the region with
NXEndSplit
(
nxagentDisplay
,
resource
);
NXEndSplit
(
nxagentDisplay
,
resource
);
/*
/*
* Now we need to check if all the messages went
* Now we need to check if all the messages went straight through
* straight through the output stream or any of
* the output stream or any of them required a split. If no split
* them required a split. If no split will take
* will take place, we will remove the association with the
* place, we will remove the association with the
* drawable and release the resource at the time we will handle
* drawable and release the resource at the time
* the no-split event.
* we will handle the no-split event.
*/
*/
split
=
nxagentWaitSplitEvent
(
resource
);
split
=
nxagentWaitSplitEvent
(
resource
);
...
@@ -843,10 +813,9 @@ FIXME: Should probably intersect the region with
...
@@ -843,10 +813,9 @@ FIXME: Should probably intersect the region with
#endif
#endif
/*
/*
* Marking the corrupted region we will check
* Marking the corrupted region we will check if the region
* if the region intersects the split region,
* intersects the split region, therefore the split region must
* therefore the split region must be added
* be added later.
* later.
*/
*/
nxagentMarkCorruptedRegion
(
pDrawable
,
pRegion
);
nxagentMarkCorruptedRegion
(
pDrawable
,
pRegion
);
...
@@ -872,9 +841,8 @@ FIXME: Should probably intersect the region with
...
@@ -872,9 +841,8 @@ FIXME: Should probably intersect the region with
if
(
nxagentDrawableStatus
(
pDrawable
)
==
NotSynchronized
)
if
(
nxagentDrawableStatus
(
pDrawable
)
==
NotSynchronized
)
{
{
/*
/*
* We just covered the drawable with
* We just covered the drawable with a solid image. We can
* a solid image. We can consider the
* consider the overlapping region as synchronized.
* overlapping region as synchronized.
*/
*/
#ifdef TEST
#ifdef TEST
...
@@ -919,8 +887,8 @@ void nxagentRealizeImage(DrawablePtr pDrawable, GCPtr pGC, int depth,
...
@@ -919,8 +887,8 @@ void nxagentRealizeImage(DrawablePtr pDrawable, GCPtr pGC, int depth,
int
totalHeight
;
int
totalHeight
;
/*
/*
* NXPutPackedImage is longer than PutPackedImage
* NXPutPackedImage is longer than PutPackedImage
so that we
* s
o that we s
ubtract the bigger one to be sure.
* subtract the bigger one to be sure.
*/
*/
const
int
subSize
=
(
MAX_REQUEST_SIZE
<<
2
)
-
sizeof
(
xNXPutPackedImageReq
);
const
int
subSize
=
(
MAX_REQUEST_SIZE
<<
2
)
-
sizeof
(
xNXPutPackedImageReq
);
...
@@ -1085,13 +1053,13 @@ void nxagentPutSubImage(DrawablePtr pDrawable, GCPtr pGC, int depth,
...
@@ -1085,13 +1053,13 @@ void nxagentPutSubImage(DrawablePtr pDrawable, GCPtr pGC, int depth,
/*
/*
* XCreateImage is the place where the leftPad should be passed.
* XCreateImage is the place where the leftPad should be passed.
* The image data is received from our client unmodified. In
* The image data is received from our client unmodified. In
theory
*
theory what we would need to do is just creating an appropri-
*
what we would need to do is just creating an appropriate XImage
*
ate XImage structure based on the incoming data and let Xlib
*
structure based on the incoming data and let Xlib do the
*
do the rest. Probably we don't have to pass leftPad again in
*
rest. Probably we don't have to pass leftPad again in the src_x
*
the src_x of XPutImage otherwise the src_x would make Xlib
*
of XPutImage otherwise the src_x would make Xlib to take into
*
to take into account the xoffset field twice. Unfortunately
*
account the xoffset field twice. Unfortunately passing the
*
passing the
leftPad doesn't work.
* leftPad doesn't work.
*
*
* plainImage = XCreateImage(nxagentDisplay, pVisual,
* plainImage = XCreateImage(nxagentDisplay, pVisual,
* depth, format, leftPad, data,
* depth, format, leftPad, data,
...
@@ -1145,10 +1113,9 @@ FIXME: Should use an unpack resource here.
...
@@ -1145,10 +1113,9 @@ FIXME: Should use an unpack resource here.
#endif
#endif
/*
/*
* We got the image data from the X client or
* We got the image data from the X client or from the frame-buffer
* from the frame-buffer with our own endianness.
* with our own endianness. Byte swap the image data if the display
* Byte swap the image data if the display has
* has a different endianness than our own.
* a different endianness than our own.
*/
*/
if
(
nxagentImageNormalize
(
plainImage
)
!=
0
)
if
(
nxagentImageNormalize
(
plainImage
)
!=
0
)
...
@@ -1165,10 +1132,9 @@ FIXME: Should use an unpack resource here.
...
@@ -1165,10 +1132,9 @@ FIXME: Should use an unpack resource here.
#endif
#endif
/*
/*
* Check if the user requested to pack the
* Check if the user requested to pack the image but don't pack it
* image but don't pack it if we are not
* if we are not connected to a proxy or if the depth is less than
* connected to a proxy or if the depth is
* 15 bpp.
* less than 15 bpp.
*/
*/
pack
=
(
nxagentOption
(
LinkType
)
!=
LINK_TYPE_NONE
&&
pack
=
(
nxagentOption
(
LinkType
)
!=
LINK_TYPE_NONE
&&
...
@@ -1179,9 +1145,8 @@ FIXME: Should use an unpack resource here.
...
@@ -1179,9 +1145,8 @@ FIXME: Should use an unpack resource here.
if
(
pack
==
1
&&
lossless
==
0
)
if
(
pack
==
1
&&
lossless
==
0
)
{
{
/*
/*
* Force the image to be sent as a plain
* Force the image to be sent as a plain bitmap if we don't have
* bitmap if we don't have any lossless
* any lossless encoder available.
* encoder available.
*/
*/
if
(
w
<=
IMAGE_PACK_WIDTH
||
h
<=
IMAGE_PACK_HEIGHT
||
if
(
w
<=
IMAGE_PACK_WIDTH
||
h
<=
IMAGE_PACK_HEIGHT
||
...
@@ -1220,8 +1185,8 @@ FIXME: Should use an unpack resource here.
...
@@ -1220,8 +1185,8 @@ FIXME: Should use an unpack resource here.
if
(
pack
==
1
)
if
(
pack
==
1
)
{
{
/*
/*
* Set the geometry and alpha channel
* Set the geometry and alpha channel
to be used for the unpacked
*
to be used for the unpacked
image.
* image.
*/
*/
if
(
nxagentUnpackVisualId
[
client
->
index
]
!=
pVisual
->
visualid
)
if
(
nxagentUnpackVisualId
[
client
->
index
]
!=
pVisual
->
visualid
)
...
@@ -1237,9 +1202,8 @@ FIXME: Should use an unpack resource here.
...
@@ -1237,9 +1202,8 @@ FIXME: Should use an unpack resource here.
}
}
/*
/*
* Check if the image is supposed to carry
* Check if the image is supposed to carry the alpha data in the
* the alpha data in the fourth byte and,
* fourth byte and, if so, send the alpha channel using the
* if so, send the alpha channel using the
* specific encoding.
* specific encoding.
*/
*/
...
@@ -1249,46 +1213,43 @@ FIXME: Should use an unpack resource here.
...
@@ -1249,46 +1213,43 @@ FIXME: Should use an unpack resource here.
}
}
/*
/*
* If the image doesn't come from the XVideo or the
* If the image doesn't come from the XVideo or the GLX extension
* GLX extension try to locate it in the cache. The
* try to locate it in the cache. The case of the lossless trap is
* case of the lossless trap is also special, as we
* also special, as we want to eventually encode the image again
* want to eventually encode the image again using
* using a lossless compression.
* a lossless compression.
*/
*/
/*
/*
FIXME: Should try to locate the image anyway, if the lossless
FIXME: Should try to locate the image anyway, if the lossless
trap is
trap is set, and if the image was encoded by a lossy
set, and if the image was encoded by a lossy compressor, roll
compressor, roll back the changes and encode the image
back the changes and encode the image again using the preferred
again using the preferred
method.
method.
*/
*/
if
(
nxagentNeedCache
(
plainImage
,
packMethod
)
&&
if
(
nxagentNeedCache
(
plainImage
,
packMethod
)
&&
nxagentGlxTrap
==
0
&&
nxagentXvTrap
==
0
&&
nxagentGlxTrap
==
0
&&
nxagentXvTrap
==
0
&&
nxagentLosslessTrap
==
0
&&
NXImageCacheSize
>
0
)
nxagentLosslessTrap
==
0
&&
NXImageCacheSize
>
0
)
{
{
/*
/*
* Be sure that the padding bits are
* Be sure that the padding bits are cleaned before calculating
* cleaned before calculating the MD5
* the MD5 checksum.
* checksum.
*/
*/
/*
/*
FIXME: There should be a callback registered by the agent that
FIXME: There should be a callback registered by the agent that
provides a statistics report, in text format, telling
provides a statistics report, in text format, telling
for
for example how many images were searched in the cache,
example how many images were searched in the cache, how many
how many were found, how many drawables are to be synch-
were found, how many drawables are to be synchronized,
ronized, etc. This statistics report would be included
etc. This statistics report would be included by the proxy in
by the proxy in
its stat output.
its stat output.
*/
*/
clean
=
1
;
clean
=
1
;
NXCleanImage
(
plainImage
);
NXCleanImage
(
plainImage
);
/*
/*
* Will return a pointer to the image and checksum
* Will return a pointer to the image and checksum taken from
* taken from the cache, if found. If the image is
* the cache, if found. If the image is not found, the function
* not found, the function returns a null image and
* returns a null image and a pointer to the calculated
* a pointer to the calculated checksum. It is up
* checksum. It is up to the application to free the memory. We
* to the application to free the memory. We will
* will use the checksum to add the image in the cache.
* use the checksum to add the image in the cache.
*/
*/
packedImage
=
NXCacheFindImage
(
plainImage
,
&
packMethod
,
&
packedChecksum
);
packedImage
=
NXCacheFindImage
(
plainImage
,
&
packMethod
,
&
packedChecksum
);
...
@@ -1325,9 +1286,8 @@ FIXME: There should be a callback registered by the agent that
...
@@ -1325,9 +1286,8 @@ FIXME: There should be a callback registered by the agent that
}
}
/*
/*
* If a specific encoder was not mandated,
* If a specific encoder was not mandated, try to guess if a
* try to guess if a lossless encoder will
* lossless encoder will compress better.
* compress better.
*/
*/
if
(
lossless
==
0
&&
nxagentOption
(
Adaptive
)
==
1
)
if
(
lossless
==
0
&&
nxagentOption
(
Adaptive
)
==
1
)
...
@@ -1355,8 +1315,7 @@ FIXME: There should be a callback registered by the agent that
...
@@ -1355,8 +1315,7 @@ FIXME: There should be a callback registered by the agent that
}
}
/*
/*
* Encode the image using the selected
* Encode the image using the selected pack method.
* pack method.
*/
*/
if
(
packMethod
==
PACK_RLE_16M_COLORS
||
if
(
packMethod
==
PACK_RLE_16M_COLORS
||
...
@@ -1364,13 +1323,11 @@ FIXME: There should be a callback registered by the agent that
...
@@ -1364,13 +1323,11 @@ FIXME: There should be a callback registered by the agent that
packMethod
==
PACK_BITMAP_16M_COLORS
)
packMethod
==
PACK_BITMAP_16M_COLORS
)
{
{
/*
/*
* Cleanup the image if we didn't do that yet.
* Cleanup the image if we didn't do that yet. We assume that
* We assume that the JPEG and PNG compression
* the JPEG and PNG compression methods will actually ignore the
* methods will actually ignore the padding
* padding bytes. In other words, bitmap images producing the
* bytes. In other words, bitmap images prod-
* same visual output should produce compressed images that are
* ucing the same visual output should produce
* bitwise the same regardless the padding bits.
* compressed images that are bitwise the same
* regardless the padding bits.
*/
*/
if
(
clean
==
0
)
if
(
clean
==
0
)
...
@@ -1386,12 +1343,10 @@ FIXME: There should be a callback registered by the agent that
...
@@ -1386,12 +1343,10 @@ FIXME: There should be a callback registered by the agent that
switch
(
packMethod
)
switch
(
packMethod
)
{
{
/*
/*
* If nothing is done by the bitmap encoder,
* If nothing is done by the bitmap encoder, it saves an
* it saves an allocation and a memory copy
* allocation and a memory copy by setting the data field of
* by setting the data field of the packed
* the packed image to the original data. We need to check
* image to the original data. We need to
* this at the time we will free the packed image.
* check this at the time we will free the
* packed image.
*/
*/
case
PACK_BITMAP_16M_COLORS
:
case
PACK_BITMAP_16M_COLORS
:
...
@@ -1433,8 +1388,8 @@ FIXME: There should be a callback registered by the agent that
...
@@ -1433,8 +1388,8 @@ FIXME: There should be a callback registered by the agent that
}
}
/*
/*
* If we didn't produce a valid packed
* If we didn't produce a valid packed
image, send the image as a X
*
image, send the image as a X
bitmap.
* bitmap.
*/
*/
if
(
packedImage
!=
NULL
)
if
(
packedImage
!=
NULL
)
...
@@ -1453,10 +1408,8 @@ FIXME: There should be a callback registered by the agent that
...
@@ -1453,10 +1408,8 @@ FIXME: There should be a callback registered by the agent that
0
,
0
,
x
,
y
,
w
,
h
);
0
,
0
,
x
,
y
,
w
,
h
);
/*
/*
* Add the image only if we have a valid
* Add the image only if we have a valid checksum. This is the
* checksum. This is the case only if we
* case only if we originally tried to find the image in cache.
* originally tried to find the image in
* cache.
*/
*/
if
(
NXImageCacheSize
>
0
&&
packedChecksum
!=
NULL
)
if
(
NXImageCacheSize
>
0
&&
packedChecksum
!=
NULL
)
...
@@ -1467,9 +1420,8 @@ FIXME: There should be a callback registered by the agent that
...
@@ -1467,9 +1420,8 @@ FIXME: There should be a callback registered by the agent that
#endif
#endif
/*
/*
* Check if both the plain and the packed
* Check if both the plain and the packed image point to the
* image point to the same data. In this
* same data. In this case we need a copy.
* case we need a copy.
*/
*/
if
(
packedImage
->
data
==
plainImage
->
data
&&
if
(
packedImage
->
data
==
plainImage
->
data
&&
...
@@ -1490,19 +1442,17 @@ FIXME: There should be a callback registered by the agent that
...
@@ -1490,19 +1442,17 @@ FIXME: There should be a callback registered by the agent that
else
else
{
{
/*
/*
* Clean the image to help the proxy to match
* Clean the image to help the proxy to match the checksum in its
* the checksum in its cache. Do that only if
* cache. Do that only if the differential compression is enabled
* the differential compression is enabled and
* and if the image is not supposed to carry the alpha data in the
* if the image is not supposed to carry the
* fourth byte of the pixel.
* alpha data in the fourth byte of the pixel.
*/
*/
/*
/*
FIXME: If we failed to encode the image by any of the available
FIXME: If we failed to encode the image by any of the available
methods, for example if we couldn't allocate memory, we
methods, for example if we couldn't allocate memory, we may
may need to ripristinate the alpha channel, that in the
need to ripristinate the alpha channel, that in the meanwhile
meanwhile was sent in the unpack alpha message. This can
was sent in the unpack alpha message. This can be done here, if
be done here, if the clean flag is true and we are going
the clean flag is true and we are going to send a plain image.
to send a plain image.
*/
*/
if
(
clean
==
0
)
if
(
clean
==
0
)
{
{
...
@@ -1596,10 +1546,9 @@ void nxagentGetImage(DrawablePtr pDrawable, int x, int y, int w, int h,
...
@@ -1596,10 +1546,9 @@ void nxagentGetImage(DrawablePtr pDrawable, int x, int y, int w, int h,
}
}
/*
/*
* We have to reset the visual cache before
* We have to reset the visual cache before connecting to another
* connecting to another display, so that a
* display, so that a new unpack geometry can be communicated to the
* new unpack geometry can be communicated
* new proxy.
* to the new proxy.
*/
*/
void
nxagentResetVisualCache
(
void
)
void
nxagentResetVisualCache
(
void
)
...
...
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