[WIN32SS] Implement D3DKMT{Create,Destroy}DCFromMemory. Brought to you by Sebastian Gasiorek. CORE-11331 CORE-13362

svn path=/trunk/; revision=75059
This commit is contained in:
Amine Khaldi 2017-06-16 18:38:08 +00:00
parent 3770c2d134
commit f6d85c300f
12 changed files with 347 additions and 0 deletions

View file

@ -0,0 +1,55 @@
/*
* Copyright 2016 Henri Verbeet for CodeWeavers
*
* 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
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WINE_D3DKMTHK_H
#define __WINE_D3DKMTHK_H
#include <d3dukmdt.h>
typedef struct _D3DKMT_CREATEDCFROMMEMORY
{
void *pMemory;
D3DDDIFORMAT Format;
UINT Width;
UINT Height;
UINT Pitch;
HDC hDeviceDc;
PALETTEENTRY *pColorTable;
HDC hDc;
HANDLE hBitmap;
} D3DKMT_CREATEDCFROMMEMORY;
typedef struct _D3DKMT_DESTROYDCFROMMEMORY
{
HDC hDc;
HANDLE hBitmap;
} D3DKMT_DESTROYDCFROMMEMORY;
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
DWORD APIENTRY D3DKMTCreateDCFromMemory(_Inout_ D3DKMT_CREATEDCFROMMEMORY*);
DWORD APIENTRY D3DKMTDestroyDCFromMemory(_In_ CONST D3DKMT_DESTROYDCFROMMEMORY*);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __WINE_D3DKMTHK_H */

View file

@ -24,6 +24,7 @@
#include <ddrawint.h> #include <ddrawint.h>
#include <d3dtypes.h> #include <d3dtypes.h>
#include <d3dcaps.h> #include <d3dcaps.h>
#include <d3dkmthk.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View file

