ReactOS 0.4.16-dev-306-g647d351
d3dkmt.c File Reference
#include <win32k.h>
Include dependency graph for d3dkmt.c:

Go to the source code of this file.

Functions

DWORD APIENTRY NtGdiDdDDICreateDCFromMemory (D3DKMT_CREATEDCFROMMEMORY *desc)
 
DWORD APIENTRY NtGdiDdDDIDestroyDCFromMemory (const D3DKMT_DESTROYDCFROMMEMORY *desc)
 

Function Documentation

◆ NtGdiDdDDICreateDCFromMemory()

DWORD APIENTRY NtGdiDdDDICreateDCFromMemory ( D3DKMT_CREATEDCFROMMEMORY *  desc)

Definition at line 13 of file d3dkmt.c.

14{
15 PSURFACE psurf;
16 HDC hDC;
17
18 const struct d3dddi_format_info
19 {
20 D3DDDIFORMAT format;
21 unsigned int bit_count;
23 unsigned int palette_size;
24 DWORD mask_r, mask_g, mask_b;
25 } *format = NULL;
26 unsigned int i;
27
28 static const struct d3dddi_format_info format_info[] =
29 {
30 { D3DDDIFMT_R8G8B8, 24, BI_RGB, 0, 0x00000000, 0x00000000, 0x00000000 },
31 { D3DDDIFMT_A8R8G8B8, 32, BI_RGB, 0, 0x00000000, 0x00000000, 0x00000000 },
32 { D3DDDIFMT_X8R8G8B8, 32, BI_RGB, 0, 0x00000000, 0x00000000, 0x00000000 },
33 { D3DDDIFMT_R5G6B5, 16, BI_BITFIELDS, 0, 0x0000f800, 0x000007e0, 0x0000001f },
34 { D3DDDIFMT_X1R5G5B5, 16, BI_BITFIELDS, 0, 0x00007c00, 0x000003e0, 0x0000001f },
35 { D3DDDIFMT_A1R5G5B5, 16, BI_BITFIELDS, 0, 0x00007c00, 0x000003e0, 0x0000001f },
36 { D3DDDIFMT_A4R4G4B4, 16, BI_BITFIELDS, 0, 0x00000f00, 0x000000f0, 0x0000000f },
37 { D3DDDIFMT_X4R4G4B4, 16, BI_BITFIELDS, 0, 0x00000f00, 0x000000f0, 0x0000000f },
38 { D3DDDIFMT_P8, 8, BI_RGB, 256, 0x00000000, 0x00000000, 0x00000000 },
39 };
40
41 if (!desc)
43
44 if (!desc->pMemory)
46
47 for (i = 0; i < sizeof(format_info) / sizeof(*format_info); ++i)
48 {
49 if (format_info[i].format == desc->Format)
50 {
52 break;
53 }
54 }
55
56 if (!format)
58
59 if (desc->Width > (UINT_MAX & ~3) / (format->bit_count / 8) ||
60 !desc->Pitch || desc->Pitch < (((desc->Width * format->bit_count + 31) >> 3) & ~3) ||
61 !desc->Height || desc->Height > UINT_MAX / desc->Pitch)
62 {
64 }
65
66 if (!desc->hDeviceDc || !(hDC = NtGdiCreateCompatibleDC(desc->hDeviceDc)))
67 {
69 }
70
71 /* Allocate a surface */
73 desc->Width,
74 desc->Height,
75 BitmapFormat(format->bit_count, format->compression),
77 desc->Pitch,
78 0,
79 desc->pMemory);
80
81 /* Mark as API bitmap */
82 psurf->flags |= (DDB_SURFACE | API_BITMAP);
83
84 desc->hDc = hDC;
85 /* Get the handle for the bitmap */
86 desc->hBitmap = (HBITMAP)psurf->SurfObj.hsurf;
87
88 /* Allocate a palette for this surface */
89 if (format->bit_count <= 8)
90 {
91 PPALETTE palette = PALETTE_AllocPalette(PAL_INDEXED, 1 << format->bit_count, NULL, 0, 0, 0);
92 if (palette)
93 {
96 }
97 }
98
99 /* Unlock the surface and return */
101
102 NtGdiSelectBitmap(desc->hDc, desc->hBitmap);
103
104 return STATUS_SUCCESS;
105}
static HDC hDC
Definition: 3dtext.c:33
_In_ fcb _In_ chunk _In_ uint64_t _In_ uint64_t _In_ bool _In_opt_ void _In_opt_ PIRP _In_ LIST_ENTRY _In_ uint8_t compression
Definition: btrfs_drv.h:1365
format_info
#define NULL
Definition: types.h:112
static unsigned int palette_size(DWORD flags)
Definition: palette.c:241
#define BI_RGB
Definition: precomp.h:56
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define UINT_MAX
Definition: intsafe.h:152
if(dx< 0)
Definition: linetemp.h:194
#define BI_BITFIELDS
Definition: mmreg.h:507
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:88
static const WCHAR desc[]
Definition: protectdata.c:36
static HPALETTE palette
Definition: clipboard.c:1345
__kernel_entry W32KAPI HDC APIENTRY NtGdiCreateCompatibleDC(_In_opt_ HDC hdc)
__kernel_entry W32KAPI HBITMAP APIENTRY NtGdiSelectBitmap(_In_ HDC hdc, _In_ HBITMAP hbm)
#define STATUS_SUCCESS
Definition: shellext.h:65
SURFOBJ SurfObj
Definition: surface.h:8
FLONG flags
Definition: surface.h:10
HSURF hsurf
Definition: winddi.h:1206
Definition: format.c:58
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
ULONG FASTCALL BitmapFormat(ULONG cBits, ULONG iCompression)
Definition: surface.c:39
PSURFACE NTAPI SURFACE_AllocSurface(_In_ USHORT iType, _In_ ULONG cx, _In_ ULONG cy, _In_ ULONG iFormat, _In_ ULONG fjBitmap, _In_opt_ ULONG cjWidth, _In_opt_ ULONG cjBufSize, _In_opt_ PVOID pvBits)
Definition: surface.c:116
FORCEINLINE VOID SURFACE_vSetPalette(_Inout_ PSURFACE psurf, _In_ PPALETTE ppal)
Definition: surface.h:136
@ API_BITMAP
Definition: surface.h:76
@ DDB_SURFACE
Definition: surface.h:73
#define SURFACE_UnlockSurface(pBMObj)
Definition: surface.h:100
PPALETTE NTAPI PALETTE_AllocPalette(_In_ ULONG iMode, _In_ ULONG cColors, _In_opt_ const PALETTEENTRY *pEntries, _In_ FLONG flRed, _In_ FLONG flGreen, _In_ FLONG flBlue)
Definition: palette.c:135
#define PALETTE_ShareUnlockPalette(ppal)
Definition: palette.h:59
#define STYPE_BITMAP
Definition: winddi.h:1175
#define BMF_TOPDOWN
Definition: winddi.h:1180
#define PAL_INDEXED
Definition: winddi.h:1561
#define BMF_NOZEROINIT
Definition: winddi.h:1181

◆ NtGdiDdDDIDestroyDCFromMemory()

DWORD APIENTRY NtGdiDdDDIDestroyDCFromMemory ( const D3DKMT_DESTROYDCFROMMEMORY *  desc)

Definition at line 109 of file d3dkmt.c.

110{
111 if (!desc)
113
117
118 NtGdiDeleteObjectApp(desc->hBitmap);
120
121 return STATUS_SUCCESS;
122}
#define GDI_OBJECT_TYPE_DC
Definition: gdi.h:46
#define GDI_HANDLE_GET_TYPE(h)
Definition: gdi.h:31
#define GDI_OBJECT_TYPE_BITMAP
Definition: gdi.h:48
__kernel_entry W32KAPI BOOL APIENTRY NtGdiDeleteObjectApp(_In_ HANDLE hobj)