Esempio n. 1
0
File: dc.c Progetto: GYGit/reactos
/*
 * @implemented
 */
BOOL
WINAPI
CancelDC(HDC hDC)
{
    PDC_ATTR pDc_Attr;

    if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC &&
            GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_METADC )
    {
        PLDC pLDC = GdiGetLDC(hDC);
        if ( !pLDC )
        {
            SetLastError(ERROR_INVALID_HANDLE);
            return FALSE;
        }
        /* If a document has started set it to die. */
        if (pLDC->Flags & LDC_INIT_DOCUMENT) pLDC->Flags |= LDC_KILL_DOCUMENT;

        return NtGdiCancelDC(hDC);
    }

    if (GdiGetHandleUserData((HGDIOBJ) hDC, GDI_OBJECT_TYPE_DC, (PVOID) &pDc_Attr))
    {
        pDc_Attr->ulDirty_ &= ~DC_PLAYMETAFILE;
        return TRUE;
    }

    return FALSE;
}
Esempio n. 2
0
/*
 * @implemented
 */
DWORD
WINAPI
SetLayout(HDC hdc,
          DWORD dwLayout)
{
#if 0
    if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC)
    {
        if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC)
            return MFDRV_SetLayout( hdc, dwLayout);
        else
        {
            PLDC pLDC = GdiGetLDC(hdc);
            if ( !pLDC )
            {
                SetLastError(ERROR_INVALID_HANDLE);
                return 0;
            }
            if (pLDC->iType == LDC_EMFLDC)
            {
                return EMFDRV_SetLayout( hdc, dwLayout);
            }
        }
    }
#endif
    if (!GdiIsHandleValid((HGDIOBJ) hdc) ||
            (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC)) return GDI_ERROR;
    return NtGdiSetLayout( hdc, -1, dwLayout);
}
Esempio n. 3
0
/*
 * @implemented
 */
int
WINAPI
DrawEscape(HDC  hDC,
           INT nEscape,
           INT cbInput,
           LPCSTR lpszInData)
{
    if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_DC)
        return NtGdiDrawEscape(hDC, nEscape, cbInput, (LPSTR) lpszInData);

    if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_METADC)
    {
        PLDC pLDC = GdiGetLDC(hDC);
        if ( pLDC )
        {
            if (pLDC->Flags & LDC_META_PRINT)
            {
//           if (nEscape != QUERYESCSUPPORT)
//              return EMFDRV_WriteEscape(hDC, nEscape, cbInput, lpszInData, EMR_DRAWESCAPE);

                return NtGdiDrawEscape(hDC, nEscape, cbInput, (LPSTR) lpszInData);
            }
        }
        SetLastError(ERROR_INVALID_HANDLE);
    }
    return 0;
}
Esempio n. 4
0
/*
 * @implemented
 */
HCOLORSPACE
WINAPI
SetColorSpace(
    HDC hDC,
    HCOLORSPACE hCS
)
{
    HCOLORSPACE rhCS = GetColorSpace(hDC);

    if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_DC)
    {
        if (NtGdiSetColorSpace(hDC, hCS)) return rhCS;
    }
#if 0
    if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_METADC)
    {
        PLDC pLDC = GdiGetLDC(hDC);
        if ( !pLDC )
        {
            SetLastError(ERROR_INVALID_HANDLE);
            return NULL;
        }
        if (pLDC->iType == LDC_EMFLDC)
        {
            return NULL;
        }
    }
#endif
    return NULL;
}
Esempio n. 5
0
/*
 * @unimplemented
 */
BOOL
WINAPI
SetViewportExtEx(HDC hdc,
                 int nXExtent,
                 int nYExtent,
                 LPSIZE lpSize)
{
    PDC_ATTR Dc_Attr;
#if 0
    if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC)
    {
        if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC)
            return MFDRV_SetViewportExtEx();
        else
        {
            PLDC pLDC = GdiGetLDC(hdc);
            if ( !pLDC )
            {
                SetLastError(ERROR_INVALID_HANDLE);
                return FALSE;
            }
            if (pLDC->iType == LDC_EMFLDC)
            {
                return EMFDRV_SetViewportExtEx();
            }
        }
    }