@ -0,0 +1,139 @@
/*
* Copyright 2016 Henri Verbeet for CodeWeavers
*
* 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
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WINE_D3DUKMDT_H
#define __WINE_D3DUKMDT_H
#ifndef MAKEFOURCC
#define MAKEFOURCC(ch0, ch1, ch2, ch3) \
((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) | \
((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24))
#endif /* MAKEFOURCC */
typedef enum _D3DDDIFORMAT
{
D3DDDIFMT_UNKNOWN = 0,
D3DDDIFMT_R8G8B8 = 0x14,
D3DDDIFMT_A8R8G8B8 = 0x15,
D3DDDIFMT_X8R8G8B8 = 0x16,
D3DDDIFMT_R5G6B5 = 0x17,
D3DDDIFMT_X1R5G5B5 = 0x18,
D3DDDIFMT_A1R5G5B5 = 0x19,
D3DDDIFMT_A4R4G4B4 = 0x1a,
D3DDDIFMT_R3G3B2 = 0x1b,
D3DDDIFMT_A8 = 0x1c,
D3DDDIFMT_A8R3G3B2 = 0x1d,
D3DDDIFMT_X4R4G4B4 = 0x1e,
D3DDDIFMT_A2B10G10R10 = 0x1f,
D3DDDIFMT_A8B8G8R8 = 0x20,
D3DDDIFMT_X8B8G8R8 = 0x21,
D3DDDIFMT_G16R16 = 0x22,
D3DDDIFMT_A2R10G10B10 = 0x23,
D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R10_XR_BIAS = 0x77,
D3DDDIFMT_DXVACOMPBUFFER_BASE = 0x96,
D3DDDIFMT_PICTUREPARAMSDATA = D3DDDIFMT_DXVACOMPBUFFER_BASE + 0,
D3DDDIFMT_MACROBLOCKDATA = D3DDDIFMT_DXVACOMPBUFFER_BASE + 0x01,
D3DDDIFMT_RESIDUALDIFFERENCEDATA = D3DDDIFMT_DXVACOMPBUFFER_BASE + 0x02,
D3DDDIFMT_DEBLOCKINGDATA = D3DDDIFMT_DXVACOMPBUFFER_BASE + 0x03,
D3DDDIFMT_INVERSEQUANTIZATIONDATA = D3DDDIFMT_DXVACOMPBUFFER_BASE + 0x04,
D3DDDIFMT_SLICECONTROLDATA = D3DDDIFMT_DXVACOMPBUFFER_BASE + 0x05,
D3DDDIFMT_BITSTREAMDATA = D3DDDIFMT_DXVACOMPBUFFER_BASE + 0x06,
D3DDDIFMT_MOTIONVECTORBUFFER = D3DDDIFMT_DXVACOMPBUFFER_BASE + 0x07,
D3DDDIFMT_FILMGRAINBUFFER = D3DDDIFMT_DXVACOMPBUFFER_BASE + 0x08,
D3DDDIFMT_DXVA_RESERVED9 = D3DDDIFMT_DXVACOMPBUFFER_BASE + 0x09,
D3DDDIFMT_DXVA_RESERVED10 = D3DDDIFMT_DXVACOMPBUFFER_BASE + 0x0a,
D3DDDIFMT_DXVA_RESERVED11 = D3DDDIFMT_DXVACOMPBUFFER_BASE + 0x0b,
D3DDDIFMT_DXVA_RESERVED12 = D3DDDIFMT_DXVACOMPBUFFER_BASE + 0x0c,
D3DDDIFMT_DXVA_RESERVED13 = D3DDDIFMT_DXVACOMPBUFFER_BASE + 0x0d,
D3DDDIFMT_DXVA_RESERVED14 = D3DDDIFMT_DXVACOMPBUFFER_BASE + 0x0e,
D3DDDIFMT_DXVA_RESERVED15 = D3DDDIFMT_DXVACOMPBUFFER_BASE + 0x0f,
D3DDDIFMT_DXVA_RESERVED16 = D3DDDIFMT_DXVACOMPBUFFER_BASE + 0x10,
D3DDDIFMT_DXVA_RESERVED17 = D3DDDIFMT_DXVACOMPBUFFER_BASE + 0x11,
D3DDDIFMT_DXVA_RESERVED18 = D3DDDIFMT_DXVACOMPBUFFER_BASE + 0x12,
D3DDDIFMT_DXVA_RESERVED19 = D3DDDIFMT_DXVACOMPBUFFER_BASE + 0x13,
D3DDDIFMT_DXVA_RESERVED20 = D3DDDIFMT_DXVACOMPBUFFER_BASE + 0x14,
D3DDDIFMT_DXVA_RESERVED21 = D3DDDIFMT_DXVACOMPBUFFER_BASE + 0x15,
D3DDDIFMT_DXVA_RESERVED22 = D3DDDIFMT_DXVACOMPBUFFER_BASE + 0x16,
D3DDDIFMT_DXVA_RESERVED23 = D3DDDIFMT_DXVACOMPBUFFER_BASE + 0x17,
D3DDDIFMT_DXVA_RESERVED24 = D3DDDIFMT_DXVACOMPBUFFER_BASE + 0x18,
D3DDDIFMT_DXVA_RESERVED25 = D3DDDIFMT_DXVACOMPBUFFER_BASE + 0x19,
D3DDDIFMT_DXVA_RESERVED26 = D3DDDIFMT_DXVACOMPBUFFER_BASE + 0x1a,
D3DDDIFMT_DXVA_RESERVED27 = D3DDDIFMT_DXVACOMPBUFFER_BASE + 0x1b,
D3DDDIFMT_DXVA_RESERVED28 = D3DDDIFMT_DXVACOMPBUFFER_BASE + 0x1c,
D3DDDIFMT_DXVA_RESERVED29 = D3DDDIFMT_DXVACOMPBUFFER_BASE + 0x1d,
D3DDDIFMT_DXVA_RESERVED30 = D3DDDIFMT_DXVACOMPBUFFER_BASE + 0x1e,
D3DDDIFMT_DXVA_RESERVED31 = D3DDDIFMT_DXVACOMPBUFFER_BASE + 0x1f,
D3DDDIFMT_DXVACOMPBUFFER_MAX = D3DDDIFMT_DXVA_RESERVED31,
D3DDDIFMT_BINARYBUFFER = 0xc7,
D3DDDIFMT_DXT1 = MAKEFOURCC('D', 'X', 'T', '1'),
D3DDDIFMT_DXT2 = MAKEFOURCC('D', 'X', 'T', '2'),
D3DDDIFMT_DXT3 = MAKEFOURCC('D', 'X', 'T', '3'),
D3DDDIFMT_DXT4 = MAKEFOURCC('D', 'X', 'T', '4'),
D3DDDIFMT_DXT5 = MAKEFOURCC('D', 'X', 'T', '5'),
D3DDDIFMT_G8R8_G8B8 = MAKEFOURCC('G', 'R', 'G', 'B'),
D3DDDIFMT_MULTI2_ARGB8 = MAKEFOURCC('M', 'E', 'T', '1'),
D3DDDIFMT_R8G8_B8G8 = MAKEFOURCC('R', 'G', 'B', 'G'),
D3DDDIFMT_UYVY = MAKEFOURCC('U', 'Y', 'V', 'Y'),
D3DDDIFMT_YUY2 = MAKEFOURCC('Y', 'U', 'Y', '2'),
D3DDDIFMT_FORCE_UINT = 0x7fffffff,
} D3DDDIFORMAT;
#endif /* __WINE_D3DUKMDT_H */

