clipping.c 15.8 KB
Newer Older
Alexandre Julliard's avatar
Alexandre Julliard committed
1 2 3 4
/*
 * DC clipping functions
 *
 * Copyright 1993 Alexandre Julliard
5 6 7 8 9 10 11 12 13 14 15 16 17
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * 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
Alexandre Julliard's avatar
Alexandre Julliard committed
19 20
 */

21
#include <stdarg.h>
22
#include <stdlib.h>
23
#include "windef.h"
24
#include "winbase.h"
25
#include "wingdi.h"
26
#include "gdi_private.h"
27
#include "wine/debug.h"
Alexandre Julliard's avatar
Alexandre Julliard committed
28

29
WINE_DEFAULT_DEBUG_CHANNEL(clipping);
Alexandre Julliard's avatar
Alexandre Julliard committed
30 31


32 33
/* return the DC device rectangle if not empty */
static inline BOOL get_dc_device_rect( DC *dc, RECT *rect )
34
{
35 36 37
    *rect = dc->device_rect;
    offset_rect( rect, -dc->vis_rect.left, -dc->vis_rect.top );
    return !is_rect_empty( rect );
38 39
}

40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
/***********************************************************************
 *           get_clip_rect
 *
 * Compute a clip rectangle from its logical coordinates.
 */
static inline RECT get_clip_rect( DC * dc, int left, int top, int right, int bottom )
{
    RECT rect;

    rect.left   = left;
    rect.top    = top;
    rect.right  = right;
    rect.bottom = bottom;
    LPtoDP( dc->hSelf, (POINT *)&rect, 2 );
    if (dc->layout & LAYOUT_RTL)
    {
        int tmp = rect.left;
        rect.left = rect.right + 1;
        rect.right = tmp + 1;
    }
    return rect;
}

63 64 65 66 67 68 69 70 71 72 73 74 75 76
/***********************************************************************
 *           clip_device_rect
 *
 * Clip a rectangle to the whole DC surface.
 */
BOOL clip_device_rect( DC *dc, RECT *dst, const RECT *src )
{
    RECT clip;

    if (get_dc_device_rect( dc, &clip )) return intersect_rect( dst, src, &clip );
    *dst = *src;
    return TRUE;
}

77 78 79 80 81 82 83 84 85
/***********************************************************************
 *           clip_visrect
 *
 * Clip a rectangle to the DC visible rect.
 */
BOOL clip_visrect( DC *dc, RECT *dst, const RECT *src )
{
    RECT clip;

86 87 88
    if (!clip_device_rect( dc, dst, src )) return FALSE;
    if (GetRgnBox( get_dc_region(dc), &clip )) return intersect_rect( dst, dst, &clip );
    return TRUE;
89 90
}

Alexandre Julliard's avatar
Alexandre Julliard committed
91
/***********************************************************************
92
 *           update_dc_clipping
Alexandre Julliard's avatar
Alexandre Julliard committed
93
 *
94
 * Update the DC and device clip regions when the ClipRgn or VisRgn have changed.
Alexandre Julliard's avatar
Alexandre Julliard committed
95
 */
96
void update_dc_clipping( DC * dc )
Alexandre Julliard's avatar
Alexandre Julliard committed
97
{
98
    PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetDeviceClipping );
99 100
    HRGN regions[3];
    int count = 0;
101

102 103 104 105 106
    if (dc->hVisRgn)  regions[count++] = dc->hVisRgn;
    if (dc->hClipRgn) regions[count++] = dc->hClipRgn;
    if (dc->hMetaRgn) regions[count++] = dc->hMetaRgn;

    if (count > 1)
107 108
    {
        if (!dc->region) dc->region = CreateRectRgn( 0, 0, 0, 0 );
109 110
        CombineRgn( dc->region, regions[0], regions[1], RGN_AND );
        if (count > 2) CombineRgn( dc->region, dc->region, regions[2], RGN_AND );
111
    }
112
    else  /* only one region, we don't need the total region */
113 114 115
    {
        if (dc->region) DeleteObject( dc->region );
        dc->region = 0;
116
    }