#endif
    if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr))
    {
        return FALSE;
    }

    if (lpSize)
    {
        lpSize->cx = Dc_Attr->szlViewportExt.cx;
        lpSize->cy = Dc_Attr->szlViewportExt.cy;
    }

    if ((Dc_Attr->szlViewportExt.cx == nXExtent) && (Dc_Attr->szlViewportExt.cy == nYExtent))
        return TRUE;

    if ((Dc_Attr->iMapMode == MM_ISOTROPIC) || (Dc_Attr->iMapMode == MM_ANISOTROPIC))
    {
        if (NtCurrentTeb()->GdiTebBatch.HDC == hdc)
        {
            if (Dc_Attr->ulDirty_ & DC_FONTTEXT_DIRTY)
            {
                NtGdiFlush(); // Sync up Dc_Attr from Kernel space.
                Dc_Attr->ulDirty_ &= ~(DC_MODE_DIRTY|DC_FONTTEXT_DIRTY);
            }
        }
        Dc_Attr->szlViewportExt.cx = nXExtent;
        Dc_Attr->szlViewportExt.cy = nYExtent;
        if (Dc_Attr->dwLayout & LAYOUT_RTL) NtGdiMirrorWindowOrg(hdc);
        Dc_Attr->flXform |= (PAGE_EXTENTS_CHANGED|INVALIDATE_ATTRIBUTES|DEVICE_TO_WORLD_INVALID);
    }
    return TRUE;
}
Esempio n. 6
0
/*
 * @implemented
 */
BOOL
WINAPI
SetBrushOrgEx(HDC hdc,
              int nXOrg,
              int nYOrg,
              LPPOINT lppt)
{
    PDC_ATTR Dc_Attr;
#if 0
// Handle something other than a normal dc object.
    if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC)
    {
        PLDC pLDC = GdiGetLDC(hdc);
        if ( (pLDC == NULL) || (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC))
        {
            SetLastError(ERROR_INVALID_HANDLE);
            return FALSE;
        }
        if (pLDC->iType == LDC_EMFLDC)
        {
            return EMFDRV_SetBrushOrg(hdc, nXOrg, nYOrg); // ReactOS only.
        }
        return FALSE;
    }
#endif
    if (GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID)&Dc_Attr))
    {
        PGDIBSSETBRHORG pgSBO;

        /* Does the caller want the current brush origin to be returned? */
        if (lppt)
        {
            lppt->x = Dc_Attr->ptlBrushOrigin.x;
            lppt->y = Dc_Attr->ptlBrushOrigin.y;
        }

        /* Check if we have nothing to do */
        if ((nXOrg == Dc_Attr->ptlBrushOrigin.x) &&
            (nYOrg == Dc_Attr->ptlBrushOrigin.y))
            return TRUE;

        /* Allocate a batch command buffer */
        pgSBO = GdiAllocBatchCommand(hdc, GdiBCSetBrushOrg);
        if (pgSBO != NULL)
        {
            /* Set current brush origin in the DC attribute */
            Dc_Attr->ptlBrushOrigin.x = nXOrg;
            Dc_Attr->ptlBrushOrigin.y = nYOrg;

            /* Setup the GDI batch command */
            pgSBO->ptlBrushOrigin = Dc_Attr->ptlBrushOrigin;

            return TRUE;
        }
    }

    /* Fall back to the slower kernel path */
    return NtGdiSetBrushOrg(hdc, nXOrg, nYOrg, lppt);
}
Esempio n. 7
0
/*
 * @unimplemented
 */
BOOL
WINAPI
SetWindowOrgEx(HDC hdc,
               int X,
               int Y,
               LPPOINT lpPoint)
{
#if 0
    PDC_ATTR Dc_Attr;
#if 0
    if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC)
    {
        if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC)
            return MFDRV_SetWindowOrgEx();
        else
        {
            PLDC pLDC = GdiGetLDC(hdc);
            if ( !pLDC )
            {
                SetLastError(ERROR_INVALID_HANDLE);
                return FALSE;
            }
            if (pLDC->iType == LDC_EMFLDC)
            {
                return EMFDRV_SetWindowOrgEx();
            }
        }
    }