View file

@ -916,6 +916,20 @@ NtGdiDdCreateSurfaceEx(
_In_ HANDLE hSurface, _In_ HANDLE hSurface,
_In_ DWORD dwSurfaceHandle); _In_ DWORD dwSurfaceHandle);
__kernel_entry
W32KAPI
DWORD
APIENTRY
NtGdiDdDDICreateDCFromMemory(
_Inout_ D3DKMT_CREATEDCFROMMEMORY *desc);
__kernel_entry
W32KAPI
DWORD
APIENTRY
NtGdiDdDDIDestroyDCFromMemory(
_In_ CONST D3DKMT_DESTROYDCFROMMEMORY *desc);
__kernel_entry __kernel_entry
W32KAPI W32KAPI
DWORD DWORD

View file

@ -96,6 +96,7 @@ list(APPEND SOURCE
reactx/ntddraw/dd.c reactx/ntddraw/dd.c
reactx/ntddraw/ddsurf.c reactx/ntddraw/ddsurf.c
reactx/ntddraw/d3d.c reactx/ntddraw/d3d.c
reactx/ntddraw/d3dkmt.c
reactx/ntddraw/dvp.c reactx/ntddraw/dvp.c
reactx/ntddraw/mocomp.c reactx/ntddraw/mocomp.c
reactx/ntddraw/eng.c reactx/ntddraw/eng.c

View file

@ -608,3 +608,6 @@
608 stdcall bMakePathNameW(wstr wstr wstr long) 608 stdcall bMakePathNameW(wstr wstr wstr long)
609 stdcall cGetTTFFromFOT(long long long long long long long) 609 stdcall cGetTTFFromFOT(long long long long long long long)
610 stdcall gdiPlaySpoolStream(long long long long long long) 610 stdcall gdiPlaySpoolStream(long long long long long long)
; FIXME: Wine DX Dlls need these
@ stdcall D3DKMTCreateDCFromMemory(ptr)
@ stdcall D3DKMTDestroyDCFromMemory(ptr)

View file

@ -44,6 +44,7 @@
#include <ddrawi.h> #include <ddrawi.h>
#include <ddrawgdi.h> #include <ddrawgdi.h>
#include <d3dkmthk.h>
/* Public Win32K Headers */ /* Public Win32K Headers */
#include <ntgdityp.h> #include <ntgdityp.h>

View file

@ -1538,3 +1538,15 @@ SelectObject(
return NULL; return NULL;
} }
/***********************************************************************
* D3DKMTCreateDCFromMemory (GDI32.@)
*/
DWORD WINAPI D3DKMTCreateDCFromMemory( D3DKMT_CREATEDCFROMMEMORY *desc )
{
return NtGdiDdDDICreateDCFromMemory( desc );
}
DWORD WINAPI D3DKMTDestroyDCFromMemory( const D3DKMT_DESTROYDCFROMMEMORY *desc )
{
return NtGdiDdDDIDestroyDCFromMemory( desc );
}

View file

