3 /* the following deal with IEEE single-precision numbers */
5 #define SIGNBIT 0x80000000L
6 #define SIGN(fp) ((fp) & SIGNBIT)
7 #define EXP(fp) (((fp) >> 23L) & 0xFF)
8 #define MANT(fp) ((fp) & 0x7FFFFFL)
9 #define PACK(s,e,m) ((s) | ((e) << 23L) | (m))
13 #define FLOAT_TO_INT(in,out) \
14 __asm__ __volatile__ ("fistpl %0" : "=m" (out) : "t" (in) : "st");
16 #define FLOAT_TO_INT(in,out) \
23 EFtoF( EFLOAT_S
* efp
)
25 long Mant
, Exp
, Sign
= 0;
27 if (!efp
->lMant
) return 0;
33 //// M$ storage emulation
34 if( Sign
) Mant
= -Mant
;
35 Mant
= ((Mant
& 0x3fffffff) >> 7);
39 return PACK(Sign
, Exp
, Mant
);
44 FtoEF( EFLOAT_S
* efp
, FLOATL f
)
46 long Mant
, Exp
, Sign
= 0;
50 worker
.l
= f
; // It's a float stored in a long.
56 Mant
= MANT(worker
.l
);
57 if (SIGN(worker
.l
)) Sign
= -1;
58 //// M$ storage emulation
59 Mant
= ((Mant
<< 7) | 0x40000000);
70 CoordCnvP(MATRIX_S
* mx
, LPPOINT Point
)
78 a
.l
= EFtoF( &mx
->efM11
);
79 b
.l
= EFtoF( &mx
->efM21
);
80 c
.l
= EFtoF( &mx
->efDx
);
81 x
= x
* a
.f
+ y
* b
.f
+ c
.f
;
83 a
.l
= EFtoF( &mx
->efM12
);
84 b
.l
= EFtoF( &mx
->efM22
);
85 c
.l
= EFtoF( &mx
->efDy
);
86 y
= x
* a
.f
+ y
* b
.f
+ c
.f
;
88 FLOAT_TO_INT(x
, Point
->x
);
89 FLOAT_TO_INT(y
, Point
->y
);
95 DPtoLP ( HDC hDC
, LPPOINT Points
, INT Count
)
101 if (!GdiGetHandleUserData((HGDIOBJ
) hDC
, GDI_OBJECT_TYPE_DC
, (PVOID
) &Dc_Attr
)) return FALSE
;
103 if (Dc_Attr
->flXform
& ( DEVICE_TO_WORLD_INVALID
| // Force a full recalibration!
104 PAGE_XLATE_CHANGED
| // Changes or Updates have been made,
105 PAGE_EXTENTS_CHANGED
| // do processing in kernel space.
106 WORLD_XFORM_CHANGED
))
108 return NtGdiTransformPoints( hDC
, Points
, Points
, Count
, GdiDpToLp
); // DPtoLP mode.
112 for ( i
= 0; i
< Count
; i
++ )
113 CoordCnvP ( &Dc_Attr
->mxDeviceToWorld
, &Points
[i
] );
122 LPtoDP ( HDC hDC
, LPPOINT Points
, INT Count
)
128 if (!GdiGetHandleUserData((HGDIOBJ
) hDC
, GDI_OBJECT_TYPE_DC
, (PVOID
) &Dc_Attr
)) return FALSE
;
130 if (Dc_Attr
->flXform
& ( PAGE_XLATE_CHANGED
| // Check for Changes and Updates
131 PAGE_EXTENTS_CHANGED
|
132 WORLD_XFORM_CHANGED
))
134 return NtGdiTransformPoints( hDC
, Points
, Points
, Count
, GdiLpToDp
); // LPtoDP mode
138 for ( i
= 0; i
< Count
; i
++ )
139 CoordCnvP ( &Dc_Attr
->mxWorldToDevice
, &Points
[i
] );
151 GetCurrentPositionEx(HDC hdc
,
156 if (!GdiGetHandleUserData((HGDIOBJ
) hdc
, GDI_OBJECT_TYPE_DC
, (PVOID
) &Dc_Attr
)) return FALSE
;
160 if ( Dc_Attr
->ulDirty_
& DIRTY_PTLCURRENT
) // have a hit!
162 lpPoint
->x
= Dc_Attr
->ptfxCurrent
.x
;
163 lpPoint
->y
= Dc_Attr
->ptfxCurrent
.y
;
164 DPtoLP ( hdc
, lpPoint
, 1); // reconvert back.
165 Dc_Attr
->ptlCurrent
.x
= lpPoint
->x
; // save it
166 Dc_Attr
->ptlCurrent
.y
= lpPoint
->y
;
167 Dc_Attr
->ulDirty_
&= ~DIRTY_PTLCURRENT
; // clear bit
171 lpPoint
->x
= Dc_Attr
->ptlCurrent
.x
;
172 lpPoint
->y
= Dc_Attr
->ptlCurrent
.y
;
177 SetLastError(ERROR_INVALID_PARAMETER
);
188 GetWorldTransform( HDC hDC
, LPXFORM lpXform
)
190 return NtGdiGetTransform( hDC
, GdiWorldSpaceToPageSpace
, lpXform
);
196 SetWorldTransform( HDC hDC
, CONST XFORM
*Xform
)
198 /* FIXME shall we add undoc #define MWT_SETXFORM 4 ?? */
199 return ModifyWorldTransform( hDC
, Xform
, MWT_MAX
+1);
205 ModifyWorldTransform(
212 // Handle something other than a normal dc object.
213 if (GDI_HANDLE_GET_TYPE(hDC
) != GDI_OBJECT_TYPE_DC
)
215 if (GDI_HANDLE_GET_TYPE(hDC
) == GDI_OBJECT_TYPE_METADC
)
219 PLDC pLDC
= GdiGetLDC(hDC
);
222 SetLastError(ERROR_INVALID_HANDLE
);
225 if (pLDC
->iType
== LDC_EMFLDC
)
227 if (iMode
== MWT_MAX
+1)
228 if (!EMFDRV_SetWorldTransform( hDC
, Xform
) ) return FALSE
;
229 return EMFDRV_ModifyWorldTransform( hDC
, Xform
, iMode
); // Ported from wine.
237 if (!GdiGetHandleUserData((HGDIOBJ
) hDC
, GDI_OBJECT_TYPE_DC
, (PVOID
) &Dc_Attr
)) return FALSE
;
239 /* Check that graphics mode is GM_ADVANCED */
240 if ( Dc_Attr
->iGraphicsMode
!= GM_ADVANCED
) return FALSE
;
242 return NtGdiModifyWorldTransform(hDC
, (CONST LPXFORM
) Xform
, iMode
);
254 if (!GdiGetHandleUserData((HGDIOBJ
) hdc
, GDI_OBJECT_TYPE_DC
, (PVOID
) &Dc_Attr
)) return FALSE
;
256 if ((Dc_Attr
->flXform
& PAGE_EXTENTS_CHANGED
) && (Dc_Attr
->iMapMode
== MM_ISOTROPIC
))
257 // Something was updated, go to kernel.
258 return NtGdiGetDCPoint( hdc
, GdiGetViewPortExt
, (LPPOINT
) lpSize
);
261 lpSize
->cx
= Dc_Attr
->szlViewportExt
.cx
;
262 lpSize
->cy
= Dc_Attr
->szlViewportExt
.cy
;
277 if (!GdiGetHandleUserData((HGDIOBJ
) hdc
, GDI_OBJECT_TYPE_DC
, (PVOID
) &Dc_Attr
)) return FALSE
;
278 lpPoint
->x
= Dc_Attr
->ptlViewportOrg
.x
;
279 lpPoint
->y
= Dc_Attr
->ptlViewportOrg
.y
;
280 if (Dc_Attr
->dwLayout
& LAYOUT_RTL
) lpPoint
->x
= -lpPoint
->x
;
282 // return NtGdiGetDCPoint( hdc, GdiGetViewPortOrg, lpPoint );
295 if (!GdiGetHandleUserData((HGDIOBJ
) hdc
, GDI_OBJECT_TYPE_DC
, (PVOID
) &Dc_Attr
)) return FALSE
;
296 lpSize
->cx
= Dc_Attr
->szlWindowExt
.cx
;
297 lpSize
->cy
= Dc_Attr
->szlWindowExt
.cy
;
298 if (Dc_Attr
->dwLayout
& LAYOUT_RTL
) lpSize
->cx
= -lpSize
->cx
;
300 // return NtGdiGetDCPoint( hdc, GdiGetWindowExt, (LPPOINT) lpSize );
313 if (!GdiGetHandleUserData((HGDIOBJ
) hdc
, GDI_OBJECT_TYPE_DC
, (PVOID
) &Dc_Attr
)) return FALSE
;
314 lpPoint
->x
= Dc_Attr
->ptlWindowOrg
.x
;
315 lpPoint
->y
= Dc_Attr
->ptlWindowOrg
.y
;
317 //return NtGdiGetDCPoint( hdc, GdiGetWindowOrg, lpPoint );
325 SetViewportExtEx(HDC hdc
,
332 if (GDI_HANDLE_GET_TYPE(hdc
) != GDI_OBJECT_TYPE_DC
)
334 if (GDI_HANDLE_GET_TYPE(hdc
) == GDI_OBJECT_TYPE_METADC
)
335 return MFDRV_SetViewportExtEx();
338 PLDC pLDC
= GdiGetLDC(hdc
);
341 SetLastError(ERROR_INVALID_HANDLE
);
344 if (pLDC
->iType
== LDC_EMFLDC
)
346 return EMFDRV_SetViewportExtEx();
351 if (!GdiGetHandleUserData((HGDIOBJ
) hdc
, GDI_OBJECT_TYPE_DC
, (PVOID
) &Dc_Attr
))
358 lpSize
->cx
= Dc_Attr
->szlViewportExt
.cx
;
359 lpSize
->cy
= Dc_Attr
->szlViewportExt
.cy
;
362 if ((Dc_Attr
->szlViewportExt
.cx
== nXExtent
) && (Dc_Attr
->szlViewportExt
.cy
== nYExtent
))
365 if ((Dc_Attr
->iMapMode
== MM_ISOTROPIC
) || (Dc_Attr
->iMapMode
== MM_ANISOTROPIC
))
367 if (NtCurrentTeb()->GdiTebBatch
.HDC
== hdc
)
369 if (Dc_Attr
->ulDirty_
& DC_FONTTEXT_DIRTY
)
371 NtGdiFlush(); // Sync up Dc_Attr from Kernel space.
372 Dc_Attr
->ulDirty_
&= ~(DC_MODE_DIRTY
|DC_FONTTEXT_DIRTY
);
375 Dc_Attr
->szlViewportExt
.cx
= nXExtent
;
376 Dc_Attr
->szlViewportExt
.cy
= nYExtent
;
377 if (Dc_Attr
->dwLayout
& LAYOUT_RTL
) NtGdiMirrorWindowOrg(hdc
);
378 Dc_Attr
->flXform
|= (PAGE_EXTENTS_CHANGED
|INVALIDATE_ATTRIBUTES
|DEVICE_TO_WORLD_INVALID
);
388 SetWindowOrgEx(HDC hdc
,
396 if (GDI_HANDLE_GET_TYPE(hdc
) != GDI_OBJECT_TYPE_DC
)
398 if (GDI_HANDLE_GET_TYPE(hdc
) == GDI_OBJECT_TYPE_METADC
)
399 return MFDRV_SetWindowOrgEx();
402 PLDC pLDC
= GdiGetLDC(hdc
);
405 SetLastError(ERROR_INVALID_HANDLE
);
408 if (pLDC
->iType
== LDC_EMFLDC
)
410 return EMFDRV_SetWindowOrgEx();
415 if (!GdiGetHandleUserData((HGDIOBJ
) hdc
, GDI_OBJECT_TYPE_DC
, (PVOID
) &Dc_Attr
)) return FALSE
;
419 lpPoint
->x
= Dc_Attr
->ptlWindowOrg
.x
;
420 lpPoint
->y
= Dc_Attr
->ptlWindowOrg
.y
;
423 if ((Dc_Attr
->ptlWindowOrg
.x
== X
) && (Dc_Attr
->ptlWindowOrg
.y
== Y
))
426 if (NtCurrentTeb()->GdiTebBatch
.HDC
== (ULONG
)hdc
)
428 if (Dc_Attr
->ulDirty_
& DC_FONTTEXT_DIRTY
)
430 NtGdiFlush(); // Sync up Dc_Attr from Kernel space.
431 Dc_Attr
->ulDirty_
&= ~(DC_MODE_DIRTY
|DC_FONTTEXT_DIRTY
);
435 Dc_Attr
->ptlWindowOrg
.x
= X
;
436 Dc_Attr
->lWindowOrgx
= X
;
437 Dc_Attr
->ptlWindowOrg
.y
= Y
;
438 if (Dc_Attr
->dwLayout
& LAYOUT_RTL
) NtGdiMirrorWindowOrg(hdc
);
439 Dc_Attr
->flXform
|= (PAGE_XLATE_CHANGED
|DEVICE_TO_WORLD_INVALID
);
442 return NtGdiSetWindowOrgEx(hdc
,X
,Y
,lpPoint
);
450 SetWindowExtEx(HDC hdc
,
457 if (GDI_HANDLE_GET_TYPE(hdc
) != GDI_OBJECT_TYPE_DC
)
459 if (GDI_HANDLE_GET_TYPE(hdc
) == GDI_OBJECT_TYPE_METADC
)
460 return MFDRV_SetWindowExtEx();
463 PLDC pLDC
= GdiGetLDC(hdc
);
466 SetLastError(ERROR_INVALID_HANDLE
);
469 if (pLDC
->iType
== LDC_EMFLDC
)
471 return EMFDRV_SetWindowExtEx();
476 if (!GdiGetHandleUserData((HGDIOBJ
) hdc
, GDI_OBJECT_TYPE_DC
, (PVOID
) &Dc_Attr
)) return FALSE
;
480 lpSize
->cx
= Dc_Attr
->szlWindowExt
.cx
;
481 lpSize
->cy
= Dc_Attr
->szlWindowExt
.cy
;
482 if (Dc_Attr
->dwLayout
& LAYOUT_RTL
) lpSize
->cx
= -lpSize
->cx
;
485 if (Dc_Attr
->dwLayout
& LAYOUT_RTL
)
487 NtGdiMirrorWindowOrg(hdc
);
488 Dc_Attr
->flXform
|= (PAGE_EXTENTS_CHANGED
|INVALIDATE_ATTRIBUTES
|DEVICE_TO_WORLD_INVALID
);
490 else if ((Dc_Attr
->iMapMode
== MM_ISOTROPIC
) || (Dc_Attr
->iMapMode
== MM_ANISOTROPIC
))
492 if ((Dc_Attr
->szlWindowExt
.cx
== nXExtent
) && (Dc_Attr
->szlWindowExt
.cy
== nYExtent
))
495 if ((!nXExtent
) || (!nYExtent
)) return FALSE
;
497 if (NtCurrentTeb()->GdiTebBatch
.HDC
== hdc
)
499 if (Dc_Attr
->ulDirty_
& DC_FONTTEXT_DIRTY
)
501 NtGdiFlush(); // Sync up Dc_Attr from Kernel space.
502 Dc_Attr
->ulDirty_
&= ~(DC_MODE_DIRTY
|DC_FONTTEXT_DIRTY
);
505 Dc_Attr
->szlWindowExt
.cx
= nXExtent
;
506 Dc_Attr
->szlWindowExt
.cy
= nYExtent
;
507 if (Dc_Attr
->dwLayout
& LAYOUT_RTL
) NtGdiMirrorWindowOrg(hdc
);
508 Dc_Attr
->flXform
|= (PAGE_EXTENTS_CHANGED
|INVALIDATE_ATTRIBUTES
|DEVICE_TO_WORLD_INVALID
);
510 return TRUE
; // Return TRUE.
518 SetViewportOrgEx(HDC hdc
,
526 if (GDI_HANDLE_GET_TYPE(hdc
) != GDI_OBJECT_TYPE_DC
)
528 if (GDI_HANDLE_GET_TYPE(hdc
) == GDI_OBJECT_TYPE_METADC
)
529 return MFDRV_SetViewportOrgEx();
532 PLDC pLDC
= GdiGetLDC(hdc
);
535 SetLastError(ERROR_INVALID_HANDLE
);
538 if (pLDC
->iType
== LDC_EMFLDC
)
540 return EMFDRV_SetViewportOrgEx();
545 if (!GdiGetHandleUserData((HGDIOBJ
) hdc
, GDI_OBJECT_TYPE_DC
, (PVOID
) &Dc_Attr
)) return FALSE
;
549 lpPoint
->x
= Dc_Attr
->ptlViewportOrg
.x
;
550 lpPoint
->y
= Dc_Attr
->ptlViewportOrg
.y
;
551 if (Dc_Attr
->dwLayout
& LAYOUT_RTL
) lpPoint
->x
= -lpPoint
->x
;
553 Dc_Attr
->flXform
|= (PAGE_XLATE_CHANGED
|DEVICE_TO_WORLD_INVALID
);
554 if (Dc_Attr
->dwLayout
& LAYOUT_RTL
) X
= -X
;
555 Dc_Attr
->ptlViewportOrg
.x
= X
;
556 Dc_Attr
->ptlViewportOrg
.y
= Y
;
559 return NtGdiSetViewportOrgEx(hdc
,X
,Y
,lpPoint
);
577 if (GDI_HANDLE_GET_TYPE(a0
) != GDI_OBJECT_TYPE_DC
)
579 if (GDI_HANDLE_GET_TYPE(a0
) == GDI_OBJECT_TYPE_METADC
)
583 PLDC pLDC
= GdiGetLDC(a0
);
586 SetLastError(ERROR_INVALID_HANDLE
);
589 if (pLDC
->iType
== LDC_EMFLDC
)
596 if (!GdiIsHandleValid((HGDIOBJ
) a0
) ||
597 (GDI_HANDLE_GET_TYPE(a0
) != GDI_OBJECT_TYPE_DC
)) return FALSE
;
599 return NtGdiScaleViewportExtEx(a0
, a1
, a2
, a3
, a4
, a5
);
617 if (GDI_HANDLE_GET_TYPE(a0
) != GDI_OBJECT_TYPE_DC
)
619 if (GDI_HANDLE_GET_TYPE(a0
) == GDI_OBJECT_TYPE_METADC
)
623 PLDC pLDC
= GdiGetLDC(a0
);
626 SetLastError(ERROR_INVALID_HANDLE
);
629 if (pLDC
->iType
== LDC_EMFLDC
)
636 if (!GdiIsHandleValid((HGDIOBJ
) a0
) ||
637 (GDI_HANDLE_GET_TYPE(a0
) != GDI_OBJECT_TYPE_DC
)) return FALSE
;
639 return NtGdiScaleWindowExtEx(a0
, a1
, a2
, a3
, a4
, a5
);
651 if (!GdiGetHandleUserData((HGDIOBJ
) hdc
, GDI_OBJECT_TYPE_DC
, (PVOID
) &Dc_Attr
)) return GDI_ERROR
;
652 return Dc_Attr
->dwLayout
;
665 if (GDI_HANDLE_GET_TYPE(hdc
) != GDI_OBJECT_TYPE_DC
)
667 if (GDI_HANDLE_GET_TYPE(hdc
) == GDI_OBJECT_TYPE_METADC
)
668 return MFDRV_SetLayout( hdc
, dwLayout
);
671 PLDC pLDC
= GdiGetLDC(hdc
);
674 SetLastError(ERROR_INVALID_HANDLE
);
677 if (pLDC
->iType
== LDC_EMFLDC
)
679 return EMFDRV_SetLayout( hdc
, dwLayout
);
684 if (!GdiIsHandleValid((HGDIOBJ
) hdc
) ||
685 (GDI_HANDLE_GET_TYPE(hdc
) != GDI_OBJECT_TYPE_DC
)) return GDI_ERROR
;
686 return NtGdiSetLayout( hdc
, -1, dwLayout
);
694 SetLayoutWidth(HDC hdc
,LONG wox
,DWORD dwLayout
)
696 if (!GdiIsHandleValid((HGDIOBJ
) hdc
) ||
697 (GDI_HANDLE_GET_TYPE(hdc
) != GDI_OBJECT_TYPE_DC
)) return GDI_ERROR
;
698 return NtGdiSetLayout( hdc
, wox
, dwLayout
);
707 OffsetViewportOrgEx(HDC hdc
,
715 if (GDI_HANDLE_GET_TYPE(hdc
) != GDI_OBJECT_TYPE_DC
)
717 if (GDI_HANDLE_GET_TYPE(hdc
) == GDI_OBJECT_TYPE_METADC
)
718 return MFDRV_OffsetViewportOrgEx(hdc
, nXOffset
, nYOffset
, lpPoint
);
721 PLDC pLDC
= GdiGetLDC(hdc
);
724 SetLastError(ERROR_INVALID_HANDLE
);
727 if (pLDC
->iType
== LDC_EMFLDC
)
729 return EMFDRV_OffsetWindowOrgEx(hdc
, nXOffset
, nYOffset
, lpPoint
);
734 if (!GdiGetHandleUserData((HGDIOBJ
) hdc
, GDI_OBJECT_TYPE_DC
, (PVOID
) &Dc_Attr
)) return FALSE
;
738 *lpPoint
= (POINT
)Dc_Attr
->ptlViewportOrg
;
739 if ( Dc_Attr
->dwLayout
& LAYOUT_RTL
) lpPoint
->x
= -lpPoint
->x
;
742 if ( nXOffset
|| nYOffset
!= nXOffset
)
744 if (NtCurrentTeb()->GdiTebBatch
.HDC
== (ULONG
)hdc
)
746 if (Dc_Attr
->ulDirty_
& DC_MODE_DIRTY
)
749 Dc_Attr
->ulDirty_
&= ~DC_MODE_DIRTY
;
752 Dc_Attr
->flXform
|= (PAGE_XLATE_CHANGED
|DEVICE_TO_WORLD_INVALID
);
753 if ( Dc_Attr
->dwLayout
& LAYOUT_RTL
) nXOffset
= -nXOffset
;
754 Dc_Attr
->ptlViewportOrg
.x
+= nXOffset
;
755 Dc_Attr
->ptlViewportOrg
.y
+= nYOffset
;
759 return NtGdiOffsetViewportOrgEx(hdc
, nXOffset
, nYOffset
, lpPoint
);
768 OffsetWindowOrgEx(HDC hdc
,
776 if (GDI_HANDLE_GET_TYPE(hdc
) != GDI_OBJECT_TYPE_DC
)
778 if (GDI_HANDLE_GET_TYPE(hdc
) == GDI_OBJECT_TYPE_METADC
)
779 return MFDRV_OffsetWindowOrgEx(hdc
, nXOffset
, nYOffset
, lpPoint
);
782 PLDC pLDC
= GdiGetLDC(hdc
);
785 SetLastError(ERROR_INVALID_HANDLE
);
788 if (pLDC
->iType
== LDC_EMFLDC
)
790 return EMFDRV_OffsetWindowOrgEx(hdc
, nXOffset
, nYOffset
, lpPoint
);
795 if (!GdiGetHandleUserData((HGDIOBJ
) hdc
, GDI_OBJECT_TYPE_DC
, (PVOID
) &Dc_Attr
)) return FALSE
;
799 *lpPoint
= (POINT
)Dc_Attr
->ptlWindowOrg
;
800 lpPoint
->x
= Dc_Attr
->lWindowOrgx
;
803 if ( nXOffset
|| nYOffset
!= nXOffset
)
805 if (NtCurrentTeb()->GdiTebBatch
.HDC
== (ULONG
)hdc
)
807 if (Dc_Attr
->ulDirty_
& DC_MODE_DIRTY
)
810 Dc_Attr
->ulDirty_
&= ~DC_MODE_DIRTY
;
813 Dc_Attr
->flXform
|= (PAGE_XLATE_CHANGED
|DEVICE_TO_WORLD_INVALID
);
814 Dc_Attr
->ptlWindowOrg
.x
+= nXOffset
;
815 Dc_Attr
->ptlWindowOrg
.y
+= nYOffset
;
816 Dc_Attr
->lWindowOrgx
+= nXOffset
;
820 return NtGdiOffsetWindowOrgEx(hdc
, nXOffset
, nYOffset
, lpPoint
);