#endif
    if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE;

    if (lpPoint)
    {
        lpPoint->x = Dc_Attr->ptlWindowOrg.x;
        lpPoint->y = Dc_Attr->ptlWindowOrg.y;
    }

    if ((Dc_Attr->ptlWindowOrg.x == X) && (Dc_Attr->ptlWindowOrg.y == Y))
        return TRUE;

    if (NtCurrentTeb()->GdiTebBatch.HDC == (ULONG)hdc)
    {
        if (Dc_Attr->ulDirty_ & DC_FONTTEXT_DIRTY)
        {
            NtGdiFlush(); // Sync up Dc_Attr from Kernel space.
            Dc_Attr->ulDirty_ &= ~(DC_MODE_DIRTY|DC_FONTTEXT_DIRTY);
        }
    }

    Dc_Attr->ptlWindowOrg.x = X;
    Dc_Attr->lWindowOrgx    = X;
    Dc_Attr->ptlWindowOrg.y = Y;
    if (Dc_Attr->dwLayout & LAYOUT_RTL) NtGdiMirrorWindowOrg(hdc);
    Dc_Attr->flXform |= (PAGE_XLATE_CHANGED|DEVICE_TO_WORLD_INVALID);
    return TRUE;
#endif
    return NtGdiSetWindowOrgEx(hdc,X,Y,lpPoint);
}
Esempio n. 8
0
/*
 * @implemented
 *
 */
BOOL
WINAPI
OffsetWindowOrgEx(HDC hdc,
                  int nXOffset,
                  int nYOffset,
                  LPPOINT lpPoint)
{
#if 0
    PDC_ATTR Dc_Attr;
#if 0
    if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC)
    {
        if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC)
            return MFDRV_OffsetWindowOrgEx(hdc, nXOffset, nYOffset, lpPoint);
        else
        {
            PLDC pLDC = GdiGetLDC(hdc);
            if ( !pLDC )
            {
                SetLastError(ERROR_INVALID_HANDLE);
                return FALSE;
            }
            if (pLDC->iType == LDC_EMFLDC)
            {
                return EMFDRV_OffsetWindowOrgEx(hdc, nXOffset, nYOffset, lpPoint);
            }
        }
    }
#endif
    if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE;

    if ( lpPoint )
    {
        *lpPoint   = (POINT)Dc_Attr->ptlWindowOrg;
        lpPoint->x = Dc_Attr->lWindowOrgx;
    }

    if ( nXOffset || nYOffset != nXOffset )
    {
        if (NtCurrentTeb()->GdiTebBatch.HDC == (ULONG)hdc)
        {
            if (Dc_Attr->ulDirty_ & DC_MODE_DIRTY)
            {
                NtGdiFlush();
                Dc_Attr->ulDirty_ &= ~DC_MODE_DIRTY;
            }
        }
        Dc_Attr->flXform |= (PAGE_XLATE_CHANGED|DEVICE_TO_WORLD_INVALID);
        Dc_Attr->ptlWindowOrg.x += nXOffset;
        Dc_Attr->ptlWindowOrg.y += nYOffset;
        Dc_Attr->lWindowOrgx += nXOffset;
    }
    return TRUE;
#endif
    return NtGdiOffsetWindowOrgEx(hdc, nXOffset, nYOffset, lpPoint);
}
Esempio n. 9
0
PBRUSH
FASTCALL
PEN_ShareLockPen(HPEN hobj)
{
    if ((GDI_HANDLE_GET_TYPE(hobj) != GDILoObjType_LO_PEN_TYPE) &&
        (GDI_HANDLE_GET_TYPE(hobj) != GDILoObjType_LO_EXTPEN_TYPE))
    {
        return NULL;
    }

    return (PBRUSH)GDIOBJ_ReferenceObjectByHandle(hobj, GDIObjType_BRUSH_TYPE);
}
Esempio n. 10
0
/*
 * @implemented
 */