@ -0,0 +1,112 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* PURPOSE: Native DirectDraw implementation
* FILE: win32ss/reactx/ntddraw/d3dkmt.c
* PROGRAMER: Sebastian Gasiorek (sebastian.gasiorek@reactos.com)
*/
#include <win32k.h>
#include <debug.h>
DWORD
APIENTRY
NtGdiDdDDICreateDCFromMemory(D3DKMT_CREATEDCFROMMEMORY *desc)
{
PSURFACE psurf;
HDC hDC;
const struct d3dddi_format_info
{
D3DDDIFORMAT format;
unsigned int bit_count;
DWORD compression;
unsigned int palette_size;
DWORD mask_r, mask_g, mask_b;
} *format = NULL;
unsigned int i;
static const struct d3dddi_format_info format_info[] =
{
{ D3DDDIFMT_R8G8B8, 24, BI_RGB, 0, 0x00000000, 0x00000000, 0x00000000 },
{ D3DDDIFMT_A8R8G8B8, 32, BI_RGB, 0, 0x00000000, 0x00000000, 0x00000000 },
{ D3DDDIFMT_X8R8G8B8, 32, BI_RGB, 0, 0x00000000, 0x00000000, 0x00000000 },
{ D3DDDIFMT_R5G6B5, 16, BI_BITFIELDS, 0, 0x0000f800, 0x000007e0, 0x0000001f },
{ D3DDDIFMT_X1R5G5B5, 16, BI_BITFIELDS, 0, 0x00007c00, 0x000003e0, 0x0000001f },
{ D3DDDIFMT_A1R5G5B5, 16, BI_BITFIELDS, 0, 0x00007c00, 0x000003e0, 0x0000001f },
{ D3DDDIFMT_A4R4G4B4, 16, BI_BITFIELDS, 0, 0x00000f00, 0x000000f0, 0x0000000f },
{ D3DDDIFMT_X4R4G4B4, 16, BI_BITFIELDS, 0, 0x00000f00, 0x000000f0, 0x0000000f },
{ D3DDDIFMT_P8, 8, BI_RGB, 256, 0x00000000, 0x00000000, 0x00000000 },
};
if (!desc)
return STATUS_INVALID_PARAMETER;
if (!desc->pMemory)
return STATUS_INVALID_PARAMETER;
for (i = 0; i < sizeof(format_info) / sizeof(*format_info); ++i)
{
if (format_info[i].format == desc->Format)
{
format = &format_info[i];
break;
}
}
if (!format)
return STATUS_INVALID_PARAMETER;
if (desc->Width > (UINT_MAX & ~3) / (format->bit_count / 8) ||
!desc->Pitch || desc->Pitch < (((desc->Width * format->bit_count + 31) >> 3) & ~3) ||
!desc->Height || desc->Height > UINT_MAX / desc->Pitch)
{
return STATUS_INVALID_PARAMETER;
}
if (!desc->hDeviceDc || !(hDC = NtGdiCreateCompatibleDC(desc->hDeviceDc)))
{
return STATUS_INVALID_PARAMETER;
}
/* Allocate a surface */
psurf = SURFACE_AllocSurface(STYPE_BITMAP,
desc->Width,
desc->Height,
BitmapFormat(format->bit_count, format->compression),
BMF_TOPDOWN | BMF_NOZEROINIT,
desc->Pitch,
0,
desc->pMemory);
/* Mark as API bitmap */
psurf->flags |= (DDB_SURFACE | API_BITMAP);
desc->hDc = hDC;
/* Get the handle for the bitmap */
desc->hBitmap = (HBITMAP)psurf->SurfObj.hsurf;
/* Unlock the surface and return */
SURFACE_UnlockSurface(psurf);
NtGdiSelectBitmap(desc->hDc, desc->hBitmap);
return STATUS_SUCCESS;
}
DWORD
APIENTRY
NtGdiDdDDIDestroyDCFromMemory(const D3DKMT_DESTROYDCFROMMEMORY *desc)
{
if (!desc)
return STATUS_INVALID_PARAMETER;
if (GDI_HANDLE_GET_TYPE(desc->hDc) != GDI_OBJECT_TYPE_DC ||
GDI_HANDLE_GET_TYPE(desc->hBitmap) != GDI_OBJECT_TYPE_BITMAP)
return STATUS_INVALID_PARAMETER;
NtGdiDeleteObjectApp(desc->hBitmap);
NtGdiDeleteObjectApp(desc->hDc);
return STATUS_SUCCESS;
}

View file

@ -1,6 +1,7 @@
#pragma once #pragma once
#include <ddrawint.h> #include <ddrawint.h>
#include <d3dkmthk.h>
#include <ddkernel.h> #include <ddkernel.h>
#include <reactos/drivers/directx/directxint.h> #include <reactos/drivers/directx/directxint.h>
#include <reactos/drivers/directx/dxg.h> #include <reactos/drivers/directx/dxg.h>

View file

@ -690,3 +690,8 @@ NtUserMonitorFromRect 2
NtUserMonitorFromWindow 2 NtUserMonitorFromWindow 2
NtUserSetScrollBarInfo 3 NtUserSetScrollBarInfo 3
# #
# Vista+ Syscall add on for Wine DX
NtGdiDdDDICreateDCFromMemory 1
NtGdiDdDDIDestroyDCFromMemory 1
#

View file

@ -688,3 +688,6 @@
SVC_(UserMonitorFromRect, 2) SVC_(UserMonitorFromRect, 2)
SVC_(UserMonitorFromWindow, 2) SVC_(UserMonitorFromWindow, 2)
SVC_(UserSetScrollBarInfo, 3) SVC_(UserSetScrollBarInfo, 3)
// For Wine DX
SVC_(GdiDdDDICreateDCFromMemory, 1)
SVC_(GdiDdDDIDestroyDCFromMemory, 1)