|
Line 0
Link Here
|
|
|
1 |
/* |
| 2 |
* sprite.c |
| 3 |
* |
| 4 |
* software sprite routines - based on misprite |
| 5 |
* |
| 6 |
* Modified for XFree86 4.x by Alan Hourihane <alanh@fairlite.demon.co.uk> |
| 7 |
*/ |
| 8 |
|
| 9 |
/* |
| 10 |
* Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved. |
| 11 |
* |
| 12 |
* This is free software; you can redistribute it and/or modify |
| 13 |
* it under the terms of the GNU General Public License as published by |
| 14 |
* the Free Software Foundation; either version 2 of the License, or |
| 15 |
* (at your option) any later version. |
| 16 |
* |
| 17 |
* This software is distributed in the hope that it will be useful, |
| 18 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 |
* GNU General Public License for more details. |
| 21 |
* |
| 22 |
* You should have received a copy of the GNU General Public License |
| 23 |
* along with this software; if not, write to the Free Software |
| 24 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
| 25 |
* USA. |
| 26 |
*/ |
| 27 |
|
| 28 |
/* $XConsortium: misprite.c,v 5.47 94/04/17 20:27:53 dpw Exp $ */ |
| 29 |
|
| 30 |
/* |
| 31 |
|
| 32 |
Copyright (c) 1989 X Consortium |
| 33 |
|
| 34 |
Permission is hereby granted, free of charge, to any person obtaining a copy |
| 35 |
of this software and associated documentation files (the "Software"), to deal |
| 36 |
in the Software without restriction, including without limitation the rights |
| 37 |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 38 |
copies of the Software, and to permit persons to whom the Software is |
| 39 |
furnished to do so, subject to the following conditions: |
| 40 |
|
| 41 |
The above copyright notice and this permission notice shall be included in |
| 42 |
all copies or substantial portions of the Software. |
| 43 |
|
| 44 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 45 |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 46 |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 47 |
X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
| 48 |
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 49 |
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 50 |
|
| 51 |
Except as contained in this notice, the name of the X Consortium shall not be |
| 52 |
used in advertising or otherwise to promote the sale, use or other dealings |
| 53 |
in this Software without prior written authorization from the X Consortium. |
| 54 |
*/ |
| 55 |
#ifdef HAVE_DIX_CONFIG_H |
| 56 |
#include <dix-config.h> |
| 57 |
#endif |
| 58 |
|
| 59 |
|
| 60 |
#include "rfb.h" |
| 61 |
# include <X11/X.h> |
| 62 |
# include <X11/Xproto.h> |
| 63 |
# include <X11/fonts/font.h> |
| 64 |
# include <X11/fonts/fontstruct.h> |
| 65 |
# include "misc.h" |
| 66 |
# include "pixmapstr.h" |
| 67 |
# include "input.h" |
| 68 |
# include "mi.h" |
| 69 |
# include "cursorstr.h" |
| 70 |
# include "scrnintstr.h" |
| 71 |
# include "colormapst.h" |
| 72 |
# include "windowstr.h" |
| 73 |
# include "gcstruct.h" |
| 74 |
# include "mipointer.h" |
| 75 |
# include "spritest.h" |
| 76 |
# include "dixfontstr.h" |
| 77 |
#ifdef RENDER |
| 78 |
# include "mipict.h" |
| 79 |
#endif |
| 80 |
|
| 81 |
/* |
| 82 |
* screen wrappers |
| 83 |
*/ |
| 84 |
|
| 85 |
static int rfbSpriteScreenIndex; |
| 86 |
static unsigned long rfbSpriteGeneration = 0; |
| 87 |
|
| 88 |
static Bool rfbSpriteCloseScreen(int i, ScreenPtr pScreen); |
| 89 |
static void rfbSpriteGetImage(DrawablePtr pDrawable, int sx, int sy, |
| 90 |
int w, int h, unsigned int format, |
| 91 |
unsigned long planemask, char *pdstLine); |
| 92 |
static void rfbSpriteGetSpans(DrawablePtr pDrawable, int wMax, |
| 93 |
DDXPointPtr ppt, int *pwidth, int nspans, |
| 94 |
char *pdstStart); |
| 95 |
static void rfbSpriteSourceValidate(DrawablePtr pDrawable, int x, int y, |
| 96 |
int width, int height); |
| 97 |
static Bool rfbSpriteCreateGC(GCPtr pGC); |
| 98 |
static void rfbSpriteBlockHandler(int i, pointer blockData, |
| 99 |
pointer pTimeout, |
| 100 |
pointer pReadMask); |
| 101 |
static void rfbSpriteInstallColormap(ColormapPtr pMap); |
| 102 |
static void rfbSpriteStoreColors(ColormapPtr pMap, int ndef, |
| 103 |
xColorItem *pdef); |
| 104 |
|
| 105 |
static void rfbSpritePaintWindowBackground(WindowPtr pWin, |
| 106 |
RegionPtr pRegion, int what); |
| 107 |
static void rfbSpritePaintWindowBorder(WindowPtr pWin, |
| 108 |
RegionPtr pRegion, int what); |
| 109 |
static void rfbSpriteCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, |
| 110 |
RegionPtr pRegion); |
| 111 |
static void rfbSpriteClearToBackground(WindowPtr pWin, int x, int y, |
| 112 |
int w, int h, |
| 113 |
Bool generateExposures); |
| 114 |
|
| 115 |
#ifdef RENDER |
| 116 |
static void rfbSpriteComposite(CARD8 op, |
| 117 |
PicturePtr pSrc, |
| 118 |
PicturePtr pMask, |
| 119 |
PicturePtr pDst, |
| 120 |
INT16 xSrc, |
| 121 |
INT16 ySrc, |
| 122 |
INT16 xMask, |
| 123 |
INT16 yMask, |
| 124 |
INT16 xDst, |
| 125 |
INT16 yDst, |
| 126 |
CARD16 width, |
| 127 |
CARD16 height); |
| 128 |
|
| 129 |
static void rfbSpriteGlyphs(CARD8 op, |
| 130 |
PicturePtr pSrc, |
| 131 |
PicturePtr pDst, |
| 132 |
PictFormatPtr maskFormat, |
| 133 |
INT16 xSrc, |
| 134 |
INT16 ySrc, |
| 135 |
int nlist, |
| 136 |
GlyphListPtr list, |
| 137 |
GlyphPtr *glyphs); |
| 138 |
#endif |
| 139 |
|
| 140 |
static void rfbSpriteSaveDoomedAreas(WindowPtr pWin, |
| 141 |
RegionPtr pObscured, int dx, |
| 142 |
int dy); |
| 143 |
static RegionPtr rfbSpriteRestoreAreas(WindowPtr pWin, RegionPtr pRgnExposed); |
| 144 |
static void rfbSpriteComputeSaved(ScreenPtr pScreen); |
| 145 |
|
| 146 |
#define SCREEN_PROLOGUE(pScreen, field)\ |
| 147 |
((pScreen)->field = \ |
| 148 |
((rfbSpriteScreenPtr) (pScreen)->devPrivates[rfbSpriteScreenIndex].ptr)->field) |
| 149 |
|
| 150 |
#define SCREEN_EPILOGUE(pScreen, field, wrapper)\ |
| 151 |
((pScreen)->field = wrapper) |
| 152 |
|
| 153 |
/* |
| 154 |
* GC func wrappers |
| 155 |
*/ |
| 156 |
|
| 157 |
static int rfbSpriteGCIndex; |
| 158 |
|
| 159 |
static void rfbSpriteValidateGC(GCPtr pGC, unsigned long stateChanges, |
| 160 |
DrawablePtr pDrawable); |
| 161 |
static void rfbSpriteCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst); |
| 162 |
static void rfbSpriteDestroyGC(GCPtr pGC); |
| 163 |
static void rfbSpriteChangeGC(GCPtr pGC, unsigned long mask); |
| 164 |
static void rfbSpriteChangeClip(GCPtr pGC, int type, pointer pvalue, int nrects); |
| 165 |
static void rfbSpriteDestroyClip(GCPtr pGC); |
| 166 |
static void rfbSpriteCopyClip(GCPtr pgcDst, GCPtr pgcSrc); |
| 167 |
|
| 168 |
static GCFuncs rfbSpriteGCFuncs = { |
| 169 |
rfbSpriteValidateGC, |
| 170 |
rfbSpriteChangeGC, |
| 171 |
rfbSpriteCopyGC, |
| 172 |
rfbSpriteDestroyGC, |
| 173 |
rfbSpriteChangeClip, |
| 174 |
rfbSpriteDestroyClip, |
| 175 |
rfbSpriteCopyClip, |
| 176 |
}; |
| 177 |
|
| 178 |
#define GC_FUNC_PROLOGUE(pGC) \ |
| 179 |
rfbSpriteGCPtr pGCPriv = \ |
| 180 |
(rfbSpriteGCPtr) (pGC)->devPrivates[rfbSpriteGCIndex].ptr;\ |
| 181 |
(pGC)->funcs = pGCPriv->wrapFuncs; \ |
| 182 |
if (pGCPriv->wrapOps) \ |
| 183 |
(pGC)->ops = pGCPriv->wrapOps; |
| 184 |
|
| 185 |
#define GC_FUNC_EPILOGUE(pGC) \ |
| 186 |
pGCPriv->wrapFuncs = (pGC)->funcs; \ |
| 187 |
(pGC)->funcs = &rfbSpriteGCFuncs; \ |
| 188 |
if (pGCPriv->wrapOps) \ |
| 189 |
{ \ |
| 190 |
pGCPriv->wrapOps = (pGC)->ops; \ |
| 191 |
(pGC)->ops = &rfbSpriteGCOps; \ |
| 192 |
} |
| 193 |
|
| 194 |
/* |
| 195 |
* GC op wrappers |
| 196 |
*/ |
| 197 |
|
| 198 |
static void rfbSpriteFillSpans(DrawablePtr pDrawable, GCPtr pGC, |
| 199 |
int nInit, DDXPointPtr pptInit, |
| 200 |
int *pwidthInit, int fSorted); |
| 201 |
static void rfbSpriteSetSpans(DrawablePtr pDrawable, GCPtr pGC, |
| 202 |
char *psrc, DDXPointPtr ppt, int *pwidth, |
| 203 |
int nspans, int fSorted); |
| 204 |
static void rfbSpritePutImage(DrawablePtr pDrawable, GCPtr pGC, |
| 205 |
int depth, int x, int y, int w, int h, |
| 206 |
int leftPad, int format, char *pBits); |
| 207 |
static RegionPtr rfbSpriteCopyArea(DrawablePtr pSrc, DrawablePtr pDst, |
| 208 |
GCPtr pGC, int srcx, int srcy, int w, |
| 209 |
int h, int dstx, int dsty); |
| 210 |
static RegionPtr rfbSpriteCopyPlane(DrawablePtr pSrc, DrawablePtr pDst, |
| 211 |
GCPtr pGC, int srcx, int srcy, int w, |
| 212 |
int h, int dstx, int dsty, |
| 213 |
unsigned long plane); |
| 214 |
static void rfbSpritePolyPoint(DrawablePtr pDrawable, GCPtr pGC, |
| 215 |
int mode, int npt, xPoint *pptInit); |
| 216 |
static void rfbSpritePolylines(DrawablePtr pDrawable, GCPtr pGC, |
| 217 |
int mode, int npt, DDXPointPtr pptInit); |
| 218 |
static void rfbSpritePolySegment(DrawablePtr pDrawable, GCPtr pGC, |
| 219 |
int nseg, xSegment *pSegs); |
| 220 |
static void rfbSpritePolyRectangle(DrawablePtr pDrawable, GCPtr pGC, |
| 221 |
int nrects, xRectangle *pRects); |
| 222 |
static void rfbSpritePolyArc(DrawablePtr pDrawable, GCPtr pGC, |
| 223 |
int narcs, xArc *parcs); |
| 224 |
static void rfbSpriteFillPolygon(DrawablePtr pDrawable, GCPtr pGC, |
| 225 |
int shape, int mode, int count, |
| 226 |
DDXPointPtr pPts); |
| 227 |
static void rfbSpritePolyFillRect(DrawablePtr pDrawable, GCPtr pGC, |
| 228 |
int nrectFill, xRectangle *prectInit); |
| 229 |
static void rfbSpritePolyFillArc(DrawablePtr pDrawable, GCPtr pGC, |
| 230 |
int narcs, xArc *parcs); |
| 231 |
static int rfbSpritePolyText8(DrawablePtr pDrawable, GCPtr pGC, |
| 232 |
int x, int y, int count, char *chars); |
| 233 |
static int rfbSpritePolyText16(DrawablePtr pDrawable, GCPtr pGC, |
| 234 |
int x, int y, int count, |
| 235 |
unsigned short *chars); |
| 236 |
static void rfbSpriteImageText8(DrawablePtr pDrawable, GCPtr pGC, |
| 237 |
int x, int y, int count, char *chars); |
| 238 |
static void rfbSpriteImageText16(DrawablePtr pDrawable, GCPtr pGC, |
| 239 |
int x, int y, int count, |
| 240 |
unsigned short *chars); |
| 241 |
static void rfbSpriteImageGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, |
| 242 |
int x, int y, unsigned int nglyph, |
| 243 |
CharInfoPtr *ppci, |
| 244 |
pointer pglyphBase); |
| 245 |
static void rfbSpritePolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, |
| 246 |
int x, int y, unsigned int nglyph, |
| 247 |
CharInfoPtr *ppci, |
| 248 |
pointer pglyphBase); |
| 249 |
static void rfbSpritePushPixels(GCPtr pGC, PixmapPtr pBitMap, |
| 250 |
DrawablePtr pDst, int w, int h, |
| 251 |
int x, int y); |
| 252 |
#ifdef NEED_LINEHELPER |
| 253 |
static void rfbSpriteLineHelper(); |
| 254 |
#endif |
| 255 |
|
| 256 |
static GCOps rfbSpriteGCOps = { |
| 257 |
rfbSpriteFillSpans, rfbSpriteSetSpans, rfbSpritePutImage, |
| 258 |
rfbSpriteCopyArea, rfbSpriteCopyPlane, rfbSpritePolyPoint, |
| 259 |
rfbSpritePolylines, rfbSpritePolySegment, rfbSpritePolyRectangle, |
| 260 |
rfbSpritePolyArc, rfbSpriteFillPolygon, rfbSpritePolyFillRect, |
| 261 |
rfbSpritePolyFillArc, rfbSpritePolyText8, rfbSpritePolyText16, |
| 262 |
rfbSpriteImageText8, rfbSpriteImageText16, rfbSpriteImageGlyphBlt, |
| 263 |
rfbSpritePolyGlyphBlt, rfbSpritePushPixels |
| 264 |
#ifdef NEED_LINEHELPER |
| 265 |
, rfbSpriteLineHelper |
| 266 |
#endif |
| 267 |
}; |
| 268 |
|
| 269 |
/* |
| 270 |
* testing only -- remove cursor for every draw. Eventually, |
| 271 |
* each draw operation will perform a bounding box check against |
| 272 |
* the saved cursor area |
| 273 |
*/ |
| 274 |
|
| 275 |
#define GC_SETUP_CHEAP(pDrawable) \ |
| 276 |
rfbSpriteScreenPtr pScreenPriv = (rfbSpriteScreenPtr) \ |
| 277 |
(pDrawable)->pScreen->devPrivates[rfbSpriteScreenIndex].ptr; \ |
| 278 |
|
| 279 |
#define GC_SETUP(pDrawable, pGC) \ |
| 280 |
GC_SETUP_CHEAP(pDrawable) \ |
| 281 |
rfbSpriteGCPtr pGCPrivate = (rfbSpriteGCPtr) \ |
| 282 |
(pGC)->devPrivates[rfbSpriteGCIndex].ptr; \ |
| 283 |
GCFuncs *oldFuncs = pGC->funcs; |
| 284 |
|
| 285 |
#define GC_SETUP_AND_CHECK(pDrawable, pGC) \ |
| 286 |
GC_SETUP(pDrawable, pGC); \ |
| 287 |
if (GC_CHECK((WindowPtr)pDrawable)) \ |
| 288 |
rfbSpriteRemoveCursor (pDrawable->pScreen); |
| 289 |
|
| 290 |
#define GC_CHECK(pWin) \ |
| 291 |
(pVNC->cursorIsDrawn && \ |
| 292 |
(pScreenPriv->pCacheWin == pWin ? \ |
| 293 |
pScreenPriv->isInCacheWin : ( \ |
| 294 |
(pScreenPriv->pCacheWin = (pWin)) , \ |
| 295 |
(pScreenPriv->isInCacheWin = \ |
| 296 |
(pWin)->drawable.x < pScreenPriv->saved.x2 && \ |
| 297 |
pScreenPriv->saved.x1 < (pWin)->drawable.x + \ |
| 298 |
(int) (pWin)->drawable.width && \ |
| 299 |
(pWin)->drawable.y < pScreenPriv->saved.y2 && \ |
| 300 |
pScreenPriv->saved.y1 < (pWin)->drawable.y + \ |
| 301 |
(int) (pWin)->drawable.height &&\ |
| 302 |
RECT_IN_REGION((pWin)->drawable.pScreen, &(pWin)->borderClip, \ |
| 303 |
&pScreenPriv->saved) != rgnOUT)))) |
| 304 |
|
| 305 |
#define GC_OP_PROLOGUE(pGC) { \ |
| 306 |
(pGC)->funcs = pGCPrivate->wrapFuncs; \ |
| 307 |
(pGC)->ops = pGCPrivate->wrapOps; \ |
| 308 |
} |
| 309 |
|
| 310 |
#define GC_OP_EPILOGUE(pGC) { \ |
| 311 |
pGCPrivate->wrapOps = (pGC)->ops; \ |
| 312 |
(pGC)->funcs = oldFuncs; \ |
| 313 |
(pGC)->ops = &rfbSpriteGCOps; \ |
| 314 |
} |
| 315 |
|
| 316 |
/* |
| 317 |
* pointer-sprite method table |
| 318 |
*/ |
| 319 |
|
| 320 |
static Bool rfbSpriteRealizeCursor (ScreenPtr pScreen, CursorPtr pCursor); |
| 321 |
static Bool rfbSpriteUnrealizeCursor (ScreenPtr pScreen, CursorPtr pCursor); |
| 322 |
static void rfbSpriteSetCursor (ScreenPtr pScreen, CursorPtr pCursor, int x, int y); |
| 323 |
static void rfbSpriteMoveCursor (ScreenPtr pScreen, int x, int y); |
| 324 |
|
| 325 |
miPointerSpriteFuncRec rfbSpritePointerFuncs = { |
| 326 |
rfbSpriteRealizeCursor, |
| 327 |
rfbSpriteUnrealizeCursor, |
| 328 |
rfbSpriteSetCursor, |
| 329 |
rfbSpriteMoveCursor, |
| 330 |
}; |
| 331 |
|
| 332 |
/* |
| 333 |
* other misc functions |
| 334 |
*/ |
| 335 |
|
| 336 |
static Bool rfbDisplayCursor (ScreenPtr pScreen, CursorPtr pCursor); |
| 337 |
|
| 338 |
|
| 339 |
/* |
| 340 |
* rfbSpriteInitialize -- called from device-dependent screen |
| 341 |
* initialization proc after all of the function pointers have |
| 342 |
* been stored in the screen structure. |
| 343 |
*/ |
| 344 |
|
| 345 |
Bool |
| 346 |
rfbSpriteInitialize (pScreen, cursorFuncs, screenFuncs) |
| 347 |
ScreenPtr pScreen; |
| 348 |
rfbSpriteCursorFuncPtr cursorFuncs; |
| 349 |
miPointerScreenFuncPtr screenFuncs; |
| 350 |
{ |
| 351 |
rfbSpriteScreenPtr pPriv; |
| 352 |
VisualPtr pVisual; |
| 353 |
#ifdef RENDER |
| 354 |
PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); |
| 355 |
#endif |
| 356 |
|
| 357 |
if (rfbSpriteGeneration != serverGeneration) |
| 358 |
{ |
| 359 |
rfbSpriteScreenIndex = AllocateScreenPrivateIndex (); |
| 360 |
if (rfbSpriteScreenIndex < 0) |
| 361 |
return FALSE; |
| 362 |
rfbSpriteGeneration = serverGeneration; |
| 363 |
rfbSpriteGCIndex = AllocateGCPrivateIndex (); |
| 364 |
} |
| 365 |
if (!AllocateGCPrivate(pScreen, rfbSpriteGCIndex, sizeof(rfbSpriteGCRec))) |
| 366 |
return FALSE; |
| 367 |
pPriv = (rfbSpriteScreenPtr) xalloc (sizeof (rfbSpriteScreenRec)); |
| 368 |
if (!pPriv) |
| 369 |
return FALSE; |
| 370 |
if (!miPointerInitialize (pScreen, &rfbSpritePointerFuncs, screenFuncs,TRUE)) |
| 371 |
{ |
| 372 |
xfree ((pointer) pPriv); |
| 373 |
return FALSE; |
| 374 |
} |
| 375 |
for (pVisual = pScreen->visuals; |
| 376 |
pVisual->vid != pScreen->rootVisual; |
| 377 |
pVisual++) |
| 378 |
; |
| 379 |
pPriv->pVisual = pVisual; |
| 380 |
pPriv->CloseScreen = pScreen->CloseScreen; |
| 381 |
pPriv->GetImage = pScreen->GetImage; |
| 382 |
pPriv->GetSpans = pScreen->GetSpans; |
| 383 |
pPriv->SourceValidate = pScreen->SourceValidate; |
| 384 |
pPriv->CreateGC = pScreen->CreateGC; |
| 385 |
#if 0 |
| 386 |
pPriv->BlockHandler = pScreen->BlockHandler; |
| 387 |
#endif |
| 388 |
pPriv->InstallColormap = pScreen->InstallColormap; |
| 389 |
pPriv->StoreColors = pScreen->StoreColors; |
| 390 |
pPriv->DisplayCursor = pScreen->DisplayCursor; |
| 391 |
|
| 392 |
pPriv->PaintWindowBackground = pScreen->PaintWindowBackground; |
| 393 |
pPriv->PaintWindowBorder = pScreen->PaintWindowBorder; |
| 394 |
pPriv->CopyWindow = pScreen->CopyWindow; |
| 395 |
pPriv->ClearToBackground = pScreen->ClearToBackground; |
| 396 |
|
| 397 |
pPriv->SaveDoomedAreas = pScreen->SaveDoomedAreas; |
| 398 |
pPriv->RestoreAreas = pScreen->RestoreAreas; |
| 399 |
#ifdef RENDER |
| 400 |
if (ps) |
| 401 |
{ |
| 402 |
pPriv->Composite = ps->Composite; |
| 403 |
pPriv->Glyphs = ps->Glyphs; |
| 404 |
} |
| 405 |
#endif |
| 406 |
|
| 407 |
pPriv->pCursor = NULL; |
| 408 |
pPriv->x = 0; |
| 409 |
pPriv->y = 0; |
| 410 |
pPriv->shouldBeUp = FALSE; |
| 411 |
pPriv->pCacheWin = NullWindow; |
| 412 |
pPriv->isInCacheWin = FALSE; |
| 413 |
pPriv->checkPixels = TRUE; |
| 414 |
pPriv->pInstalledMap = NULL; |
| 415 |
pPriv->pColormap = NULL; |
| 416 |
pPriv->funcs = cursorFuncs; |
| 417 |
pPriv->colors[SOURCE_COLOR].red = 0; |
| 418 |
pPriv->colors[SOURCE_COLOR].green = 0; |
| 419 |
pPriv->colors[SOURCE_COLOR].blue = 0; |
| 420 |
pPriv->colors[MASK_COLOR].red = 0; |
| 421 |
pPriv->colors[MASK_COLOR].green = 0; |
| 422 |
pPriv->colors[MASK_COLOR].blue = 0; |
| 423 |
pScreen->devPrivates[rfbSpriteScreenIndex].ptr = (pointer) pPriv; |
| 424 |
pScreen->CloseScreen = rfbSpriteCloseScreen; |
| 425 |
pScreen->GetImage = rfbSpriteGetImage; |
| 426 |
pScreen->GetSpans = rfbSpriteGetSpans; |
| 427 |
pScreen->SourceValidate = rfbSpriteSourceValidate; |
| 428 |
pScreen->CreateGC = rfbSpriteCreateGC; |
| 429 |
#if 0 |
| 430 |
pScreen->BlockHandler = rfbSpriteBlockHandler; |
| 431 |
#endif |
| 432 |
pScreen->InstallColormap = rfbSpriteInstallColormap; |
| 433 |
pScreen->StoreColors = rfbSpriteStoreColors; |
| 434 |
|
| 435 |
pScreen->PaintWindowBackground = rfbSpritePaintWindowBackground; |
| 436 |
pScreen->PaintWindowBorder = rfbSpritePaintWindowBorder; |
| 437 |
pScreen->CopyWindow = rfbSpriteCopyWindow; |
| 438 |
pScreen->ClearToBackground = rfbSpriteClearToBackground; |
| 439 |
|
| 440 |
pScreen->SaveDoomedAreas = rfbSpriteSaveDoomedAreas; |
| 441 |
pScreen->RestoreAreas = rfbSpriteRestoreAreas; |
| 442 |
|
| 443 |
pScreen->DisplayCursor = rfbDisplayCursor; |
| 444 |
#ifdef RENDER |
| 445 |
if (ps) |
| 446 |
{ |
| 447 |
ps->Composite = rfbSpriteComposite; |
| 448 |
ps->Glyphs = rfbSpriteGlyphs; |
| 449 |
} |
| 450 |
#endif |
| 451 |
|
| 452 |
return TRUE; |
| 453 |
} |
| 454 |
|
| 455 |
/* |
| 456 |
* Screen wrappers |
| 457 |
*/ |
| 458 |
|
| 459 |
/* |
| 460 |
* CloseScreen wrapper -- unwrap everything, free the private data |
| 461 |
* and call the wrapped function |
| 462 |
*/ |
| 463 |
|
| 464 |
static Bool |
| 465 |
rfbSpriteCloseScreen (i, pScreen) |
| 466 |
ScreenPtr pScreen; |
| 467 |
{ |
| 468 |
rfbSpriteScreenPtr pScreenPriv; |
| 469 |
#ifdef RENDER |
| 470 |
PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); |
| 471 |
#endif |
| 472 |
|
| 473 |
pScreenPriv = (rfbSpriteScreenPtr) pScreen->devPrivates[rfbSpriteScreenIndex].ptr; |
| 474 |
|
| 475 |
pScreen->CloseScreen = pScreenPriv->CloseScreen; |
| 476 |
pScreen->GetImage = pScreenPriv->GetImage; |
| 477 |
pScreen->GetSpans = pScreenPriv->GetSpans; |
| 478 |
pScreen->SourceValidate = pScreenPriv->SourceValidate; |
| 479 |
pScreen->CreateGC = pScreenPriv->CreateGC; |
| 480 |
#if 0 |
| 481 |
pScreen->BlockHandler = pScreenPriv->BlockHandler; |
| 482 |
#endif |
| 483 |
pScreen->InstallColormap = pScreenPriv->InstallColormap; |
| 484 |
pScreen->StoreColors = pScreenPriv->StoreColors; |
| 485 |
|
| 486 |
pScreen->PaintWindowBackground = pScreenPriv->PaintWindowBackground; |
| 487 |
pScreen->PaintWindowBorder = pScreenPriv->PaintWindowBorder; |
| 488 |
pScreen->CopyWindow = pScreenPriv->CopyWindow; |
| 489 |
pScreen->ClearToBackground = pScreenPriv->ClearToBackground; |
| 490 |
|
| 491 |
pScreen->SaveDoomedAreas = pScreenPriv->SaveDoomedAreas; |
| 492 |
pScreen->RestoreAreas = pScreenPriv->RestoreAreas; |
| 493 |
#ifdef RENDER |
| 494 |
if (ps) |
| 495 |
{ |
| 496 |
ps->Composite = pScreenPriv->Composite; |
| 497 |
ps->Glyphs = pScreenPriv->Glyphs; |
| 498 |
} |
| 499 |
#endif |
| 500 |
|
| 501 |
xfree ((pointer) pScreenPriv); |
| 502 |
|
| 503 |
return (*pScreen->CloseScreen) (i, pScreen); |
| 504 |
} |
| 505 |
|
| 506 |
static void |
| 507 |
rfbSpriteGetImage (pDrawable, sx, sy, w, h, format, planemask, pdstLine) |
| 508 |
DrawablePtr pDrawable; |
| 509 |
int sx, sy, w, h; |
| 510 |
unsigned int format; |
| 511 |
unsigned long planemask; |
| 512 |
char *pdstLine; |
| 513 |
{ |
| 514 |
ScreenPtr pScreen = pDrawable->pScreen; |
| 515 |
rfbSpriteScreenPtr pScreenPriv; |
| 516 |
VNCSCREENPTR(pScreen); |
| 517 |
|
| 518 |
SCREEN_PROLOGUE (pScreen, GetImage); |
| 519 |
|
| 520 |
pScreenPriv = (rfbSpriteScreenPtr) pScreen->devPrivates[rfbSpriteScreenIndex].ptr; |
| 521 |
|
| 522 |
if (pDrawable->type == DRAWABLE_WINDOW && |
| 523 |
pVNC->cursorIsDrawn && |
| 524 |
ORG_OVERLAP(&pScreenPriv->saved,pDrawable->x,pDrawable->y, sx, sy, w, h)) |
| 525 |
{ |
| 526 |
rfbSpriteRemoveCursor (pScreen); |
| 527 |
} |
| 528 |
|
| 529 |
(*pScreen->GetImage) (pDrawable, sx, sy, w, h, |
| 530 |
format, planemask, pdstLine); |
| 531 |
|
| 532 |
SCREEN_EPILOGUE (pScreen, GetImage, rfbSpriteGetImage); |
| 533 |
} |
| 534 |
|
| 535 |
static void |
| 536 |
rfbSpriteGetSpans (pDrawable, wMax, ppt, pwidth, nspans, pdstStart) |
| 537 |
DrawablePtr pDrawable; |
| 538 |
int wMax; |
| 539 |
DDXPointPtr ppt; |
| 540 |
int *pwidth; |
| 541 |
int nspans; |
| 542 |
char *pdstStart; |
| 543 |
{ |
| 544 |
ScreenPtr pScreen = pDrawable->pScreen; |
| 545 |
rfbSpriteScreenPtr pScreenPriv; |
| 546 |
VNCSCREENPTR(pScreen); |
| 547 |
|
| 548 |
SCREEN_PROLOGUE (pScreen, GetSpans); |
| 549 |
|
| 550 |
pScreenPriv = (rfbSpriteScreenPtr) pScreen->devPrivates[rfbSpriteScreenIndex].ptr; |
| 551 |
|
| 552 |
if (pDrawable->type == DRAWABLE_WINDOW && pVNC->cursorIsDrawn) |
| 553 |
{ |
| 554 |
register DDXPointPtr pts; |
| 555 |
register int *widths; |
| 556 |
register int nPts; |
| 557 |
register int xorg, |
| 558 |
yorg; |
| 559 |
|
| 560 |
xorg = pDrawable->x; |
| 561 |
yorg = pDrawable->y; |
| 562 |
|
| 563 |
for (pts = ppt, widths = pwidth, nPts = nspans; |
| 564 |
nPts--; |
| 565 |
pts++, widths++) |
| 566 |
{ |
| 567 |
if (SPN_OVERLAP(&pScreenPriv->saved,pts->y+yorg, |
| 568 |
pts->x+xorg,*widths)) |
| 569 |
{ |
| 570 |
rfbSpriteRemoveCursor (pScreen); |
| 571 |
break; |
| 572 |
} |
| 573 |
} |
| 574 |
} |
| 575 |
|
| 576 |
(*pScreen->GetSpans) (pDrawable, wMax, ppt, pwidth, nspans, pdstStart); |
| 577 |
|
| 578 |
SCREEN_EPILOGUE (pScreen, GetSpans, rfbSpriteGetSpans); |
| 579 |
} |
| 580 |
|
| 581 |
static void |
| 582 |
rfbSpriteSourceValidate (pDrawable, x, y, width, height) |
| 583 |
DrawablePtr pDrawable; |
| 584 |
int x, y, width, height; |
| 585 |
{ |
| 586 |
ScreenPtr pScreen = pDrawable->pScreen; |
| 587 |
rfbSpriteScreenPtr pScreenPriv; |
| 588 |
VNCSCREENPTR(pScreen); |
| 589 |
|
| 590 |
SCREEN_PROLOGUE (pScreen, SourceValidate); |
| 591 |
|
| 592 |
pScreenPriv = (rfbSpriteScreenPtr) pScreen->devPrivates[rfbSpriteScreenIndex].ptr; |
| 593 |
|
| 594 |
if (pDrawable->type == DRAWABLE_WINDOW && pVNC->cursorIsDrawn && |
| 595 |
ORG_OVERLAP(&pScreenPriv->saved, pDrawable->x, pDrawable->y, |
| 596 |
x, y, width, height)) |
| 597 |
{ |
| 598 |
rfbSpriteRemoveCursor (pScreen); |
| 599 |
} |
| 600 |
|
| 601 |
if (pScreen->SourceValidate) |
| 602 |
(*pScreen->SourceValidate) (pDrawable, x, y, width, height); |
| 603 |
|
| 604 |
SCREEN_EPILOGUE (pScreen, SourceValidate, rfbSpriteSourceValidate); |
| 605 |
} |
| 606 |
|
| 607 |
static Bool |
| 608 |
rfbSpriteCreateGC (pGC) |
| 609 |
GCPtr pGC; |
| 610 |
{ |
| 611 |
ScreenPtr pScreen = pGC->pScreen; |
| 612 |
Bool ret; |
| 613 |
rfbSpriteGCPtr pPriv; |
| 614 |
|
| 615 |
SCREEN_PROLOGUE (pScreen, CreateGC); |
| 616 |
|
| 617 |
pPriv = (rfbSpriteGCPtr)pGC->devPrivates[rfbSpriteGCIndex].ptr; |
| 618 |
|
| 619 |
ret = (*pScreen->CreateGC) (pGC); |
| 620 |
|
| 621 |
pPriv->wrapOps = NULL; |
| 622 |
pPriv->wrapFuncs = pGC->funcs; |
| 623 |
pGC->funcs = &rfbSpriteGCFuncs; |
| 624 |
|
| 625 |
SCREEN_EPILOGUE (pScreen, CreateGC, rfbSpriteCreateGC); |
| 626 |
|
| 627 |
return ret; |
| 628 |
} |
| 629 |
|
| 630 |
static void |
| 631 |
rfbSpriteBlockHandler (i, blockData, pTimeout, pReadmask) |
| 632 |
int i; |
| 633 |
pointer blockData; |
| 634 |
pointer pTimeout; |
| 635 |
pointer pReadmask; |
| 636 |
{ |
| 637 |
ScreenPtr pScreen = screenInfo.screens[i]; |
| 638 |
rfbSpriteScreenPtr pPriv; |
| 639 |
VNCSCREENPTR(pScreen); |
| 640 |
|
| 641 |
pPriv = (rfbSpriteScreenPtr) pScreen->devPrivates[rfbSpriteScreenIndex].ptr; |
| 642 |
|
| 643 |
SCREEN_PROLOGUE(pScreen, BlockHandler); |
| 644 |
|
| 645 |
(*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask); |
| 646 |
|
| 647 |
SCREEN_EPILOGUE(pScreen, BlockHandler, rfbSpriteBlockHandler); |
| 648 |
|
| 649 |
if (!pVNC->cursorIsDrawn && pPriv->shouldBeUp) |
| 650 |
rfbSpriteRestoreCursor (pScreen); |
| 651 |
} |
| 652 |
|
| 653 |
static void |
| 654 |
rfbSpriteInstallColormap (pMap) |
| 655 |
ColormapPtr pMap; |
| 656 |
{ |
| 657 |
ScreenPtr pScreen = pMap->pScreen; |
| 658 |
rfbSpriteScreenPtr pPriv; |
| 659 |
VNCSCREENPTR(pScreen); |
| 660 |
|
| 661 |
pPriv = (rfbSpriteScreenPtr) pScreen->devPrivates[rfbSpriteScreenIndex].ptr; |
| 662 |
|
| 663 |
SCREEN_PROLOGUE(pScreen, InstallColormap); |
| 664 |
|
| 665 |
(*pScreen->InstallColormap) (pMap); |
| 666 |
|
| 667 |
SCREEN_EPILOGUE(pScreen, InstallColormap, rfbSpriteInstallColormap); |
| 668 |
|
| 669 |
pPriv->pInstalledMap = pMap; |
| 670 |
if (pPriv->pColormap != pMap) |
| 671 |
{ |
| 672 |
pPriv->checkPixels = TRUE; |
| 673 |
if (pVNC->cursorIsDrawn) |
| 674 |
rfbSpriteRemoveCursor (pScreen); |
| 675 |
} |
| 676 |
} |
| 677 |
|
| 678 |
static void |
| 679 |
rfbSpriteStoreColors (pMap, ndef, pdef) |
| 680 |
ColormapPtr pMap; |
| 681 |
int ndef; |
| 682 |
xColorItem *pdef; |
| 683 |
{ |
| 684 |
ScreenPtr pScreen = pMap->pScreen; |
| 685 |
rfbSpriteScreenPtr pPriv; |
| 686 |
int i; |
| 687 |
int updated; |
| 688 |
VisualPtr pVisual; |
| 689 |
VNCSCREENPTR(pScreen); |
| 690 |
|
| 691 |
pPriv = (rfbSpriteScreenPtr) pScreen->devPrivates[rfbSpriteScreenIndex].ptr; |
| 692 |
|
| 693 |
SCREEN_PROLOGUE(pScreen, StoreColors); |
| 694 |
|
| 695 |
(*pScreen->StoreColors) (pMap, ndef, pdef); |
| 696 |
|
| 697 |
SCREEN_EPILOGUE(pScreen, StoreColors, rfbSpriteStoreColors); |
| 698 |
|
| 699 |
if (pPriv->pColormap == pMap) |
| 700 |
{ |
| 701 |
updated = 0; |
| 702 |
pVisual = pMap->pVisual; |
| 703 |
if (pVisual->class == DirectColor) |
| 704 |
{ |
| 705 |
/* Direct color - match on any of the subfields */ |
| 706 |
|
| 707 |
#define MaskMatch(a,b,mask) ((a) & ((pVisual->mask) == (b)) & (pVisual->mask)) |
| 708 |
|
| 709 |
#define UpdateDAC(plane,dac,mask) {\ |
| 710 |
if (MaskMatch (pPriv->colors[plane].pixel,pdef[i].pixel,mask)) {\ |
| 711 |
pPriv->colors[plane].dac = pdef[i].dac; \ |
| 712 |
updated = 1; \ |
| 713 |
} \ |
| 714 |
} |
| 715 |
|
| 716 |
#define CheckDirect(plane) \ |
| 717 |
UpdateDAC(plane,red,redMask) \ |
| 718 |
UpdateDAC(plane,green,greenMask) \ |
| 719 |
UpdateDAC(plane,blue,blueMask) |
| 720 |
|
| 721 |
for (i = 0; i < ndef; i++) |
| 722 |
{ |
| 723 |
CheckDirect (SOURCE_COLOR) |
| 724 |
CheckDirect (MASK_COLOR) |
| 725 |
} |
| 726 |
} |
| 727 |
else |
| 728 |
{ |
| 729 |
/* PseudoColor/GrayScale - match on exact pixel */ |
| 730 |
for (i = 0; i < ndef; i++) |
| 731 |
{ |
| 732 |
if (pdef[i].pixel == pPriv->colors[SOURCE_COLOR].pixel) |
| 733 |
{ |
| 734 |
pPriv->colors[SOURCE_COLOR] = pdef[i]; |
| 735 |
if (++updated == 2) |
| 736 |
break; |
| 737 |
} |
| 738 |
if (pdef[i].pixel == pPriv->colors[MASK_COLOR].pixel) |
| 739 |
{ |
| 740 |
pPriv->colors[MASK_COLOR] = pdef[i]; |
| 741 |
if (++updated == 2) |
| 742 |
break; |
| 743 |
} |
| 744 |
} |
| 745 |
} |
| 746 |
if (updated) |
| 747 |
{ |
| 748 |
pPriv->checkPixels = TRUE; |
| 749 |
if (pVNC->cursorIsDrawn) |
| 750 |
rfbSpriteRemoveCursor (pScreen); |
| 751 |
} |
| 752 |
} |
| 753 |
} |
| 754 |
|
| 755 |
static void |
| 756 |
rfbSpriteFindColors (ScreenPtr pScreen) |
| 757 |
{ |
| 758 |
rfbSpriteScreenPtr pScreenPriv = (rfbSpriteScreenPtr) |
| 759 |
pScreen->devPrivates[rfbSpriteScreenIndex].ptr; |
| 760 |
CursorPtr pCursor; |
| 761 |
xColorItem *sourceColor, *maskColor; |
| 762 |
|
| 763 |
pCursor = pScreenPriv->pCursor; |
| 764 |
sourceColor = &pScreenPriv->colors[SOURCE_COLOR]; |
| 765 |
maskColor = &pScreenPriv->colors[MASK_COLOR]; |
| 766 |
if (pScreenPriv->pColormap != pScreenPriv->pInstalledMap || |
| 767 |
!(pCursor->foreRed == sourceColor->red && |
| 768 |
pCursor->foreGreen == sourceColor->green && |
| 769 |
pCursor->foreBlue == sourceColor->blue && |
| 770 |
pCursor->backRed == maskColor->red && |
| 771 |
pCursor->backGreen == maskColor->green && |
| 772 |
pCursor->backBlue == maskColor->blue)) |
| 773 |
{ |
| 774 |
pScreenPriv->pColormap = pScreenPriv->pInstalledMap; |
| 775 |
sourceColor->red = pCursor->foreRed; |
| 776 |
sourceColor->green = pCursor->foreGreen; |
| 777 |
sourceColor->blue = pCursor->foreBlue; |
| 778 |
FakeAllocColor (pScreenPriv->pColormap, sourceColor); |
| 779 |
maskColor->red = pCursor->backRed; |
| 780 |
maskColor->green = pCursor->backGreen; |
| 781 |
maskColor->blue = pCursor->backBlue; |
| 782 |
FakeAllocColor (pScreenPriv->pColormap, maskColor); |
| 783 |
/* "free" the pixels right away, don't let this confuse you */ |
| 784 |
FakeFreeColor(pScreenPriv->pColormap, sourceColor->pixel); |
| 785 |
FakeFreeColor(pScreenPriv->pColormap, maskColor->pixel); |
| 786 |
} |
| 787 |
pScreenPriv->checkPixels = FALSE; |
| 788 |
} |
| 789 |
|
| 790 |
/* |
| 791 |
* BackingStore wrappers |
| 792 |
*/ |
| 793 |
|
| 794 |
static void |
| 795 |
rfbSpriteSaveDoomedAreas (pWin, pObscured, dx, dy) |
| 796 |
WindowPtr pWin; |
| 797 |
RegionPtr pObscured; |
| 798 |
int dx, dy; |
| 799 |
{ |
| 800 |
ScreenPtr pScreen = pWin->drawable.pScreen; |
| 801 |
rfbSpriteScreenPtr pScreenPriv; |
| 802 |
BoxRec cursorBox; |
| 803 |
VNCSCREENPTR(pScreen); |
| 804 |
|
| 805 |
SCREEN_PROLOGUE (pScreen, SaveDoomedAreas); |
| 806 |
|
| 807 |
pScreenPriv = (rfbSpriteScreenPtr) pScreen->devPrivates[rfbSpriteScreenIndex].ptr; |
| 808 |
if (pVNC->cursorIsDrawn) |
| 809 |
{ |
| 810 |
cursorBox = pScreenPriv->saved; |
| 811 |
|
| 812 |
if (dx || dy) |
| 813 |
{ |
| 814 |
cursorBox.x1 += dx; |
| 815 |
cursorBox.y1 += dy; |
| 816 |
cursorBox.x2 += dx; |
| 817 |
cursorBox.y2 += dy; |
| 818 |
} |
| 819 |
if (RECT_IN_REGION( pScreen, pObscured, &cursorBox) != rgnOUT) |
| 820 |
rfbSpriteRemoveCursor (pScreen); |
| 821 |
} |
| 822 |
|
| 823 |
(*pScreen->SaveDoomedAreas) (pWin, pObscured, dx, dy); |
| 824 |
|
| 825 |
SCREEN_EPILOGUE (pScreen, SaveDoomedAreas, rfbSpriteSaveDoomedAreas); |
| 826 |
} |
| 827 |
|
| 828 |
static RegionPtr |
| 829 |
rfbSpriteRestoreAreas (pWin, prgnExposed) |
| 830 |
WindowPtr pWin; |
| 831 |
RegionPtr prgnExposed; |
| 832 |
{ |
| 833 |
ScreenPtr pScreen = pWin->drawable.pScreen; |
| 834 |
rfbSpriteScreenPtr pScreenPriv; |
| 835 |
RegionPtr result; |
| 836 |
VNCSCREENPTR(pScreen); |
| 837 |
|
| 838 |
SCREEN_PROLOGUE (pScreen, RestoreAreas); |
| 839 |
|
| 840 |
pScreenPriv = (rfbSpriteScreenPtr) pScreen->devPrivates[rfbSpriteScreenIndex].ptr; |
| 841 |
if (pVNC->cursorIsDrawn) |
| 842 |
{ |
| 843 |
if (RECT_IN_REGION( pScreen, prgnExposed, &pScreenPriv->saved) != rgnOUT) |
| 844 |
rfbSpriteRemoveCursor (pScreen); |
| 845 |
} |
| 846 |
|
| 847 |
result = (*pScreen->RestoreAreas) (pWin, prgnExposed); |
| 848 |
|
| 849 |
SCREEN_EPILOGUE (pScreen, RestoreAreas, rfbSpriteRestoreAreas); |
| 850 |
|
| 851 |
return result; |
| 852 |
} |
| 853 |
|
| 854 |
/* |
| 855 |
* Window wrappers |
| 856 |
*/ |
| 857 |
|
| 858 |
static void |
| 859 |
rfbSpritePaintWindowBackground (pWin, pRegion, what) |
| 860 |
WindowPtr pWin; |
| 861 |
RegionPtr pRegion; |
| 862 |
int what; |
| 863 |
{ |
| 864 |
ScreenPtr pScreen = pWin->drawable.pScreen; |
| 865 |
rfbSpriteScreenPtr pScreenPriv; |
| 866 |
VNCSCREENPTR(pScreen); |
| 867 |
|
| 868 |
SCREEN_PROLOGUE (pScreen, PaintWindowBackground); |
| 869 |
|
| 870 |
pScreenPriv = (rfbSpriteScreenPtr) pScreen->devPrivates[rfbSpriteScreenIndex].ptr; |
| 871 |
if (pVNC->cursorIsDrawn) |
| 872 |
{ |
| 873 |
/* |
| 874 |
* If the cursor is on the same screen as the window, check the |
| 875 |
* region to paint for the cursor and remove it as necessary |
| 876 |
*/ |
| 877 |
if (RECT_IN_REGION( pScreen, pRegion, &pScreenPriv->saved) != rgnOUT) |
| 878 |
rfbSpriteRemoveCursor (pScreen); |
| 879 |
} |
| 880 |
|
| 881 |
(*pScreen->PaintWindowBackground) (pWin, pRegion, what); |
| 882 |
|
| 883 |
SCREEN_EPILOGUE (pScreen, PaintWindowBackground, rfbSpritePaintWindowBackground); |
| 884 |
} |
| 885 |
|
| 886 |
static void |
| 887 |
rfbSpritePaintWindowBorder (pWin, pRegion, what) |
| 888 |
WindowPtr pWin; |
| 889 |
RegionPtr pRegion; |
| 890 |
int what; |
| 891 |
{ |
| 892 |
ScreenPtr pScreen = pWin->drawable.pScreen; |
| 893 |
rfbSpriteScreenPtr pScreenPriv; |
| 894 |
VNCSCREENPTR(pScreen); |
| 895 |
|
| 896 |
SCREEN_PROLOGUE (pScreen, PaintWindowBorder); |
| 897 |
|
| 898 |
pScreenPriv = (rfbSpriteScreenPtr) pScreen->devPrivates[rfbSpriteScreenIndex].ptr; |
| 899 |
if (pVNC->cursorIsDrawn) |
| 900 |
{ |
| 901 |
/* |
| 902 |
* If the cursor is on the same screen as the window, check the |
| 903 |
* region to paint for the cursor and remove it as necessary |
| 904 |
*/ |
| 905 |
if (RECT_IN_REGION( pScreen, pRegion, &pScreenPriv->saved) != rgnOUT) |
| 906 |
rfbSpriteRemoveCursor (pScreen); |
| 907 |
} |
| 908 |
|
| 909 |
(*pScreen->PaintWindowBorder) (pWin, pRegion, what); |
| 910 |
|
| 911 |
SCREEN_EPILOGUE (pScreen, PaintWindowBorder, rfbSpritePaintWindowBorder); |
| 912 |
} |
| 913 |
|
| 914 |
static void |
| 915 |
rfbSpriteCopyWindow (pWin, ptOldOrg, pRegion) |
| 916 |
WindowPtr pWin; |
| 917 |
DDXPointRec ptOldOrg; |
| 918 |
RegionPtr pRegion; |
| 919 |
{ |
| 920 |
ScreenPtr pScreen = pWin->drawable.pScreen; |
| 921 |
rfbSpriteScreenPtr pScreenPriv; |
| 922 |
BoxRec cursorBox; |
| 923 |
int dx, dy; |
| 924 |
VNCSCREENPTR(pScreen); |
| 925 |
|
| 926 |
SCREEN_PROLOGUE (pScreen, CopyWindow); |
| 927 |
|
| 928 |
pScreenPriv = (rfbSpriteScreenPtr) pScreen->devPrivates[rfbSpriteScreenIndex].ptr; |
| 929 |
if (pVNC->cursorIsDrawn) |
| 930 |
{ |
| 931 |
/* |
| 932 |
* check both the source and the destination areas. The given |
| 933 |
* region is source relative, so offset the cursor box by |
| 934 |
* the delta position |
| 935 |
*/ |
| 936 |
cursorBox = pScreenPriv->saved; |
| 937 |
dx = pWin->drawable.x - ptOldOrg.x; |
| 938 |
dy = pWin->drawable.y - ptOldOrg.y; |
| 939 |
cursorBox.x1 -= dx; |
| 940 |
cursorBox.x2 -= dx; |
| 941 |
cursorBox.y1 -= dy; |
| 942 |
cursorBox.y2 -= dy; |
| 943 |
if (RECT_IN_REGION( pScreen, pRegion, &pScreenPriv->saved) != rgnOUT || |
| 944 |
RECT_IN_REGION( pScreen, pRegion, &cursorBox) != rgnOUT) |
| 945 |
rfbSpriteRemoveCursor (pScreen); |
| 946 |
} |
| 947 |
|
| 948 |
(*pScreen->CopyWindow) (pWin, ptOldOrg, pRegion); |
| 949 |
|
| 950 |
SCREEN_EPILOGUE (pScreen, CopyWindow, rfbSpriteCopyWindow); |
| 951 |
} |
| 952 |
|
| 953 |
static void |
| 954 |
rfbSpriteClearToBackground (pWin, x, y, w, h, generateExposures) |
| 955 |
WindowPtr pWin; |
| 956 |
short x,y; |
| 957 |
unsigned short w,h; |
| 958 |
Bool generateExposures; |
| 959 |
{ |
| 960 |
ScreenPtr pScreen = pWin->drawable.pScreen; |
| 961 |
rfbSpriteScreenPtr pScreenPriv; |
| 962 |
int realw, realh; |
| 963 |
VNCSCREENPTR(pScreen); |
| 964 |
|
| 965 |
SCREEN_PROLOGUE (pScreen, ClearToBackground); |
| 966 |
|
| 967 |
pScreenPriv = (rfbSpriteScreenPtr) pScreen->devPrivates[rfbSpriteScreenIndex].ptr; |
| 968 |
if (GC_CHECK(pWin)) |
| 969 |
{ |
| 970 |
if (!(realw = w)) |
| 971 |
realw = (int) pWin->drawable.width - x; |
| 972 |
if (!(realh = h)) |
| 973 |
realh = (int) pWin->drawable.height - y; |
| 974 |
if (ORG_OVERLAP(&pScreenPriv->saved, pWin->drawable.x, pWin->drawable.y, |
| 975 |
x, y, realw, realh)) |
| 976 |
{ |
| 977 |
rfbSpriteRemoveCursor (pScreen); |
| 978 |
} |
| 979 |
} |
| 980 |
|
| 981 |
(*pScreen->ClearToBackground) (pWin, x, y, w, h, generateExposures); |
| 982 |
|
| 983 |
SCREEN_EPILOGUE (pScreen, ClearToBackground, rfbSpriteClearToBackground); |
| 984 |
} |
| 985 |
|
| 986 |
/* |
| 987 |
* GC Func wrappers |
| 988 |
*/ |
| 989 |
|
| 990 |
static void |
| 991 |
rfbSpriteValidateGC (pGC, changes, pDrawable) |
| 992 |
GCPtr pGC; |
| 993 |
unsigned long changes; |
| 994 |
DrawablePtr pDrawable; |
| 995 |
{ |
| 996 |
GC_FUNC_PROLOGUE (pGC); |
| 997 |
|
| 998 |
(*pGC->funcs->ValidateGC) (pGC, changes, pDrawable); |
| 999 |
|
| 1000 |
pGCPriv->wrapOps = NULL; |
| 1001 |
if (pDrawable->type == DRAWABLE_WINDOW && ((WindowPtr) pDrawable)->viewable) |
| 1002 |
{ |
| 1003 |
WindowPtr pWin; |
| 1004 |
RegionPtr pRegion; |
| 1005 |
|
| 1006 |
pWin = (WindowPtr) pDrawable; |
| 1007 |
pRegion = &pWin->clipList; |
| 1008 |
if (pGC->subWindowMode == IncludeInferiors) |
| 1009 |
pRegion = &pWin->borderClip; |
| 1010 |
if (REGION_NOTEMPTY(pDrawable->pScreen, pRegion)) |
| 1011 |
pGCPriv->wrapOps = pGC->ops; |
| 1012 |
} |
| 1013 |
|
| 1014 |
GC_FUNC_EPILOGUE (pGC); |
| 1015 |
} |
| 1016 |
|
| 1017 |
static void |
| 1018 |
rfbSpriteChangeGC (pGC, mask) |
| 1019 |
GCPtr pGC; |
| 1020 |
unsigned long mask; |
| 1021 |
{ |
| 1022 |
GC_FUNC_PROLOGUE (pGC); |
| 1023 |
|
| 1024 |
(*pGC->funcs->ChangeGC) (pGC, mask); |
| 1025 |
|
| 1026 |
GC_FUNC_EPILOGUE (pGC); |
| 1027 |
} |
| 1028 |
|
| 1029 |
static void |
| 1030 |
rfbSpriteCopyGC (pGCSrc, mask, pGCDst) |
| 1031 |
GCPtr pGCSrc, pGCDst; |
| 1032 |
unsigned long mask; |
| 1033 |
{ |
| 1034 |
GC_FUNC_PROLOGUE (pGCDst); |
| 1035 |
|
| 1036 |
(*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst); |
| 1037 |
|
| 1038 |
GC_FUNC_EPILOGUE (pGCDst); |
| 1039 |
} |
| 1040 |
|
| 1041 |
static void |
| 1042 |
rfbSpriteDestroyGC (pGC) |
| 1043 |
GCPtr pGC; |
| 1044 |
{ |
| 1045 |
GC_FUNC_PROLOGUE (pGC); |
| 1046 |
|
| 1047 |
(*pGC->funcs->DestroyGC) (pGC); |
| 1048 |
|
| 1049 |
GC_FUNC_EPILOGUE (pGC); |
| 1050 |
} |
| 1051 |
|
| 1052 |
static void |
| 1053 |
rfbSpriteChangeClip (pGC, type, pvalue, nrects) |
| 1054 |
GCPtr pGC; |
| 1055 |
int type; |
| 1056 |
pointer pvalue; |
| 1057 |
int nrects; |
| 1058 |
{ |
| 1059 |
GC_FUNC_PROLOGUE (pGC); |
| 1060 |
|
| 1061 |
(*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects); |
| 1062 |
|
| 1063 |
GC_FUNC_EPILOGUE (pGC); |
| 1064 |
} |
| 1065 |
|
| 1066 |
static void |
| 1067 |
rfbSpriteCopyClip(pgcDst, pgcSrc) |
| 1068 |
GCPtr pgcDst, pgcSrc; |
| 1069 |
{ |
| 1070 |
GC_FUNC_PROLOGUE (pgcDst); |
| 1071 |
|
| 1072 |
(* pgcDst->funcs->CopyClip)(pgcDst, pgcSrc); |
| 1073 |
|
| 1074 |
GC_FUNC_EPILOGUE (pgcDst); |
| 1075 |
} |
| 1076 |
|
| 1077 |
static void |
| 1078 |
rfbSpriteDestroyClip(pGC) |
| 1079 |
GCPtr pGC; |
| 1080 |
{ |
| 1081 |
GC_FUNC_PROLOGUE (pGC); |
| 1082 |
|
| 1083 |
(* pGC->funcs->DestroyClip)(pGC); |
| 1084 |
|
| 1085 |
GC_FUNC_EPILOGUE (pGC); |
| 1086 |
} |
| 1087 |
|
| 1088 |
/* |
| 1089 |
* GC Op wrappers |
| 1090 |
*/ |
| 1091 |
|
| 1092 |
static void |
| 1093 |
rfbSpriteFillSpans(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted) |
| 1094 |
DrawablePtr pDrawable; |
| 1095 |
GCPtr pGC; |
| 1096 |
int nInit; /* number of spans to fill */ |
| 1097 |
DDXPointPtr pptInit; /* pointer to list of start points */ |
| 1098 |
int *pwidthInit; /* pointer to list of n widths */ |
| 1099 |
int fSorted; |
| 1100 |
{ |
| 1101 |
VNCSCREENPTR(pDrawable->pScreen); |
| 1102 |
|
| 1103 |
GC_SETUP(pDrawable, pGC); |
| 1104 |
|
| 1105 |
if (GC_CHECK((WindowPtr) pDrawable)) |
| 1106 |
{ |
| 1107 |
register DDXPointPtr pts; |
| 1108 |
register int *widths; |
| 1109 |
register int nPts; |
| 1110 |
|
| 1111 |
for (pts = pptInit, widths = pwidthInit, nPts = nInit; |
| 1112 |
nPts--; |
| 1113 |
pts++, widths++) |
| 1114 |
{ |
| 1115 |
if (SPN_OVERLAP(&pScreenPriv->saved,pts->y,pts->x,*widths)) |
| 1116 |
{ |
| 1117 |
rfbSpriteRemoveCursor (pDrawable->pScreen); |
| 1118 |
break; |
| 1119 |
} |
| 1120 |
} |
| 1121 |
} |
| 1122 |
|
| 1123 |
GC_OP_PROLOGUE (pGC); |
| 1124 |
|
| 1125 |
(*pGC->ops->FillSpans) (pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted); |
| 1126 |
|
| 1127 |
GC_OP_EPILOGUE (pGC); |
| 1128 |
} |
| 1129 |
|
| 1130 |
static void |
| 1131 |
rfbSpriteSetSpans(pDrawable, pGC, psrc, ppt, pwidth, nspans, fSorted) |
| 1132 |
DrawablePtr pDrawable; |
| 1133 |
GCPtr pGC; |
| 1134 |
char *psrc; |
| 1135 |
register DDXPointPtr ppt; |
| 1136 |
int *pwidth; |
| 1137 |
int nspans; |
| 1138 |
int fSorted; |
| 1139 |
{ |
| 1140 |
VNCSCREENPTR(pDrawable->pScreen); |
| 1141 |
|
| 1142 |
GC_SETUP(pDrawable, pGC); |
| 1143 |
|
| 1144 |
if (GC_CHECK((WindowPtr) pDrawable)) |
| 1145 |
{ |
| 1146 |
register DDXPointPtr pts; |
| 1147 |
register int *widths; |
| 1148 |
register int nPts; |
| 1149 |
|
| 1150 |
for (pts = ppt, widths = pwidth, nPts = nspans; |
| 1151 |
nPts--; |
| 1152 |
pts++, widths++) |
| 1153 |
{ |
| 1154 |
if (SPN_OVERLAP(&pScreenPriv->saved,pts->y,pts->x,*widths)) |
| 1155 |
{ |
| 1156 |
rfbSpriteRemoveCursor(pDrawable->pScreen); |
| 1157 |
break; |
| 1158 |
} |
| 1159 |
} |
| 1160 |
} |
| 1161 |
|
| 1162 |
GC_OP_PROLOGUE (pGC); |
| 1163 |
|
| 1164 |
(*pGC->ops->SetSpans) (pDrawable, pGC, psrc, ppt, pwidth, nspans, fSorted); |
| 1165 |
|
| 1166 |
GC_OP_EPILOGUE (pGC); |
| 1167 |
} |
| 1168 |
|
| 1169 |
static void |
| 1170 |
rfbSpritePutImage(pDrawable, pGC, depth, x, y, w, h, leftPad, format, pBits) |
| 1171 |
DrawablePtr pDrawable; |
| 1172 |
GCPtr pGC; |
| 1173 |
int depth; |
| 1174 |
int x; |
| 1175 |
int y; |
| 1176 |
int w; |
| 1177 |
int h; |
| 1178 |
int format; |
| 1179 |
char *pBits; |
| 1180 |
{ |
| 1181 |
VNCSCREENPTR(pDrawable->pScreen); |
| 1182 |
|
| 1183 |
GC_SETUP(pDrawable, pGC); |
| 1184 |
|
| 1185 |
if (GC_CHECK((WindowPtr) pDrawable)) |
| 1186 |
{ |
| 1187 |
if (ORG_OVERLAP(&pScreenPriv->saved,pDrawable->x,pDrawable->y, |
| 1188 |
x,y,w,h)) |
| 1189 |
{ |
| 1190 |
rfbSpriteRemoveCursor (pDrawable->pScreen); |
| 1191 |
} |
| 1192 |
} |
| 1193 |
|
| 1194 |
GC_OP_PROLOGUE (pGC); |
| 1195 |
|
| 1196 |
(*pGC->ops->PutImage) (pDrawable, pGC, depth, x, y, w, h, leftPad, format, pBits); |
| 1197 |
|
| 1198 |
GC_OP_EPILOGUE (pGC); |
| 1199 |
} |
| 1200 |
|
| 1201 |
static RegionPtr |
| 1202 |
rfbSpriteCopyArea (pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty) |
| 1203 |
DrawablePtr pSrc; |
| 1204 |
DrawablePtr pDst; |
| 1205 |
GCPtr pGC; |
| 1206 |
int srcx; |
| 1207 |
int srcy; |
| 1208 |
int w; |
| 1209 |
int h; |
| 1210 |
int dstx; |
| 1211 |
int dsty; |
| 1212 |
{ |
| 1213 |
RegionPtr rgn; |
| 1214 |
VNCSCREENPTR(pGC->pScreen); |
| 1215 |
|
| 1216 |
GC_SETUP(pDst, pGC); |
| 1217 |
|
| 1218 |
/* check destination/source overlap. */ |
| 1219 |
if (GC_CHECK((WindowPtr) pDst) && |
| 1220 |
(ORG_OVERLAP(&pScreenPriv->saved,pDst->x,pDst->y,dstx,dsty,w,h) || |
| 1221 |
((pDst == pSrc) && |
| 1222 |
ORG_OVERLAP(&pScreenPriv->saved,pSrc->x,pSrc->y,srcx,srcy,w,h)))) |
| 1223 |
{ |
| 1224 |
rfbSpriteRemoveCursor (pDst->pScreen); |
| 1225 |
} |
| 1226 |
|
| 1227 |
GC_OP_PROLOGUE (pGC); |
| 1228 |
|
| 1229 |
rgn = (*pGC->ops->CopyArea) (pSrc, pDst, pGC, srcx, srcy, w, h, |
| 1230 |
dstx, dsty); |
| 1231 |
|
| 1232 |
GC_OP_EPILOGUE (pGC); |
| 1233 |
|
| 1234 |
return rgn; |
| 1235 |
} |
| 1236 |
|
| 1237 |
static RegionPtr |
| 1238 |
rfbSpriteCopyPlane (pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty, plane) |
| 1239 |
DrawablePtr pSrc; |
| 1240 |
DrawablePtr pDst; |
| 1241 |
register GCPtr pGC; |
| 1242 |
int srcx, |
| 1243 |
srcy; |
| 1244 |
int w, |
| 1245 |
h; |
| 1246 |
int dstx, |
| 1247 |
dsty; |
| 1248 |
unsigned long plane; |
| 1249 |
{ |
| 1250 |
RegionPtr rgn; |
| 1251 |
VNCSCREENPTR(pGC->pScreen); |
| 1252 |
|
| 1253 |
GC_SETUP(pDst, pGC); |
| 1254 |
|
| 1255 |
/* |
| 1256 |
* check destination/source for overlap. |
| 1257 |
*/ |
| 1258 |
if (GC_CHECK((WindowPtr) pDst) && |
| 1259 |
(ORG_OVERLAP(&pScreenPriv->saved,pDst->x,pDst->y,dstx,dsty,w,h) || |
| 1260 |
((pDst == pSrc) && |
| 1261 |
ORG_OVERLAP(&pScreenPriv->saved,pSrc->x,pSrc->y,srcx,srcy,w,h)))) |
| 1262 |
{ |
| 1263 |
rfbSpriteRemoveCursor (pDst->pScreen); |
| 1264 |
} |
| 1265 |
|
| 1266 |
GC_OP_PROLOGUE (pGC); |
| 1267 |
|
| 1268 |
rgn = (*pGC->ops->CopyPlane) (pSrc, pDst, pGC, srcx, srcy, w, h, |
| 1269 |
dstx, dsty, plane); |
| 1270 |
|
| 1271 |
GC_OP_EPILOGUE (pGC); |
| 1272 |
|
| 1273 |
return rgn; |
| 1274 |
} |
| 1275 |
|
| 1276 |
static void |
| 1277 |
rfbSpritePolyPoint (pDrawable, pGC, mode, npt, pptInit) |
| 1278 |
DrawablePtr pDrawable; |
| 1279 |
GCPtr pGC; |
| 1280 |
int mode; /* Origin or Previous */ |
| 1281 |
int npt; |
| 1282 |
xPoint *pptInit; |
| 1283 |
{ |
| 1284 |
xPoint t; |
| 1285 |
int n; |
| 1286 |
BoxRec cursor; |
| 1287 |
register xPoint *pts; |
| 1288 |
VNCSCREENPTR(pDrawable->pScreen); |
| 1289 |
|
| 1290 |
GC_SETUP (pDrawable, pGC); |
| 1291 |
|
| 1292 |
if (npt && GC_CHECK((WindowPtr) pDrawable)) |
| 1293 |
{ |
| 1294 |
cursor.x1 = pScreenPriv->saved.x1 - pDrawable->x; |
| 1295 |
cursor.y1 = pScreenPriv->saved.y1 - pDrawable->y; |
| 1296 |
cursor.x2 = pScreenPriv->saved.x2 - pDrawable->x; |
| 1297 |
cursor.y2 = pScreenPriv->saved.y2 - pDrawable->y; |
| 1298 |
|
| 1299 |
if (mode == CoordModePrevious) |
| 1300 |
{ |
| 1301 |
t.x = 0; |
| 1302 |
t.y = 0; |
| 1303 |
for (pts = pptInit, n = npt; n--; pts++) |
| 1304 |
{ |
| 1305 |
t.x += pts->x; |
| 1306 |
t.y += pts->y; |
| 1307 |
if (cursor.x1 <= t.x && t.x <= cursor.x2 && |
| 1308 |
cursor.y1 <= t.y && t.y <= cursor.y2) |
| 1309 |
{ |
| 1310 |
rfbSpriteRemoveCursor (pDrawable->pScreen); |
| 1311 |
break; |
| 1312 |
} |
| 1313 |
} |
| 1314 |
} |
| 1315 |
else |
| 1316 |
{ |
| 1317 |
for (pts = pptInit, n = npt; n--; pts++) |
| 1318 |
{ |
| 1319 |
if (cursor.x1 <= pts->x && pts->x <= cursor.x2 && |
| 1320 |
cursor.y1 <= pts->y && pts->y <= cursor.y2) |
| 1321 |
{ |
| 1322 |
rfbSpriteRemoveCursor (pDrawable->pScreen); |
| 1323 |
break; |
| 1324 |
} |
| 1325 |
} |
| 1326 |
} |
| 1327 |
} |
| 1328 |
|
| 1329 |
GC_OP_PROLOGUE (pGC); |
| 1330 |
|
| 1331 |
(*pGC->ops->PolyPoint) (pDrawable, pGC, mode, npt, pptInit); |
| 1332 |
|
| 1333 |
GC_OP_EPILOGUE (pGC); |
| 1334 |
} |
| 1335 |
|
| 1336 |
static void |
| 1337 |
rfbSpritePolylines (pDrawable, pGC, mode, npt, pptInit) |
| 1338 |
DrawablePtr pDrawable; |
| 1339 |
GCPtr pGC; |
| 1340 |
int mode; |
| 1341 |
int npt; |
| 1342 |
DDXPointPtr pptInit; |
| 1343 |
{ |
| 1344 |
BoxPtr cursor; |
| 1345 |
register DDXPointPtr pts; |
| 1346 |
int n; |
| 1347 |
int x, y, x1, y1, x2, y2; |
| 1348 |
int lw; |
| 1349 |
int extra; |
| 1350 |
VNCSCREENPTR(pDrawable->pScreen); |
| 1351 |
|
| 1352 |
GC_SETUP (pDrawable, pGC); |
| 1353 |
|
| 1354 |
if (npt && GC_CHECK((WindowPtr) pDrawable)) |
| 1355 |
{ |
| 1356 |
cursor = &pScreenPriv->saved; |
| 1357 |
lw = pGC->lineWidth; |
| 1358 |
x = pptInit->x + pDrawable->x; |
| 1359 |
y = pptInit->y + pDrawable->y; |
| 1360 |
|
| 1361 |
if (npt == 1) |
| 1362 |
{ |
| 1363 |
extra = lw >> 1; |
| 1364 |
if (LINE_OVERLAP(cursor, x, y, x, y, extra)) |
| 1365 |
rfbSpriteRemoveCursor (pDrawable->pScreen); |
| 1366 |
} |
| 1367 |
else |
| 1368 |
{ |
| 1369 |
extra = lw >> 1; |
| 1370 |
/* |
| 1371 |
* mitered joins can project quite a way from |
| 1372 |
* the line end; the 11 degree miter limit limits |
| 1373 |
* this extension to 10.43 * lw / 2, rounded up |
| 1374 |
* and converted to int yields 6 * lw |
| 1375 |
*/ |
| 1376 |
if (pGC->joinStyle == JoinMiter) |
| 1377 |
extra = 6 * lw; |
| 1378 |
else if (pGC->capStyle == CapProjecting) |
| 1379 |
extra = lw; |
| 1380 |
for (pts = pptInit + 1, n = npt - 1; n--; pts++) |
| 1381 |
{ |
| 1382 |
x1 = x; |
| 1383 |
y1 = y; |
| 1384 |
if (mode == CoordModeOrigin) |
| 1385 |
{ |
| 1386 |
x2 = pDrawable->x + pts->x; |
| 1387 |
y2 = pDrawable->y + pts->y; |
| 1388 |
} |
| 1389 |
else |
| 1390 |
{ |
| 1391 |
x2 = x + pts->x; |
| 1392 |
y2 = y + pts->y; |
| 1393 |
} |
| 1394 |
x = x2; |
| 1395 |
y = y2; |
| 1396 |
LINE_SORT(x1, y1, x2, y2); |
| 1397 |
if (LINE_OVERLAP(cursor, x1, y1, x2, y2, extra)) |
| 1398 |
{ |
| 1399 |
rfbSpriteRemoveCursor (pDrawable->pScreen); |
| 1400 |
break; |
| 1401 |
} |
| 1402 |
} |
| 1403 |
} |
| 1404 |
} |
| 1405 |
GC_OP_PROLOGUE (pGC); |
| 1406 |
|
| 1407 |
(*pGC->ops->Polylines) (pDrawable, pGC, mode, npt, pptInit); |
| 1408 |
|
| 1409 |
GC_OP_EPILOGUE (pGC); |
| 1410 |
} |
| 1411 |
|
| 1412 |
static void |
| 1413 |
rfbSpritePolySegment(pDrawable, pGC, nseg, pSegs) |
| 1414 |
DrawablePtr pDrawable; |
| 1415 |
GCPtr pGC; |
| 1416 |
int nseg; |
| 1417 |
xSegment *pSegs; |
| 1418 |
{ |
| 1419 |
int n; |
| 1420 |
register xSegment *segs; |
| 1421 |
BoxPtr cursor; |
| 1422 |
int x1, y1, x2, y2; |
| 1423 |
int extra; |
| 1424 |
VNCSCREENPTR(pDrawable->pScreen); |
| 1425 |
|
| 1426 |
GC_SETUP(pDrawable, pGC); |
| 1427 |
|
| 1428 |
if (nseg && GC_CHECK((WindowPtr) pDrawable)) |
| 1429 |
{ |
| 1430 |
cursor = &pScreenPriv->saved; |
| 1431 |
extra = pGC->lineWidth >> 1; |
| 1432 |
if (pGC->capStyle == CapProjecting) |
| 1433 |
extra = pGC->lineWidth; |
| 1434 |
for (segs = pSegs, n = nseg; n--; segs++) |
| 1435 |
{ |
| 1436 |
x1 = segs->x1 + pDrawable->x; |
| 1437 |
y1 = segs->y1 + pDrawable->y; |
| 1438 |
x2 = segs->x2 + pDrawable->x; |
| 1439 |
y2 = segs->y2 + pDrawable->y; |
| 1440 |
LINE_SORT(x1, y1, x2, y2); |
| 1441 |
if (LINE_OVERLAP(cursor, x1, y1, x2, y2, extra)) |
| 1442 |
{ |
| 1443 |
rfbSpriteRemoveCursor (pDrawable->pScreen); |
| 1444 |
break; |
| 1445 |
} |
| 1446 |
} |
| 1447 |
} |
| 1448 |
|
| 1449 |
GC_OP_PROLOGUE (pGC); |
| 1450 |
|
| 1451 |
(*pGC->ops->PolySegment) (pDrawable, pGC, nseg, pSegs); |
| 1452 |
|
| 1453 |
GC_OP_EPILOGUE (pGC); |
| 1454 |
} |
| 1455 |
|
| 1456 |
static void |
| 1457 |
rfbSpritePolyRectangle(pDrawable, pGC, nrects, pRects) |
| 1458 |
DrawablePtr pDrawable; |
| 1459 |
GCPtr pGC; |
| 1460 |
int nrects; |
| 1461 |
xRectangle *pRects; |
| 1462 |
{ |
| 1463 |
register xRectangle *rects; |
| 1464 |
BoxPtr cursor; |
| 1465 |
int lw; |
| 1466 |
int n; |
| 1467 |
int x1, y1, x2, y2; |
| 1468 |
VNCSCREENPTR(pDrawable->pScreen); |
| 1469 |
|
| 1470 |
GC_SETUP (pDrawable, pGC); |
| 1471 |
|
| 1472 |
if (GC_CHECK((WindowPtr) pDrawable)) |
| 1473 |
{ |
| 1474 |
lw = pGC->lineWidth >> 1; |
| 1475 |
cursor = &pScreenPriv->saved; |
| 1476 |
for (rects = pRects, n = nrects; n--; rects++) |
| 1477 |
{ |
| 1478 |
x1 = rects->x + pDrawable->x; |
| 1479 |
y1 = rects->y + pDrawable->y; |
| 1480 |
x2 = x1 + (int)rects->width; |
| 1481 |
y2 = y1 + (int)rects->height; |
| 1482 |
if (LINE_OVERLAP(cursor, x1, y1, x2, y1, lw) || |
| 1483 |
LINE_OVERLAP(cursor, x2, y1, x2, y2, lw) || |
| 1484 |
LINE_OVERLAP(cursor, x1, y2, x2, y2, lw) || |
| 1485 |
LINE_OVERLAP(cursor, x1, y1, x1, y2, lw)) |
| 1486 |
{ |
| 1487 |
rfbSpriteRemoveCursor (pDrawable->pScreen); |
| 1488 |
break; |
| 1489 |
} |
| 1490 |
} |
| 1491 |
} |
| 1492 |
|
| 1493 |
GC_OP_PROLOGUE (pGC); |
| 1494 |
|
| 1495 |
(*pGC->ops->PolyRectangle) (pDrawable, pGC, nrects, pRects); |
| 1496 |
|
| 1497 |
GC_OP_EPILOGUE (pGC); |
| 1498 |
} |
| 1499 |
|
| 1500 |
static void |
| 1501 |
rfbSpritePolyArc(pDrawable, pGC, narcs, parcs) |
| 1502 |
DrawablePtr pDrawable; |
| 1503 |
register GCPtr pGC; |
| 1504 |
int narcs; |
| 1505 |
xArc *parcs; |
| 1506 |
{ |
| 1507 |
BoxPtr cursor; |
| 1508 |
int lw; |
| 1509 |
int n; |
| 1510 |
register xArc *arcs; |
| 1511 |
VNCSCREENPTR(pDrawable->pScreen); |
| 1512 |
|
| 1513 |
GC_SETUP (pDrawable, pGC); |
| 1514 |
|
| 1515 |
if (GC_CHECK((WindowPtr) pDrawable)) |
| 1516 |
{ |
| 1517 |
lw = pGC->lineWidth >> 1; |
| 1518 |
cursor = &pScreenPriv->saved; |
| 1519 |
for (arcs = parcs, n = narcs; n--; arcs++) |
| 1520 |
{ |
| 1521 |
if (ORG_OVERLAP (cursor, pDrawable->x, pDrawable->y, |
| 1522 |
arcs->x - lw, arcs->y - lw, |
| 1523 |
(int) arcs->width + pGC->lineWidth, |
| 1524 |
(int) arcs->height + pGC->lineWidth)) |
| 1525 |
{ |
| 1526 |
rfbSpriteRemoveCursor (pDrawable->pScreen); |
| 1527 |
break; |
| 1528 |
} |
| 1529 |
} |
| 1530 |
} |
| 1531 |
|
| 1532 |
GC_OP_PROLOGUE (pGC); |
| 1533 |
|
| 1534 |
(*pGC->ops->PolyArc) (pDrawable, pGC, narcs, parcs); |
| 1535 |
|
| 1536 |
GC_OP_EPILOGUE (pGC); |
| 1537 |
} |
| 1538 |
|
| 1539 |
static void |
| 1540 |
rfbSpriteFillPolygon(pDrawable, pGC, shape, mode, count, pPts) |
| 1541 |
register DrawablePtr pDrawable; |
| 1542 |
register GCPtr pGC; |
| 1543 |
int shape, mode; |
| 1544 |
int count; |
| 1545 |
DDXPointPtr pPts; |
| 1546 |
{ |
| 1547 |
int x, y, minx, miny, maxx, maxy; |
| 1548 |
register DDXPointPtr pts; |
| 1549 |
int n; |
| 1550 |
VNCSCREENPTR(pDrawable->pScreen); |
| 1551 |
|
| 1552 |
GC_SETUP (pDrawable, pGC); |
| 1553 |
|
| 1554 |
if (count && GC_CHECK((WindowPtr) pDrawable)) |
| 1555 |
{ |
| 1556 |
x = pDrawable->x; |
| 1557 |
y = pDrawable->y; |
| 1558 |
pts = pPts; |
| 1559 |
minx = maxx = pts->x; |
| 1560 |
miny = maxy = pts->y; |
| 1561 |
pts++; |
| 1562 |
n = count - 1; |
| 1563 |
|
| 1564 |
if (mode == CoordModeOrigin) |
| 1565 |
{ |
| 1566 |
for (; n--; pts++) |
| 1567 |
{ |
| 1568 |
if (pts->x < minx) |
| 1569 |
minx = pts->x; |
| 1570 |
else if (pts->x > maxx) |
| 1571 |
maxx = pts->x; |
| 1572 |
if (pts->y < miny) |
| 1573 |
miny = pts->y; |
| 1574 |
else if (pts->y > maxy) |
| 1575 |
maxy = pts->y; |
| 1576 |
} |
| 1577 |
minx += x; |
| 1578 |
miny += y; |
| 1579 |
maxx += x; |
| 1580 |
maxy += y; |
| 1581 |
} |
| 1582 |
else |
| 1583 |
{ |
| 1584 |
x += minx; |
| 1585 |
y += miny; |
| 1586 |
minx = maxx = x; |
| 1587 |
miny = maxy = y; |
| 1588 |
for (; n--; pts++) |
| 1589 |
{ |
| 1590 |
x += pts->x; |
| 1591 |
y += pts->y; |
| 1592 |
if (x < minx) |
| 1593 |
minx = x; |
| 1594 |
else if (x > maxx) |
| 1595 |
maxx = x; |
| 1596 |
if (y < miny) |
| 1597 |
miny = y; |
| 1598 |
else if (y > maxy) |
| 1599 |
maxy = y; |
| 1600 |
} |
| 1601 |
} |
| 1602 |
if (BOX_OVERLAP(&pScreenPriv->saved,minx,miny,maxx,maxy)) |
| 1603 |
rfbSpriteRemoveCursor (pDrawable->pScreen); |
| 1604 |
} |
| 1605 |
|
| 1606 |
GC_OP_PROLOGUE (pGC); |
| 1607 |
|
| 1608 |
(*pGC->ops->FillPolygon) (pDrawable, pGC, shape, mode, count, pPts); |
| 1609 |
|
| 1610 |
GC_OP_EPILOGUE (pGC); |
| 1611 |
} |
| 1612 |
|
| 1613 |
static void |
| 1614 |
rfbSpritePolyFillRect(pDrawable, pGC, nrectFill, prectInit) |
| 1615 |
DrawablePtr pDrawable; |
| 1616 |
GCPtr pGC; |
| 1617 |
int nrectFill; /* number of rectangles to fill */ |
| 1618 |
xRectangle *prectInit; /* Pointer to first rectangle to fill */ |
| 1619 |
{ |
| 1620 |
VNCSCREENPTR(pDrawable->pScreen); |
| 1621 |
|
| 1622 |
GC_SETUP(pDrawable, pGC); |
| 1623 |
|
| 1624 |
if (GC_CHECK((WindowPtr) pDrawable)) |
| 1625 |
{ |
| 1626 |
register int nRect; |
| 1627 |
register xRectangle *pRect; |
| 1628 |
register int xorg, yorg; |
| 1629 |
|
| 1630 |
xorg = pDrawable->x; |
| 1631 |
yorg = pDrawable->y; |
| 1632 |
|
| 1633 |
for (nRect = nrectFill, pRect = prectInit; nRect--; pRect++) { |
| 1634 |
if (ORGRECT_OVERLAP(&pScreenPriv->saved,xorg,yorg,pRect)){ |
| 1635 |
rfbSpriteRemoveCursor(pDrawable->pScreen); |
| 1636 |
break; |
| 1637 |
} |
| 1638 |
} |
| 1639 |
} |
| 1640 |
|
| 1641 |
GC_OP_PROLOGUE (pGC); |
| 1642 |
|
| 1643 |
(*pGC->ops->PolyFillRect) (pDrawable, pGC, nrectFill, prectInit); |
| 1644 |
|
| 1645 |
GC_OP_EPILOGUE (pGC); |
| 1646 |
} |
| 1647 |
|
| 1648 |
static void |
| 1649 |
rfbSpritePolyFillArc(pDrawable, pGC, narcs, parcs) |
| 1650 |
DrawablePtr pDrawable; |
| 1651 |
GCPtr pGC; |
| 1652 |
int narcs; |
| 1653 |
xArc *parcs; |
| 1654 |
{ |
| 1655 |
VNCSCREENPTR(pDrawable->pScreen); |
| 1656 |
|
| 1657 |
GC_SETUP(pDrawable, pGC); |
| 1658 |
|
| 1659 |
if (GC_CHECK((WindowPtr) pDrawable)) |
| 1660 |
{ |
| 1661 |
register int n; |
| 1662 |
BoxPtr cursor; |
| 1663 |
register xArc *arcs; |
| 1664 |
|
| 1665 |
cursor = &pScreenPriv->saved; |
| 1666 |
|
| 1667 |
for (arcs = parcs, n = narcs; n--; arcs++) |
| 1668 |
{ |
| 1669 |
if (ORG_OVERLAP(cursor, pDrawable->x, pDrawable->y, |
| 1670 |
arcs->x, arcs->y, |
| 1671 |
(int) arcs->width, (int) arcs->height)) |
| 1672 |
{ |
| 1673 |
rfbSpriteRemoveCursor (pDrawable->pScreen); |
| 1674 |
break; |
| 1675 |
} |
| 1676 |
} |
| 1677 |
} |
| 1678 |
|
| 1679 |
GC_OP_PROLOGUE (pGC); |
| 1680 |
|
| 1681 |
(*pGC->ops->PolyFillArc) (pDrawable, pGC, narcs, parcs); |
| 1682 |
|
| 1683 |
GC_OP_EPILOGUE (pGC); |
| 1684 |
} |
| 1685 |
|
| 1686 |
/* |
| 1687 |
* general Poly/Image text function. Extract glyph information, |
| 1688 |
* compute bounding box and remove cursor if it is overlapped. |
| 1689 |
*/ |
| 1690 |
|
| 1691 |
static Bool |
| 1692 |
rfbSpriteTextOverlap (DrawablePtr pDraw, FontPtr font, int x, int y, unsigned int n, CharInfoPtr *charinfo, Bool imageblt, unsigned int w, BoxPtr cursorBox) |
| 1693 |
{ |
| 1694 |
ExtentInfoRec extents; |
| 1695 |
|
| 1696 |
x += pDraw->x; |
| 1697 |
y += pDraw->y; |
| 1698 |
|
| 1699 |
if (FONTMINBOUNDS(font,characterWidth) >= 0) |
| 1700 |
{ |
| 1701 |
/* compute an approximate (but covering) bounding box */ |
| 1702 |
if (!imageblt || (charinfo[0]->metrics.leftSideBearing < 0)) |
| 1703 |
extents.overallLeft = charinfo[0]->metrics.leftSideBearing; |
| 1704 |
else |
| 1705 |
extents.overallLeft = 0; |
| 1706 |
if (w) |
| 1707 |
extents.overallRight = w - charinfo[n-1]->metrics.characterWidth; |
| 1708 |
else |
| 1709 |
extents.overallRight = FONTMAXBOUNDS(font,characterWidth) |
| 1710 |
* (n - 1); |
| 1711 |
if (imageblt && (charinfo[n-1]->metrics.characterWidth > |
| 1712 |
charinfo[n-1]->metrics.rightSideBearing)) |
| 1713 |
extents.overallRight += charinfo[n-1]->metrics.characterWidth; |
| 1714 |
else |
| 1715 |
extents.overallRight += charinfo[n-1]->metrics.rightSideBearing; |
| 1716 |
if (imageblt && FONTASCENT(font) > FONTMAXBOUNDS(font,ascent)) |
| 1717 |
extents.overallAscent = FONTASCENT(font); |
| 1718 |
else |
| 1719 |
extents.overallAscent = FONTMAXBOUNDS(font, ascent); |
| 1720 |
if (imageblt && FONTDESCENT(font) > FONTMAXBOUNDS(font,descent)) |
| 1721 |
extents.overallDescent = FONTDESCENT(font); |
| 1722 |
else |
| 1723 |
extents.overallDescent = FONTMAXBOUNDS(font,descent); |
| 1724 |
if (!BOX_OVERLAP(cursorBox, |
| 1725 |
x + extents.overallLeft, |
| 1726 |
y - extents.overallAscent, |
| 1727 |
x + extents.overallRight, |
| 1728 |
y + extents.overallDescent)) |
| 1729 |
return FALSE; |
| 1730 |
else if (imageblt && w) |
| 1731 |
return TRUE; |
| 1732 |
/* if it does overlap, fall through and compute exactly, because |
| 1733 |
* taking down the cursor is expensive enough to make this worth it |
| 1734 |
*/ |
| 1735 |
} |
| 1736 |
QueryGlyphExtents(font, charinfo, n, &extents); |
| 1737 |
if (imageblt) |
| 1738 |
{ |
| 1739 |
if (extents.overallWidth > extents.overallRight) |
| 1740 |
extents.overallRight = extents.overallWidth; |
| 1741 |
if (extents.overallWidth < extents.overallLeft) |
| 1742 |
extents.overallLeft = extents.overallWidth; |
| 1743 |
if (extents.overallLeft > 0) |
| 1744 |
extents.overallLeft = 0; |
| 1745 |
if (extents.fontAscent > extents.overallAscent) |
| 1746 |
extents.overallAscent = extents.fontAscent; |
| 1747 |
if (extents.fontDescent > extents.overallDescent) |
| 1748 |
extents.overallDescent = extents.fontDescent; |
| 1749 |
} |
| 1750 |
return (BOX_OVERLAP(cursorBox, |
| 1751 |
x + extents.overallLeft, |
| 1752 |
y - extents.overallAscent, |
| 1753 |
x + extents.overallRight, |
| 1754 |
y + extents.overallDescent)); |
| 1755 |
} |
| 1756 |
|
| 1757 |
/* |
| 1758 |
* values for textType: |
| 1759 |
*/ |
| 1760 |
#define TT_POLY8 0 |
| 1761 |
#define TT_IMAGE8 1 |
| 1762 |
#define TT_POLY16 2 |
| 1763 |
#define TT_IMAGE16 3 |
| 1764 |
|
| 1765 |
static int |
| 1766 |
rfbSpriteText (DrawablePtr pDraw, GCPtr pGC, int x, int y, unsigned long count, char *chars, FontEncoding fontEncoding, Bool textType, BoxPtr cursorBox) |
| 1767 |
{ |
| 1768 |
CharInfoPtr *charinfo; |
| 1769 |
register CharInfoPtr *info; |
| 1770 |
unsigned long i; |
| 1771 |
unsigned int n; |
| 1772 |
int w; |
| 1773 |
void (*drawFunc)() = NULL; |
| 1774 |
|
| 1775 |
Bool imageblt; |
| 1776 |
|
| 1777 |
imageblt = (textType == TT_IMAGE8) || (textType == TT_IMAGE16); |
| 1778 |
|
| 1779 |
charinfo = (CharInfoPtr *) ALLOCATE_LOCAL(count * sizeof(CharInfoPtr)); |
| 1780 |
if (!charinfo) |
| 1781 |
return x; |
| 1782 |
|
| 1783 |
GetGlyphs(pGC->font, count, (unsigned char *)chars, |
| 1784 |
fontEncoding, &i, charinfo); |
| 1785 |
n = (unsigned int)i; |
| 1786 |
w = 0; |
| 1787 |
if (!imageblt) |
| 1788 |
for (info = charinfo; i--; info++) |
| 1789 |
w += (*info)->metrics.characterWidth; |
| 1790 |
|
| 1791 |
if (n != 0) { |
| 1792 |
if (rfbSpriteTextOverlap(pDraw, pGC->font, x, y, n, charinfo, imageblt, w, cursorBox)) |
| 1793 |
rfbSpriteRemoveCursor(pDraw->pScreen); |
| 1794 |
|
| 1795 |
#ifdef AVOID_GLYPHBLT |
| 1796 |
/* |
| 1797 |
* On displays like Apollos, which do not optimize the GlyphBlt functions because they |
| 1798 |
* convert fonts to their internal form in RealizeFont and optimize text directly, we |
| 1799 |
* want to invoke the text functions here, not the GlyphBlt functions. |
| 1800 |
*/ |
| 1801 |
switch (textType) |
| 1802 |
{ |
| 1803 |
case TT_POLY8: |
| 1804 |
drawFunc = (void (*)())pGC->ops->PolyText8; |
| 1805 |
break; |
| 1806 |
case TT_IMAGE8: |
| 1807 |
drawFunc = pGC->ops->ImageText8; |
| 1808 |
break; |
| 1809 |
case TT_POLY16: |
| 1810 |
drawFunc = (void (*)())pGC->ops->PolyText16; |
| 1811 |
break; |
| 1812 |
case TT_IMAGE16: |
| 1813 |
drawFunc = pGC->ops->ImageText16; |
| 1814 |
break; |
| 1815 |
} |
| 1816 |
(*drawFunc) (pDraw, pGC, x, y, (int) count, chars); |
| 1817 |
#else /* don't AVOID_GLYPHBLT */ |
| 1818 |
/* |
| 1819 |
* On the other hand, if the device does use GlyphBlt ultimately to do text, we |
| 1820 |
* don't want to slow it down by invoking the text functions and having them call |
| 1821 |
* GetGlyphs all over again, so we go directly to the GlyphBlt functions here. |
| 1822 |
*/ |
| 1823 |
drawFunc = imageblt ? pGC->ops->ImageGlyphBlt : pGC->ops->PolyGlyphBlt; |
| 1824 |
(*drawFunc) (pDraw, pGC, x, y, n, charinfo, FONTGLYPHS(pGC->font)); |
| 1825 |
#endif /* AVOID_GLYPHBLT */ |
| 1826 |
} |
| 1827 |
DEALLOCATE_LOCAL(charinfo); |
| 1828 |
return x + w; |
| 1829 |
} |
| 1830 |
|
| 1831 |
static int |
| 1832 |
rfbSpritePolyText8(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count, char *chars) |
| 1833 |
{ |
| 1834 |
int ret; |
| 1835 |
VNCSCREENPTR(pDrawable->pScreen); |
| 1836 |
|
| 1837 |
GC_SETUP (pDrawable, pGC); |
| 1838 |
|
| 1839 |
GC_OP_PROLOGUE (pGC); |
| 1840 |
|
| 1841 |
if (GC_CHECK((WindowPtr) pDrawable)) |
| 1842 |
ret = rfbSpriteText (pDrawable, pGC, x, y, (unsigned long)count, chars, |
| 1843 |
Linear8Bit, TT_POLY8, &pScreenPriv->saved); |
| 1844 |
else |
| 1845 |
ret = (*pGC->ops->PolyText8) (pDrawable, pGC, x, y, count, chars); |
| 1846 |
|
| 1847 |
GC_OP_EPILOGUE (pGC); |
| 1848 |
return ret; |
| 1849 |
} |
| 1850 |
|
| 1851 |
static int |
| 1852 |
rfbSpritePolyText16(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count, unsigned short *chars) |
| 1853 |
{ |
| 1854 |
int ret; |
| 1855 |
VNCSCREENPTR(pDrawable->pScreen); |
| 1856 |
|
| 1857 |
GC_SETUP(pDrawable, pGC); |
| 1858 |
|
| 1859 |
GC_OP_PROLOGUE (pGC); |
| 1860 |
|
| 1861 |
if (GC_CHECK((WindowPtr) pDrawable)) |
| 1862 |
ret = rfbSpriteText (pDrawable, pGC, x, y, (unsigned long)count, |
| 1863 |
(char *)chars, |
| 1864 |
FONTLASTROW(pGC->font) == 0 ? |
| 1865 |
Linear16Bit : TwoD16Bit, TT_POLY16, &pScreenPriv->saved); |
| 1866 |
else |
| 1867 |
ret = (*pGC->ops->PolyText16) (pDrawable, pGC, x, y, count, chars); |
| 1868 |
|
| 1869 |
GC_OP_EPILOGUE (pGC); |
| 1870 |
return ret; |
| 1871 |
} |
| 1872 |
|
| 1873 |
static void |
| 1874 |
rfbSpriteImageText8(pDrawable, pGC, x, y, count, chars) |
| 1875 |
DrawablePtr pDrawable; |
| 1876 |
GCPtr pGC; |
| 1877 |
int x, y; |
| 1878 |
int count; |
| 1879 |
char *chars; |
| 1880 |
{ |
| 1881 |
VNCSCREENPTR(pDrawable->pScreen); |
| 1882 |
|
| 1883 |
GC_SETUP(pDrawable, pGC); |
| 1884 |
|
| 1885 |
GC_OP_PROLOGUE (pGC); |
| 1886 |
|
| 1887 |
if (GC_CHECK((WindowPtr) pDrawable)) |
| 1888 |
(void) rfbSpriteText (pDrawable, pGC, x, y, (unsigned long)count, |
| 1889 |
chars, Linear8Bit, TT_IMAGE8, &pScreenPriv->saved); |
| 1890 |
else |
| 1891 |
(*pGC->ops->ImageText8) (pDrawable, pGC, x, y, count, chars); |
| 1892 |
|
| 1893 |
GC_OP_EPILOGUE (pGC); |
| 1894 |
} |
| 1895 |
|
| 1896 |
static void |
| 1897 |
rfbSpriteImageText16(pDrawable, pGC, x, y, count, chars) |
| 1898 |
DrawablePtr pDrawable; |
| 1899 |
GCPtr pGC; |
| 1900 |
int x, y; |
| 1901 |
int count; |
| 1902 |
unsigned short *chars; |
| 1903 |
{ |
| 1904 |
VNCSCREENPTR(pDrawable->pScreen); |
| 1905 |
|
| 1906 |
GC_SETUP(pDrawable, pGC); |
| 1907 |
|
| 1908 |
GC_OP_PROLOGUE (pGC); |
| 1909 |
|
| 1910 |
if (GC_CHECK((WindowPtr) pDrawable)) |
| 1911 |
(void) rfbSpriteText (pDrawable, pGC, x, y, (unsigned long)count, |
| 1912 |
(char *)chars, |
| 1913 |
FONTLASTROW(pGC->font) == 0 ? |
| 1914 |
Linear16Bit : TwoD16Bit, TT_IMAGE16, &pScreenPriv->saved); |
| 1915 |
else |
| 1916 |
(*pGC->ops->ImageText16) (pDrawable, pGC, x, y, count, chars); |
| 1917 |
|
| 1918 |
GC_OP_EPILOGUE (pGC); |
| 1919 |
} |
| 1920 |
|
| 1921 |
static void |
| 1922 |
rfbSpriteImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase) |
| 1923 |
DrawablePtr pDrawable; |
| 1924 |
GCPtr pGC; |
| 1925 |
int x, y; |
| 1926 |
unsigned int nglyph; |
| 1927 |
CharInfoPtr *ppci; /* array of character info */ |
| 1928 |
pointer pglyphBase; /* start of array of glyphs */ |
| 1929 |
{ |
| 1930 |
VNCSCREENPTR(pDrawable->pScreen); |
| 1931 |
|
| 1932 |
GC_SETUP(pDrawable, pGC); |
| 1933 |
|
| 1934 |
GC_OP_PROLOGUE (pGC); |
| 1935 |
|
| 1936 |
if (GC_CHECK((WindowPtr) pDrawable) && |
| 1937 |
rfbSpriteTextOverlap (pDrawable, pGC->font, x, y, nglyph, ppci, TRUE, 0, &pScreenPriv->saved)) |
| 1938 |
{ |
| 1939 |
rfbSpriteRemoveCursor(pDrawable->pScreen); |
| 1940 |
} |
| 1941 |
(*pGC->ops->ImageGlyphBlt) (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase); |
| 1942 |
|
| 1943 |
GC_OP_EPILOGUE (pGC); |
| 1944 |
} |
| 1945 |
|
| 1946 |
static void |
| 1947 |
rfbSpritePolyGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase) |
| 1948 |
DrawablePtr pDrawable; |
| 1949 |
GCPtr pGC; |
| 1950 |
int x, y; |
| 1951 |
unsigned int nglyph; |
| 1952 |
CharInfoPtr *ppci; /* array of character info */ |
| 1953 |
pointer pglyphBase; /* start of array of glyphs */ |
| 1954 |
{ |
| 1955 |
VNCSCREENPTR(pDrawable->pScreen); |
| 1956 |
|
| 1957 |
GC_SETUP (pDrawable, pGC); |
| 1958 |
|
| 1959 |
GC_OP_PROLOGUE (pGC); |
| 1960 |
|
| 1961 |
if (GC_CHECK((WindowPtr) pDrawable) && |
| 1962 |
rfbSpriteTextOverlap (pDrawable, pGC->font, x, y, nglyph, ppci, FALSE, 0, &pScreenPriv->saved)) |
| 1963 |
{ |
| 1964 |
rfbSpriteRemoveCursor(pDrawable->pScreen); |
| 1965 |
} |
| 1966 |
(*pGC->ops->PolyGlyphBlt) (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase); |
| 1967 |
|
| 1968 |
GC_OP_EPILOGUE (pGC); |
| 1969 |
} |
| 1970 |
|
| 1971 |
static void |
| 1972 |
rfbSpritePushPixels(pGC, pBitMap, pDrawable, w, h, x, y) |
| 1973 |
GCPtr pGC; |
| 1974 |
PixmapPtr pBitMap; |
| 1975 |
DrawablePtr pDrawable; |
| 1976 |
int w, h, x, y; |
| 1977 |
{ |
| 1978 |
VNCSCREENPTR(pDrawable->pScreen); |
| 1979 |
GC_SETUP(pDrawable, pGC); |
| 1980 |
|
| 1981 |
if (GC_CHECK((WindowPtr) pDrawable) && |
| 1982 |
ORG_OVERLAP(&pScreenPriv->saved,pDrawable->x,pDrawable->y,x,y,w,h)) |
| 1983 |
{ |
| 1984 |
rfbSpriteRemoveCursor (pDrawable->pScreen); |
| 1985 |
} |
| 1986 |
|
| 1987 |
GC_OP_PROLOGUE (pGC); |
| 1988 |
|
| 1989 |
(*pGC->ops->PushPixels) (pGC, pBitMap, pDrawable, w, h, x, y); |
| 1990 |
|
| 1991 |
GC_OP_EPILOGUE (pGC); |
| 1992 |
} |
| 1993 |
|
| 1994 |
#ifdef NEED_LINEHELPER |
| 1995 |
/* |
| 1996 |
* I don't expect this routine will ever be called, as the GC |
| 1997 |
* will have been unwrapped for the line drawing |
| 1998 |
*/ |
| 1999 |
|
| 2000 |
static void |
| 2001 |
rfbSpriteLineHelper() |
| 2002 |
{ |
| 2003 |
FatalError("rfbSpriteLineHelper called\n"); |
| 2004 |
} |
| 2005 |
#endif |
| 2006 |
|
| 2007 |
#ifdef RENDER |
| 2008 |
|
| 2009 |
# define mod(a,b) ((b) == 1 ? 0 : (a) >= 0 ? (a) % (b) : (b) - (-a) % (b)) |
| 2010 |
|
| 2011 |
static void |
| 2012 |
rfbSpritePictureOverlap (PicturePtr pPict, |
| 2013 |
INT16 x, |
| 2014 |
INT16 y, |
| 2015 |
CARD16 w, |
| 2016 |
CARD16 h) |
| 2017 |
{ |
| 2018 |
VNCSCREENPTR(pPict->pDrawable->pScreen); |
| 2019 |
|
| 2020 |
if (pPict->pDrawable->type == DRAWABLE_WINDOW) |
| 2021 |
{ |
| 2022 |
WindowPtr pWin = (WindowPtr) (pPict->pDrawable); |
| 2023 |
rfbSpriteScreenPtr pScreenPriv = (rfbSpriteScreenPtr) |
| 2024 |
pPict->pDrawable->pScreen->devPrivates[rfbSpriteScreenIndex].ptr; |
| 2025 |
if (GC_CHECK(pWin)) |
| 2026 |
{ |
| 2027 |
if (pPict->repeat) |
| 2028 |
{ |
| 2029 |
x = mod(x,pWin->drawable.width); |
| 2030 |
y = mod(y,pWin->drawable.height); |
| 2031 |
} |
| 2032 |
if (ORG_OVERLAP (&pScreenPriv->saved, pWin->drawable.x, pWin->drawable.y, |
| 2033 |
x, y, w, h)) |
| 2034 |
rfbSpriteRemoveCursor (pWin->drawable.pScreen); |
| 2035 |
} |
| 2036 |
} |
| 2037 |
} |
| 2038 |
|
| 2039 |
#define PICTURE_PROLOGUE(ps, pScreenPriv, field) \ |
| 2040 |
ps->field = pScreenPriv->field |
| 2041 |
|
| 2042 |
#define PICTURE_EPILOGUE(ps, field, wrap) \ |
| 2043 |
ps->field = wrap |
| 2044 |
|
| 2045 |
static void |
| 2046 |
rfbSpriteComposite(CARD8 op, |
| 2047 |
PicturePtr pSrc, |
| 2048 |
PicturePtr pMask, |
| 2049 |
PicturePtr pDst, |
| 2050 |
INT16 xSrc, |
| 2051 |
INT16 ySrc, |
| 2052 |
INT16 xMask, |
| 2053 |
INT16 yMask, |
| 2054 |
INT16 xDst, |
| 2055 |
INT16 yDst, |
| 2056 |
CARD16 width, |
| 2057 |
CARD16 height) |
| 2058 |
{ |
| 2059 |
ScreenPtr pScreen = pDst->pDrawable->pScreen; |
| 2060 |
PictureScreenPtr ps = GetPictureScreen(pScreen); |
| 2061 |
rfbSpriteScreenPtr pScreenPriv; |
| 2062 |
|
| 2063 |
pScreenPriv = (rfbSpriteScreenPtr) pScreen->devPrivates[rfbSpriteScreenIndex].ptr; |
| 2064 |
PICTURE_PROLOGUE(ps, pScreenPriv, Composite); |
| 2065 |
rfbSpritePictureOverlap (pSrc, xSrc, ySrc, width, height); |
| 2066 |
if (pMask) |
| 2067 |
rfbSpritePictureOverlap (pMask, xMask, yMask, width, height); |
| 2068 |
rfbSpritePictureOverlap (pDst, xDst, yDst, width, height); |
| 2069 |
|
| 2070 |
(*ps->Composite) (op, |
| 2071 |
pSrc, |
| 2072 |
pMask, |
| 2073 |
pDst, |
| 2074 |
xSrc, |
| 2075 |
ySrc, |
| 2076 |
xMask, |
| 2077 |
yMask, |
| 2078 |
xDst, |
| 2079 |
yDst, |
| 2080 |
width, |
| 2081 |
height); |
| 2082 |
|
| 2083 |
PICTURE_EPILOGUE(ps, Composite, rfbSpriteComposite); |
| 2084 |
} |
| 2085 |
|
| 2086 |
static void |
| 2087 |
rfbSpriteGlyphs(CARD8 op, |
| 2088 |
PicturePtr pSrc, |
| 2089 |
PicturePtr pDst, |
| 2090 |
PictFormatPtr maskFormat, |
| 2091 |
INT16 xSrc, |
| 2092 |
INT16 ySrc, |
| 2093 |
int nlist, |
| 2094 |
GlyphListPtr list, |
| 2095 |
GlyphPtr *glyphs) |
| 2096 |
{ |
| 2097 |
ScreenPtr pScreen = pDst->pDrawable->pScreen; |
| 2098 |
VNCSCREENPTR(pScreen); |
| 2099 |
PictureScreenPtr ps = GetPictureScreen(pScreen); |
| 2100 |
rfbSpriteScreenPtr pScreenPriv; |
| 2101 |
|
| 2102 |
pScreenPriv = (rfbSpriteScreenPtr) pScreen->devPrivates[rfbSpriteScreenIndex].ptr; |
| 2103 |
PICTURE_PROLOGUE(ps, pScreenPriv, Glyphs); |
| 2104 |
if (pSrc->pDrawable->type == DRAWABLE_WINDOW) |
| 2105 |
{ |
| 2106 |
WindowPtr pSrcWin = (WindowPtr) (pSrc->pDrawable); |
| 2107 |
|
| 2108 |
if (GC_CHECK(pSrcWin)) |
| 2109 |
rfbSpriteRemoveCursor (pScreen); |
| 2110 |
} |
| 2111 |
if (pDst->pDrawable->type == DRAWABLE_WINDOW) |
| 2112 |
{ |
| 2113 |
WindowPtr pDstWin = (WindowPtr) (pDst->pDrawable); |
| 2114 |
|
| 2115 |
if (GC_CHECK(pDstWin)) |
| 2116 |
{ |
| 2117 |
BoxRec extents; |
| 2118 |
|
| 2119 |
miGlyphExtents (nlist, list, glyphs, &extents); |
| 2120 |
if (BOX_OVERLAP(&pScreenPriv->saved, |
| 2121 |
extents.x1 + pDstWin->drawable.x, |
| 2122 |
extents.y1 + pDstWin->drawable.y, |
| 2123 |
extents.x2 + pDstWin->drawable.x, |
| 2124 |
extents.y2 + pDstWin->drawable.y)) |
| 2125 |
{ |
| 2126 |
rfbSpriteRemoveCursor (pScreen); |
| 2127 |
} |
| 2128 |
} |
| 2129 |
} |
| 2130 |
|
| 2131 |
(*ps->Glyphs) (op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, list, glyphs); |
| 2132 |
|
| 2133 |
PICTURE_EPILOGUE (ps, Glyphs, rfbSpriteGlyphs); |
| 2134 |
} |
| 2135 |
#endif |
| 2136 |
|
| 2137 |
/* |
| 2138 |
* miPointer interface routines |
| 2139 |
*/ |
| 2140 |
|
| 2141 |
#define SPRITE_PAD 8 |
| 2142 |
|
| 2143 |
static Bool |
| 2144 |
rfbSpriteRealizeCursor (ScreenPtr pScreen, CursorPtr pCursor) |
| 2145 |
{ |
| 2146 |
rfbSpriteScreenPtr pScreenPriv; |
| 2147 |
|
| 2148 |
pScreenPriv = (rfbSpriteScreenPtr) pScreen->devPrivates[rfbSpriteScreenIndex].ptr; |
| 2149 |
if (pCursor == pScreenPriv->pCursor) |
| 2150 |
pScreenPriv->checkPixels = TRUE; |
| 2151 |
return (*pScreenPriv->funcs->RealizeCursor) (pScreen, pCursor); |
| 2152 |
} |
| 2153 |
|
| 2154 |
static Bool |
| 2155 |
rfbSpriteUnrealizeCursor (ScreenPtr pScreen, CursorPtr pCursor) |
| 2156 |
{ |
| 2157 |
rfbSpriteScreenPtr pScreenPriv; |
| 2158 |
|
| 2159 |
pScreenPriv = (rfbSpriteScreenPtr) pScreen->devPrivates[rfbSpriteScreenIndex].ptr; |
| 2160 |
return (*pScreenPriv->funcs->UnrealizeCursor) (pScreen, pCursor); |
| 2161 |
} |
| 2162 |
|
| 2163 |
static void |
| 2164 |
rfbSpriteSetCursor (ScreenPtr pScreen, CursorPtr pCursor, int x, int y) |
| 2165 |
{ |
| 2166 |
rfbSpriteScreenPtr pScreenPriv; |
| 2167 |
rfbClientPtr cl, nextCl; |
| 2168 |
VNCSCREENPTR(pScreen); |
| 2169 |
|
| 2170 |
pScreenPriv |
| 2171 |
= (rfbSpriteScreenPtr) pScreen->devPrivates[rfbSpriteScreenIndex].ptr; |
| 2172 |
if (!pCursor) |
| 2173 |
{ |
| 2174 |
pScreenPriv->shouldBeUp = FALSE; |
| 2175 |
if (pVNC->cursorIsDrawn) |
| 2176 |
rfbSpriteRemoveCursor (pScreen); |
| 2177 |
pScreenPriv->pCursor = 0; |
| 2178 |
return; |
| 2179 |
} |
| 2180 |
pScreenPriv->shouldBeUp = TRUE; |
| 2181 |
if (pScreenPriv->x == x && |
| 2182 |
pScreenPriv->y == y && |
| 2183 |
pScreenPriv->pCursor == pCursor && |
| 2184 |
!pScreenPriv->checkPixels) |
| 2185 |
{ |
| 2186 |
return; |
| 2187 |
} |
| 2188 |
pScreenPriv->x = x; |
| 2189 |
pScreenPriv->y = y; |
| 2190 |
pScreenPriv->pCacheWin = NullWindow; |
| 2191 |
if (pScreenPriv->checkPixels || pScreenPriv->pCursor != pCursor) |
| 2192 |
{ |
| 2193 |
pScreenPriv->pCursor = pCursor; |
| 2194 |
rfbSpriteFindColors (pScreen); |
| 2195 |
} |
| 2196 |
if (pVNC->cursorIsDrawn) { |
| 2197 |
int sx, sy; |
| 2198 |
/* |
| 2199 |
* check to see if the old saved region |
| 2200 |
* encloses the new sprite, in which case we use |
| 2201 |
* the flicker-free MoveCursor primitive. |
| 2202 |
*/ |
| 2203 |
sx = pScreenPriv->x - (int)pCursor->bits->xhot; |
| 2204 |
sy = pScreenPriv->y - (int)pCursor->bits->yhot; |
| 2205 |
if (sx + (int) pCursor->bits->width >= pScreenPriv->saved.x1 && |
| 2206 |
sx < pScreenPriv->saved.x2 && |
| 2207 |
sy + (int) pCursor->bits->height >= pScreenPriv->saved.y1 && |
| 2208 |
sy < pScreenPriv->saved.y2 && |
| 2209 |
(int) pCursor->bits->width + (2 * SPRITE_PAD) == |
| 2210 |
pScreenPriv->saved.x2 - pScreenPriv->saved.x1 && |
| 2211 |
(int) pCursor->bits->height + (2 * SPRITE_PAD) == |
| 2212 |
pScreenPriv->saved.y2 - pScreenPriv->saved.y1 |
| 2213 |
) |
| 2214 |
{ |
| 2215 |
pVNC->cursorIsDrawn = FALSE; |
| 2216 |
if (!(sx >= pScreenPriv->saved.x1 && |
| 2217 |
sx + (int)pCursor->bits->width < pScreenPriv->saved.x2 && |
| 2218 |
sy >= pScreenPriv->saved.y1 && |
| 2219 |
sy + (int)pCursor->bits->height < pScreenPriv->saved.y2)) |
| 2220 |
{ |
| 2221 |
int oldx1, oldy1, dx, dy; |
| 2222 |
|
| 2223 |
oldx1 = pScreenPriv->saved.x1; |
| 2224 |
oldy1 = pScreenPriv->saved.y1; |
| 2225 |
dx = oldx1 - (sx - SPRITE_PAD); |
| 2226 |
dy = oldy1 - (sy - SPRITE_PAD); |
| 2227 |
pScreenPriv->saved.x1 -= dx; |
| 2228 |
pScreenPriv->saved.y1 -= dy; |
| 2229 |
pScreenPriv->saved.x2 -= dx; |
| 2230 |
pScreenPriv->saved.y2 -= dy; |
| 2231 |
(void) (*pScreenPriv->funcs->ChangeSave) (pScreen, |
| 2232 |
pScreenPriv->saved.x1, |
| 2233 |
pScreenPriv->saved.y1, |
| 2234 |
pScreenPriv->saved.x2 - pScreenPriv->saved.x1, |
| 2235 |
pScreenPriv->saved.y2 - pScreenPriv->saved.y1, |
| 2236 |
dx, dy); |
| 2237 |
} |
| 2238 |
(void) (*pScreenPriv->funcs->MoveCursor) (pScreen, pCursor, |
| 2239 |
pScreenPriv->saved.x1, |
| 2240 |
pScreenPriv->saved.y1, |
| 2241 |
pScreenPriv->saved.x2 - pScreenPriv->saved.x1, |
| 2242 |
pScreenPriv->saved.y2 - pScreenPriv->saved.y1, |
| 2243 |
sx - pScreenPriv->saved.x1, |
| 2244 |
sy - pScreenPriv->saved.y1, |
| 2245 |
pScreenPriv->colors[SOURCE_COLOR].pixel, |
| 2246 |
pScreenPriv->colors[MASK_COLOR].pixel); |
| 2247 |
pVNC->cursorIsDrawn = TRUE; |
| 2248 |
} |
| 2249 |
else |
| 2250 |
{ |
| 2251 |
rfbSpriteRemoveCursor (pScreen); |
| 2252 |
} |
| 2253 |
} |
| 2254 |
#if 0 |
| 2255 |
if (!pVNC->cursorIsDrawn && pScreenPriv->pCursor) |
| 2256 |
rfbSpriteRestoreCursor (pScreen); |
| 2257 |
#endif |
| 2258 |
if (pVNC->cursorIsDrawn) |
| 2259 |
rfbSpriteRemoveCursor (pScreen); |
| 2260 |
|
| 2261 |
for (cl = rfbClientHead; cl; cl = nextCl) { |
| 2262 |
nextCl = cl->next; |
| 2263 |
if (cl->enableCursorPosUpdates) { |
| 2264 |
if (x == cl->cursorX && y == cl->cursorY) { |
| 2265 |
cl->cursorWasMoved = FALSE; |
| 2266 |
continue; |
| 2267 |
} |
| 2268 |
cl->cursorWasMoved = TRUE; |
| 2269 |
} |
| 2270 |
if (REGION_NOTEMPTY(pScreen,&cl->requestedRegion)) { |
| 2271 |
/* cursorIsDrawn is guaranteed to be FALSE here, so we definitely |
| 2272 |
want to send a screen update to the client, even if that's only |
| 2273 |
putting up the cursor */ |
| 2274 |
rfbSendFramebufferUpdate(pScreen, cl); |
| 2275 |
} |
| 2276 |
} |
| 2277 |
} |
| 2278 |
|
| 2279 |
static void |
| 2280 |
rfbSpriteMoveCursor (ScreenPtr pScreen, int x, int y) |
| 2281 |
{ |
| 2282 |
rfbSpriteScreenPtr pScreenPriv; |
| 2283 |
|
| 2284 |
pScreenPriv = (rfbSpriteScreenPtr) pScreen->devPrivates[rfbSpriteScreenIndex].ptr; |
| 2285 |
rfbSpriteSetCursor (pScreen, pScreenPriv->pCursor, x, y); |
| 2286 |
} |
| 2287 |
|
| 2288 |
/* |
| 2289 |
* undraw/draw cursor |
| 2290 |
*/ |
| 2291 |
|
| 2292 |
void |
| 2293 |
rfbSpriteRemoveCursor (pScreen) |
| 2294 |
ScreenPtr pScreen; |
| 2295 |
{ |
| 2296 |
rfbSpriteScreenPtr pScreenPriv; |
| 2297 |
VNCSCREENPTR(pScreen); |
| 2298 |
|
| 2299 |
if (!pVNC->cursorIsDrawn) |
| 2300 |
return; |
| 2301 |
|
| 2302 |
pScreenPriv |
| 2303 |
= (rfbSpriteScreenPtr) pScreen->devPrivates[rfbSpriteScreenIndex].ptr; |
| 2304 |
|
| 2305 |
pVNC->dontSendFramebufferUpdate = TRUE; |
| 2306 |
pVNC->cursorIsDrawn = FALSE; |
| 2307 |
pScreenPriv->pCacheWin = NullWindow; |
| 2308 |
if (!(*pScreenPriv->funcs->RestoreUnderCursor) (pScreen, |
| 2309 |
pScreenPriv->saved.x1, |
| 2310 |
pScreenPriv->saved.y1, |
| 2311 |
pScreenPriv->saved.x2 - pScreenPriv->saved.x1, |
| 2312 |
pScreenPriv->saved.y2 - pScreenPriv->saved.y1)) |
| 2313 |
{ |
| 2314 |
pVNC->cursorIsDrawn = TRUE; |
| 2315 |
} |
| 2316 |
pVNC->dontSendFramebufferUpdate = FALSE; |
| 2317 |
} |
| 2318 |
|
| 2319 |
|
| 2320 |
void |
| 2321 |
rfbSpriteRestoreCursor (pScreen) |
| 2322 |
ScreenPtr pScreen; |
| 2323 |
{ |
| 2324 |
rfbSpriteScreenPtr pScreenPriv; |
| 2325 |
int x, y; |
| 2326 |
CursorPtr pCursor; |
| 2327 |
VNCSCREENPTR(pScreen); |
| 2328 |
|
| 2329 |
pScreenPriv |
| 2330 |
= (rfbSpriteScreenPtr) pScreen->devPrivates[rfbSpriteScreenIndex].ptr; |
| 2331 |
pCursor = pScreenPriv->pCursor; |
| 2332 |
|
| 2333 |
if (pVNC->cursorIsDrawn || !pCursor) |
| 2334 |
return; |
| 2335 |
|
| 2336 |
pVNC->dontSendFramebufferUpdate = TRUE; |
| 2337 |
|
| 2338 |
rfbSpriteComputeSaved (pScreen); |
| 2339 |
|
| 2340 |
x = pScreenPriv->x - (int)pCursor->bits->xhot; |
| 2341 |
y = pScreenPriv->y - (int)pCursor->bits->yhot; |
| 2342 |
if ((*pScreenPriv->funcs->SaveUnderCursor) (pScreen, |
| 2343 |
pScreenPriv->saved.x1, |
| 2344 |
pScreenPriv->saved.y1, |
| 2345 |
pScreenPriv->saved.x2 - pScreenPriv->saved.x1, |
| 2346 |
pScreenPriv->saved.y2 - pScreenPriv->saved.y1)) |
| 2347 |
{ |
| 2348 |
if (pScreenPriv->checkPixels) |
| 2349 |
rfbSpriteFindColors (pScreen); |
| 2350 |
if ((*pScreenPriv->funcs->PutUpCursor) (pScreen, pCursor, x, y, |
| 2351 |
pScreenPriv->colors[SOURCE_COLOR].pixel, |
| 2352 |
pScreenPriv->colors[MASK_COLOR].pixel)) |
| 2353 |
pVNC->cursorIsDrawn = TRUE; |
| 2354 |
} |
| 2355 |
|
| 2356 |
pVNC->dontSendFramebufferUpdate = FALSE; |
| 2357 |
} |
| 2358 |
|
| 2359 |
/* |
| 2360 |
* compute the desired area of the screen to save |
| 2361 |
*/ |
| 2362 |
|
| 2363 |
static void |
| 2364 |
rfbSpriteComputeSaved (pScreen) |
| 2365 |
ScreenPtr pScreen; |
| 2366 |
{ |
| 2367 |
rfbSpriteScreenPtr pScreenPriv; |
| 2368 |
int x, y, w, h; |
| 2369 |
int wpad, hpad; |
| 2370 |
CursorPtr pCursor; |
| 2371 |
|
| 2372 |
pScreenPriv = (rfbSpriteScreenPtr) pScreen->devPrivates[rfbSpriteScreenIndex].ptr; |
| 2373 |
pCursor = pScreenPriv->pCursor; |
| 2374 |
x = pScreenPriv->x - (int)pCursor->bits->xhot; |
| 2375 |
y = pScreenPriv->y - (int)pCursor->bits->yhot; |
| 2376 |
w = pCursor->bits->width; |
| 2377 |
h = pCursor->bits->height; |
| 2378 |
wpad = SPRITE_PAD; |
| 2379 |
hpad = SPRITE_PAD; |
| 2380 |
pScreenPriv->saved.x1 = x - wpad; |
| 2381 |
pScreenPriv->saved.y1 = y - hpad; |
| 2382 |
pScreenPriv->saved.x2 = pScreenPriv->saved.x1 + w + wpad * 2; |
| 2383 |
pScreenPriv->saved.y2 = pScreenPriv->saved.y1 + h + hpad * 2; |
| 2384 |
} |
| 2385 |
|
| 2386 |
|
| 2387 |
/* |
| 2388 |
* this function is called when the cursor shape is being changed |
| 2389 |
*/ |
| 2390 |
|
| 2391 |
static Bool |
| 2392 |
rfbDisplayCursor(pScreen, pCursor) |
| 2393 |
ScreenPtr pScreen; |
| 2394 |
CursorPtr pCursor; |
| 2395 |
{ |
| 2396 |
rfbClientPtr cl; |
| 2397 |
rfbSpriteScreenPtr pPriv; |
| 2398 |
Bool status; |
| 2399 |
|
| 2400 |
for (cl = rfbClientHead; cl ; cl = cl->next) { |
| 2401 |
if (cl->enableCursorShapeUpdates) |
| 2402 |
cl->cursorWasChanged = TRUE; |
| 2403 |
} |
| 2404 |
|
| 2405 |
pPriv = (rfbSpriteScreenPtr)pScreen->devPrivates[rfbSpriteScreenIndex].ptr; |
| 2406 |
status = (*pPriv->DisplayCursor)(pScreen, pCursor); |
| 2407 |
|
| 2408 |
/* send new cursor shape to interested viewers */ |
| 2409 |
for (cl = rfbClientHead; cl ; cl = cl->next) { |
| 2410 |
if (cl->cursorWasChanged) { |
| 2411 |
rfbSendFramebufferUpdate(pScreen, cl); |
| 2412 |
} |
| 2413 |
} |
| 2414 |
|
| 2415 |
return status; |
| 2416 |
} |
| 2417 |
|
| 2418 |
|
| 2419 |
/* |
| 2420 |
* obtain current cursor pointer |
| 2421 |
*/ |
| 2422 |
|
| 2423 |
CursorPtr |
| 2424 |
rfbSpriteGetCursorPtr (pScreen) |
| 2425 |
ScreenPtr pScreen; |
| 2426 |
{ |
| 2427 |
rfbSpriteScreenPtr pScreenPriv; |
| 2428 |
|
| 2429 |
pScreenPriv = (rfbSpriteScreenPtr) |
| 2430 |
pScreen->devPrivates[rfbSpriteScreenIndex].ptr; |
| 2431 |
|
| 2432 |
return pScreenPriv->pCursor; |
| 2433 |
} |
| 2434 |
|
| 2435 |
/* |
| 2436 |
* obtain current cursor position |
| 2437 |
*/ |
| 2438 |
|
| 2439 |
void |
| 2440 |
rfbSpriteGetCursorPos (pScreen, px, py) |
| 2441 |
ScreenPtr pScreen; |
| 2442 |
int *px, *py; |
| 2443 |
{ |
| 2444 |
rfbSpriteScreenPtr pScreenPriv; |
| 2445 |
|
| 2446 |
pScreenPriv = (rfbSpriteScreenPtr) |
| 2447 |
pScreen->devPrivates[rfbSpriteScreenIndex].ptr; |
| 2448 |
|
| 2449 |
*px = pScreenPriv->x; |
| 2450 |
*py = pScreenPriv->y; |
| 2451 |
} |
| 2452 |
|