BOOL
WINAPI
UnrealizeObject(HGDIOBJ  hgdiobj)
{
    BOOL retValue = TRUE;
    /*
       Win 2k Graphics API, Black Book. by coriolis.com
       Page 62, Note that Steps 3, 5, and 6 are not required for Windows NT(tm)
       and Windows 2000(tm).

       Step 5. UnrealizeObject(hTrackBrush);
     */
    /*
        msdn.microsoft.com,
        "Windows 2000/XP: If hgdiobj is a brush, UnrealizeObject does nothing,
        and the function returns TRUE. Use SetBrushOrgEx to set the origin of
        a brush."
     */
    if (GDI_HANDLE_GET_TYPE(hgdiobj) != GDI_OBJECT_TYPE_BRUSH)
    {
        retValue = NtGdiUnrealizeObject(hgdiobj);
    }

    return retValue;
}
Esempio n. 11
0
File: dc.c Progetto: GYGit/reactos
/*
 * @implemented
 */
BOOL
WINAPI
DeleteDC(HDC hdc)
{
    BOOL bResult = TRUE;
    PLDC pLDC = NULL;
    HANDLE hPrinter = NULL;
    ULONG hType = GDI_HANDLE_GET_TYPE(hdc);

    pLDC = GdiGetLDC(hdc);

    if (hType != GDILoObjType_LO_DC_TYPE)
    {
        return METADC_DeleteDC(hdc);
    }

    bResult = NtGdiDeleteObjectApp(hdc);

    if (bResult && pLDC)
    {
        DPRINT1("Delete the Local DC structure\n");
        LocalFree( pLDC );
    }

    if (hPrinter)
        fpClosePrinter(hPrinter);

    return bResult;
}
Esempio n. 12
0
BOOL
WINAPI
GdiAlphaBlend(
    HDC hDCDst,
    int DstX,
    int DstY,
    int DstCx,
    int DstCy,
    HDC hDCSrc,
    int SrcX,
    int SrcY,
    int SrcCx,
    int SrcCy,
    BLENDFUNCTION BlendFunction
)
{
    if ( hDCSrc == NULL ) return FALSE;

    if (GDI_HANDLE_GET_TYPE(hDCSrc) == GDI_OBJECT_TYPE_METADC) return FALSE;

    return NtGdiAlphaBlend(
               hDCDst,
               DstX,
               DstY,
               DstCx,
               DstCy,
               hDCSrc,
               SrcX,
               SrcY,
               SrcCx,
               SrcCy,
               BlendFunction,
               0 );
}
Esempio n. 13
0
BOOL
NTAPI
GreSetBitmapOwner(
    _In_ HBITMAP hbmp,
    _In_ ULONG ulOwner)
{
    /* Check if we have the correct object type */
    if (GDI_HANDLE_GET_TYPE(hbmp) != GDILoObjType_LO_BITMAP_TYPE)
    {
        DPRINT1("Incorrect type for hbmp: %p\n", hbmp);
        return FALSE;
    }

    /// FIXME: this is a hack and doesn't handle a race condition properly.
    /// It needs to be done in GDIOBJ_vSetObjectOwner atomically.

    /* Check if we set public or none */
    if ((ulOwner == GDI_OBJ_HMGR_PUBLIC) ||
        (ulOwner == GDI_OBJ_HMGR_NONE))
    {
        /* Only allow this for owned objects */
        if (GreGetObjectOwner(hbmp) != GDI_OBJ_HMGR_POWNED)
        {
            DPRINT1("Cannot change owner for non-powned hbmp\n");
            return FALSE;
        }
    }

    return GreSetObjectOwner(hbmp, ulOwner);
}
Esempio n. 14
0
/*
 * @implemented
 */
DWORD
WINAPI
SetLayoutWidth(HDC hdc,LONG wox,DWORD dwLayout)
{
    if (!GdiIsHandleValid((HGDIOBJ) hdc) ||
            (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC)) return GDI_ERROR;
    return NtGdiSetLayout( hdc, wox, dwLayout);
}
Esempio n. 15
0
/*
 * @implemented
 */
int
WINAPI
SetROP2(HDC hdc,
        int fnDrawMode)
{
    PDC_ATTR Dc_Attr;
    INT Old_ROP2;

#if 0
// Handle something other than a normal dc object.
    if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC)
    {
        if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC)
            return MFDRV_SetROP2( hdc, fnDrawMode);
        else
        {
            PLDC pLDC = GdiGetLDC(hdc);
            if ( !pLDC )
            {
                SetLastError(ERROR_INVALID_HANDLE);
                return FALSE;
            }
            if (pLDC->iType == LDC_EMFLDC)
            {
                return EMFDRV_SetROP2(( hdc, fnDrawMode);
                                  }
                                  return FALSE;
        }
    }
