2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS System Libraries
4 * FILE: dll/gdi32/objects/coord.c
5 * PURPOSE: Functions for coordinate transformation
10 /* Currently we use a MATRIX inside the DC_ATTR containing the
11 coordinate transformations, while we deal with XFORM structures
12 internally. If we move all coordinate transformation to gdi32,
13 we might as well have an XFORM structure in the DC_ATTR. */
15 MatrixToXForm(XFORM
*pxform
, const MATRIX
*pmx
)
17 XFORML
*pxforml
= (XFORML
*)pxform
;
18 pxforml
->eM11
= FOtoF(&pmx
->efM11
);
19 pxforml
->eM12
= FOtoF(&pmx
->efM12
);
20 pxforml
->eM21
= FOtoF(&pmx
->efM21
);
21 pxforml
->eM22
= FOtoF(&pmx
->efM22
);
22 pxforml
->eDx
= FOtoF(&pmx
->efDx
);
23 pxforml
->eDy
= FOtoF(&pmx
->efDy
);
29 _Out_writes_(nCount
) PPOINT pptOut
,
30 _In_reads_(nCount
) PPOINT pptIn
,
36 for (i
= 0; i
< nCount
; i
++)
38 x
= pptIn
[i
].x
* pxform
->eM11
+ pptIn
[i
].y
* pxform
->eM12
+ pxform
->eDx
;
39 pptOut
[i
].x
= _lrintf(x
);
40 y
= pptIn
[i
].x
* pxform
->eM21
+ pptIn
[i
].y
* pxform
->eM22
+ pxform
->eDy
;
41 pptOut
[i
].y
= _lrintf(y
);
49 _Out_writes_(nCount
) PPOINT pptOut
,
50 _In_reads_(nCount
) PPOINT pptIn
,
55 MatrixToXForm(&xform
, pmx
);
56 GdiTransformPoints2(&xform
, pptOut
, pptIn
, nCount
);
59 #define MAX_OFFSET 4294967041.0
60 #define _fmul(x,y) (((x) == 0) ? 0 : (x) * (y))
65 _Out_ LPXFORM pxfResult
,
66 _In_
const XFORM
*pxf1
,
67 _In_
const XFORM
*pxf2
)
72 if (!pxfResult
|| !pxf1
|| !pxf2
) return FALSE
;
74 /* Do matrix multiplication, start with scaling elements */
75 xformTmp
.eM11
= (pxf1
->eM11
* pxf2
->eM11
) + (pxf1
->eM12
* pxf2
->eM21
);
76 xformTmp
.eM22
= (pxf1
->eM21
* pxf2
->eM12
) + (pxf1
->eM22
* pxf2
->eM22
);
78 /* Calculate shear/rotate elements only of they are present */
79 if ((pxf1
->eM12
!= 0.) || (pxf1
->eM21
!= 0.) ||
80 (pxf2
->eM12
!= 0.) || (pxf2
->eM21
!= 0.))
82 xformTmp
.eM12
= (pxf1
->eM11
* pxf2
->eM12
) + (pxf1
->eM12
* pxf2
->eM22
);
83 xformTmp
.eM21
= (pxf1
->eM21
* pxf2
->eM11
) + (pxf1
->eM22
* pxf2
->eM21
);
91 /* Calculate the offset */
92 xformTmp
.eDx
= _fmul(pxf1
->eDx
, pxf2
->eM11
) + _fmul(pxf1
->eDy
, pxf2
->eM21
) + pxf2
->eDx
;
93 xformTmp
.eDy
= _fmul(pxf1
->eDx
, pxf2
->eM12
) + _fmul(pxf1
->eDy
, pxf2
->eM22
) + pxf2
->eDy
;
95 /* Check for invalid offset ranges */
96 if ((xformTmp
.eDx
> MAX_OFFSET
) || (xformTmp
.eDx
< -MAX_OFFSET
) ||
97 (xformTmp
.eDy
> MAX_OFFSET
) || (xformTmp
.eDy
< -MAX_OFFSET
))
102 /* All is ok, return the calculated values */
103 *pxfResult
= xformTmp
;
119 /* Get the DC attribute */
120 pdcattr
= GdiGetDcAttr(hdc
);
123 SetLastError(ERROR_INVALID_PARAMETER
);
127 /* Return the map mode */
128 return pdcattr
->iMapMode
;
142 /* Get the DC attribute */
143 pdcattr
= GdiGetDcAttr(hdc
);
146 SetLastError(ERROR_INVALID_PARAMETER
);
151 if (GDI_HANDLE_GET_TYPE(hdc
) != GDI_OBJECT_TYPE_DC
)
153 if (GDI_HANDLE_GET_TYPE(hdc
) == GDI_OBJECT_TYPE_METADC
)
154 return MFDRV_SetMapMode(hdc
, iMode
);
157 SetLastError(ERROR_INVALID_HANDLE
);
163 /* Force change if Isotropic is set for recompute. */
164 if ((iMode
!= pdcattr
->iMapMode
) || (iMode
== MM_ISOTROPIC
))
166 pdcattr
->ulDirty_
&= ~SLOW_WIDTHS
;
167 return GetAndSetDCDWord(hdc
, GdiGetSetMapMode
, iMode
, 0, 0, 0);
170 /* Simply return the old mode, which equals the new mode */
171 return pdcattr
->iMapMode
;
179 _Inout_updates_(nCount
) LPPOINT lpPoints
,
186 /* Get the DC attribute */
187 pdcattr
= GdiGetDcAttr(hdc
);
190 SetLastError(ERROR_INVALID_PARAMETER
);
194 if (pdcattr
->flXform
& ANY_XFORM_CHANGES
)
196 GdiFixupTransforms(pdcattr
);
199 // FIXME: can this fail on Windows?
200 GdiTransformPoints(&pdcattr
->mxDeviceToWorld
, lpPoints
, lpPoints
, nCount
);
204 return NtGdiTransformPoints(hdc
, lpPoints
, lpPoints
, nCount
, GdiDpToLp
);
211 _Inout_updates_(nCount
) LPPOINT lpPoints
,
218 /* Get the DC attribute */
219 pdcattr
= GdiGetDcAttr(hdc
);
222 SetLastError(ERROR_INVALID_PARAMETER
);
226 if (pdcattr
->flXform
& ANY_XFORM_CHANGES
)
228 GdiFixupTransforms(pdcattr
);
231 // FIXME: can this fail on Windows?
232 GdiTransformPoints(&pdcattr
->mxWorldToDevice
, lpPoints
, lpPoints
, nCount
);
236 return NtGdiTransformPoints(hdc
, lpPoints
, lpPoints
, nCount
, GdiLpToDp
);
245 GetCurrentPositionEx(
247 _Out_ LPPOINT lpPoint
)
251 /* Get the DC attribute */
252 pdcattr
= GdiGetDcAttr(hdc
);
253 if ((pdcattr
== NULL
) || (lpPoint
== NULL
))
255 SetLastError(ERROR_INVALID_PARAMETER
);
259 if (pdcattr
->ulDirty_
& DIRTY_PTLCURRENT
) // have a hit!
261 lpPoint
->x
= pdcattr
->ptfxCurrent
.x
;
262 lpPoint
->y
= pdcattr
->ptfxCurrent
.y
;
263 DPtoLP(hdc
, lpPoint
, 1); // reconvert back.
264 pdcattr
->ptlCurrent
.x
= lpPoint
->x
; // save it
265 pdcattr
->ptlCurrent
.y
= lpPoint
->y
;
266 pdcattr
->ulDirty_
&= ~DIRTY_PTLCURRENT
; // clear bit
270 lpPoint
->x
= pdcattr
->ptlCurrent
.x
;
271 lpPoint
->y
= pdcattr
->ptlCurrent
.y
;
284 _Out_ LPXFORM pxform
)
289 pdcattr
= GdiGetDcAttr(hdc
);
292 SetLastError(ERROR_INVALID_HANDLE
);
296 if (pdcattr
->flXform
& ANY_XFORM_INVALID
)
298 GdiFixupTransforms(pdcattr
);
301 MatrixToXForm(pxform
, &pdcattr
->mxWorldToDevice
);
303 return NtGdiGetTransform(hdc
, GdiWorldSpaceToPageSpace
, pxform
);
311 _Out_ CONST XFORM
*pxform
)
313 /* FIXME shall we add undoc #define MWT_SETXFORM 4 ?? */
314 return ModifyWorldTransform(hdc
, pxform
, MWT_MAX
+1);
320 ModifyWorldTransform(
322 _In_opt_ CONST XFORM
*pxform
,
328 // Handle something other than a normal dc object.
329 if (GDI_HANDLE_GET_TYPE(hdc
) != GDI_OBJECT_TYPE_DC
)
331 if (GDI_HANDLE_GET_TYPE(hdc
) == GDI_OBJECT_TYPE_METADC
)
335 PLDC pLDC
= GdiGetLDC(hdc
);
338 SetLastError(ERROR_INVALID_HANDLE
);
341 if (pLDC
->iType
== LDC_EMFLDC
)
343 if (dwMode
== MWT_MAX
+1)
344 if (!EMFDRV_SetWorldTransform(hdc
, pxform
) ) return FALSE
;
345 return EMFDRV_ModifyWorldTransform(hdc
, pxform
, dwMode
); // Ported from wine.
352 /* Get the DC attribute */
353 pdcattr
= GdiGetDcAttr(hdc
);
356 SetLastError(ERROR_INVALID_PARAMETER
);
360 /* Check that graphics mode is GM_ADVANCED */
361 if (pdcattr
->iGraphicsMode
!= GM_ADVANCED
)
364 /* Call win32k to do the work */
365 return NtGdiModifyWorldTransform(hdc
, (LPXFORM
)pxform
, dwMode
);
376 /* Get the DC attribute */
377 pdcattr
= GdiGetDcAttr(hdc
);
380 /* Do not set LastError here! */
384 /* Check if we need to update values */
385 if ((pdcattr
->flXform
& PAGE_EXTENTS_CHANGED
) &&
386 (pdcattr
->iMapMode
== MM_ISOTROPIC
))
388 /* Call win32k to do the work */
389 return NtGdiGetDCPoint(hdc
, GdiGetViewPortExt
, (PPOINTL
)lpSize
);
392 /* Nothing to calculate, return the current extension */
393 lpSize
->cx
= pdcattr
->szlViewportExt
.cx
;
394 lpSize
->cy
= pdcattr
->szlViewportExt
.cy
;
404 _Out_ LPPOINT lpPoint
)
408 /* Get the DC attribute */
409 pdcattr
= GdiGetDcAttr(hdc
);
412 /* Do not set LastError here! */
416 /* Get the current viewport org */
417 lpPoint
->x
= pdcattr
->ptlViewportOrg
.x
;
418 lpPoint
->y
= pdcattr
->ptlViewportOrg
.y
;
420 /* Handle right-to-left layout */
421 if (pdcattr
->dwLayout
& LAYOUT_RTL
)
422 lpPoint
->x
= -lpPoint
->x
;
436 /* Get the DC attribute */
437 pdcattr
= GdiGetDcAttr(hdc
);
440 /* Do not set LastError here! */
444 /* Get the current window extension */
445 lpSize
->cx
= pdcattr
->szlWindowExt
.cx
;
446 lpSize
->cy
= pdcattr
->szlWindowExt
.cy
;
448 /* Handle right-to-left layout */
449 if (pdcattr
->dwLayout
& LAYOUT_RTL
)
450 lpSize
->cx
= -lpSize
->cx
;
460 _Out_ LPPOINT lpPoint
)
464 /* Get the DC attribute */
465 pdcattr
= GdiGetDcAttr(hdc
);
468 /* Do not set LastError here! */
472 /* Get the current window origin */
473 lpPoint
->x
= pdcattr
->ptlWindowOrg
.x
;
474 lpPoint
->y
= pdcattr
->ptlWindowOrg
.y
;
488 _Out_opt_ LPSIZE lpSize
)
492 if (GDI_HANDLE_GET_TYPE(hdc
) != GDI_OBJECT_TYPE_DC
)
494 if (GDI_HANDLE_GET_TYPE(hdc
) == GDI_OBJECT_TYPE_METADC
)
495 return MFDRV_SetViewportExtEx();
498 PLDC pLDC
= GdiGetLDC(hdc
);
501 SetLastError(ERROR_INVALID_HANDLE
);
504 if (pLDC
->iType
== LDC_EMFLDC
)
506 return EMFDRV_SetViewportExtEx();
512 /* Get the DC attribute */
513 pdcattr
= GdiGetDcAttr(hdc
);
516 SetLastError(ERROR_INVALID_PARAMETER
);
520 /* Check if the caller wants the old extension */
523 /* Return the current viewport extension */
524 lpSize
->cx
= pdcattr
->szlViewportExt
.cx
;
525 lpSize
->cy
= pdcattr
->szlViewportExt
.cy
;
528 /* Check for trivial case */
529 if ((pdcattr
->szlViewportExt
.cx
== nXExtent
) &&
530 (pdcattr
->szlViewportExt
.cy
== nYExtent
))
533 /* Only change viewport extension if we are in iso or aniso mode */
534 if ((pdcattr
->iMapMode
== MM_ISOTROPIC
) ||
535 (pdcattr
->iMapMode
== MM_ANISOTROPIC
))
537 if (NtCurrentTeb()->GdiTebBatch
.HDC
== hdc
)
539 if (pdcattr
->ulDirty_
& DC_FONTTEXT_DIRTY
)
541 NtGdiFlush(); // Sync up pdcattr from Kernel space.
542 pdcattr
->ulDirty_
&= ~(DC_MODE_DIRTY
|DC_FONTTEXT_DIRTY
);
546 /* Set the new viewport extension */
547 pdcattr
->szlViewportExt
.cx
= nXExtent
;
548 pdcattr
->szlViewportExt
.cy
= nYExtent
;
550 /* Handle right-to-left layout */
551 if (pdcattr
->dwLayout
& LAYOUT_RTL
)
552 NtGdiMirrorWindowOrg(hdc
);
554 /* Update xform flags */
555 pdcattr
->flXform
|= (PAGE_EXTENTS_CHANGED
|INVALIDATE_ATTRIBUTES
|DEVICE_TO_WORLD_INVALID
);
570 _Out_opt_ LPPOINT lpPoint
)
575 if (GDI_HANDLE_GET_TYPE(hdc
) != GDI_OBJECT_TYPE_DC
)
577 if (GDI_HANDLE_GET_TYPE(hdc
) == GDI_OBJECT_TYPE_METADC
)
578 return MFDRV_SetWindowOrgEx();
581 PLDC pLDC
= GdiGetLDC(hdc
);
584 SetLastError(ERROR_INVALID_HANDLE
);
587 if (pLDC
->iType
== LDC_EMFLDC
)
589 return EMFDRV_SetWindowOrgEx();
594 /* Get the DC attribute */
595 pdcattr
= GdiGetDcAttr(hdc
);
598 /* Do not set LastError here! */
604 lpPoint
->x
= pdcattr
->ptlWindowOrg
.x
;
605 lpPoint
->y
= pdcattr
->ptlWindowOrg
.y
;
608 if ((pdcattr
->ptlWindowOrg
.x
== X
) && (pdcattr
->ptlWindowOrg
.y
== Y
))
611 if (NtCurrentTeb()->GdiTebBatch
.HDC
== (ULONG
)hdc
)
613 if (pdcattr
->ulDirty_
& DC_FONTTEXT_DIRTY
)
615 NtGdiFlush(); // Sync up pdcattr from Kernel space.
616 pdcattr
->ulDirty_
&= ~(DC_MODE_DIRTY
|DC_FONTTEXT_DIRTY
);
620 pdcattr
->ptlWindowOrg
.x
= X
;
621 pdcattr
->lWindowOrgx
= X
;
622 pdcattr
->ptlWindowOrg
.y
= Y
;
623 if (pdcattr
->dwLayout
& LAYOUT_RTL
) NtGdiMirrorWindowOrg(hdc
);
624 pdcattr
->flXform
|= (PAGE_XLATE_CHANGED
|DEVICE_TO_WORLD_INVALID
);
627 return NtGdiSetWindowOrgEx(hdc
,X
,Y
,lpPoint
);
639 _Out_opt_ LPSIZE lpSize
)
644 /* Check what type of DC that is */
645 ulType
= GDI_HANDLE_GET_TYPE(hdc
);
648 case GDILoObjType_LO_ALTDC_TYPE
:
649 case GDILoObjType_LO_DC_TYPE
:
650 /* Handle this in the path below */
652 #if 0// FIXME: we don't support this
653 case GDILoObjType_LO_METADC16_TYPE
:
654 return MFDRV_SetWindowExtEx(hdc
, nXExtent
, nYExtent
, lpSize
);
656 case GDILoObjType_LO_METAFILE_TYPE
:
657 return EMFDRV_SetWindowExtEx(hdc
, nXExtent
, nYExtent
, lpSize
);
660 /* Other types are not allowed */
661 SetLastError(ERROR_INVALID_HANDLE
);
665 /* Get the DC attr */
666 pdcattr
= GdiGetDcAttr(hdc
);
669 /* Set the error value and return failure */
670 SetLastError(ERROR_INVALID_PARAMETER
);
674 /* Check if the caller wants the old extension */
677 /* Return the current window extension */
678 lpSize
->cx
= pdcattr
->szlWindowExt
.cx
;
679 lpSize
->cy
= pdcattr
->szlWindowExt
.cy
;
681 /* Handle right-to-left layout */
682 if (pdcattr
->dwLayout
& LAYOUT_RTL
)
683 lpSize
->cx
= -lpSize
->cx
;
686 if (pdcattr
->dwLayout
& LAYOUT_RTL
)
688 NtGdiMirrorWindowOrg(hdc
);
689 pdcattr
->flXform
|= (PAGE_EXTENTS_CHANGED
|INVALIDATE_ATTRIBUTES
|DEVICE_TO_WORLD_INVALID
);
691 else if ((pdcattr
->iMapMode
== MM_ISOTROPIC
) ||
692 (pdcattr
->iMapMode
== MM_ANISOTROPIC
))
694 if ((pdcattr
->szlWindowExt
.cx
== nXExtent
) &&
695 (pdcattr
->szlWindowExt
.cy
== nYExtent
))
698 if ((!nXExtent
) || (!nYExtent
))
701 if (NtCurrentTeb()->GdiTebBatch
.HDC
== hdc
)
703 if (pdcattr
->ulDirty_
& DC_FONTTEXT_DIRTY
)
705 NtGdiFlush(); // Sync up Dc_Attr from Kernel space.
706 pdcattr
->ulDirty_
&= ~(DC_MODE_DIRTY
|DC_FONTTEXT_DIRTY
);
710 pdcattr
->szlWindowExt
.cx
= nXExtent
;
711 pdcattr
->szlWindowExt
.cy
= nYExtent
;
712 if (pdcattr
->dwLayout
& LAYOUT_RTL
)
713 NtGdiMirrorWindowOrg(hdc
);
715 pdcattr
->flXform
|= (PAGE_EXTENTS_CHANGED
|INVALIDATE_ATTRIBUTES
|DEVICE_TO_WORLD_INVALID
);
730 _Out_opt_ LPPOINT lpPoint
)
735 if (GDI_HANDLE_GET_TYPE(hdc
) != GDI_OBJECT_TYPE_DC
)
737 if (GDI_HANDLE_GET_TYPE(hdc
) == GDI_OBJECT_TYPE_METADC
)
738 return MFDRV_SetViewportOrgEx();
741 PLDC pLDC
= GdiGetLDC(hdc
);
744 SetLastError(ERROR_INVALID_HANDLE
);
747 if (pLDC
->iType
== LDC_EMFLDC
)
749 return EMFDRV_SetViewportOrgEx();
755 /* Get the DC attribute */
756 pdcattr
= GdiGetDcAttr(hdc
);
759 /* Do not set LastError here! */
765 lpPoint
->x
= pdcattr
->ptlViewportOrg
.x
;
766 lpPoint
->y
= pdcattr
->ptlViewportOrg
.y
;
767 if (pdcattr
->dwLayout
& LAYOUT_RTL
) lpPoint
->x
= -lpPoint
->x
;
769 pdcattr
->flXform
|= (PAGE_XLATE_CHANGED
|DEVICE_TO_WORLD_INVALID
);
770 if (pdcattr
->dwLayout
& LAYOUT_RTL
) X
= -X
;
771 pdcattr
->ptlViewportOrg
.x
= X
;
772 pdcattr
->ptlViewportOrg
.y
= Y
;
775 return NtGdiSetViewportOrgEx(hdc
,X
,Y
,lpPoint
);
792 if (GDI_HANDLE_GET_TYPE(hdc
) != GDI_OBJECT_TYPE_DC
)
794 if (GDI_HANDLE_GET_TYPE(a0
) == GDI_OBJECT_TYPE_METADC
)
798 PLDC pLDC
= GdiGetLDC(hdc
);
801 SetLastError(ERROR_INVALID_HANDLE
);
804 if (pLDC
->iType
== LDC_EMFLDC
)
811 if (!GdiGetDcAttr(hdc
))
813 SetLastError(ERROR_INVALID_PARAMETER
);
817 return NtGdiScaleViewportExtEx(hdc
, xNum
, xDenom
, yNum
, yDenom
, lpSize
);
834 if (GDI_HANDLE_GET_TYPE(hdc
) != GDI_OBJECT_TYPE_DC
)
836 if (GDI_HANDLE_GET_TYPE(hdc
) == GDI_OBJECT_TYPE_METADC
)
840 PLDC pLDC
= GdiGetLDC(hdc
);
843 SetLastError(ERROR_INVALID_HANDLE
);
846 if (pLDC
->iType
== LDC_EMFLDC
)
854 if (!GdiGetDcAttr(hdc
))
856 SetLastError(ERROR_INVALID_PARAMETER
);
860 return NtGdiScaleWindowExtEx(hdc
, xNum
, xDenom
, yNum
, yDenom
, lpSize
);
873 /* METADC16 is not supported in this API */
874 if (GDI_HANDLE_GET_TYPE(hdc
) == GDILoObjType_LO_METADC16_TYPE
)
879 /* Get the DC attribute */
880 pdcattr
= GdiGetDcAttr(hdc
);
883 /* Set the error value and return failure */
884 SetLastError(ERROR_INVALID_PARAMETER
);
888 /* Return the layout */
889 return pdcattr
->dwLayout
;
903 if (GDI_HANDLE_GET_TYPE(hdc
) != GDI_OBJECT_TYPE_DC
)
905 if (GDI_HANDLE_GET_TYPE(hdc
) == GDI_OBJECT_TYPE_METADC
)
906 return MFDRV_SetLayout( hdc
, dwLayout
);
909 PLDC pLDC
= GdiGetLDC(hdc
);
912 SetLastError(ERROR_INVALID_HANDLE
);
915 if (pLDC
->iType
== LDC_EMFLDC
)
917 return EMFDRV_SetLayout( hdc
, dwLayout
);
922 if (!GdiGetDcAttr(hdc
))
924 SetLastError(ERROR_INVALID_PARAMETER
);
928 return NtGdiSetLayout(hdc
, -1, dwLayout
);
941 /* Only normal DCs are handled here */
942 if (GDI_HANDLE_GET_TYPE(hdc
) != GDILoObjType_LO_DC_TYPE
)
947 if (!GdiGetDcAttr(hdc
))
949 SetLastError(ERROR_INVALID_PARAMETER
);
953 return NtGdiSetLayout( hdc
, wox
, dwLayout
);
963 _Out_ LPPOINT lpPoint
)
965 return NtGdiGetDCPoint(hdc
, GdiGetDCOrg
, (PPOINTL
)lpPoint
);
979 /* Call the new API */
980 if (!GetDCOrgEx(hdc
, &pt
))
983 /* Return the point in the old way */
984 return(MAKELONG(pt
.x
, pt
.y
));
998 _Out_opt_ LPPOINT lpPoint
)
1003 if (GDI_HANDLE_GET_TYPE(hdc
) != GDI_OBJECT_TYPE_DC
)
1005 if (GDI_HANDLE_GET_TYPE(hdc
) == GDI_OBJECT_TYPE_METADC
)
1006 return MFDRV_OffsetViewportOrgEx(hdc
, nXOffset
, nYOffset
, lpPoint
);
1009 PLDC pLDC
= GdiGetLDC(hdc
);
1012 SetLastError(ERROR_INVALID_HANDLE
);
1015 if (pLDC
->iType
== LDC_EMFLDC
)
1017 return EMFDRV_OffsetWindowOrgEx(hdc
, nXOffset
, nYOffset
, lpPoint
);
1022 /* Get the DC attribute */
1023 pdcattr
= GdiGetDcAttr(hdc
);
1026 /* Do not set LastError here! */
1032 *lpPoint
= (POINT
)pdcattr
->ptlViewportOrg
;
1033 if ( pdcattr
->dwLayout
& LAYOUT_RTL
) lpPoint
->x
= -lpPoint
->x
;
1036 if ( nXOffset
|| nYOffset
!= nXOffset
)
1038 if (NtCurrentTeb()->GdiTebBatch
.HDC
== (ULONG
)hdc
)
1040 if (pdcattr
->ulDirty_
& DC_MODE_DIRTY
)
1043 pdcattr
->ulDirty_
&= ~DC_MODE_DIRTY
;
1047 pdcattr
->flXform
|= (PAGE_XLATE_CHANGED
|DEVICE_TO_WORLD_INVALID
);
1048 if (pdcattr
->dwLayout
& LAYOUT_RTL
) nXOffset
= -nXOffset
;
1049 pdcattr
->ptlViewportOrg
.x
+= nXOffset
;
1050 pdcattr
->ptlViewportOrg
.y
+= nYOffset
;
1054 return NtGdiOffsetViewportOrgEx(hdc
, nXOffset
, nYOffset
, lpPoint
);
1067 _Out_opt_ LPPOINT lpPoint
)
1072 if (GDI_HANDLE_GET_TYPE(hdc
) != GDI_OBJECT_TYPE_DC
)
1074 if (GDI_HANDLE_GET_TYPE(hdc
) == GDI_OBJECT_TYPE_METADC
)
1075 return MFDRV_OffsetWindowOrgEx(hdc
, nXOffset
, nYOffset
, lpPoint
);
1078 PLDC pLDC
= GdiGetLDC(hdc
);
1081 SetLastError(ERROR_INVALID_HANDLE
);
1084 if (pLDC
->iType
== LDC_EMFLDC
)
1086 return EMFDRV_OffsetWindowOrgEx(hdc
, nXOffset
, nYOffset
, lpPoint
);
1091 /* Get the DC attribute */
1092 pdcattr
= GdiGetDcAttr(hdc
);
1095 /* Do not set LastError here! */
1101 *lpPoint
= (POINT
)pdcattr
->ptlWindowOrg
;
1102 lpPoint
->x
= pdcattr
->lWindowOrgx
;
1105 if ( nXOffset
|| nYOffset
!= nXOffset
)
1107 if (NtCurrentTeb()->GdiTebBatch
.HDC
== (ULONG
)hdc
)
1109 if (pdcattr
->ulDirty_
& DC_MODE_DIRTY
)
1112 pdcattr
->ulDirty_
&= ~DC_MODE_DIRTY
;
1116 pdcattr
->flXform
|= (PAGE_XLATE_CHANGED
|DEVICE_TO_WORLD_INVALID
);
1117 pdcattr
->ptlWindowOrg
.x
+= nXOffset
;
1118 pdcattr
->ptlWindowOrg
.y
+= nYOffset
;
1119 pdcattr
->lWindowOrgx
+= nXOffset
;
1123 return NtGdiOffsetWindowOrgEx(hdc
, nXOffset
, nYOffset
, lpPoint
);