GDI separation patch (take 2)
Andreas Mohr
andi at rhlx01.fht-esslingen.de
Tue May 7 14:46:46 CDT 2002
Hi all,
this one tackles
"551 [NEW] - DLL Separation: gdi32 from ntdll (misc)"
http://bugs.winehq.com/long_list.cgi?buglist=551
- replace SELECTOR_AllocBlock and SELECTOR_FreeBlock with standard Win16
selector calls and some (IMHO ugly) duplicated selector glue code
- slight optimization in SELECTOR_SetEntries
Thanks to Dmitry Timoshkov for noticing my stupid messup !
(the previous code logic even showed how it had to be done, yet I failed to
do it this way ! :-\)
--
Andreas Mohr Stauferstr. 6, D-71272 Renningen, Germany
-------------- next part --------------
Determining best CVS host...
Using CVSROOT :pserver:cvs at rhlx01.fht-esslingen.de:/home/wine
Index: memory/selector.c
===================================================================
RCS file: /home/wine/wine/memory/selector.c,v
retrieving revision 1.46
diff -u -r1.46 selector.c
--- memory/selector.c 4 May 2002 18:37:08 -0000 1.46
+++ memory/selector.c 7 May 2002 19:43:57 -0000
@@ -161,15 +161,18 @@
WORD i, count;
wine_ldt_set_base( &entry, base );
- wine_ldt_set_limit( &entry, size - 1 );
+ if (!base && size == 1)
+ /* Make sure base and limit are not 0 together if the size is not 0 */
+ wine_ldt_set_limit( &entry, 1 );
+ else /* default case */
+ wine_ldt_set_limit( &entry, size - 1 );
wine_ldt_set_flags( &entry, flags );
- /* Make sure base and limit are not 0 together if the size is not 0 */
- if (!base && size == 1) wine_ldt_set_limit( &entry, 1 );
count = (size + 0xffff) / 0x10000;
for (i = 0; i < count; i++)
{
wine_ldt_set_entry( sel + (i << __AHSHIFT), &entry );
wine_ldt_set_base( &entry, wine_ldt_get_base(&entry) + 0x10000 );
+ /* yep, Windows sets limit like that, not 64K sel units instead ! */
wine_ldt_set_limit( &entry, wine_ldt_get_limit(&entry) - 0x10000 );
}
}
Index: objects/bitmap.c
===================================================================
RCS file: /home/wine/wine/objects/bitmap.c,v
retrieving revision 1.47
diff -u -r1.47 bitmap.c
--- objects/bitmap.c 28 Mar 2002 22:22:07 -0000 1.47
+++ objects/bitmap.c 7 May 2002 19:43:58 -0000
@@ -443,7 +443,15 @@
}
HeapFree(GetProcessHeap(), 0, dib);
bmp->dib = NULL;
- if (bmp->segptr_bits) SELECTOR_FreeBlock( SELECTOROF(bmp->segptr_bits) );
+ if (bmp->segptr_bits)
+ { /* free its selector array */
+ WORD sel = SELECTOROF(bmp->segptr_bits);
+ WORD count = ((GetSelectorLimit16(sel) + 1) + 0xffff) / 0x10000;
+ int i;
+
+ for (i = 0; i < count; i++)
+ FreeSelector16(sel + (i << __AHSHIFT));
+ }
}
return GDI_FreeObject( hbitmap, bmp );
}
Index: objects/dib.c
===================================================================
RCS file: /home/wine/wine/objects/dib.c,v
retrieving revision 1.64
diff -u -r1.64 dib.c
--- objects/dib.c 28 Mar 2002 22:22:07 -0000 1.64
+++ objects/dib.c 7 May 2002 19:43:58 -0000
@@ -895,7 +895,21 @@
INT size = (bi->biSizeImage && bi->biCompression != BI_RGB) ?
bi->biSizeImage : width_bytes * height;
- WORD sel = SELECTOR_AllocBlock( bits32, size, WINE_LDT_FLAGS_DATA );
+ /* calculate number of sel's needed for size with 64K steps */
+ WORD count = (size + 0xffff) / 0x10000;
+ WORD sel = AllocSelectorArray16(count);
+ DWORD sizeRemain;
+ int i;
+
+ sizeRemain = size;
+ for (i = 0; i < count; i++)
+ {
+ SetSelectorBase(sel + (i << __AHSHIFT),
+ (DWORD)bits32 + i * 0x10000);
+ SetSelectorLimit16(sel + (i << __AHSHIFT),
+ sizeRemain - 1); /* yep, this limit */
+ sizeRemain -= 0x10000; /* is correct */
+ }
bmp->segptr_bits = MAKESEGPTR( sel, 0 );
if (bits16) *bits16 = bmp->segptr_bits;
}
More information about the wine-patches
mailing list