#endif
    if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE;

    if (NtCurrentTeb()->GdiTebBatch.HDC == hdc)
    {
        if (Dc_Attr->ulDirty_ & DC_MODE_DIRTY)
        {
            NtGdiFlush();
            Dc_Attr->ulDirty_ &= ~DC_MODE_DIRTY;
        }
    }

    Old_ROP2 = Dc_Attr->jROP2;
    Dc_Attr->jROP2 = fnDrawMode;

    return Old_ROP2;
}
Esempio n. 16
0
/*
 * @unimplemented
 */
BOOL
WINAPI
SetViewportOrgEx(HDC hdc,
                 int X,
                 int Y,
                 LPPOINT lpPoint)
{
#if 0
    PDC_ATTR Dc_Attr;
#if 0
    if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC)
    {
        if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC)
            return MFDRV_SetViewportOrgEx();
        else
        {
            PLDC pLDC = GdiGetLDC(hdc);
            if ( !pLDC )
            {
                SetLastError(ERROR_INVALID_HANDLE);
                return FALSE;
            }
            if (pLDC->iType == LDC_EMFLDC)
            {
                return EMFDRV_SetViewportOrgEx();
            }
        }
    }
#endif
    if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE;

    if (lpPoint)
    {
        lpPoint->x = Dc_Attr->ptlViewportOrg.x;
        lpPoint->y = Dc_Attr->ptlViewportOrg.y;
        if (Dc_Attr->dwLayout & LAYOUT_RTL) lpPoint->x = -lpPoint->x;
    }
    Dc_Attr->flXform |= (PAGE_XLATE_CHANGED|DEVICE_TO_WORLD_INVALID);
    if (Dc_Attr->dwLayout & LAYOUT_RTL) X = -X;
    Dc_Attr->ptlViewportOrg.x = X;
    Dc_Attr->ptlViewportOrg.y = Y;
    return TRUE;
#endif
    return NtGdiSetViewportOrgEx(hdc,X,Y,lpPoint);
}
Esempio n. 17
0
File: dc.c Progetto: GYGit/reactos
/*
 * @implemented
 */
BOOL
WINAPI
GdiCleanCacheDC(HDC hdc)
{
    if (GDI_HANDLE_GET_TYPE(hdc) == GDILoObjType_LO_DC_TYPE)
        return TRUE;
    SetLastError(ERROR_INVALID_HANDLE);
    return FALSE;
}
Esempio n. 18
0
/*
 * @implemented
 */
int
WINAPI
SetMetaRgn(HDC hDC)
{
    if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_DC)
        return NtGdiSetMetaRgn(hDC);
#if 0
    PLDC pLDC = GdiGetLDC(hDC);
    if ( pLDC && GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_METADC )
    {
        if (pLDC->iType == LDC_EMFLDC || EMFDRV_SetMetaRgn(hDC))
        {
            return NtGdiSetMetaRgn(hDC);
        }
        else
            SetLastError(ERROR_INVALID_HANDLE);
    }
#endif
    return ERROR;
}
Esempio n. 19
0
/*
 * @implemented
 */
COLORREF
WINAPI
GetPixel(
    _In_ HDC hdc,
    _In_ INT x,
    _In_ INT y)
{
    if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) return CLR_INVALID;
    if (!GdiIsHandleValid((HGDIOBJ) hdc)) return CLR_INVALID;
    return NtGdiGetPixel(hdc, x, y);
}
Esempio n. 20
0
BOOL
WINAPI
ModifyWorldTransform(
    HDC hDC,
    CONST XFORM *Xform,
    DWORD iMode
)
{
#if 0
// Handle something other than a normal dc object.
    if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC)
    {
        if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC)
            return FALSE;
        else
        {
            PLDC pLDC = GdiGetLDC(hDC);
            if ( !pLDC )
            {
                SetLastError(ERROR_INVALID_HANDLE);
                return FALSE;
            }
            if (pLDC->iType == LDC_EMFLDC)
            {
                if (iMode ==  MWT_MAX+1)
                    if (!EMFDRV_SetWorldTransform( hDC, Xform) ) return FALSE;
                return EMFDRV_ModifyWorldTransform( hDC, Xform, iMode); // Ported from wine.
            }
            return FALSE;
        }
    }
