Moved a few remaining 16-bit window functions to wnd16.c and moved it
[wine/multimedia.git] / graphics / x11drv / graphics.c
blobc36646d0a787aa486f2daeb9a044a6088d8eb5db
1 /*
2 * X11 graphics driver graphics functions
4 * Copyright 1993,1994 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * FIXME: only some of these functions obey the GM_ADVANCED
23 * graphics mode
26 #include "config.h"
28 #include <X11/Intrinsic.h>
30 #include "ts_xlib.h"
31 #include <X11/Xresource.h>
32 #include <X11/Xutil.h>
34 #include <math.h>
35 #ifdef HAVE_FLOAT_H
36 # include <float.h>
37 #endif
38 #include <stdlib.h>
39 #ifndef PI
40 #define PI M_PI
41 #endif
42 #include <string.h>
44 #include "x11drv.h"
45 #include "x11font.h"
46 #include "bitmap.h"
47 #include "gdi.h"
48 #include "palette.h"
49 #include "wine/debug.h"
51 WINE_DEFAULT_DEBUG_CHANNEL(graphics);
53 #define ABS(x) ((x)<0?(-(x)):(x))
55 /* ROP code to GC function conversion */
56 const int X11DRV_XROPfunction[16] =
58 GXclear, /* R2_BLACK */
59 GXnor, /* R2_NOTMERGEPEN */
60 GXandInverted, /* R2_MASKNOTPEN */
61 GXcopyInverted, /* R2_NOTCOPYPEN */
62 GXandReverse, /* R2_MASKPENNOT */
63 GXinvert, /* R2_NOT */
64 GXxor, /* R2_XORPEN */
65 GXnand, /* R2_NOTMASKPEN */
66 GXand, /* R2_MASKPEN */
67 GXequiv, /* R2_NOTXORPEN */
68 GXnoop, /* R2_NOP */
69 GXorInverted, /* R2_MERGENOTPEN */
70 GXcopy, /* R2_COPYPEN */
71 GXorReverse, /* R2_MERGEPENNOT */
72 GXor, /* R2_MERGEPEN */
73 GXset /* R2_WHITE */
77 /***********************************************************************
78 * X11DRV_SetupGCForPatBlt
80 * Setup the GC for a PatBlt operation using current brush.
81 * If fMapColors is TRUE, X pixels are mapped to Windows colors.
82 * Return FALSE if brush is BS_NULL, TRUE otherwise.
84 BOOL X11DRV_SetupGCForPatBlt( X11DRV_PDEVICE *physDev, GC gc, BOOL fMapColors )
86 XGCValues val;
87 unsigned long mask;
88 Pixmap pixmap = 0;
89 POINT pt;
91 if (physDev->brush.style == BS_NULL) return FALSE;
92 if (physDev->brush.pixel == -1)
94 /* Special case used for monochrome pattern brushes.
95 * We need to swap foreground and background because
96 * Windows does it the wrong way...
98 val.foreground = physDev->backgroundPixel;
99 val.background = physDev->textPixel;
101 else
103 val.foreground = physDev->brush.pixel;
104 val.background = physDev->backgroundPixel;
106 if (fMapColors && X11DRV_PALETTE_XPixelToPalette)
108 val.foreground = X11DRV_PALETTE_XPixelToPalette[val.foreground];
109 val.background = X11DRV_PALETTE_XPixelToPalette[val.background];
112 val.function = X11DRV_XROPfunction[GetROP2(physDev->hdc)-1];
114 ** Let's replace GXinvert by GXxor with (black xor white)
115 ** This solves the selection color and leak problems in excel
116 ** FIXME : Let's do that only if we work with X-pixels, not with Win-pixels
118 if (val.function == GXinvert)
120 val.foreground = (WhitePixel( gdi_display, DefaultScreen(gdi_display) ) ^
121 BlackPixel( gdi_display, DefaultScreen(gdi_display) ));
122 val.function = GXxor;
124 val.fill_style = physDev->brush.fillStyle;
125 switch(val.fill_style)
127 case FillStippled:
128 case FillOpaqueStippled:
129 if (GetBkMode(physDev->hdc)==OPAQUE) val.fill_style = FillOpaqueStippled;
130 val.stipple = physDev->brush.pixmap;
131 mask = GCStipple;
132 break;
134 case FillTiled:
135 if (fMapColors && X11DRV_PALETTE_XPixelToPalette)
137 register int x, y;
138 XImage *image;
139 wine_tsx11_lock();
140 pixmap = XCreatePixmap( gdi_display, root_window, 8, 8, screen_depth );
141 image = XGetImage( gdi_display, physDev->brush.pixmap, 0, 0, 8, 8,
142 AllPlanes, ZPixmap );
143 for (y = 0; y < 8; y++)
144 for (x = 0; x < 8; x++)
145 XPutPixel( image, x, y,
146 X11DRV_PALETTE_XPixelToPalette[XGetPixel( image, x, y)] );
147 XPutImage( gdi_display, pixmap, gc, image, 0, 0, 0, 0, 8, 8 );
148 XDestroyImage( image );
149 wine_tsx11_unlock();
150 val.tile = pixmap;
152 else val.tile = physDev->brush.pixmap;
153 mask = GCTile;
154 break;
156 default:
157 mask = 0;
158 break;
160 GetBrushOrgEx( physDev->hdc, &pt );
161 val.ts_x_origin = physDev->org.x + pt.x;
162 val.ts_y_origin = physDev->org.y + pt.y;
163 val.fill_rule = (GetPolyFillMode(physDev->hdc) == WINDING) ? WindingRule : EvenOddRule;
164 wine_tsx11_lock();
165 XChangeGC( gdi_display, gc,
166 GCFunction | GCForeground | GCBackground | GCFillStyle |
167 GCFillRule | GCTileStipXOrigin | GCTileStipYOrigin | mask,
168 &val );
169 if (pixmap) XFreePixmap( gdi_display, pixmap );
170 wine_tsx11_unlock();
171 return TRUE;
175 /***********************************************************************
176 * X11DRV_SetupGCForBrush
178 * Setup physDev->gc for drawing operations using current brush.
179 * Return FALSE if brush is BS_NULL, TRUE otherwise.
181 BOOL X11DRV_SetupGCForBrush( X11DRV_PDEVICE *physDev )
183 return X11DRV_SetupGCForPatBlt( physDev, physDev->gc, FALSE );
187 /***********************************************************************
188 * X11DRV_SetupGCForPen
190 * Setup physDev->gc for drawing operations using current pen.
191 * Return FALSE if pen is PS_NULL, TRUE otherwise.
193 BOOL X11DRV_SetupGCForPen( X11DRV_PDEVICE *physDev )
195 XGCValues val;
196 UINT rop2 = GetROP2(physDev->hdc);
198 if (physDev->pen.style == PS_NULL) return FALSE;
200 switch (rop2)
202 case R2_BLACK :
203 val.foreground = BlackPixel( gdi_display, DefaultScreen(gdi_display) );
204 val.function = GXcopy;
205 break;
206 case R2_WHITE :
207 val.foreground = WhitePixel( gdi_display, DefaultScreen(gdi_display) );
208 val.function = GXcopy;
209 break;
210 case R2_XORPEN :
211 val.foreground = physDev->pen.pixel;
212 /* It is very unlikely someone wants to XOR with 0 */
213 /* This fixes the rubber-drawings in paintbrush */
214 if (val.foreground == 0)
215 val.foreground = (WhitePixel( gdi_display, DefaultScreen(gdi_display) ) ^
216 BlackPixel( gdi_display, DefaultScreen(gdi_display) ));
217 val.function = GXxor;
218 break;
219 default :
220 val.foreground = physDev->pen.pixel;
221 val.function = X11DRV_XROPfunction[rop2-1];
223 val.background = physDev->backgroundPixel;
224 val.fill_style = FillSolid;
225 if ((physDev->pen.width <= 1) &&
226 (physDev->pen.style != PS_SOLID) &&
227 (physDev->pen.style != PS_INSIDEFRAME))
229 TSXSetDashes( gdi_display, physDev->gc, 0, physDev->pen.dashes, physDev->pen.dash_len );
230 val.line_style = (GetBkMode(physDev->hdc) == OPAQUE) ? LineDoubleDash : LineOnOffDash;
232 else val.line_style = LineSolid;
233 val.line_width = physDev->pen.width;
234 if (val.line_width <= 1) {
235 val.cap_style = CapNotLast;
236 } else {
237 switch (physDev->pen.endcap)
239 case PS_ENDCAP_SQUARE:
240 val.cap_style = CapProjecting;
241 break;
242 case PS_ENDCAP_FLAT:
243 val.cap_style = CapButt;
244 break;
245 case PS_ENDCAP_ROUND:
246 default:
247 val.cap_style = CapRound;
250 switch (physDev->pen.linejoin)
252 case PS_JOIN_BEVEL:
253 val.join_style = JoinBevel;
254 break;
255 case PS_JOIN_MITER:
256 val.join_style = JoinMiter;
257 break;
258 case PS_JOIN_ROUND:
259 default:
260 val.join_style = JoinRound;
262 TSXChangeGC( gdi_display, physDev->gc,
263 GCFunction | GCForeground | GCBackground | GCLineWidth |
264 GCLineStyle | GCCapStyle | GCJoinStyle | GCFillStyle, &val );
265 return TRUE;
269 /***********************************************************************
270 * X11DRV_SetupGCForText
272 * Setup physDev->gc for text drawing operations.
273 * Return FALSE if the font is null, TRUE otherwise.
275 BOOL X11DRV_SetupGCForText( X11DRV_PDEVICE *physDev )
277 XFontStruct* xfs = XFONT_GetFontStruct( physDev->font );
279 if( xfs )
281 XGCValues val;
283 val.function = GXcopy; /* Text is always GXcopy */
284 val.foreground = physDev->textPixel;
285 val.background = physDev->backgroundPixel;
286 val.fill_style = FillSolid;
287 val.font = xfs->fid;
289 TSXChangeGC( gdi_display, physDev->gc,
290 GCFunction | GCForeground | GCBackground | GCFillStyle |
291 GCFont, &val );
292 return TRUE;
294 WARN("Physical font failure\n" );
295 return FALSE;
298 /***********************************************************************
299 * X11DRV_LineTo
301 BOOL
302 X11DRV_LineTo( X11DRV_PDEVICE *physDev, INT x, INT y )
304 POINT pt[2];
306 if (X11DRV_SetupGCForPen( physDev )) {
307 /* Update the pixmap from the DIB section */
308 X11DRV_LockDIBSection(physDev, DIB_Status_GdiMod, FALSE);
310 GetCurrentPositionEx( physDev->hdc, &pt[0] );
311 pt[1].x = x;
312 pt[1].y = y;
313 LPtoDP( physDev->hdc, pt, 2 );
315 TSXDrawLine(gdi_display, physDev->drawable, physDev->gc,
316 physDev->org.x + pt[0].x, physDev->org.y + pt[0].y,
317 physDev->org.x + pt[1].x, physDev->org.y + pt[1].y );
319 /* Update the DIBSection from the pixmap */
320 X11DRV_UnlockDIBSection(physDev, TRUE);
322 return TRUE;
327 /***********************************************************************
328 * X11DRV_DrawArc
330 * Helper functions for Arc(), Chord() and Pie().
331 * 'lines' is the number of lines to draw: 0 for Arc, 1 for Chord, 2 for Pie.
334 static BOOL
335 X11DRV_DrawArc( X11DRV_PDEVICE *physDev, INT left, INT top, INT right,
336 INT bottom, INT xstart, INT ystart,
337 INT xend, INT yend, INT lines )
339 INT xcenter, ycenter, istart_angle, idiff_angle;
340 INT width, oldwidth, oldendcap;
341 double start_angle, end_angle;
342 XPoint points[4];
343 BOOL update = FALSE;
344 POINT start, end;
345 RECT rc;
347 SetRect(&rc, left, top, right, bottom);
348 start.x = xstart;
349 start.y = ystart;
350 end.x = xend;
351 end.y = yend;
352 LPtoDP(physDev->hdc, (POINT*)&rc, 2);
353 LPtoDP(physDev->hdc, &start, 1);
354 LPtoDP(physDev->hdc, &end, 1);
356 if (rc.right < rc.left) { INT tmp = rc.right; rc.right = rc.left; rc.left = tmp; }
357 if (rc.bottom < rc.top) { INT tmp = rc.bottom; rc.bottom = rc.top; rc.top = tmp; }
358 if ((rc.left == rc.right) || (rc.top == rc.bottom)
359 ||(lines && ((rc.right-rc.left==1)||(rc.bottom-rc.top==1)))) return TRUE;
361 if (GetArcDirection( physDev->hdc ) == AD_CLOCKWISE)
362 { POINT tmp = start; start = end; end = tmp; }
364 oldwidth = width = physDev->pen.width;
365 oldendcap = physDev->pen.endcap;
366 if (!width) width = 1;
367 if(physDev->pen.style == PS_NULL) width = 0;
369 if ((physDev->pen.style == PS_INSIDEFRAME))
371 if (2*width > (rc.right-rc.left)) width=(rc.right-rc.left + 1)/2;
372 if (2*width > (rc.bottom-rc.top)) width=(rc.bottom-rc.top + 1)/2;
373 rc.left += width / 2;
374 rc.right -= (width - 1) / 2;
375 rc.top += width / 2;
376 rc.bottom -= (width - 1) / 2;
378 if(width == 0) width = 1; /* more accurate */
379 physDev->pen.width = width;
380 physDev->pen.endcap = PS_ENDCAP_SQUARE;
382 xcenter = (rc.right + rc.left) / 2;
383 ycenter = (rc.bottom + rc.top) / 2;
384 start_angle = atan2( (double)(ycenter-start.y)*(rc.right-rc.left),
385 (double)(start.x-xcenter)*(rc.bottom-rc.top) );
386 end_angle = atan2( (double)(ycenter-end.y)*(rc.right-rc.left),
387 (double)(end.x-xcenter)*(rc.bottom-rc.top) );
388 if ((start.x==end.x)&&(start.y==end.y))
389 { /* A lazy program delivers xstart=xend=ystart=yend=0) */
390 start_angle = 0;
391 end_angle = 2* PI;
393 else /* notorious cases */
394 if ((start_angle == PI)&&( end_angle <0))
395 start_angle = - PI;
396 else
397 if ((end_angle == PI)&&( start_angle <0))
398 end_angle = - PI;
399 istart_angle = (INT)(start_angle * 180 * 64 / PI + 0.5);
400 idiff_angle = (INT)((end_angle - start_angle) * 180 * 64 / PI + 0.5);
401 if (idiff_angle <= 0) idiff_angle += 360 * 64;
403 /* Update the pixmap from the DIB section */
404 X11DRV_LockDIBSection(physDev, DIB_Status_GdiMod, FALSE);
406 /* Fill arc with brush if Chord() or Pie() */
408 if ((lines > 0) && X11DRV_SetupGCForBrush( physDev )) {
409 TSXSetArcMode( gdi_display, physDev->gc, (lines==1) ? ArcChord : ArcPieSlice);
410 TSXFillArc( gdi_display, physDev->drawable, physDev->gc,
411 physDev->org.x + rc.left, physDev->org.y + rc.top,
412 rc.right-rc.left-1, rc.bottom-rc.top-1, istart_angle, idiff_angle );
413 update = TRUE;
416 /* Draw arc and lines */
418 if (X11DRV_SetupGCForPen( physDev )){
419 TSXDrawArc( gdi_display, physDev->drawable, physDev->gc,
420 physDev->org.x + rc.left, physDev->org.y + rc.top,
421 rc.right-rc.left-1, rc.bottom-rc.top-1, istart_angle, idiff_angle );
422 if (lines) {
423 /* use the truncated values */
424 start_angle=(double)istart_angle*PI/64./180.;
425 end_angle=(double)(istart_angle+idiff_angle)*PI/64./180.;
426 /* calculate the endpoints and round correctly */
427 points[0].x = (int) floor(physDev->org.x + (rc.right+rc.left)/2.0 +
428 cos(start_angle) * (rc.right-rc.left-width*2+2) / 2. + 0.5);
429 points[0].y = (int) floor(physDev->org.y + (rc.top+rc.bottom)/2.0 -
430 sin(start_angle) * (rc.bottom-rc.top-width*2+2) / 2. + 0.5);
431 points[1].x = (int) floor(physDev->org.x + (rc.right+rc.left)/2.0 +
432 cos(end_angle) * (rc.right-rc.left-width*2+2) / 2. + 0.5);
433 points[1].y = (int) floor(physDev->org.y + (rc.top+rc.bottom)/2.0 -
434 sin(end_angle) * (rc.bottom-rc.top-width*2+2) / 2. + 0.5);
436 /* OK, this stuff is optimized for Xfree86
437 * which is probably the server most used by
438 * wine users. Other X servers will not
439 * display correctly. (eXceed for instance)
440 * so if you feel you must make changes, make sure that
441 * you either use Xfree86 or separate your changes
442 * from these (compile switch or whatever)
444 if (lines == 2) {
445 INT dx1,dy1;
446 points[3] = points[1];
447 points[1].x = physDev->org.x + xcenter;
448 points[1].y = physDev->org.y + ycenter;
449 points[2] = points[1];
450 dx1=points[1].x-points[0].x;
451 dy1=points[1].y-points[0].y;
452 if(((rc.top-rc.bottom) | -2) == -2)
453 if(dy1>0) points[1].y--;
454 if(dx1<0) {
455 if (((-dx1)*64)<=ABS(dy1)*37) points[0].x--;
456 if(((-dx1*9))<(dy1*16)) points[0].y--;
457 if( dy1<0 && ((dx1*9)) < (dy1*16)) points[0].y--;
458 } else {
459 if(dy1 < 0) points[0].y--;
460 if(((rc.right-rc.left) | -2) == -2) points[1].x--;
462 dx1=points[3].x-points[2].x;
463 dy1=points[3].y-points[2].y;
464 if(((rc.top-rc.bottom) | -2 ) == -2)
465 if(dy1 < 0) points[2].y--;
466 if( dx1<0){
467 if( dy1>0) points[3].y--;
468 if(((rc.right-rc.left) | -2) == -2 ) points[2].x--;
469 }else {
470 points[3].y--;
471 if( dx1 * 64 < dy1 * -37 ) points[3].x--;
473 lines++;
475 TSXDrawLines( gdi_display, physDev->drawable, physDev->gc,
476 points, lines+1, CoordModeOrigin );
478 update = TRUE;
481 /* Update the DIBSection of the pixmap */
482 X11DRV_UnlockDIBSection(physDev, update);
484 physDev->pen.width = oldwidth;
485 physDev->pen.endcap = oldendcap;
486 return TRUE;
490 /***********************************************************************
491 * X11DRV_Arc
493 BOOL
494 X11DRV_Arc( X11DRV_PDEVICE *physDev, INT left, INT top, INT right, INT bottom,
495 INT xstart, INT ystart, INT xend, INT yend )
497 return X11DRV_DrawArc( physDev, left, top, right, bottom,
498 xstart, ystart, xend, yend, 0 );
502 /***********************************************************************
503 * X11DRV_Pie
505 BOOL
506 X11DRV_Pie( X11DRV_PDEVICE *physDev, INT left, INT top, INT right, INT bottom,
507 INT xstart, INT ystart, INT xend, INT yend )
509 return X11DRV_DrawArc( physDev, left, top, right, bottom,
510 xstart, ystart, xend, yend, 2 );
513 /***********************************************************************
514 * X11DRV_Chord
516 BOOL
517 X11DRV_Chord( X11DRV_PDEVICE *physDev, INT left, INT top, INT right, INT bottom,
518 INT xstart, INT ystart, INT xend, INT yend )
520 return X11DRV_DrawArc( physDev, left, top, right, bottom,
521 xstart, ystart, xend, yend, 1 );
525 /***********************************************************************
526 * X11DRV_Ellipse
528 BOOL
529 X11DRV_Ellipse( X11DRV_PDEVICE *physDev, INT left, INT top, INT right, INT bottom )
531 INT width, oldwidth;
532 BOOL update = FALSE;
533 RECT rc;
535 SetRect(&rc, left, top, right, bottom);
536 LPtoDP(physDev->hdc, (POINT*)&rc, 2);
538 if ((rc.left == rc.right) || (rc.top == rc.bottom)) return TRUE;
540 if (rc.right < rc.left) { INT tmp = rc.right; rc.right = rc.left; rc.left = tmp; }
541 if (rc.bottom < rc.top) { INT tmp = rc.bottom; rc.bottom = rc.top; rc.top = tmp; }
543 oldwidth = width = physDev->pen.width;
544 if (!width) width = 1;
545 if(physDev->pen.style == PS_NULL) width = 0;
547 if ((physDev->pen.style == PS_INSIDEFRAME))
549 if (2*width > (rc.right-rc.left)) width=(rc.right-rc.left + 1)/2;
550 if (2*width > (rc.bottom-rc.top)) width=(rc.bottom-rc.top + 1)/2;
551 rc.left += width / 2;
552 rc.right -= (width - 1) / 2;
553 rc.top += width / 2;
554 rc.bottom -= (width - 1) / 2;
556 if(width == 0) width = 1; /* more accurate */
557 physDev->pen.width = width;
559 /* Update the pixmap from the DIB section */
560 X11DRV_LockDIBSection(physDev, DIB_Status_GdiMod, FALSE);
562 if (X11DRV_SetupGCForBrush( physDev ))
564 TSXFillArc( gdi_display, physDev->drawable, physDev->gc,
565 physDev->org.x + rc.left, physDev->org.y + rc.top,
566 rc.right-rc.left-1, rc.bottom-rc.top-1, 0, 360*64 );
567 update = TRUE;
569 if (X11DRV_SetupGCForPen( physDev ))
571 TSXDrawArc( gdi_display, physDev->drawable, physDev->gc,
572 physDev->org.x + rc.left, physDev->org.y + rc.top,
573 rc.right-rc.left-1, rc.bottom-rc.top-1, 0, 360*64 );
574 update = TRUE;
577 /* Update the DIBSection from the pixmap */
578 X11DRV_UnlockDIBSection(physDev, update);
580 physDev->pen.width = oldwidth;
581 return TRUE;
585 /***********************************************************************
586 * X11DRV_Rectangle
588 BOOL
589 X11DRV_Rectangle(X11DRV_PDEVICE *physDev, INT left, INT top, INT right, INT bottom)
591 INT width, oldwidth, oldjoinstyle;
592 BOOL update = FALSE;
593 RECT rc;
595 TRACE("(%d %d %d %d)\n", left, top, right, bottom);
597 SetRect(&rc, left, top, right, bottom);
598 LPtoDP(physDev->hdc, (POINT*)&rc, 2);
600 if ((rc.left == rc.right) || (rc.top == rc.bottom)) return TRUE;
602 if (rc.right < rc.left) { INT tmp = rc.right; rc.right = rc.left; rc.left = tmp; }
603 if (rc.bottom < rc.top) { INT tmp = rc.bottom; rc.bottom = rc.top; rc.top = tmp; }
605 oldwidth = width = physDev->pen.width;
606 if (!width) width = 1;
607 if(physDev->pen.style == PS_NULL) width = 0;
609 if ((physDev->pen.style == PS_INSIDEFRAME))
611 if (2*width > (rc.right-rc.left)) width=(rc.right-rc.left + 1)/2;
612 if (2*width > (rc.bottom-rc.top)) width=(rc.bottom-rc.top + 1)/2;
613 rc.left += width / 2;
614 rc.right -= (width - 1) / 2;
615 rc.top += width / 2;
616 rc.bottom -= (width - 1) / 2;
618 if(width == 1) width = 0;
619 physDev->pen.width = width;
620 oldjoinstyle = physDev->pen.linejoin;
621 if(physDev->pen.type != PS_GEOMETRIC)
622 physDev->pen.linejoin = PS_JOIN_MITER;
624 /* Update the pixmap from the DIB section */
625 X11DRV_LockDIBSection(physDev, DIB_Status_GdiMod, FALSE);
627 if ((rc.right > rc.left + width) && (rc.bottom > rc.top + width))
629 if (X11DRV_SetupGCForBrush( physDev ))
631 TSXFillRectangle( gdi_display, physDev->drawable, physDev->gc,
632 physDev->org.x + rc.left + (width + 1) / 2,
633 physDev->org.y + rc.top + (width + 1) / 2,
634 rc.right-rc.left-width-1, rc.bottom-rc.top-width-1);
635 update = TRUE;
638 if (X11DRV_SetupGCForPen( physDev ))
640 TSXDrawRectangle( gdi_display, physDev->drawable, physDev->gc,
641 physDev->org.x + rc.left, physDev->org.y + rc.top,
642 rc.right-rc.left-1, rc.bottom-rc.top-1 );
643 update = TRUE;
646 /* Update the DIBSection from the pixmap */
647 X11DRV_UnlockDIBSection(physDev, update);
649 physDev->pen.width = oldwidth;
650 physDev->pen.linejoin = oldjoinstyle;
651 return TRUE;
654 /***********************************************************************
655 * X11DRV_RoundRect
657 BOOL
658 X11DRV_RoundRect( X11DRV_PDEVICE *physDev, INT left, INT top, INT right,
659 INT bottom, INT ell_width, INT ell_height )
661 INT width, oldwidth, oldendcap;
662 BOOL update = FALSE;
663 RECT rc;
664 POINT pts[2];
666 TRACE("(%d %d %d %d %d %d\n",
667 left, top, right, bottom, ell_width, ell_height);
669 SetRect(&rc, left, top, right, bottom);
670 LPtoDP(physDev->hdc, (POINT*)&rc, 2);
672 if ((rc.left == rc.right) || (rc.top == rc.bottom))
673 return TRUE;
675 /* Make sure ell_width and ell_height are >= 1 otherwise XDrawArc gets
676 called with width/height < 0 */
677 pts[0].x = pts[0].y = 0;
678 pts[1].x = ell_width;
679 pts[1].y = ell_height;
680 LPtoDP(physDev->hdc, pts, 2);
681 ell_width = max(abs( pts[1].x - pts[0].x ), 1);
682 ell_height = max(abs( pts[1].y - pts[0].y ), 1);
684 /* Fix the coordinates */
686 if (rc.right < rc.left) { INT tmp = rc.right; rc.right = rc.left; rc.left = tmp; }
687 if (rc.bottom < rc.top) { INT tmp = rc.bottom; rc.bottom = rc.top; rc.top = tmp; }
689 oldwidth = width = physDev->pen.width;
690 oldendcap = physDev->pen.endcap;
691 if (!width) width = 1;
692 if(physDev->pen.style == PS_NULL) width = 0;
694 if ((physDev->pen.style == PS_INSIDEFRAME))
696 if (2*width > (rc.right-rc.left)) width=(rc.right-rc.left + 1)/2;
697 if (2*width > (rc.bottom-rc.top)) width=(rc.bottom-rc.top + 1)/2;
698 rc.left += width / 2;
699 rc.right -= (width - 1) / 2;
700 rc.top += width / 2;
701 rc.bottom -= (width - 1) / 2;
703 if(width == 0) width = 1;
704 physDev->pen.width = width;
705 physDev->pen.endcap = PS_ENDCAP_SQUARE;
707 /* Update the pixmap from the DIB section */
708 X11DRV_LockDIBSection(physDev, DIB_Status_GdiMod, FALSE);
710 wine_tsx11_lock();
711 if (X11DRV_SetupGCForBrush( physDev ))
713 if (ell_width > (rc.right-rc.left) )
714 if (ell_height > (rc.bottom-rc.top) )
715 XFillArc( gdi_display, physDev->drawable, physDev->gc,
716 physDev->org.x + rc.left, physDev->org.y + rc.top,
717 rc.right - rc.left - 1, rc.bottom - rc.top - 1,
718 0, 360 * 64 );
719 else{
720 XFillArc( gdi_display, physDev->drawable, physDev->gc,
721 physDev->org.x + rc.left, physDev->org.y + rc.top,
722 rc.right - rc.left - 1, ell_height, 0, 180 * 64 );
723 XFillArc( gdi_display, physDev->drawable, physDev->gc,
724 physDev->org.x + rc.left,
725 physDev->org.y + rc.bottom - ell_height - 1,
726 rc.right - rc.left - 1, ell_height, 180 * 64,
727 180 * 64 );
729 else if (ell_height > (rc.bottom-rc.top) ){
730 XFillArc( gdi_display, physDev->drawable, physDev->gc,
731 physDev->org.x + rc.left, physDev->org.y + rc.top,
732 ell_width, rc.bottom - rc.top - 1, 90 * 64, 180 * 64 );
733 XFillArc( gdi_display, physDev->drawable, physDev->gc,
734 physDev->org.x + rc.right - ell_width - 1, physDev->org.y + rc.top,
735 ell_width, rc.bottom - rc.top - 1, 270 * 64, 180 * 64 );
736 }else{
737 XFillArc( gdi_display, physDev->drawable, physDev->gc,
738 physDev->org.x + rc.left, physDev->org.y + rc.top,
739 ell_width, ell_height, 90 * 64, 90 * 64 );
740 XFillArc( gdi_display, physDev->drawable, physDev->gc,
741 physDev->org.x + rc.left,
742 physDev->org.y + rc.bottom - ell_height - 1,
743 ell_width, ell_height, 180 * 64, 90 * 64 );
744 XFillArc( gdi_display, physDev->drawable, physDev->gc,
745 physDev->org.x + rc.right - ell_width - 1,
746 physDev->org.y + rc.bottom - ell_height - 1,
747 ell_width, ell_height, 270 * 64, 90 * 64 );
748 XFillArc( gdi_display, physDev->drawable, physDev->gc,
749 physDev->org.x + rc.right - ell_width - 1,
750 physDev->org.y + rc.top,
751 ell_width, ell_height, 0, 90 * 64 );
753 if (ell_width < rc.right - rc.left)
755 XFillRectangle( gdi_display, physDev->drawable, physDev->gc,
756 physDev->org.x + rc.left + (ell_width + 1) / 2,
757 physDev->org.y + rc.top + 1,
758 rc.right - rc.left - ell_width - 1,
759 (ell_height + 1) / 2 - 1);
760 XFillRectangle( gdi_display, physDev->drawable, physDev->gc,
761 physDev->org.x + rc.left + (ell_width + 1) / 2,
762 physDev->org.y + rc.bottom - (ell_height) / 2 - 1,
763 rc.right - rc.left - ell_width - 1,
764 (ell_height) / 2 );
766 if (ell_height < rc.bottom - rc.top)
768 XFillRectangle( gdi_display, physDev->drawable, physDev->gc,
769 physDev->org.x + rc.left + 1,
770 physDev->org.y + rc.top + (ell_height + 1) / 2,
771 rc.right - rc.left - 2,
772 rc.bottom - rc.top - ell_height - 1);
774 update = TRUE;
776 /* FIXME: this could be done with on X call
777 * more efficient and probably more correct
778 * on any X server: XDrawArcs will draw
779 * straight horizontal and vertical lines
780 * if width or height are zero.
782 * BTW this stuff is optimized for an Xfree86 server
783 * read the comments inside the X11DRV_DrawArc function
785 if (X11DRV_SetupGCForPen( physDev ))
787 if (ell_width > (rc.right-rc.left) )
788 if (ell_height > (rc.bottom-rc.top) )
789 XDrawArc( gdi_display, physDev->drawable, physDev->gc,
790 physDev->org.x + rc.left, physDev->org.y + rc.top,
791 rc.right - rc.left - 1, rc.bottom - rc.top - 1, 0 , 360 * 64 );
792 else{
793 XDrawArc( gdi_display, physDev->drawable, physDev->gc,
794 physDev->org.x + rc.left, physDev->org.y + rc.top,
795 rc.right - rc.left - 1, ell_height - 1, 0 , 180 * 64 );
796 XDrawArc( gdi_display, physDev->drawable, physDev->gc,
797 physDev->org.x + rc.left,
798 physDev->org.y + rc.bottom - ell_height,
799 rc.right - rc.left - 1, ell_height - 1, 180 * 64 , 180 * 64 );
801 else if (ell_height > (rc.bottom-rc.top) ){
802 XDrawArc( gdi_display, physDev->drawable, physDev->gc,
803 physDev->org.x + rc.left, physDev->org.y + rc.top,
804 ell_width - 1 , rc.bottom - rc.top - 1, 90 * 64 , 180 * 64 );
805 XDrawArc( gdi_display, physDev->drawable, physDev->gc,
806 physDev->org.x + rc.right - ell_width,
807 physDev->org.y + rc.top,
808 ell_width - 1 , rc.bottom - rc.top - 1, 270 * 64 , 180 * 64 );
809 }else{
810 XDrawArc( gdi_display, physDev->drawable, physDev->gc,
811 physDev->org.x + rc.left, physDev->org.y + rc.top,
812 ell_width - 1, ell_height - 1, 90 * 64, 90 * 64 );
813 XDrawArc( gdi_display, physDev->drawable, physDev->gc,
814 physDev->org.x + rc.left, physDev->org.y + rc.bottom - ell_height,
815 ell_width - 1, ell_height - 1, 180 * 64, 90 * 64 );
816 XDrawArc( gdi_display, physDev->drawable, physDev->gc,
817 physDev->org.x + rc.right - ell_width,
818 physDev->org.y + rc.bottom - ell_height,
819 ell_width - 1, ell_height - 1, 270 * 64, 90 * 64 );
820 XDrawArc( gdi_display, physDev->drawable, physDev->gc,
821 physDev->org.x + rc.right - ell_width, physDev->org.y + rc.top,
822 ell_width - 1, ell_height - 1, 0, 90 * 64 );
824 if (ell_width < rc.right - rc.left)
826 XDrawLine( gdi_display, physDev->drawable, physDev->gc,
827 physDev->org.x + rc.left + ell_width / 2,
828 physDev->org.y + rc.top,
829 physDev->org.x + rc.right - (ell_width+1) / 2,
830 physDev->org.y + rc.top);
831 XDrawLine( gdi_display, physDev->drawable, physDev->gc,
832 physDev->org.x + rc.left + ell_width / 2 ,
833 physDev->org.y + rc.bottom - 1,
834 physDev->org.x + rc.right - (ell_width+1)/ 2,
835 physDev->org.y + rc.bottom - 1);
837 if (ell_height < rc.bottom - rc.top)
839 XDrawLine( gdi_display, physDev->drawable, physDev->gc,
840 physDev->org.x + rc.right - 1,
841 physDev->org.y + rc.top + ell_height / 2,
842 physDev->org.x + rc.right - 1,
843 physDev->org.y + rc.bottom - (ell_height+1) / 2);
844 XDrawLine( gdi_display, physDev->drawable, physDev->gc,
845 physDev->org.x + rc.left,
846 physDev->org.y + rc.top + ell_height / 2,
847 physDev->org.x + rc.left,
848 physDev->org.y + rc.bottom - (ell_height+1) / 2);
850 update = TRUE;
852 wine_tsx11_unlock();
853 /* Update the DIBSection from the pixmap */
854 X11DRV_UnlockDIBSection(physDev, update);
856 physDev->pen.width = oldwidth;
857 physDev->pen.endcap = oldendcap;
858 return TRUE;
862 /***********************************************************************
863 * X11DRV_SetPixel
865 COLORREF
866 X11DRV_SetPixel( X11DRV_PDEVICE *physDev, INT x, INT y, COLORREF color )
868 Pixel pixel;
869 POINT pt;
871 pt.x = x;
872 pt.y = y;
873 LPtoDP( physDev->hdc, &pt, 1 );
874 pixel = X11DRV_PALETTE_ToPhysical( physDev, color );
876 /* Update the pixmap from the DIB section */
877 X11DRV_LockDIBSection(physDev, DIB_Status_GdiMod, FALSE);
879 /* inefficient but simple... */
880 wine_tsx11_lock();
881 XSetForeground( gdi_display, physDev->gc, pixel );
882 XSetFunction( gdi_display, physDev->gc, GXcopy );
883 XDrawPoint( gdi_display, physDev->drawable, physDev->gc,
884 physDev->org.x + pt.x, physDev->org.y + pt.y );
885 wine_tsx11_unlock();
887 /* Update the DIBSection from the pixmap */
888 X11DRV_UnlockDIBSection(physDev, TRUE);
890 return X11DRV_PALETTE_ToLogical(pixel);
894 /***********************************************************************
895 * X11DRV_GetPixel
897 COLORREF
898 X11DRV_GetPixel( X11DRV_PDEVICE *physDev, INT x, INT y )
900 static Pixmap pixmap = 0;
901 XImage * image;
902 int pixel;
903 POINT pt;
904 DC *dc = physDev->dc;
906 pt.x = x;
907 pt.y = y;
908 LPtoDP( physDev->hdc, &pt, 1 );
910 /* Update the pixmap from the DIB section */
911 X11DRV_LockDIBSection(physDev, DIB_Status_GdiMod, FALSE);
913 wine_tsx11_lock();
914 if (dc->flags & DC_MEMORY)
916 image = XGetImage( gdi_display, physDev->drawable,
917 physDev->org.x + pt.x, physDev->org.y + pt.y,
918 1, 1, AllPlanes, ZPixmap );
920 else
922 /* If we are reading from the screen, use a temporary copy */
923 /* to avoid a BadMatch error */
924 if (!pixmap) pixmap = XCreatePixmap( gdi_display, root_window,
925 1, 1, dc->bitsPerPixel );
926 XCopyArea( gdi_display, physDev->drawable, pixmap, BITMAP_colorGC,
927 physDev->org.x + pt.x, physDev->org.y + pt.y, 1, 1, 0, 0 );
928 image = XGetImage( gdi_display, pixmap, 0, 0, 1, 1, AllPlanes, ZPixmap );
930 pixel = XGetPixel( image, 0, 0 );
931 XDestroyImage( image );
932 wine_tsx11_unlock();
934 /* Update the DIBSection from the pixmap */
935 X11DRV_UnlockDIBSection(physDev, FALSE);
937 return X11DRV_PALETTE_ToLogical(pixel);
941 /***********************************************************************
942 * X11DRV_PaintRgn
944 BOOL
945 X11DRV_PaintRgn( X11DRV_PDEVICE *physDev, HRGN hrgn )
947 if (X11DRV_SetupGCForBrush( physDev ))
949 int i;
950 XRectangle *rect;
951 RGNDATA *data = X11DRV_GetRegionData( hrgn, physDev->hdc );
953 if (!data) return FALSE;
954 rect = (XRectangle *)data->Buffer;
955 for (i = 0; i < data->rdh.nCount; i++)
957 rect[i].x += physDev->org.x;
958 rect[i].y += physDev->org.y;
961 X11DRV_LockDIBSection(physDev, DIB_Status_GdiMod, FALSE);
962 wine_tsx11_lock();
963 XFillRectangles( gdi_display, physDev->drawable, physDev->gc, rect, data->rdh.nCount );
964 wine_tsx11_unlock();
965 X11DRV_UnlockDIBSection(physDev, TRUE);
966 HeapFree( GetProcessHeap(), 0, data );
968 return TRUE;
971 /**********************************************************************
972 * X11DRV_Polyline
974 BOOL
975 X11DRV_Polyline( X11DRV_PDEVICE *physDev, const POINT* pt, INT count )
977 INT oldwidth;
978 register int i;
979 XPoint *points;
981 if((oldwidth = physDev->pen.width) == 0) physDev->pen.width = 1;
983 if (!(points = HeapAlloc( GetProcessHeap(), 0, sizeof(XPoint) * count )))
985 WARN("No memory to convert POINTs to XPoints!\n");
986 return FALSE;
988 for (i = 0; i < count; i++)
990 POINT tmp = pt[i];
991 LPtoDP(physDev->hdc, &tmp, 1);
992 points[i].x = physDev->org.x + tmp.x;
993 points[i].y = physDev->org.y + tmp.y;
996 if (X11DRV_SetupGCForPen ( physDev ))
998 /* Update the pixmap from the DIB section */
999 X11DRV_LockDIBSection(physDev, DIB_Status_GdiMod, FALSE);
1001 TSXDrawLines( gdi_display, physDev->drawable, physDev->gc,
1002 points, count, CoordModeOrigin );
1004 /* Update the DIBSection from the pixmap */
1005 X11DRV_UnlockDIBSection(physDev, TRUE);
1008 HeapFree( GetProcessHeap(), 0, points );
1009 physDev->pen.width = oldwidth;
1010 return TRUE;
1014 /**********************************************************************
1015 * X11DRV_Polygon
1017 BOOL
1018 X11DRV_Polygon( X11DRV_PDEVICE *physDev, const POINT* pt, INT count )
1020 register int i;
1021 XPoint *points;
1022 BOOL update = FALSE;
1024 if (!(points = HeapAlloc( GetProcessHeap(), 0, sizeof(XPoint) * (count+1) )))
1026 WARN("No memory to convert POINTs to XPoints!\n");
1027 return FALSE;
1029 for (i = 0; i < count; i++)
1031 POINT tmp = pt[i];
1032 LPtoDP(physDev->hdc, &tmp, 1);
1033 points[i].x = physDev->org.x + tmp.x;
1034 points[i].y = physDev->org.y + tmp.y;
1036 points[count] = points[0];
1038 /* Update the pixmap from the DIB section */
1039 X11DRV_LockDIBSection(physDev, DIB_Status_GdiMod, FALSE);
1041 if (X11DRV_SetupGCForBrush( physDev ))
1043 TSXFillPolygon( gdi_display, physDev->drawable, physDev->gc,
1044 points, count+1, Complex, CoordModeOrigin);
1045 update = TRUE;
1047 if (X11DRV_SetupGCForPen ( physDev ))
1049 TSXDrawLines( gdi_display, physDev->drawable, physDev->gc,
1050 points, count+1, CoordModeOrigin );
1051 update = TRUE;
1054 /* Update the DIBSection from the pixmap */
1055 X11DRV_UnlockDIBSection(physDev, update);
1057 HeapFree( GetProcessHeap(), 0, points );
1058 return TRUE;
1062 /**********************************************************************
1063 * X11DRV_PolyPolygon
1065 BOOL
1066 X11DRV_PolyPolygon( X11DRV_PDEVICE *physDev, const POINT* pt, const INT* counts, UINT polygons)
1068 HRGN hrgn;
1070 /* FIXME: The points should be converted to device coords before */
1071 /* creating the region. */
1073 hrgn = CreatePolyPolygonRgn( pt, counts, polygons, GetPolyFillMode( physDev->hdc ) );
1074 X11DRV_PaintRgn( physDev, hrgn );
1075 DeleteObject( hrgn );
1077 /* Draw the outline of the polygons */
1079 if (X11DRV_SetupGCForPen ( physDev ))
1081 int i, j, max = 0;
1082 XPoint *points;
1084 /* Update the pixmap from the DIB section */
1085 X11DRV_LockDIBSection(physDev, DIB_Status_GdiMod, FALSE);
1087 for (i = 0; i < polygons; i++) if (counts[i] > max) max = counts[i];
1088 if (!(points = HeapAlloc( GetProcessHeap(), 0, sizeof(XPoint) * (max+1) )))
1090 WARN("No memory to convert POINTs to XPoints!\n");
1091 return FALSE;
1093 for (i = 0; i < polygons; i++)
1095 for (j = 0; j < counts[i]; j++)
1097 POINT tmp = *pt;
1098 LPtoDP(physDev->hdc, &tmp, 1);
1099 points[j].x = physDev->org.x + tmp.x;
1100 points[j].y = physDev->org.y + tmp.y;
1101 pt++;
1103 points[j] = points[0];
1104 TSXDrawLines( gdi_display, physDev->drawable, physDev->gc,
1105 points, j + 1, CoordModeOrigin );
1108 /* Update the DIBSection of the dc's bitmap */
1109 X11DRV_UnlockDIBSection(physDev, TRUE);
1111 HeapFree( GetProcessHeap(), 0, points );
1113 return TRUE;
1117 /**********************************************************************
1118 * X11DRV_PolyPolyline
1120 BOOL
1121 X11DRV_PolyPolyline( X11DRV_PDEVICE *physDev, const POINT* pt, const DWORD* counts, DWORD polylines )
1123 if (X11DRV_SetupGCForPen ( physDev ))
1125 int i, j, max = 0;
1126 XPoint *points;
1128 /* Update the pixmap from the DIB section */
1129 X11DRV_LockDIBSection(physDev, DIB_Status_GdiMod, FALSE);
1131 for (i = 0; i < polylines; i++) if (counts[i] > max) max = counts[i];
1132 if (!(points = HeapAlloc( GetProcessHeap(), 0, sizeof(XPoint) * max )))
1134 WARN("No memory to convert POINTs to XPoints!\n");
1135 return FALSE;
1137 for (i = 0; i < polylines; i++)
1139 for (j = 0; j < counts[i]; j++)
1141 POINT tmp = *pt;
1142 LPtoDP(physDev->hdc, &tmp, 1);
1143 points[j].x = physDev->org.x + tmp.x;
1144 points[j].y = physDev->org.y + tmp.y;
1145 pt++;
1147 TSXDrawLines( gdi_display, physDev->drawable, physDev->gc,
1148 points, j, CoordModeOrigin );
1151 /* Update the DIBSection of the dc's bitmap */
1152 X11DRV_UnlockDIBSection(physDev, TRUE);
1154 HeapFree( GetProcessHeap(), 0, points );
1156 return TRUE;
1160 /**********************************************************************
1161 * X11DRV_InternalFloodFill
1163 * Internal helper function for flood fill.
1164 * (xorg,yorg) is the origin of the X image relative to the drawable.
1165 * (x,y) is relative to the origin of the X image.
1167 static void X11DRV_InternalFloodFill(XImage *image, X11DRV_PDEVICE *physDev,
1168 int x, int y,
1169 int xOrg, int yOrg,
1170 Pixel pixel, WORD fillType )
1172 int left, right;
1174 #define TO_FLOOD(x,y) ((fillType == FLOODFILLBORDER) ? \
1175 (XGetPixel(image,x,y) != pixel) : \
1176 (XGetPixel(image,x,y) == pixel))
1178 if (!TO_FLOOD(x,y)) return;
1180 /* Find left and right boundaries */
1182 left = right = x;
1183 while ((left > 0) && TO_FLOOD( left-1, y )) left--;
1184 while ((right < image->width) && TO_FLOOD( right, y )) right++;
1185 XFillRectangle( gdi_display, physDev->drawable, physDev->gc,
1186 xOrg + left, yOrg + y, right-left, 1 );
1188 /* Set the pixels of this line so we don't fill it again */
1190 for (x = left; x < right; x++)
1192 if (fillType == FLOODFILLBORDER) XPutPixel( image, x, y, pixel );
1193 else XPutPixel( image, x, y, ~pixel );
1196 /* Fill the line above */
1198 if (--y >= 0)
1200 x = left;
1201 while (x < right)
1203 while ((x < right) && !TO_FLOOD(x,y)) x++;
1204 if (x >= right) break;
1205 while ((x < right) && TO_FLOOD(x,y)) x++;
1206 X11DRV_InternalFloodFill(image, physDev, x-1, y,
1207 xOrg, yOrg, pixel, fillType );
1211 /* Fill the line below */
1213 if ((y += 2) < image->height)
1215 x = left;
1216 while (x < right)
1218 while ((x < right) && !TO_FLOOD(x,y)) x++;
1219 if (x >= right) break;
1220 while ((x < right) && TO_FLOOD(x,y)) x++;
1221 X11DRV_InternalFloodFill(image, physDev, x-1, y,
1222 xOrg, yOrg, pixel, fillType );
1225 #undef TO_FLOOD
1229 /**********************************************************************
1230 * X11DRV_ExtFloodFill
1232 BOOL
1233 X11DRV_ExtFloodFill( X11DRV_PDEVICE *physDev, INT x, INT y, COLORREF color,
1234 UINT fillType )
1236 XImage *image;
1237 RECT rect;
1238 DC *dc = physDev->dc;
1240 TRACE("X11DRV_ExtFloodFill %d,%d %06lx %d\n", x, y, color, fillType );
1242 if (!PtVisible( physDev->hdc, x, y )) return FALSE;
1243 if (GetRgnBox( dc->hGCClipRgn, &rect ) == ERROR) return FALSE;
1245 if (!(image = TSXGetImage( gdi_display, physDev->drawable,
1246 physDev->org.x + rect.left,
1247 physDev->org.y + rect.top,
1248 rect.right - rect.left,
1249 rect.bottom - rect.top,
1250 AllPlanes, ZPixmap ))) return FALSE;
1252 if (X11DRV_SetupGCForBrush( physDev ))
1254 POINT pt;
1255 pt.x = x;
1256 pt.y = y;
1257 LPtoDP(physDev->hdc, &pt, 1);
1258 /* Update the pixmap from the DIB section */
1259 X11DRV_LockDIBSection(physDev, DIB_Status_GdiMod, FALSE);
1261 /* ROP mode is always GXcopy for flood-fill */
1262 wine_tsx11_lock();
1263 XSetFunction( gdi_display, physDev->gc, GXcopy );
1264 X11DRV_InternalFloodFill(image, physDev,
1265 physDev->org.x + pt.x - rect.left,
1266 physDev->org.y + pt.y - rect.top,
1267 rect.left, rect.top,
1268 X11DRV_PALETTE_ToPhysical( physDev, color ),
1269 fillType );
1270 wine_tsx11_unlock();
1271 /* Update the DIBSection of the dc's bitmap */
1272 X11DRV_UnlockDIBSection(physDev, TRUE);
1275 wine_tsx11_lock();
1276 XDestroyImage( image );
1277 wine_tsx11_unlock();
1278 return TRUE;
1281 /**********************************************************************
1282 * X11DRV_SetBkColor
1284 COLORREF
1285 X11DRV_SetBkColor( X11DRV_PDEVICE *physDev, COLORREF color )
1287 physDev->backgroundPixel = X11DRV_PALETTE_ToPhysical( physDev, color );
1288 return color;
1291 /**********************************************************************
1292 * X11DRV_SetTextColor
1294 COLORREF
1295 X11DRV_SetTextColor( X11DRV_PDEVICE *physDev, COLORREF color )
1297 physDev->textPixel = X11DRV_PALETTE_ToPhysical( physDev, color );
1298 return color;
1301 /***********************************************************************
1302 * GetDCOrgEx (X11DRV.@)
1304 BOOL X11DRV_GetDCOrgEx( X11DRV_PDEVICE *physDev, LPPOINT lpp )
1306 lpp->x = physDev->org.x + physDev->drawable_org.x;
1307 lpp->y = physDev->org.y + physDev->drawable_org.y;
1308 return TRUE;
1312 /***********************************************************************
1313 * SetDCOrg (X11DRV.@)
1315 DWORD X11DRV_SetDCOrg( X11DRV_PDEVICE *physDev, INT x, INT y )
1317 DWORD ret = MAKELONG( physDev->org.x + physDev->drawable_org.x,
1318 physDev->org.y + physDev->drawable_org.y );
1319 physDev->org.x = x - physDev->drawable_org.x;
1320 physDev->org.y = y - physDev->drawable_org.y;
1321 return ret;