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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 * FIXME: only some of these functions obey the GM_ADVANCED
40 #include "wine/debug.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(graphics
);
44 #define ABS(x) ((x)<0?(-(x)):(x))
46 /* ROP code to GC function conversion */
47 const int X11DRV_XROPfunction
[16] =
49 GXclear
, /* R2_BLACK */
50 GXnor
, /* R2_NOTMERGEPEN */
51 GXandInverted
, /* R2_MASKNOTPEN */
52 GXcopyInverted
, /* R2_NOTCOPYPEN */
53 GXandReverse
, /* R2_MASKPENNOT */
54 GXinvert
, /* R2_NOT */
55 GXxor
, /* R2_XORPEN */
56 GXnand
, /* R2_NOTMASKPEN */
57 GXand
, /* R2_MASKPEN */
58 GXequiv
, /* R2_NOTXORPEN */
60 GXorInverted
, /* R2_MERGENOTPEN */
61 GXcopy
, /* R2_COPYPEN */
62 GXorReverse
, /* R2_MERGEPENNOT */
63 GXor
, /* R2_MERGEPEN */
68 /***********************************************************************
69 * X11DRV_SetupGCForPatBlt
71 * Setup the GC for a PatBlt operation using current brush.
72 * If fMapColors is TRUE, X pixels are mapped to Windows colors.
73 * Return FALSE if brush is BS_NULL, TRUE otherwise.
75 BOOL
X11DRV_SetupGCForPatBlt( X11DRV_PDEVICE
*physDev
, GC gc
, BOOL fMapColors
)
82 if (physDev
->brush
.style
== BS_NULL
) return FALSE
;
83 if (physDev
->brush
.pixel
== -1)
85 /* Special case used for monochrome pattern brushes.
86 * We need to swap foreground and background because
87 * Windows does it the wrong way...
89 val
.foreground
= physDev
->backgroundPixel
;
90 val
.background
= physDev
->textPixel
;
94 val
.foreground
= physDev
->brush
.pixel
;
95 val
.background
= physDev
->backgroundPixel
;
97 if (fMapColors
&& X11DRV_PALETTE_XPixelToPalette
)
99 val
.foreground
= X11DRV_PALETTE_XPixelToPalette
[val
.foreground
];
100 val
.background
= X11DRV_PALETTE_XPixelToPalette
[val
.background
];
103 val
.function
= X11DRV_XROPfunction
[GetROP2(physDev
->hdc
)-1];
105 ** Let's replace GXinvert by GXxor with (black xor white)
106 ** This solves the selection color and leak problems in excel
107 ** FIXME : Let's do that only if we work with X-pixels, not with Win-pixels
109 if (val
.function
== GXinvert
)
111 val
.foreground
= (WhitePixel( gdi_display
, DefaultScreen(gdi_display
) ) ^
112 BlackPixel( gdi_display
, DefaultScreen(gdi_display
) ));
113 val
.function
= GXxor
;
115 val
.fill_style
= physDev
->brush
.fillStyle
;
116 switch(val
.fill_style
)
119 case FillOpaqueStippled
:
120 if (GetBkMode(physDev
->hdc
)==OPAQUE
) val
.fill_style
= FillOpaqueStippled
;
121 val
.stipple
= physDev
->brush
.pixmap
;
126 if (fMapColors
&& X11DRV_PALETTE_XPixelToPalette
)
131 pixmap
= XCreatePixmap( gdi_display
, root_window
, 8, 8, screen_depth
);
132 image
= XGetImage( gdi_display
, physDev
->brush
.pixmap
, 0, 0, 8, 8,
133 AllPlanes
, ZPixmap
);
134 for (y
= 0; y
< 8; y
++)
135 for (x
= 0; x
< 8; x
++)
136 XPutPixel( image
, x
, y
,
137 X11DRV_PALETTE_XPixelToPalette
[XGetPixel( image
, x
, y
)] );
138 XPutImage( gdi_display
, pixmap
, gc
, image
, 0, 0, 0, 0, 8, 8 );
139 XDestroyImage( image
);
143 else val
.tile
= physDev
->brush
.pixmap
;
151 GetBrushOrgEx( physDev
->hdc
, &pt
);
152 val
.ts_x_origin
= physDev
->dc_rect
.left
+ pt
.x
;
153 val
.ts_y_origin
= physDev
->dc_rect
.top
+ pt
.y
;
154 val
.fill_rule
= (GetPolyFillMode(physDev
->hdc
) == WINDING
) ? WindingRule
: EvenOddRule
;
156 XChangeGC( gdi_display
, gc
,
157 GCFunction
| GCForeground
| GCBackground
| GCFillStyle
|
158 GCFillRule
| GCTileStipXOrigin
| GCTileStipYOrigin
| mask
,
160 if (pixmap
) XFreePixmap( gdi_display
, pixmap
);
166 /***********************************************************************
167 * X11DRV_SetupGCForBrush
169 * Setup physDev->gc for drawing operations using current brush.
170 * Return FALSE if brush is BS_NULL, TRUE otherwise.
172 BOOL
X11DRV_SetupGCForBrush( X11DRV_PDEVICE
*physDev
)
174 return X11DRV_SetupGCForPatBlt( physDev
, physDev
->gc
, FALSE
);
178 /***********************************************************************
179 * X11DRV_SetupGCForPen
181 * Setup physDev->gc for drawing operations using current pen.
182 * Return FALSE if pen is PS_NULL, TRUE otherwise.
184 BOOL
X11DRV_SetupGCForPen( X11DRV_PDEVICE
*physDev
)
187 UINT rop2
= GetROP2(physDev
->hdc
);
189 if (physDev
->pen
.style
== PS_NULL
) return FALSE
;
194 val
.foreground
= BlackPixel( gdi_display
, DefaultScreen(gdi_display
) );
195 val
.function
= GXcopy
;
198 val
.foreground
= WhitePixel( gdi_display
, DefaultScreen(gdi_display
) );
199 val
.function
= GXcopy
;
202 val
.foreground
= physDev
->pen
.pixel
;
203 /* It is very unlikely someone wants to XOR with 0 */
204 /* This fixes the rubber-drawings in paintbrush */
205 if (val
.foreground
== 0)
206 val
.foreground
= (WhitePixel( gdi_display
, DefaultScreen(gdi_display
) ) ^
207 BlackPixel( gdi_display
, DefaultScreen(gdi_display
) ));
208 val
.function
= GXxor
;
211 val
.foreground
= physDev
->pen
.pixel
;
212 val
.function
= X11DRV_XROPfunction
[rop2
-1];
214 val
.background
= physDev
->backgroundPixel
;
215 val
.fill_style
= FillSolid
;
216 val
.line_width
= physDev
->pen
.width
;
217 if (val
.line_width
<= 1) {
218 val
.cap_style
= CapNotLast
;
220 switch (physDev
->pen
.endcap
)
222 case PS_ENDCAP_SQUARE
:
223 val
.cap_style
= CapProjecting
;
226 val
.cap_style
= CapButt
;
228 case PS_ENDCAP_ROUND
:
230 val
.cap_style
= CapRound
;
233 switch (physDev
->pen
.linejoin
)
236 val
.join_style
= JoinBevel
;
239 val
.join_style
= JoinMiter
;
243 val
.join_style
= JoinRound
;
246 if (physDev
->pen
.dash_len
)
248 XSetDashes( gdi_display
, physDev
->gc
, 0, physDev
->pen
.dashes
, physDev
->pen
.dash_len
);
249 val
.line_style
= ((GetBkMode(physDev
->hdc
) == OPAQUE
) && (!physDev
->pen
.ext
))
250 ? LineDoubleDash
: LineOnOffDash
;
252 else val
.line_style
= LineSolid
;
254 XChangeGC( gdi_display
, physDev
->gc
,
255 GCFunction
| GCForeground
| GCBackground
| GCLineWidth
|
256 GCLineStyle
| GCCapStyle
| GCJoinStyle
| GCFillStyle
, &val
);
262 /***********************************************************************
263 * X11DRV_SetupGCForText
265 * Setup physDev->gc for text drawing operations.
266 * Return FALSE if the font is null, TRUE otherwise.
268 BOOL
X11DRV_SetupGCForText( X11DRV_PDEVICE
*physDev
)
270 XFontStruct
* xfs
= XFONT_GetFontStruct( physDev
->font
);
276 val
.function
= GXcopy
; /* Text is always GXcopy */
277 val
.foreground
= physDev
->textPixel
;
278 val
.background
= physDev
->backgroundPixel
;
279 val
.fill_style
= FillSolid
;
283 XChangeGC( gdi_display
, physDev
->gc
,
284 GCFunction
| GCForeground
| GCBackground
| GCFillStyle
|
289 WARN("Physical font failure\n" );
293 /***********************************************************************
296 * Performs a world-to-viewport transformation on the specified width.
298 INT
X11DRV_XWStoDS( X11DRV_PDEVICE
*physDev
, INT width
)
306 LPtoDP( physDev
->hdc
, pt
, 2 );
307 return pt
[1].x
- pt
[0].x
;
310 /***********************************************************************
313 * Performs a world-to-viewport transformation on the specified height.
315 INT
X11DRV_YWStoDS( X11DRV_PDEVICE
*physDev
, INT height
)
323 LPtoDP( physDev
->hdc
, pt
, 2 );
324 return pt
[1].y
- pt
[0].y
;
327 /***********************************************************************
331 X11DRV_LineTo( X11DRV_PDEVICE
*physDev
, INT x
, INT y
)
335 if (X11DRV_SetupGCForPen( physDev
)) {
336 /* Update the pixmap from the DIB section */
337 X11DRV_LockDIBSection(physDev
, DIB_Status_GdiMod
, FALSE
);
339 GetCurrentPositionEx( physDev
->hdc
, &pt
[0] );
342 LPtoDP( physDev
->hdc
, pt
, 2 );
345 XDrawLine(gdi_display
, physDev
->drawable
, physDev
->gc
,
346 physDev
->dc_rect
.left
+ pt
[0].x
, physDev
->dc_rect
.top
+ pt
[0].y
,
347 physDev
->dc_rect
.left
+ pt
[1].x
, physDev
->dc_rect
.top
+ pt
[1].y
);
350 /* Update the DIBSection from the pixmap */
351 X11DRV_UnlockDIBSection(physDev
, TRUE
);
358 /***********************************************************************
361 * Helper functions for Arc(), Chord() and Pie().
362 * 'lines' is the number of lines to draw: 0 for Arc, 1 for Chord, 2 for Pie.
366 X11DRV_DrawArc( X11DRV_PDEVICE
*physDev
, INT left
, INT top
, INT right
,
367 INT bottom
, INT xstart
, INT ystart
,
368 INT xend
, INT yend
, INT lines
)
370 INT xcenter
, ycenter
, istart_angle
, idiff_angle
;
372 double start_angle
, end_angle
;
378 SetRect(&rc
, left
, top
, right
, bottom
);
383 LPtoDP(physDev
->hdc
, (POINT
*)&rc
, 2);
384 LPtoDP(physDev
->hdc
, &start
, 1);
385 LPtoDP(physDev
->hdc
, &end
, 1);
387 if (rc
.right
< rc
.left
) { INT tmp
= rc
.right
; rc
.right
= rc
.left
; rc
.left
= tmp
; }
388 if (rc
.bottom
< rc
.top
) { INT tmp
= rc
.bottom
; rc
.bottom
= rc
.top
; rc
.top
= tmp
; }
389 if ((rc
.left
== rc
.right
) || (rc
.top
== rc
.bottom
)
390 ||(lines
&& ((rc
.right
-rc
.left
==1)||(rc
.bottom
-rc
.top
==1)))) return TRUE
;
392 if (GetArcDirection( physDev
->hdc
) == AD_CLOCKWISE
)
393 { POINT tmp
= start
; start
= end
; end
= tmp
; }
395 oldwidth
= width
= physDev
->pen
.width
;
396 if (!width
) width
= 1;
397 if(physDev
->pen
.style
== PS_NULL
) width
= 0;
399 if ((physDev
->pen
.style
== PS_INSIDEFRAME
))
401 if (2*width
> (rc
.right
-rc
.left
)) width
=(rc
.right
-rc
.left
+ 1)/2;
402 if (2*width
> (rc
.bottom
-rc
.top
)) width
=(rc
.bottom
-rc
.top
+ 1)/2;
403 rc
.left
+= width
/ 2;
404 rc
.right
-= (width
- 1) / 2;
406 rc
.bottom
-= (width
- 1) / 2;
408 if(width
== 0) width
= 1; /* more accurate */
409 physDev
->pen
.width
= width
;
411 xcenter
= (rc
.right
+ rc
.left
) / 2;
412 ycenter
= (rc
.bottom
+ rc
.top
) / 2;
413 start_angle
= atan2( (double)(ycenter
-start
.y
)*(rc
.right
-rc
.left
),
414 (double)(start
.x
-xcenter
)*(rc
.bottom
-rc
.top
) );
415 end_angle
= atan2( (double)(ycenter
-end
.y
)*(rc
.right
-rc
.left
),
416 (double)(end
.x
-xcenter
)*(rc
.bottom
-rc
.top
) );
417 if ((start
.x
==end
.x
)&&(start
.y
==end
.y
))
418 { /* A lazy program delivers xstart=xend=ystart=yend=0) */
422 else /* notorious cases */
423 if ((start_angle
== PI
)&&( end_angle
<0))
426 if ((end_angle
== PI
)&&( start_angle
<0))
428 istart_angle
= (INT
)(start_angle
* 180 * 64 / PI
+ 0.5);
429 idiff_angle
= (INT
)((end_angle
- start_angle
) * 180 * 64 / PI
+ 0.5);
430 if (idiff_angle
<= 0) idiff_angle
+= 360 * 64;
432 /* Update the pixmap from the DIB section */
433 X11DRV_LockDIBSection(physDev
, DIB_Status_GdiMod
, FALSE
);
435 /* Fill arc with brush if Chord() or Pie() */
437 if ((lines
> 0) && X11DRV_SetupGCForBrush( physDev
)) {
439 XSetArcMode( gdi_display
, physDev
->gc
, (lines
==1) ? ArcChord
: ArcPieSlice
);
440 XFillArc( gdi_display
, physDev
->drawable
, physDev
->gc
,
441 physDev
->dc_rect
.left
+ rc
.left
, physDev
->dc_rect
.top
+ rc
.top
,
442 rc
.right
-rc
.left
-1, rc
.bottom
-rc
.top
-1, istart_angle
, idiff_angle
);
447 /* Draw arc and lines */
449 if (X11DRV_SetupGCForPen( physDev
))
452 XDrawArc( gdi_display
, physDev
->drawable
, physDev
->gc
,
453 physDev
->dc_rect
.left
+ rc
.left
, physDev
->dc_rect
.top
+ rc
.top
,
454 rc
.right
-rc
.left
-1, rc
.bottom
-rc
.top
-1, istart_angle
, idiff_angle
);
456 /* use the truncated values */
457 start_angle
=(double)istart_angle
*PI
/64./180.;
458 end_angle
=(double)(istart_angle
+idiff_angle
)*PI
/64./180.;
459 /* calculate the endpoints and round correctly */
460 points
[0].x
= (int) floor(physDev
->dc_rect
.left
+ (rc
.right
+rc
.left
)/2.0 +
461 cos(start_angle
) * (rc
.right
-rc
.left
-width
*2+2) / 2. + 0.5);
462 points
[0].y
= (int) floor(physDev
->dc_rect
.top
+ (rc
.top
+rc
.bottom
)/2.0 -
463 sin(start_angle
) * (rc
.bottom
-rc
.top
-width
*2+2) / 2. + 0.5);
464 points
[1].x
= (int) floor(physDev
->dc_rect
.left
+ (rc
.right
+rc
.left
)/2.0 +
465 cos(end_angle
) * (rc
.right
-rc
.left
-width
*2+2) / 2. + 0.5);
466 points
[1].y
= (int) floor(physDev
->dc_rect
.top
+ (rc
.top
+rc
.bottom
)/2.0 -
467 sin(end_angle
) * (rc
.bottom
-rc
.top
-width
*2+2) / 2. + 0.5);
469 /* OK, this stuff is optimized for Xfree86
470 * which is probably the server most used by
471 * wine users. Other X servers will not
472 * display correctly. (eXceed for instance)
473 * so if you feel you must make changes, make sure that
474 * you either use Xfree86 or separate your changes
475 * from these (compile switch or whatever)
479 points
[3] = points
[1];
480 points
[1].x
= physDev
->dc_rect
.left
+ xcenter
;
481 points
[1].y
= physDev
->dc_rect
.top
+ ycenter
;
482 points
[2] = points
[1];
483 dx1
=points
[1].x
-points
[0].x
;
484 dy1
=points
[1].y
-points
[0].y
;
485 if(((rc
.top
-rc
.bottom
) | -2) == -2)
486 if(dy1
>0) points
[1].y
--;
488 if (((-dx1
)*64)<=ABS(dy1
)*37) points
[0].x
--;
489 if(((-dx1
*9))<(dy1
*16)) points
[0].y
--;
490 if( dy1
<0 && ((dx1
*9)) < (dy1
*16)) points
[0].y
--;
492 if(dy1
< 0) points
[0].y
--;
493 if(((rc
.right
-rc
.left
) | -2) == -2) points
[1].x
--;
495 dx1
=points
[3].x
-points
[2].x
;
496 dy1
=points
[3].y
-points
[2].y
;
497 if(((rc
.top
-rc
.bottom
) | -2 ) == -2)
498 if(dy1
< 0) points
[2].y
--;
500 if( dy1
>0) points
[3].y
--;
501 if(((rc
.right
-rc
.left
) | -2) == -2 ) points
[2].x
--;
504 if( dx1
* 64 < dy1
* -37 ) points
[3].x
--;
508 XDrawLines( gdi_display
, physDev
->drawable
, physDev
->gc
,
509 points
, lines
+1, CoordModeOrigin
);
515 /* Update the DIBSection of the pixmap */
516 X11DRV_UnlockDIBSection(physDev
, update
);
518 physDev
->pen
.width
= oldwidth
;
523 /***********************************************************************
527 X11DRV_Arc( X11DRV_PDEVICE
*physDev
, INT left
, INT top
, INT right
, INT bottom
,
528 INT xstart
, INT ystart
, INT xend
, INT yend
)
530 return X11DRV_DrawArc( physDev
, left
, top
, right
, bottom
,
531 xstart
, ystart
, xend
, yend
, 0 );
535 /***********************************************************************
539 X11DRV_Pie( X11DRV_PDEVICE
*physDev
, INT left
, INT top
, INT right
, INT bottom
,
540 INT xstart
, INT ystart
, INT xend
, INT yend
)
542 return X11DRV_DrawArc( physDev
, left
, top
, right
, bottom
,
543 xstart
, ystart
, xend
, yend
, 2 );
546 /***********************************************************************
550 X11DRV_Chord( X11DRV_PDEVICE
*physDev
, INT left
, INT top
, INT right
, INT bottom
,
551 INT xstart
, INT ystart
, INT xend
, INT yend
)
553 return X11DRV_DrawArc( physDev
, left
, top
, right
, bottom
,
554 xstart
, ystart
, xend
, yend
, 1 );
558 /***********************************************************************
562 X11DRV_Ellipse( X11DRV_PDEVICE
*physDev
, INT left
, INT top
, INT right
, INT bottom
)
568 SetRect(&rc
, left
, top
, right
, bottom
);
569 LPtoDP(physDev
->hdc
, (POINT
*)&rc
, 2);
571 if ((rc
.left
== rc
.right
) || (rc
.top
== rc
.bottom
)) return TRUE
;
573 if (rc
.right
< rc
.left
) { INT tmp
= rc
.right
; rc
.right
= rc
.left
; rc
.left
= tmp
; }
574 if (rc
.bottom
< rc
.top
) { INT tmp
= rc
.bottom
; rc
.bottom
= rc
.top
; rc
.top
= tmp
; }
576 oldwidth
= width
= physDev
->pen
.width
;
577 if (!width
) width
= 1;
578 if(physDev
->pen
.style
== PS_NULL
) width
= 0;
580 if ((physDev
->pen
.style
== PS_INSIDEFRAME
))
582 if (2*width
> (rc
.right
-rc
.left
)) width
=(rc
.right
-rc
.left
+ 1)/2;
583 if (2*width
> (rc
.bottom
-rc
.top
)) width
=(rc
.bottom
-rc
.top
+ 1)/2;
584 rc
.left
+= width
/ 2;
585 rc
.right
-= (width
- 1) / 2;
587 rc
.bottom
-= (width
- 1) / 2;
589 if(width
== 0) width
= 1; /* more accurate */
590 physDev
->pen
.width
= width
;
592 /* Update the pixmap from the DIB section */
593 X11DRV_LockDIBSection(physDev
, DIB_Status_GdiMod
, FALSE
);
595 if (X11DRV_SetupGCForBrush( physDev
))
598 XFillArc( gdi_display
, physDev
->drawable
, physDev
->gc
,
599 physDev
->dc_rect
.left
+ rc
.left
, physDev
->dc_rect
.top
+ rc
.top
,
600 rc
.right
-rc
.left
-1, rc
.bottom
-rc
.top
-1, 0, 360*64 );
604 if (X11DRV_SetupGCForPen( physDev
))
607 XDrawArc( gdi_display
, physDev
->drawable
, physDev
->gc
,
608 physDev
->dc_rect
.left
+ rc
.left
, physDev
->dc_rect
.top
+ rc
.top
,
609 rc
.right
-rc
.left
-1, rc
.bottom
-rc
.top
-1, 0, 360*64 );
614 /* Update the DIBSection from the pixmap */
615 X11DRV_UnlockDIBSection(physDev
, update
);
617 physDev
->pen
.width
= oldwidth
;
622 /***********************************************************************
626 X11DRV_Rectangle(X11DRV_PDEVICE
*physDev
, INT left
, INT top
, INT right
, INT bottom
)
628 INT width
, oldwidth
, oldjoinstyle
;
632 TRACE("(%d %d %d %d)\n", left
, top
, right
, bottom
);
634 SetRect(&rc
, left
, top
, right
, bottom
);
635 LPtoDP(physDev
->hdc
, (POINT
*)&rc
, 2);
637 if ((rc
.left
== rc
.right
) || (rc
.top
== rc
.bottom
)) return TRUE
;
639 if (rc
.right
< rc
.left
) { INT tmp
= rc
.right
; rc
.right
= rc
.left
; rc
.left
= tmp
; }
640 if (rc
.bottom
< rc
.top
) { INT tmp
= rc
.bottom
; rc
.bottom
= rc
.top
; rc
.top
= tmp
; }
642 oldwidth
= width
= physDev
->pen
.width
;
643 if (!width
) width
= 1;
644 if(physDev
->pen
.style
== PS_NULL
) width
= 0;
646 if ((physDev
->pen
.style
== PS_INSIDEFRAME
))
648 if (2*width
> (rc
.right
-rc
.left
)) width
=(rc
.right
-rc
.left
+ 1)/2;
649 if (2*width
> (rc
.bottom
-rc
.top
)) width
=(rc
.bottom
-rc
.top
+ 1)/2;
650 rc
.left
+= width
/ 2;
651 rc
.right
-= (width
- 1) / 2;
653 rc
.bottom
-= (width
- 1) / 2;
655 if(width
== 1) width
= 0;
656 physDev
->pen
.width
= width
;
657 oldjoinstyle
= physDev
->pen
.linejoin
;
658 if(physDev
->pen
.type
!= PS_GEOMETRIC
)
659 physDev
->pen
.linejoin
= PS_JOIN_MITER
;
661 /* Update the pixmap from the DIB section */
662 X11DRV_LockDIBSection(physDev
, DIB_Status_GdiMod
, FALSE
);
664 if ((rc
.right
> rc
.left
+ width
) && (rc
.bottom
> rc
.top
+ width
))
666 if (X11DRV_SetupGCForBrush( physDev
))
669 XFillRectangle( gdi_display
, physDev
->drawable
, physDev
->gc
,
670 physDev
->dc_rect
.left
+ rc
.left
+ (width
+ 1) / 2,
671 physDev
->dc_rect
.top
+ rc
.top
+ (width
+ 1) / 2,
672 rc
.right
-rc
.left
-width
-1, rc
.bottom
-rc
.top
-width
-1);
677 if (X11DRV_SetupGCForPen( physDev
))
680 XDrawRectangle( gdi_display
, physDev
->drawable
, physDev
->gc
,
681 physDev
->dc_rect
.left
+ rc
.left
, physDev
->dc_rect
.top
+ rc
.top
,
682 rc
.right
-rc
.left
-1, rc
.bottom
-rc
.top
-1 );
687 /* Update the DIBSection from the pixmap */
688 X11DRV_UnlockDIBSection(physDev
, update
);
690 physDev
->pen
.width
= oldwidth
;
691 physDev
->pen
.linejoin
= oldjoinstyle
;
695 /***********************************************************************
699 X11DRV_RoundRect( X11DRV_PDEVICE
*physDev
, INT left
, INT top
, INT right
,
700 INT bottom
, INT ell_width
, INT ell_height
)
702 INT width
, oldwidth
, oldendcap
;
707 TRACE("(%d %d %d %d %d %d\n",
708 left
, top
, right
, bottom
, ell_width
, ell_height
);
710 SetRect(&rc
, left
, top
, right
, bottom
);
711 LPtoDP(physDev
->hdc
, (POINT
*)&rc
, 2);
713 if ((rc
.left
== rc
.right
) || (rc
.top
== rc
.bottom
))
716 /* Make sure ell_width and ell_height are >= 1 otherwise XDrawArc gets
717 called with width/height < 0 */
718 pts
[0].x
= pts
[0].y
= 0;
719 pts
[1].x
= ell_width
;
720 pts
[1].y
= ell_height
;
721 LPtoDP(physDev
->hdc
, pts
, 2);
722 ell_width
= max(abs( pts
[1].x
- pts
[0].x
), 1);
723 ell_height
= max(abs( pts
[1].y
- pts
[0].y
), 1);
725 /* Fix the coordinates */
727 if (rc
.right
< rc
.left
) { INT tmp
= rc
.right
; rc
.right
= rc
.left
; rc
.left
= tmp
; }
728 if (rc
.bottom
< rc
.top
) { INT tmp
= rc
.bottom
; rc
.bottom
= rc
.top
; rc
.top
= tmp
; }
730 oldwidth
= width
= physDev
->pen
.width
;
731 oldendcap
= physDev
->pen
.endcap
;
732 if (!width
) width
= 1;
733 if(physDev
->pen
.style
== PS_NULL
) width
= 0;
735 if ((physDev
->pen
.style
== PS_INSIDEFRAME
))
737 if (2*width
> (rc
.right
-rc
.left
)) width
=(rc
.right
-rc
.left
+ 1)/2;
738 if (2*width
> (rc
.bottom
-rc
.top
)) width
=(rc
.bottom
-rc
.top
+ 1)/2;
739 rc
.left
+= width
/ 2;
740 rc
.right
-= (width
- 1) / 2;
742 rc
.bottom
-= (width
- 1) / 2;
744 if(width
== 0) width
= 1;
745 physDev
->pen
.width
= width
;
746 physDev
->pen
.endcap
= PS_ENDCAP_SQUARE
;
748 /* Update the pixmap from the DIB section */
749 X11DRV_LockDIBSection(physDev
, DIB_Status_GdiMod
, FALSE
);
752 if (X11DRV_SetupGCForBrush( physDev
))
754 if (ell_width
> (rc
.right
-rc
.left
) )
755 if (ell_height
> (rc
.bottom
-rc
.top
) )
756 XFillArc( gdi_display
, physDev
->drawable
, physDev
->gc
,
757 physDev
->dc_rect
.left
+ rc
.left
, physDev
->dc_rect
.top
+ rc
.top
,
758 rc
.right
- rc
.left
- 1, rc
.bottom
- rc
.top
- 1,
761 XFillArc( gdi_display
, physDev
->drawable
, physDev
->gc
,
762 physDev
->dc_rect
.left
+ rc
.left
, physDev
->dc_rect
.top
+ rc
.top
,
763 rc
.right
- rc
.left
- 1, ell_height
, 0, 180 * 64 );
764 XFillArc( gdi_display
, physDev
->drawable
, physDev
->gc
,
765 physDev
->dc_rect
.left
+ rc
.left
,
766 physDev
->dc_rect
.top
+ rc
.bottom
- ell_height
- 1,
767 rc
.right
- rc
.left
- 1, ell_height
, 180 * 64,
770 else if (ell_height
> (rc
.bottom
-rc
.top
) ){
771 XFillArc( gdi_display
, physDev
->drawable
, physDev
->gc
,
772 physDev
->dc_rect
.left
+ rc
.left
, physDev
->dc_rect
.top
+ rc
.top
,
773 ell_width
, rc
.bottom
- rc
.top
- 1, 90 * 64, 180 * 64 );
774 XFillArc( gdi_display
, physDev
->drawable
, physDev
->gc
,
775 physDev
->dc_rect
.left
+ rc
.right
- ell_width
- 1, physDev
->dc_rect
.top
+ rc
.top
,
776 ell_width
, rc
.bottom
- rc
.top
- 1, 270 * 64, 180 * 64 );
778 XFillArc( gdi_display
, physDev
->drawable
, physDev
->gc
,
779 physDev
->dc_rect
.left
+ rc
.left
, physDev
->dc_rect
.top
+ rc
.top
,
780 ell_width
, ell_height
, 90 * 64, 90 * 64 );
781 XFillArc( gdi_display
, physDev
->drawable
, physDev
->gc
,
782 physDev
->dc_rect
.left
+ rc
.left
,
783 physDev
->dc_rect
.top
+ rc
.bottom
- ell_height
- 1,
784 ell_width
, ell_height
, 180 * 64, 90 * 64 );
785 XFillArc( gdi_display
, physDev
->drawable
, physDev
->gc
,
786 physDev
->dc_rect
.left
+ rc
.right
- ell_width
- 1,
787 physDev
->dc_rect
.top
+ rc
.bottom
- ell_height
- 1,
788 ell_width
, ell_height
, 270 * 64, 90 * 64 );
789 XFillArc( gdi_display
, physDev
->drawable
, physDev
->gc
,
790 physDev
->dc_rect
.left
+ rc
.right
- ell_width
- 1,
791 physDev
->dc_rect
.top
+ rc
.top
,
792 ell_width
, ell_height
, 0, 90 * 64 );
794 if (ell_width
< rc
.right
- rc
.left
)
796 XFillRectangle( gdi_display
, physDev
->drawable
, physDev
->gc
,
797 physDev
->dc_rect
.left
+ rc
.left
+ (ell_width
+ 1) / 2,
798 physDev
->dc_rect
.top
+ rc
.top
+ 1,
799 rc
.right
- rc
.left
- ell_width
- 1,
800 (ell_height
+ 1) / 2 - 1);
801 XFillRectangle( gdi_display
, physDev
->drawable
, physDev
->gc
,
802 physDev
->dc_rect
.left
+ rc
.left
+ (ell_width
+ 1) / 2,
803 physDev
->dc_rect
.top
+ rc
.bottom
- (ell_height
) / 2 - 1,
804 rc
.right
- rc
.left
- ell_width
- 1,
807 if (ell_height
< rc
.bottom
- rc
.top
)
809 XFillRectangle( gdi_display
, physDev
->drawable
, physDev
->gc
,
810 physDev
->dc_rect
.left
+ rc
.left
+ 1,
811 physDev
->dc_rect
.top
+ rc
.top
+ (ell_height
+ 1) / 2,
812 rc
.right
- rc
.left
- 2,
813 rc
.bottom
- rc
.top
- ell_height
- 1);
817 /* FIXME: this could be done with on X call
818 * more efficient and probably more correct
819 * on any X server: XDrawArcs will draw
820 * straight horizontal and vertical lines
821 * if width or height are zero.
823 * BTW this stuff is optimized for an Xfree86 server
824 * read the comments inside the X11DRV_DrawArc function
826 if (X11DRV_SetupGCForPen( physDev
))
828 if (ell_width
> (rc
.right
-rc
.left
) )
829 if (ell_height
> (rc
.bottom
-rc
.top
) )
830 XDrawArc( gdi_display
, physDev
->drawable
, physDev
->gc
,
831 physDev
->dc_rect
.left
+ rc
.left
, physDev
->dc_rect
.top
+ rc
.top
,
832 rc
.right
- rc
.left
- 1, rc
.bottom
- rc
.top
- 1, 0 , 360 * 64 );
834 XDrawArc( gdi_display
, physDev
->drawable
, physDev
->gc
,
835 physDev
->dc_rect
.left
+ rc
.left
, physDev
->dc_rect
.top
+ rc
.top
,
836 rc
.right
- rc
.left
- 1, ell_height
- 1, 0 , 180 * 64 );
837 XDrawArc( gdi_display
, physDev
->drawable
, physDev
->gc
,
838 physDev
->dc_rect
.left
+ rc
.left
,
839 physDev
->dc_rect
.top
+ rc
.bottom
- ell_height
,
840 rc
.right
- rc
.left
- 1, ell_height
- 1, 180 * 64 , 180 * 64 );
842 else if (ell_height
> (rc
.bottom
-rc
.top
) ){
843 XDrawArc( gdi_display
, physDev
->drawable
, physDev
->gc
,
844 physDev
->dc_rect
.left
+ rc
.left
, physDev
->dc_rect
.top
+ rc
.top
,
845 ell_width
- 1 , rc
.bottom
- rc
.top
- 1, 90 * 64 , 180 * 64 );
846 XDrawArc( gdi_display
, physDev
->drawable
, physDev
->gc
,
847 physDev
->dc_rect
.left
+ rc
.right
- ell_width
,
848 physDev
->dc_rect
.top
+ rc
.top
,
849 ell_width
- 1 , rc
.bottom
- rc
.top
- 1, 270 * 64 , 180 * 64 );
851 XDrawArc( gdi_display
, physDev
->drawable
, physDev
->gc
,
852 physDev
->dc_rect
.left
+ rc
.left
, physDev
->dc_rect
.top
+ rc
.top
,
853 ell_width
- 1, ell_height
- 1, 90 * 64, 90 * 64 );
854 XDrawArc( gdi_display
, physDev
->drawable
, physDev
->gc
,
855 physDev
->dc_rect
.left
+ rc
.left
, physDev
->dc_rect
.top
+ rc
.bottom
- ell_height
,
856 ell_width
- 1, ell_height
- 1, 180 * 64, 90 * 64 );
857 XDrawArc( gdi_display
, physDev
->drawable
, physDev
->gc
,
858 physDev
->dc_rect
.left
+ rc
.right
- ell_width
,
859 physDev
->dc_rect
.top
+ rc
.bottom
- ell_height
,
860 ell_width
- 1, ell_height
- 1, 270 * 64, 90 * 64 );
861 XDrawArc( gdi_display
, physDev
->drawable
, physDev
->gc
,
862 physDev
->dc_rect
.left
+ rc
.right
- ell_width
, physDev
->dc_rect
.top
+ rc
.top
,
863 ell_width
- 1, ell_height
- 1, 0, 90 * 64 );
865 if (ell_width
< rc
.right
- rc
.left
)
867 XDrawLine( gdi_display
, physDev
->drawable
, physDev
->gc
,
868 physDev
->dc_rect
.left
+ rc
.left
+ ell_width
/ 2,
869 physDev
->dc_rect
.top
+ rc
.top
,
870 physDev
->dc_rect
.left
+ rc
.right
- (ell_width
+1) / 2,
871 physDev
->dc_rect
.top
+ rc
.top
);
872 XDrawLine( gdi_display
, physDev
->drawable
, physDev
->gc
,
873 physDev
->dc_rect
.left
+ rc
.left
+ ell_width
/ 2 ,
874 physDev
->dc_rect
.top
+ rc
.bottom
- 1,
875 physDev
->dc_rect
.left
+ rc
.right
- (ell_width
+1)/ 2,
876 physDev
->dc_rect
.top
+ rc
.bottom
- 1);
878 if (ell_height
< rc
.bottom
- rc
.top
)
880 XDrawLine( gdi_display
, physDev
->drawable
, physDev
->gc
,
881 physDev
->dc_rect
.left
+ rc
.right
- 1,
882 physDev
->dc_rect
.top
+ rc
.top
+ ell_height
/ 2,
883 physDev
->dc_rect
.left
+ rc
.right
- 1,
884 physDev
->dc_rect
.top
+ rc
.bottom
- (ell_height
+1) / 2);
885 XDrawLine( gdi_display
, physDev
->drawable
, physDev
->gc
,
886 physDev
->dc_rect
.left
+ rc
.left
,
887 physDev
->dc_rect
.top
+ rc
.top
+ ell_height
/ 2,
888 physDev
->dc_rect
.left
+ rc
.left
,
889 physDev
->dc_rect
.top
+ rc
.bottom
- (ell_height
+1) / 2);
894 /* Update the DIBSection from the pixmap */
895 X11DRV_UnlockDIBSection(physDev
, update
);
897 physDev
->pen
.width
= oldwidth
;
898 physDev
->pen
.endcap
= oldendcap
;
903 /***********************************************************************
907 X11DRV_SetPixel( X11DRV_PDEVICE
*physDev
, INT x
, INT y
, COLORREF color
)
914 LPtoDP( physDev
->hdc
, &pt
, 1 );
915 pixel
= X11DRV_PALETTE_ToPhysical( physDev
, color
);
917 /* Update the pixmap from the DIB section */
918 X11DRV_LockDIBSection(physDev
, DIB_Status_GdiMod
, FALSE
);
920 /* inefficient but simple... */
922 XSetForeground( gdi_display
, physDev
->gc
, pixel
);
923 XSetFunction( gdi_display
, physDev
->gc
, GXcopy
);
924 XDrawPoint( gdi_display
, physDev
->drawable
, physDev
->gc
,
925 physDev
->dc_rect
.left
+ pt
.x
, physDev
->dc_rect
.top
+ pt
.y
);
928 /* Update the DIBSection from the pixmap */
929 X11DRV_UnlockDIBSection(physDev
, TRUE
);
931 return X11DRV_PALETTE_ToLogical(pixel
);
935 /***********************************************************************
939 X11DRV_GetPixel( X11DRV_PDEVICE
*physDev
, INT x
, INT y
)
941 static Pixmap pixmap
= 0;
945 BOOL memdc
= (GetObjectType(physDev
->hdc
) == OBJ_MEMDC
);
949 LPtoDP( physDev
->hdc
, &pt
, 1 );
951 /* Update the pixmap from the DIB section */
952 X11DRV_LockDIBSection(physDev
, DIB_Status_GdiMod
, FALSE
);
957 image
= XGetImage( gdi_display
, physDev
->drawable
,
958 physDev
->dc_rect
.left
+ pt
.x
, physDev
->dc_rect
.top
+ pt
.y
,
959 1, 1, AllPlanes
, ZPixmap
);
963 /* If we are reading from the screen, use a temporary copy */
964 /* to avoid a BadMatch error */
965 if (!pixmap
) pixmap
= XCreatePixmap( gdi_display
, root_window
,
966 1, 1, physDev
->depth
);
967 XCopyArea( gdi_display
, physDev
->drawable
, pixmap
, BITMAP_colorGC
,
968 physDev
->dc_rect
.left
+ pt
.x
, physDev
->dc_rect
.top
+ pt
.y
, 1, 1, 0, 0 );
969 image
= XGetImage( gdi_display
, pixmap
, 0, 0, 1, 1, AllPlanes
, ZPixmap
);
971 pixel
= XGetPixel( image
, 0, 0 );
972 XDestroyImage( image
);
975 /* Update the DIBSection from the pixmap */
976 X11DRV_UnlockDIBSection(physDev
, FALSE
);
978 return X11DRV_PALETTE_ToLogical(pixel
);
982 /***********************************************************************
986 X11DRV_PaintRgn( X11DRV_PDEVICE
*physDev
, HRGN hrgn
)
988 if (X11DRV_SetupGCForBrush( physDev
))
992 RGNDATA
*data
= X11DRV_GetRegionData( hrgn
, physDev
->hdc
);
994 if (!data
) return FALSE
;
995 rect
= (XRectangle
*)data
->Buffer
;
996 for (i
= 0; i
< data
->rdh
.nCount
; i
++)
998 rect
[i
].x
+= physDev
->dc_rect
.left
;
999 rect
[i
].y
+= physDev
->dc_rect
.top
;
1002 X11DRV_LockDIBSection(physDev
, DIB_Status_GdiMod
, FALSE
);
1004 XFillRectangles( gdi_display
, physDev
->drawable
, physDev
->gc
, rect
, data
->rdh
.nCount
);
1005 wine_tsx11_unlock();
1006 X11DRV_UnlockDIBSection(physDev
, TRUE
);
1007 HeapFree( GetProcessHeap(), 0, data
);
1012 /**********************************************************************
1016 X11DRV_Polyline( X11DRV_PDEVICE
*physDev
, const POINT
* pt
, INT count
)
1021 if (!(points
= HeapAlloc( GetProcessHeap(), 0, sizeof(XPoint
) * count
)))
1023 WARN("No memory to convert POINTs to XPoints!\n");
1026 for (i
= 0; i
< count
; i
++)
1029 LPtoDP(physDev
->hdc
, &tmp
, 1);
1030 points
[i
].x
= physDev
->dc_rect
.left
+ tmp
.x
;
1031 points
[i
].y
= physDev
->dc_rect
.top
+ tmp
.y
;
1034 if (X11DRV_SetupGCForPen ( physDev
))
1036 X11DRV_LockDIBSection(physDev
, DIB_Status_GdiMod
, FALSE
);
1038 XDrawLines( gdi_display
, physDev
->drawable
, physDev
->gc
,
1039 points
, count
, CoordModeOrigin
);
1040 wine_tsx11_unlock();
1041 X11DRV_UnlockDIBSection(physDev
, TRUE
);
1044 HeapFree( GetProcessHeap(), 0, points
);
1049 /**********************************************************************
1053 X11DRV_Polygon( X11DRV_PDEVICE
*physDev
, const POINT
* pt
, INT count
)
1057 BOOL update
= FALSE
;
1059 if (!(points
= HeapAlloc( GetProcessHeap(), 0, sizeof(XPoint
) * (count
+1) )))
1061 WARN("No memory to convert POINTs to XPoints!\n");
1064 for (i
= 0; i
< count
; i
++)
1067 LPtoDP(physDev
->hdc
, &tmp
, 1);
1068 points
[i
].x
= physDev
->dc_rect
.left
+ tmp
.x
;
1069 points
[i
].y
= physDev
->dc_rect
.top
+ tmp
.y
;
1071 points
[count
] = points
[0];
1073 /* Update the pixmap from the DIB section */
1074 X11DRV_LockDIBSection(physDev
, DIB_Status_GdiMod
, FALSE
);
1076 if (X11DRV_SetupGCForBrush( physDev
))
1079 XFillPolygon( gdi_display
, physDev
->drawable
, physDev
->gc
,
1080 points
, count
+1, Complex
, CoordModeOrigin
);
1081 wine_tsx11_unlock();
1084 if (X11DRV_SetupGCForPen ( physDev
))
1087 XDrawLines( gdi_display
, physDev
->drawable
, physDev
->gc
,
1088 points
, count
+1, CoordModeOrigin
);
1089 wine_tsx11_unlock();
1093 /* Update the DIBSection from the pixmap */
1094 X11DRV_UnlockDIBSection(physDev
, update
);
1096 HeapFree( GetProcessHeap(), 0, points
);
1101 /**********************************************************************
1102 * X11DRV_PolyPolygon
1105 X11DRV_PolyPolygon( X11DRV_PDEVICE
*physDev
, const POINT
* pt
, const INT
* counts
, UINT polygons
)
1109 /* FIXME: The points should be converted to device coords before */
1110 /* creating the region. */
1112 hrgn
= CreatePolyPolygonRgn( pt
, counts
, polygons
, GetPolyFillMode( physDev
->hdc
) );
1113 X11DRV_PaintRgn( physDev
, hrgn
);
1114 DeleteObject( hrgn
);
1116 /* Draw the outline of the polygons */
1118 if (X11DRV_SetupGCForPen ( physDev
))
1124 /* Update the pixmap from the DIB section */
1125 X11DRV_LockDIBSection(physDev
, DIB_Status_GdiMod
, FALSE
);
1127 for (i
= 0; i
< polygons
; i
++) if (counts
[i
] > max
) max
= counts
[i
];
1128 if (!(points
= HeapAlloc( GetProcessHeap(), 0, sizeof(XPoint
) * (max
+1) )))
1130 WARN("No memory to convert POINTs to XPoints!\n");
1133 for (i
= 0; i
< polygons
; i
++)
1135 for (j
= 0; j
< counts
[i
]; j
++)
1138 LPtoDP(physDev
->hdc
, &tmp
, 1);
1139 points
[j
].x
= physDev
->dc_rect
.left
+ tmp
.x
;
1140 points
[j
].y
= physDev
->dc_rect
.top
+ tmp
.y
;
1143 points
[j
] = points
[0];
1145 XDrawLines( gdi_display
, physDev
->drawable
, physDev
->gc
,
1146 points
, j
+ 1, CoordModeOrigin
);
1147 wine_tsx11_unlock();
1150 /* Update the DIBSection of the dc's bitmap */
1151 X11DRV_UnlockDIBSection(physDev
, TRUE
);
1153 HeapFree( GetProcessHeap(), 0, points
);
1159 /**********************************************************************
1160 * X11DRV_PolyPolyline
1163 X11DRV_PolyPolyline( X11DRV_PDEVICE
*physDev
, const POINT
* pt
, const DWORD
* counts
, DWORD polylines
)
1165 if (X11DRV_SetupGCForPen ( physDev
))
1167 unsigned int i
, j
, max
= 0;
1170 /* Update the pixmap from the DIB section */
1171 X11DRV_LockDIBSection(physDev
, DIB_Status_GdiMod
, FALSE
);
1173 for (i
= 0; i
< polylines
; i
++) if (counts
[i
] > max
) max
= counts
[i
];
1174 if (!(points
= HeapAlloc( GetProcessHeap(), 0, sizeof(XPoint
) * max
)))
1176 WARN("No memory to convert POINTs to XPoints!\n");
1179 for (i
= 0; i
< polylines
; i
++)
1181 for (j
= 0; j
< counts
[i
]; j
++)
1184 LPtoDP(physDev
->hdc
, &tmp
, 1);
1185 points
[j
].x
= physDev
->dc_rect
.left
+ tmp
.x
;
1186 points
[j
].y
= physDev
->dc_rect
.top
+ tmp
.y
;
1190 XDrawLines( gdi_display
, physDev
->drawable
, physDev
->gc
,
1191 points
, j
, CoordModeOrigin
);
1192 wine_tsx11_unlock();
1195 /* Update the DIBSection of the dc's bitmap */
1196 X11DRV_UnlockDIBSection(physDev
, TRUE
);
1198 HeapFree( GetProcessHeap(), 0, points
);
1204 /**********************************************************************
1205 * X11DRV_InternalFloodFill
1207 * Internal helper function for flood fill.
1208 * (xorg,yorg) is the origin of the X image relative to the drawable.
1209 * (x,y) is relative to the origin of the X image.
1211 static void X11DRV_InternalFloodFill(XImage
*image
, X11DRV_PDEVICE
*physDev
,
1214 unsigned long pixel
, WORD fillType
)
1218 #define TO_FLOOD(x,y) ((fillType == FLOODFILLBORDER) ? \
1219 (XGetPixel(image,x,y) != pixel) : \
1220 (XGetPixel(image,x,y) == pixel))
1222 if (!TO_FLOOD(x
,y
)) return;
1224 /* Find left and right boundaries */
1227 while ((left
> 0) && TO_FLOOD( left
-1, y
)) left
--;
1228 while ((right
< image
->width
) && TO_FLOOD( right
, y
)) right
++;
1229 XFillRectangle( gdi_display
, physDev
->drawable
, physDev
->gc
,
1230 xOrg
+ left
, yOrg
+ y
, right
-left
, 1 );
1232 /* Set the pixels of this line so we don't fill it again */
1234 for (x
= left
; x
< right
; x
++)
1236 if (fillType
== FLOODFILLBORDER
) XPutPixel( image
, x
, y
, pixel
);
1237 else XPutPixel( image
, x
, y
, ~pixel
);
1240 /* Fill the line above */
1247 while ((x
< right
) && !TO_FLOOD(x
,y
)) x
++;
1248 if (x
>= right
) break;
1249 while ((x
< right
) && TO_FLOOD(x
,y
)) x
++;
1250 X11DRV_InternalFloodFill(image
, physDev
, x
-1, y
,
1251 xOrg
, yOrg
, pixel
, fillType
);
1255 /* Fill the line below */
1257 if ((y
+= 2) < image
->height
)
1262 while ((x
< right
) && !TO_FLOOD(x
,y
)) x
++;
1263 if (x
>= right
) break;
1264 while ((x
< right
) && TO_FLOOD(x
,y
)) x
++;
1265 X11DRV_InternalFloodFill(image
, physDev
, x
-1, y
,
1266 xOrg
, yOrg
, pixel
, fillType
);
1273 static int ExtFloodFillXGetImageErrorHandler( Display
*dpy
, XErrorEvent
*event
, void *arg
)
1275 return (event
->request_code
== X_GetImage
&& event
->error_code
== BadMatch
);
1278 /**********************************************************************
1279 * X11DRV_ExtFloodFill
1282 X11DRV_ExtFloodFill( X11DRV_PDEVICE
*physDev
, INT x
, INT y
, COLORREF color
,
1289 TRACE("X11DRV_ExtFloodFill %d,%d %06x %d\n", x
, y
, color
, fillType
);
1293 LPtoDP( physDev
->hdc
, &pt
, 1 );
1294 if (!PtInRegion( physDev
->region
, pt
.x
, pt
.y
)) return FALSE
;
1295 GetRgnBox( physDev
->region
, &rect
);
1298 X11DRV_expect_error( gdi_display
, ExtFloodFillXGetImageErrorHandler
, NULL
);
1299 image
= XGetImage( gdi_display
, physDev
->drawable
,
1300 physDev
->dc_rect
.left
+ rect
.left
, physDev
->dc_rect
.top
+ rect
.top
,
1301 rect
.right
- rect
.left
, rect
.bottom
- rect
.top
,
1302 AllPlanes
, ZPixmap
);
1303 if(X11DRV_check_error()) image
= NULL
;
1304 wine_tsx11_unlock();
1305 if (!image
) return FALSE
;
1307 if (X11DRV_SetupGCForBrush( physDev
))
1309 /* Update the pixmap from the DIB section */
1310 X11DRV_LockDIBSection(physDev
, DIB_Status_GdiMod
, FALSE
);
1312 /* ROP mode is always GXcopy for flood-fill */
1314 XSetFunction( gdi_display
, physDev
->gc
, GXcopy
);
1315 X11DRV_InternalFloodFill(image
, physDev
,
1318 physDev
->dc_rect
.left
+ rect
.left
,
1319 physDev
->dc_rect
.top
+ rect
.top
,
1320 X11DRV_PALETTE_ToPhysical( physDev
, color
),
1322 wine_tsx11_unlock();
1323 /* Update the DIBSection of the dc's bitmap */
1324 X11DRV_UnlockDIBSection(physDev
, TRUE
);
1328 XDestroyImage( image
);
1329 wine_tsx11_unlock();
1333 /**********************************************************************
1337 X11DRV_SetBkColor( X11DRV_PDEVICE
*physDev
, COLORREF color
)
1339 physDev
->backgroundPixel
= X11DRV_PALETTE_ToPhysical( physDev
, color
);
1343 /**********************************************************************
1344 * X11DRV_SetTextColor
1347 X11DRV_SetTextColor( X11DRV_PDEVICE
*physDev
, COLORREF color
)
1349 physDev
->textPixel
= X11DRV_PALETTE_ToPhysical( physDev
, color
);
1353 /***********************************************************************
1354 * GetDCOrgEx (X11DRV.@)
1356 BOOL
X11DRV_GetDCOrgEx( X11DRV_PDEVICE
*physDev
, LPPOINT lpp
)
1358 lpp
->x
= physDev
->dc_rect
.left
+ physDev
->drawable_rect
.left
;
1359 lpp
->y
= physDev
->dc_rect
.top
+ physDev
->drawable_rect
.top
;
1364 /***********************************************************************
1365 * SetDCOrg (X11DRV.@)
1367 DWORD
X11DRV_SetDCOrg( X11DRV_PDEVICE
*physDev
, INT x
, INT y
)
1369 DWORD ret
= MAKELONG( physDev
->dc_rect
.left
+ physDev
->drawable_rect
.left
,
1370 physDev
->dc_rect
.top
+ physDev
->drawable_rect
.top
);
1371 physDev
->dc_rect
.left
= x
- physDev
->drawable_rect
.left
;
1372 physDev
->dc_rect
.top
= y
- physDev
->drawable_rect
.top
;