#endif
    PDC_ATTR Dc_Attr;

    if (!GdiGetHandleUserData((HGDIOBJ) hDC, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE;

    /* Check that graphics mode is GM_ADVANCED */
    if ( Dc_Attr->iGraphicsMode != GM_ADVANCED ) return FALSE;

    return NtGdiModifyWorldTransform(hDC, (CONST LPXFORM) Xform, iMode);
}
Esempio n. 21
0
INT
WINAPI
MirrorRgnDC(
    _In_ HDC hdc,
    _In_ HRGN hrgn,
    _In_ HRGN *phrn)
{
    if (!GdiIsHandleValid((HGDIOBJ) hdc) ||
        (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC))
        return 0;

    return MirrorRgnByWidth(hrgn, NtGdiGetDeviceWidth(hdc), phrn);
}
Esempio n. 22
0
/*
 * @implemented
 */
BOOL
WINAPI
ScaleWindowExtEx(
    HDC	a0,
    int	a1,
    int	a2,
    int	a3,
    int	a4,
    LPSIZE	a5
)
{
#if 0
    if (GDI_HANDLE_GET_TYPE(a0) != GDI_OBJECT_TYPE_DC)
    {
        if (GDI_HANDLE_GET_TYPE(a0) == GDI_OBJECT_TYPE_METADC)
            return MFDRV_;
        else
        {
            PLDC pLDC = GdiGetLDC(a0);
            if ( !pLDC )
            {
                SetLastError(ERROR_INVALID_HANDLE);
                return FALSE;
            }
            if (pLDC->iType == LDC_EMFLDC)
            {
                return EMFDRV_;
            }
        }
    }
#endif
    if (!GdiIsHandleValid((HGDIOBJ) a0) ||
            (GDI_HANDLE_GET_TYPE(a0) != GDI_OBJECT_TYPE_DC)) return FALSE;

    return NtGdiScaleWindowExtEx(a0, a1, a2, a3, a4, a5);
}
Esempio n. 23
0
BOOL
FASTCALL
IntGdiDeleteColorSpace(
    HCOLORSPACE hColorSpace)
{
  BOOL Ret = FALSE;

  if ( hColorSpace != hStockColorSpace &&
      GDI_HANDLE_GET_TYPE(hColorSpace) == GDILoObjType_LO_ICMLCS_TYPE)
  {
     Ret = GreDeleteObject(hColorSpace);
     if ( !Ret ) EngSetLastError(ERROR_INVALID_PARAMETER);
  }
  return Ret;
}
Esempio n. 24
0
BOOL GdiIsHandleValid(HGDIOBJ hGdiObj)
{
    PGDI_TABLE_ENTRY Entry = GdiHandleTable + GDI_HANDLE_GET_INDEX(hGdiObj);
// We are only looking for TYPE not the rest here, and why is FullUnique filled up with CRAP!?
// DPRINT1("FullUnique -> %x\n", Entry->FullUnique);
    if((Entry->Type & GDI_ENTRY_BASETYPE_MASK) != 0 &&
            ( (Entry->Type << GDI_ENTRY_UPPER_SHIFT) & GDI_HANDLE_TYPE_MASK ) ==
            GDI_HANDLE_GET_TYPE(hGdiObj))
    {
        HANDLE pid = (HANDLE)((ULONG_PTR)Entry->ProcessId & ~0x1);
        if(pid == NULL || pid == CurrentProcessId)
        {
            return TRUE;
        }
    }
    return FALSE;
}
Esempio n. 25
0
File: dc.c Progetto: GYGit/reactos
/*
 * @implemented
 *
 */
HGDIOBJ
WINAPI
SelectObject(
    _In_ HDC hdc,
    _In_ HGDIOBJ hobj)
{
    /* Fix up 16 bit handles */
    hobj = GdiFixUpHandle(hobj);
    if (!GdiIsHandleValid(hobj))
    {
        return NULL;
    }

    /* Call the appropriate select function */
    switch (GDI_HANDLE_GET_TYPE(hobj))
    {
        case GDILoObjType_LO_REGION_TYPE:
            return (HGDIOBJ)ExtSelectClipRgn(hdc, hobj, RGN_COPY);

        case GDILoObjType_LO_BITMAP_TYPE:
        case GDILoObjType_LO_DIBSECTION_TYPE:
            return GdiSelectBitmap(hdc, hobj);

        case GDILoObjType_LO_BRUSH_TYPE:
            return GdiSelectBrush(hdc, hobj);

        case GDILoObjType_LO_PEN_TYPE:
        case GDILoObjType_LO_EXTPEN_TYPE:
            return GdiSelectPen(hdc, hobj);

        case GDILoObjType_LO_FONT_TYPE:
            return GdiSelectFont(hdc, hobj);

        case GDILoObjType_LO_ICMLCS_TYPE:
            return SetColorSpace(hdc, hobj);

        case GDILoObjType_LO_PALETTE_TYPE:
            SetLastError(ERROR_INVALID_FUNCTION);

        default:
            return NULL;
    }

    return NULL;
}
Esempio n. 26
0
/*
 * @implemented
 */
BOOL
WINAPI
GdiValidateHandle(HGDIOBJ hobj)
{
    PGDI_TABLE_ENTRY Entry = GdiHandleTable + GDI_HANDLE_GET_INDEX(hobj);
    if ( (Entry->Type & GDI_ENTRY_BASETYPE_MASK) != 0 &&
            ( (Entry->Type << GDI_ENTRY_UPPER_SHIFT) & GDI_HANDLE_TYPE_MASK ) ==
            GDI_HANDLE_GET_TYPE(hobj) )
    {
        HANDLE pid = (HANDLE)((ULONG_PTR)Entry->ProcessId & ~0x1);
        if(pid == NULL || pid == CurrentProcessId)
        {
            return TRUE;
        }
    }
    return FALSE;

}
Esempio n. 27
0
File: dc.c Progetto: GYGit/reactos
/*
 * @implemented
 */
HDC
WINAPI
GdiConvertAndCheckDC(HDC hdc)
{
    PLDC pldc;
    ULONG hType = GDI_HANDLE_GET_TYPE(hdc);
    if (hType == GDILoObjType_LO_DC_TYPE || hType == GDILoObjType_LO_METADC16_TYPE)
        return hdc;
    pldc = GdiGetLDC(hdc);
    if (pldc)
    {
        if (pldc->Flags & LDC_SAPCALLBACK) GdiSAPCallback(pldc);
        if (pldc->Flags & LDC_KILL_DOCUMENT) return NULL;
        if (pldc->Flags & LDC_STARTPAGE) StartPage(hdc);
        return hdc;
    }
    SetLastError(ERROR_INVALID_HANDLE);
    return NULL;
}
Esempio n. 28
0
/*
 * @implemented
 */
INT
WINAPI
GetPath(HDC hdc,
        LPPOINT pptlBuf,
        LPBYTE pjTypes,
        INT cptBuf)
{
    INT retValue = -1;

    if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC)
    {
        SetLastError(ERROR_INVALID_PARAMETER);
    }
    else
    {
        retValue = NtGdiGetPath(hdc,pptlBuf,pjTypes,cptBuf);
    }

    return retValue;
}
Esempio n. 29
0
BOOL GdiGetHandleUserData(HGDIOBJ hGdiObj, DWORD ObjectType, PVOID *UserData)
{
    PGDI_TABLE_ENTRY Entry = GdiHandleTable + GDI_HANDLE_GET_INDEX(hGdiObj);

    /* Check if twe have the correct type */
    if (GDI_HANDLE_GET_TYPE(hGdiObj) != ObjectType ||
        ((Entry->Type << GDI_ENTRY_UPPER_SHIFT) & GDI_HANDLE_TYPE_MASK) != ObjectType ||
        (Entry->Type & GDI_ENTRY_BASETYPE_MASK) != (ObjectType & GDI_ENTRY_BASETYPE_MASK))
    {
        return FALSE;
    }

    /* Check if we are the owner */
    if ((HANDLE)((ULONG_PTR)Entry->ProcessId & ~0x1) != CurrentProcessId)
    {
        return FALSE;
    }

    *UserData = Entry->UserData;
    return TRUE;
}
Esempio n. 30
0
/*
 * @unimplemented
 */