117
    physdev->funcs->pSetDeviceClipping( physdev, get_dc_region( dc ));
Alexandre Julliard's avatar
Alexandre Julliard committed
118 119
}

120
/***********************************************************************
121
 *           create_default_clip_region
122 123 124 125 126
 *
 * Create a default clipping region when none already exists.
 */
static inline void create_default_clip_region( DC * dc )
{
127
    RECT rect;
128

129
    if (!get_dc_device_rect( dc, &rect ))
130
    {
131 132 133 134
        rect.left = 0;
        rect.top = 0;
        rect.right = GetDeviceCaps( dc->hSelf, DESKTOPHORZRES );
        rect.bottom = GetDeviceCaps( dc->hSelf, DESKTOPVERTRES );
135
    }
136
    dc->hClipRgn = CreateRectRgnIndirect( &rect );
137 138
}

Alexandre Julliard's avatar
Alexandre Julliard committed
139

Alexandre Julliard's avatar
Alexandre Julliard committed
140
/***********************************************************************
141
 *           null driver fallback implementations
Alexandre Julliard's avatar
Alexandre Julliard committed
142
 */
143

144
INT nulldrv_ExtSelectClipRgn( PHYSDEV dev, HRGN rgn, INT mode )
Alexandre Julliard's avatar
Alexandre Julliard committed
145
{
146 147
    DC *dc = get_nulldrv_dc( dev );
    INT ret;
148

149
    if (!rgn)
Alexandre Julliard's avatar
Alexandre Julliard committed
150
    {
151
        if (mode != RGN_COPY)
152
        {
153
            FIXME("Unimplemented: hrgn NULL in mode: %d\n", mode);
154 155
            return ERROR;
        }
156 157 158
        if (dc->hClipRgn) DeleteObject( dc->hClipRgn );
        dc->hClipRgn = 0;
        ret = SIMPLEREGION;
Alexandre Julliard's avatar
Alexandre Julliard committed
159
    }
160
    else
Alexandre Julliard's avatar
Alexandre Julliard committed
161
    {
162 163 164 165
        HRGN mirrored = 0;

        if (dc->layout & LAYOUT_RTL)
        {
166 167 168
            if (!(mirrored = CreateRectRgn( 0, 0, 0, 0 ))) return ERROR;
            mirror_region( mirrored, rgn, dc->vis_rect.right - dc->vis_rect.left );
            rgn = mirrored;
169 170
        }

171
        if (!dc->hClipRgn)
172
            create_default_clip_region( dc );
173

174 175
        if (mode == RGN_COPY)
            ret = CombineRgn( dc->hClipRgn, rgn, 0, mode );
176
        else
177
            ret = CombineRgn( dc->hClipRgn, dc->hClipRgn, rgn, mode);
178 179

        if (mirrored) DeleteObject( mirrored );
Alexandre Julliard's avatar
Alexandre Julliard committed
180
    }
181
    update_dc_clipping( dc );
182 183
    return ret;
}
184