int
WINAPI
StretchDIBits(
    HDC hdc,
    int XDest,
    int YDest,
    int nDestWidth,
    int nDestHeight,
    int XSrc,
    int YSrc,
    int nSrcWidth,
    int nSrcHeight,
    CONST VOID *lpBits,
    CONST BITMAPINFO *lpBitsInfo,
    UINT iUsage,
    DWORD dwRop)

{
    PDC_ATTR pDc_Attr;
    PBITMAPINFO pConvertedInfo = NULL;
    UINT ConvertedInfoSize = 0;
    INT LinesCopied = 0;
    UINT cjBmpScanSize = 0;
    PVOID pvSafeBits = NULL;
    BOOL Hit = FALSE;

    DPRINT("StretchDIBits %p : %p : %u\n", lpBits, lpBitsInfo, iUsage);
#if 0
// Handle something other than a normal dc object.
    if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC)
    {
        if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC)
        return MFDRV_StretchBlt( hdc,
                XDest,
                YDest,
                nDestWidth,
                nDestHeight,
                XSrc,
                YSrc,
                nSrcWidth,
                nSrcHeight,
                lpBits,
                lpBitsInfo,
                iUsage,
                dwRop);
        else
        {
            PLDC pLDC = GdiGetLDC(hdc);
            if ( !pLDC )
            {
                SetLastError(ERROR_INVALID_HANDLE);
                return 0;
            }
            if (pLDC->iType == LDC_EMFLDC)
            {
                return EMFDRV_StretchBlt(hdc,
                        XDest,
                        YDest,
                        nDestWidth,
                        nDestHeight,
                        XSrc,
                        YSrc,
                        nSrcWidth,
                        nSrcHeight,
                        lpBits,
                        lpBitsInfo,
                        iUsage,
                        dwRop);
            }
            return 0;
        }
    }