185
INT nulldrv_ExcludeClipRect( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
186 187 188 189 190 191 192 193 194 195
{
    DC *dc = get_nulldrv_dc( dev );
    RECT rect = get_clip_rect( dc, left, top, right, bottom );
    INT ret;
    HRGN rgn;

    if (!(rgn = CreateRectRgnIndirect( &rect ))) return ERROR;
    if (!dc->hClipRgn) create_default_clip_region( dc );
    ret = CombineRgn( dc->hClipRgn, dc->hClipRgn, rgn, RGN_DIFF );
    DeleteObject( rgn );
196
    if (ret != ERROR) update_dc_clipping( dc );
197 198 199
    return ret;
}

200
INT nulldrv_IntersectClipRect( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
{
    DC *dc = get_nulldrv_dc( dev );
    RECT rect = get_clip_rect( dc, left, top, right, bottom );
    INT ret;
    HRGN rgn;

    if (!dc->hClipRgn)
    {
        dc->hClipRgn = CreateRectRgnIndirect( &rect );
        ret = SIMPLEREGION;
    }
    else
    {
        if (!(rgn = CreateRectRgnIndirect( &rect ))) return ERROR;
        ret = CombineRgn( dc->hClipRgn, dc->hClipRgn, rgn, RGN_AND );
        DeleteObject( rgn );
    }
218
    if (ret != ERROR) update_dc_clipping( dc );
219 220 221
    return ret;
}

222
INT nulldrv_OffsetClipRgn( PHYSDEV dev, INT x, INT y )
223 224 225 226 227 228 229 230 231 232
{
    DC *dc = get_nulldrv_dc( dev );
    INT ret = NULLREGION;

    if (dc->hClipRgn)
    {
        x = MulDiv( x, dc->vportExtX, dc->wndExtX );
        y = MulDiv( y, dc->vportExtY, dc->wndExtY );
        if (dc->layout & LAYOUT_RTL) x = -x;
        ret = OffsetRgn( dc->hClipRgn, x, y );
233
	update_dc_clipping( dc );
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252
    }
    return ret;
}


/***********************************************************************
 *           SelectClipRgn    (GDI32.@)
 */
INT WINAPI SelectClipRgn( HDC hdc, HRGN hrgn )
{
    return ExtSelectClipRgn( hdc, hrgn, RGN_COPY );
}


/******************************************************************************
 *		ExtSelectClipRgn	[GDI32.@]
 */
INT WINAPI ExtSelectClipRgn( HDC hdc, HRGN hrgn, INT fnMode )
{
253 254
    PHYSDEV physdev;
    INT retval;
255 256 257 258
    DC * dc = get_dc_ptr( hdc );

    TRACE("%p %p %d\n", hdc, hrgn, fnMode );

259 260 261 262 263
    if (!dc) return ERROR;
    update_dc( dc );
    physdev = GET_DC_PHYSDEV( dc, pExtSelectClipRgn );
    retval = physdev->funcs->pExtSelectClipRgn( physdev, hrgn, fnMode );
    release_dc_ptr( dc );
264
    return retval;
Alexandre Julliard's avatar
Alexandre Julliard committed
265 266 267
}

/***********************************************************************
268
 *           __wine_set_visible_region   (GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
269
 */
270 271
void CDECL __wine_set_visible_region( HDC hdc, HRGN hrgn, const RECT *vis_rect, const RECT *device_rect,
                                      struct window_surface *surface )
Alexandre Julliard's avatar
Alexandre Julliard committed
272
{
273 274
    DC * dc;

275
    if (!(dc = get_dc_ptr( hdc ))) return;
Alexandre Julliard's avatar
Alexandre Julliard committed
276

277 278
    TRACE( "%p %p %s %s %p\n", hdc, hrgn,
           wine_dbgstr_rect(vis_rect), wine_dbgstr_rect(device_rect), surface );
Alexandre Julliard's avatar
Alexandre Julliard committed
279

280 281
    /* map region to DC coordinates */
    OffsetRgn( hrgn, -vis_rect->left, -vis_rect->top );
Alexandre Julliard's avatar
Alexandre Julliard committed
282

283
    if (dc->hVisRgn) DeleteObject( dc->hVisRgn );
284
    dc->dirty = 0;
285
    dc->vis_rect = *vis_rect;
286
    dc->device_rect = *device_rect;
287
    dc->hVisRgn = hrgn;
288
    dibdrv_set_window_surface( dc, surface );
289
    DC_UpdateXforms( dc );
290
    update_dc_clipping( dc );
291
    release_dc_ptr( dc );
Alexandre Julliard's avatar
Alexandre Julliard committed
292 293 294
}


Alexandre Julliard's avatar
Alexandre Julliard committed
295
/***********************************************************************
296
 *           OffsetClipRgn    (GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
297
 */
298
INT WINAPI OffsetClipRgn( HDC hdc, INT x, INT y )
Alexandre Julliard's avatar
Alexandre Julliard committed
299
{
300 301
    PHYSDEV physdev;
    INT ret;
302
    DC *dc = get_dc_ptr( hdc );
Alexandre Julliard's avatar
Alexandre Julliard committed
303

304
    TRACE("%p %d,%d\n", hdc, x, y );
Alexandre Julliard's avatar
Alexandre Julliard committed
305

306 307 308 309 310
    if (!dc) return ERROR;
    update_dc( dc );
    physdev = GET_DC_PHYSDEV( dc, pOffsetClipRgn );
    ret = physdev->funcs->pOffsetClipRgn( physdev, x, y );
    release_dc_ptr( dc );
311
    return ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
312 313 314
}


Alexandre Julliard's avatar
Alexandre Julliard committed
315
/***********************************************************************
316
 *           ExcludeClipRect    (GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
317
 */
318 319
INT WINAPI ExcludeClipRect( HDC hdc, INT left, INT top,
                                INT right, INT bottom )
Alexandre Julliard's avatar
Alexandre Julliard committed
320
{
321 322
    PHYSDEV physdev;
    INT ret;
323
    DC *dc = get_dc_ptr( hdc );
Alexandre Julliard's avatar
Alexandre Julliard committed
324

325
    TRACE("%p %d,%d-%d,%d\n", hdc, left, top, right, bottom );
326

327 328 329 330 331
    if (!dc) return ERROR;
    update_dc( dc );
    physdev = GET_DC_PHYSDEV( dc, pExcludeClipRect );
    ret = physdev->funcs->pExcludeClipRect( physdev, left, top, right, bottom );
    release_dc_ptr( dc );
Alexandre Julliard's avatar
Alexandre Julliard committed
332
    return ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
333 334 335
}


Alexandre Julliard's avatar
Alexandre Julliard committed
336
/***********************************************************************
337
 *           IntersectClipRect    (GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
338
 */
339
INT WINAPI IntersectClipRect( HDC hdc, INT left, INT top, INT right, INT bottom )
Alexandre Julliard's avatar
Alexandre Julliard committed
340
{
341 342
    PHYSDEV physdev;
    INT ret;
343
    DC *dc = get_dc_ptr( hdc );
Alexandre Julliard's avatar
Alexandre Julliard committed
344

345
    TRACE("%p %d,%d - %d,%d\n", hdc, left, top, right, bottom );
346

347 348 349 350 351
    if (!dc) return ERROR;
    update_dc( dc );
    physdev = GET_DC_PHYSDEV( dc, pIntersectClipRect );
    ret = physdev->funcs->pIntersectClipRect( physdev, left, top, right, bottom );
    release_dc_ptr( dc );
Alexandre Julliard's avatar
Alexandre Julliard committed
352
    return ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
353 354 355
}


Alexandre Julliard's avatar
Alexandre Julliard committed
356
/***********************************************************************
357
 *           PtVisible    (GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
358
 */
359
BOOL WINAPI PtVisible( HDC hdc, INT x, INT y )
Alexandre Julliard's avatar
Alexandre Julliard committed
360
{
361
    POINT pt;
362
    RECT visrect;
363
    BOOL ret;
364
    DC *dc = get_dc_ptr( hdc );
Alexandre Julliard's avatar
Alexandre Julliard committed
365

366
    TRACE("%p %d,%d\n", hdc, x, y );
367
    if (!dc) return FALSE;
368

369 370 371
    pt.x = x;
    pt.y = y;
    LPtoDP( hdc, &pt, 1 );
372
    update_dc( dc );
373
    ret = (!get_dc_device_rect( dc, &visrect ) ||
374 375
           (pt.x >= visrect.left && pt.x < visrect.right &&
            pt.y >= visrect.top && pt.y < visrect.bottom));
376
    if (ret && get_dc_region( dc )) ret = PtInRegion( get_dc_region( dc ), pt.x, pt.y );
377
    release_dc_ptr( dc );
378 379
    return ret;
}
Alexandre Julliard's avatar
Alexandre Julliard committed
380 381


382 383 384 385
/***********************************************************************
 *           RectVisible    (GDI32.@)
 */
BOOL WINAPI RectVisible( HDC hdc, const RECT* rect )
Alexandre Julliard's avatar
Alexandre Julliard committed
386
{
387
    RECT tmpRect, visrect;
388
    BOOL ret;
389
    DC *dc = get_dc_ptr( hdc );
Alexandre Julliard's avatar
Alexandre Julliard committed
390
    if (!dc) return FALSE;
391
    TRACE("%p %s\n", hdc, wine_dbgstr_rect( rect ));
392

393 394 395
    tmpRect = *rect;
    LPtoDP( hdc, (POINT *)&tmpRect, 2 );

396
    update_dc( dc );
397
    ret = (!get_dc_device_rect( dc, &visrect ) || intersect_rect( &visrect, &visrect, &tmpRect ));
398
    if (ret && get_dc_region( dc )) ret = RectInRegion( get_dc_region( dc ), &tmpRect );
399
    release_dc_ptr( dc );
400
    return ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
401 402 403
}


Alexandre Julliard's avatar
Alexandre Julliard committed
404
/***********************************************************************
405
 *           GetClipBox    (GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
406
 */
407
INT WINAPI GetClipBox( HDC hdc, LPRECT rect )
Alexandre Julliard's avatar
Alexandre Julliard committed
408
{
409
    RECT visrect;
410
    INT ret;
411
    DC *dc = get_dc_ptr( hdc );
412
    if (!dc) return ERROR;
413 414

    update_dc( dc );
415 416 417 418
    if (get_dc_region( dc ))
    {
        ret = GetRgnBox( get_dc_region( dc ), rect );
    }
419 420 421 422 423
    else
    {
        ret = is_rect_empty( &dc->vis_rect ) ? ERROR : SIMPLEREGION;
        *rect = dc->vis_rect;
    }
424

425 426
    if (get_dc_device_rect( dc, &visrect ) && !intersect_rect( rect, rect, &visrect )) ret = NULLREGION;

427 428 429 430 431 432
    if (dc->layout & LAYOUT_RTL)
    {
        int tmp = rect->left;
        rect->left = rect->right - 1;
        rect->right = tmp - 1;
    }
433
    DPtoLP( hdc, (LPPOINT)rect, 2 );
434
    release_dc_ptr( dc );
435
    TRACE("%p => %d %s\n", hdc, ret, wine_dbgstr_rect( rect ));
Alexandre Julliard's avatar
Alexandre Julliard committed
436
    return ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
437 438
}

Alexandre Julliard's avatar
Alexandre Julliard committed
439

Alexandre Julliard's avatar
Alexandre Julliard committed
440
/***********************************************************************
441
 *           GetClipRgn  (GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
442
 */
443
INT WINAPI GetClipRgn( HDC hdc, HRGN hRgn )
Alexandre Julliard's avatar
Alexandre Julliard committed
444
{
445 446
    INT ret = -1;
    DC * dc;
447
    if ((dc = get_dc_ptr( hdc )))
448
    {
449
      if( dc->hClipRgn )
450
      {
451 452 453 454 455 456
          if( CombineRgn(hRgn, dc->hClipRgn, 0, RGN_COPY) != ERROR )
          {
              ret = 1;
              if (dc->layout & LAYOUT_RTL)
                  mirror_region( hRgn, hRgn, dc->vis_rect.right - dc->vis_rect.left );
          }
Alexandre Julliard's avatar
Alexandre Julliard committed
457
      }
458
      else ret = 0;
459
      release_dc_ptr( dc );
460
    }
461
    return ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
462
}
Alexandre Julliard's avatar
Alexandre Julliard committed
463

464 465 466 467 468 469 470

/***********************************************************************
 *           GetMetaRgn    (GDI32.@)
 */
INT WINAPI GetMetaRgn( HDC hdc, HRGN hRgn )
{
    INT ret = 0;
471
    DC * dc = get_dc_ptr( hdc );
472 473 474 475

    if (dc)
    {
        if (dc->hMetaRgn && CombineRgn( hRgn, dc->hMetaRgn, 0, RGN_COPY ) != ERROR)
476
        {
477
            ret = 1;
478 479 480
            if (dc->layout & LAYOUT_RTL)
                mirror_region( hRgn, hRgn, dc->vis_rect.right - dc->vis_rect.left );
        }
481
        release_dc_ptr( dc );
482 483 484 485 486
    }
    return ret;
}


487 488 489 490 491
/***********************************************************************
 * GetRandomRgn [GDI32.@]
 *
 * NOTES
 *     This function is documented in MSDN online for the case of
492
 *     iCode == SYSRGN (4).
493
 *
494 495 496 497
 *     For iCode == 1 it should return the clip region
 *                  2 "    "       "   the meta region
 *                  3 "    "       "   the intersection of the clip with
 *                                     the meta region (== 'Rao' region).
498 499 500
 *
 *     See http://www.codeproject.com/gdi/cliprgnguide.asp
 */
501
INT WINAPI GetRandomRgn(HDC hDC, HRGN hRgn, INT iCode)
502
{
503
    INT ret = 1;
504
    DC *dc = get_dc_ptr( hDC );
505 506 507

    if (!dc) return -1;

508
    switch (iCode)
509
    {
510
    case 1:
511 512
        if (dc->hClipRgn) CombineRgn( hRgn, dc->hClipRgn, 0, RGN_COPY );
        else ret = 0;
513 514
        break;
    case 2:
515 516
        if (dc->hMetaRgn) CombineRgn( hRgn, dc->hMetaRgn, 0, RGN_COPY );
        else ret = 0;
517 518
        break;
    case 3:
519
        if (dc->hClipRgn && dc->hMetaRgn) CombineRgn( hRgn, dc->hClipRgn, dc->hMetaRgn, RGN_AND );
520 521 522
        else if (dc->hClipRgn) CombineRgn( hRgn, dc->hClipRgn, 0, RGN_COPY );
        else if (dc->hMetaRgn) CombineRgn( hRgn, dc->hMetaRgn, 0, RGN_COPY );
        else ret = 0;
523
        break;
524
    case SYSRGN: /* == 4 */
525
        update_dc( dc );
526
        if (dc->hVisRgn)
527
        {
528
            CombineRgn( hRgn, dc->hVisRgn, 0, RGN_COPY );
529 530 531 532 533 534
            /* On Windows NT/2000, the SYSRGN returned is in screen coordinates */
            if (!(GetVersion() & 0x80000000)) OffsetRgn( hRgn, dc->vis_rect.left, dc->vis_rect.top );
        }
        else if (!is_rect_empty( &dc->device_rect ))
            SetRectRgn( hRgn, dc->device_rect.left, dc->device_rect.top,
                        dc->device_rect.right, dc->device_rect.bottom );
535 536
        else
            ret = 0;
537
        break;
538
    default:
539
        WARN("Unknown code %d\n", iCode);
540 541
        ret = -1;
        break;
542
    }
543
    release_dc_ptr( dc );
544
    return ret;
545 546 547 548
}


/***********************************************************************
549
 *           SetMetaRgn    (GDI32.@)
550
 */
551
INT WINAPI SetMetaRgn( HDC hdc )
552
{
553 554
    INT ret;
    RECT dummy;
555
    DC *dc = get_dc_ptr( hdc );
556

557
    if (!dc) return ERROR;
558

559
    if (dc->hClipRgn)
560
    {
561 562 563 564 565 566 567 568 569 570 571 572
        if (dc->hMetaRgn)
        {
            /* the intersection becomes the new meta region */
            CombineRgn( dc->hMetaRgn, dc->hMetaRgn, dc->hClipRgn, RGN_AND );
            DeleteObject( dc->hClipRgn );
            dc->hClipRgn = 0;
        }
        else
        {
            dc->hMetaRgn = dc->hClipRgn;
            dc->hClipRgn = 0;
        }
573 574
    }
    /* else nothing to do */
575

576
    /* Note: no need to call update_dc_clipping, the overall clip region hasn't changed */
577

578
    ret = GetRgnBox( dc->hMetaRgn, &dummy );
579
    release_dc_ptr( dc );
580
    return ret;
581
}