#endif
    pConvertedInfo = ConvertBitmapInfo(lpBitsInfo, iUsage, &ConvertedInfoSize,
        FALSE);
    if (!pConvertedInfo)
    {
        return 0;
    }

    cjBmpScanSize = GdiGetBitmapBitsSize((BITMAPINFO *) pConvertedInfo);

    if (lpBits)
    {
        pvSafeBits = RtlAllocateHeap(GetProcessHeap(), 0, cjBmpScanSize);
        if (pvSafeBits)
        {
            _SEH2_TRY
            {
                RtlCopyMemory(pvSafeBits, lpBits, cjBmpScanSize);
            }
            _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
            {
                Hit = TRUE;
            }
            _SEH2_END

            if (Hit)
            {
                // We don't die, we continue on with a allocated safe pointer to kernel
                // space.....
                DPRINT1("StretchDIBits fail to read BitMapInfo: %p or Bits: %p & Size: %u\n",
                    pConvertedInfo, lpBits, cjBmpScanSize);
            }
            DPRINT("StretchDIBits Allocate Bits %u!!!\n", cjBmpScanSize);
        }
    }

    if (!GdiGetHandleUserData(hdc, GDI_OBJECT_TYPE_DC, (PVOID) & pDc_Attr))
    {
        SetLastError(ERROR_INVALID_PARAMETER);
        return 0;
    }
    /*
     if ( !pDc_Attr ||
     iUsage == DIB_PAL_COLORS ||
     ((pConvertedInfo->bmiHeader.biSize >= sizeof(BITMAPINFOHEADER)) &&
     (pConvertedInfo->bmiHeader.biCompression == BI_JPEG ||
     pConvertedInfo->bmiHeader.biCompression  == BI_PNG )) )*/
    {
        LinesCopied = NtGdiStretchDIBitsInternal(hdc, XDest, YDest, nDestWidth, nDestHeight, XSrc,
            YSrc, nSrcWidth, nSrcHeight, pvSafeBits, pConvertedInfo, (DWORD) iUsage, dwRop,
            ConvertedInfoSize, cjBmpScanSize,
            NULL);
    }
    if (pvSafeBits)
        RtlFreeHeap(RtlGetProcessHeap(), 0, pvSafeBits);
    if (lpBitsInfo != pConvertedInfo)
        RtlFreeHeap(RtlGetProcessHeap(), 0, pConvertedInfo);

    return LinesCopied;
}