Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
9591466a
Commit
9591466a
authored
Apr 13, 2005
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved the driver-independent part of CreateDIBSection into GDI.
parent
da56a9c1
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
190 additions
and
229 deletions
+190
-229
dib.c
dlls/gdi/dib.c
+158
-32
gdi_private.h
dlls/gdi/gdi_private.h
+1
-1
dib.c
dlls/x11drv/dib.c
+30
-193
x11drv.h
dlls/x11drv/x11drv.h
+0
-2
x11drv.spec
dlls/x11drv/x11drv.spec
+1
-1
No files found.
dlls/gdi/dib.c
View file @
9591466a
This diff is collapsed.
Click to expand it.
dlls/gdi/gdi_private.h
View file @
9591466a
...
...
@@ -66,7 +66,7 @@ typedef struct tagDC_FUNCS
BOOL
(
*
pCloseFigure
)(
PHYSDEV
);
BOOL
(
*
pCreateBitmap
)(
PHYSDEV
,
HBITMAP
);
BOOL
(
*
pCreateDC
)(
HDC
,
PHYSDEV
*
,
LPCWSTR
,
LPCWSTR
,
LPCWSTR
,
const
DEVMODEW
*
);
HBITMAP
(
*
pCreateDIBSection
)(
PHYSDEV
,
const
BITMAPINFO
*
,
UINT
,
VOID
**
,
HANDLE
,
DWORD
,
DWORD
);
HBITMAP
(
*
pCreateDIBSection
)(
PHYSDEV
,
HBITMAP
,
const
BITMAPINFO
*
,
UINT
);
BOOL
(
*
pDeleteBitmap
)(
HBITMAP
);
BOOL
(
*
pDeleteDC
)(
PHYSDEV
);
BOOL
(
*
pDeleteObject
)(
PHYSDEV
,
HGDIOBJ
);
...
...
dlls/x11drv/dib.c
View file @
9591466a
...
...
@@ -36,7 +36,7 @@
#include <string.h>
#include "windef.h"
#include "winbase.h"
#include "gdi.h"
#include "
win
gdi.h"
#include "x11drv.h"
#include "wine/debug.h"
...
...
@@ -4531,217 +4531,54 @@ static XImage *X11DRV_XShmCreateImage( int width, int height, int bpp,
/***********************************************************************
* X11DRV_
DIB_CreateDIBSection
* X11DRV_
CreateDIBSection (X11DRV.@)
*/
HBITMAP
X11DRV_DIB_CreateDIBSection
(
X11DRV_PDEVICE
*
physDev
,
const
BITMAPINFO
*
bmi
,
UINT
usage
,
VOID
**
bits
,
HANDLE
section
,
DWORD
offset
,
DWORD
ovr_pitch
)
HBITMAP
X11DRV_CreateDIBSection
(
X11DRV_PDEVICE
*
physDev
,
HBITMAP
hbitmap
,
const
BITMAPINFO
*
bmi
,
UINT
usage
)
{
HBITMAP
res
=
0
;
X_PHYSBITMAP
*
physBitmap
=
NULL
;
DIBSECTION
*
dib
=
NULL
;
int
*
colorMap
=
NULL
;
int
nColorMap
;
RGBQUAD
*
colorTable
=
NULL
;
/* Fill BITMAP structure with DIB data */
INT
effHeight
,
totalSize
;
BITMAP
bm
;
LPVOID
mapBits
=
NULL
;
int
bitmap_type
;
BOOL
core_header
;
LONG
width
,
height
;
WORD
planes
,
bpp
,
compression
;
DWORD
sizeImage
;
void
*
colorPtr
;
if
(((
bitmap_type
=
DIB_GetBitmapInfoEx
((
BITMAPINFOHEADER
*
)
bmi
,
&
width
,
&
height
,
&
planes
,
&
bpp
,
&
compression
,
&
sizeImage
))
==
-
1
))
{
ERR
(
"Invalid bitmap
\n
"
);
return
0
;
}
core_header
=
(
bitmap_type
==
0
);
TRACE
(
"format (%ld,%ld), planes %d, bpp %d, size %ld, %s
\n
"
,
width
,
height
,
planes
,
bpp
,
sizeImage
,
usage
==
DIB_PAL_COLORS
?
"PAL"
:
"RGB"
);
effHeight
=
height
>=
0
?
height
:
-
height
;
bm
.
bmType
=
0
;
bm
.
bmWidth
=
width
;
bm
.
bmHeight
=
effHeight
;
bm
.
bmWidthBytes
=
ovr_pitch
?
ovr_pitch
:
X11DRV_DIB_GetDIBWidthBytes
(
bm
.
bmWidth
,
bpp
);
bm
.
bmPlanes
=
planes
;
bm
.
bmBitsPixel
=
bpp
;
bm
.
bmBits
=
NULL
;
/* Get storage location for DIB bits. Only use sizeImage if it's valid and
we're dealing with a compressed bitmap. Otherwise, use width * height. */
if
(
sizeImage
&&
(
compression
==
BI_RLE4
||
compression
==
BI_RLE8
))
totalSize
=
sizeImage
;
else
totalSize
=
bm
.
bmWidthBytes
*
effHeight
;
if
(
section
)
{
SYSTEM_INFO
SystemInfo
;
DWORD
mapOffset
;
INT
mapSize
;
GetSystemInfo
(
&
SystemInfo
);
mapOffset
=
offset
-
(
offset
%
SystemInfo
.
dwAllocationGranularity
);
mapSize
=
totalSize
+
(
offset
-
mapOffset
);
mapBits
=
MapViewOfFile
(
section
,
FILE_MAP_ALL_ACCESS
,
0L
,
mapOffset
,
mapSize
);
bm
.
bmBits
=
(
char
*
)
mapBits
+
(
offset
-
mapOffset
);
}
else
if
(
ovr_pitch
&&
offset
)
bm
.
bmBits
=
(
LPVOID
)
offset
;
else
{
offset
=
0
;
bm
.
bmBits
=
VirtualAlloc
(
NULL
,
totalSize
,
MEM_RESERVE
|
MEM_COMMIT
,
PAGE_READWRITE
);
}
/* Create Color Map */
if
(
bm
.
bmBits
&&
bm
.
bmBitsPixel
<=
8
)
{
colorMap
=
X11DRV_DIB_BuildColorMap
(
usage
==
DIB_PAL_COLORS
?
physDev
:
NULL
,
usage
,
bm
.
bmBitsPixel
,
bmi
,
&
nColorMap
);
colorTable
=
X11DRV_DIB_BuildColorTable
(
physDev
,
usage
,
bm
.
bmBitsPixel
,
bmi
);
}
/* Allocate Memory for DIB and fill structure */
if
(
bm
.
bmBits
)
dib
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
*
dib
));
if
(
dib
)
{
dib
->
dsBm
=
bm
;
if
(
core_header
)
{
/* Convert the BITMAPCOREHEADER to a BITMAPINFOHEADER.
The structure is already filled with zeros */
dib
->
dsBmih
.
biSize
=
sizeof
(
BITMAPINFOHEADER
);
dib
->
dsBmih
.
biWidth
=
width
;
dib
->
dsBmih
.
biHeight
=
height
;
dib
->
dsBmih
.
biPlanes
=
planes
;
dib
->
dsBmih
.
biBitCount
=
bpp
;
dib
->
dsBmih
.
biCompression
=
compression
;
}
else
{
/* Truncate extended bitmap headers (BITMAPV4HEADER etc.) */
dib
->
dsBmih
=
*
((
BITMAPINFOHEADER
*
)
bmi
);
dib
->
dsBmih
.
biSize
=
sizeof
(
BITMAPINFOHEADER
);
}
dib
->
dsBmih
.
biSizeImage
=
totalSize
;
colorPtr
=
(
LPBYTE
)
bmi
+
(
WORD
)
bmi
->
bmiHeader
.
biSize
;
/* Set dsBitfields values */
if
(
usage
==
DIB_PAL_COLORS
||
bpp
<=
8
)
{
dib
->
dsBitfields
[
0
]
=
dib
->
dsBitfields
[
1
]
=
dib
->
dsBitfields
[
2
]
=
0
;
}
else
switch
(
bpp
)
{
case
15
:
case
16
:
dib
->
dsBitfields
[
0
]
=
(
compression
==
BI_BITFIELDS
)
?
*
((
const
DWORD
*
)
colorPtr
)
:
0x7c00
;
dib
->
dsBitfields
[
1
]
=
(
compression
==
BI_BITFIELDS
)
?
*
((
const
DWORD
*
)
colorPtr
+
1
)
:
0x03e0
;
dib
->
dsBitfields
[
2
]
=
(
compression
==
BI_BITFIELDS
)
?
*
((
const
DWORD
*
)
colorPtr
+
2
)
:
0x001f
;
break
;
case
24
:
case
32
:
dib
->
dsBitfields
[
0
]
=
(
compression
==
BI_BITFIELDS
)
?
*
((
const
DWORD
*
)
colorPtr
)
:
0xff0000
;
dib
->
dsBitfields
[
1
]
=
(
compression
==
BI_BITFIELDS
)
?
*
((
const
DWORD
*
)
colorPtr
+
1
)
:
0x00ff00
;
dib
->
dsBitfields
[
2
]
=
(
compression
==
BI_BITFIELDS
)
?
*
((
const
DWORD
*
)
colorPtr
+
2
)
:
0x0000ff
;
break
;
}
dib
->
dshSection
=
section
;
dib
->
dsOffset
=
offset
;
extern
BOOL
VIRTUAL_SetFaultHandler
(
LPCVOID
addr
,
BOOL
(
*
proc
)(
LPVOID
,
LPCVOID
),
LPVOID
arg
);
X_PHYSBITMAP
*
physBitmap
;
DIBSECTION
dib
;
}
if
(
!
(
physBitmap
=
X11DRV_init_phys_bitmap
(
hbitmap
)))
return
0
;
physBitmap
->
status
=
DIB_Status_None
;
/* Create Device Dependent Bitmap and add DIB pointer */
if
(
dib
)
{
int
depth
=
(
bpp
==
1
)
?
1
:
GetDeviceCaps
(
physDev
->
hdc
,
BITSPIXEL
);
res
=
CreateBitmap
(
width
,
effHeight
,
1
,
depth
,
NULL
);
GetObjectW
(
hbitmap
,
sizeof
(
dib
),
&
dib
);
if
(
res
)
/* create color map */
if
(
dib
.
dsBm
.
bmBitsPixel
<=
8
)
{
BITMAPOBJ
*
bmp
=
GDI_GetObjPtr
(
res
,
BITMAP_MAGIC
);
if
(
bmp
)
bmp
->
dib
=
dib
;
GDI_ReleaseObj
(
res
);
physBitmap
=
X11DRV_init_phys_bitmap
(
res
);
physBitmap
->
status
=
DIB_Status_None
;
physBitmap
->
nColorMap
=
nColorMap
;
physBitmap
->
colorMap
=
colorMap
;
physBitmap
->
colorTable
=
colorTable
;
}
physBitmap
->
colorMap
=
X11DRV_DIB_BuildColorMap
(
usage
==
DIB_PAL_COLORS
?
physDev
:
NULL
,
usage
,
dib
.
dsBm
.
bmBitsPixel
,
bmi
,
&
physBitmap
->
nColorMap
);
physBitmap
->
colorTable
=
X11DRV_DIB_BuildColorTable
(
physDev
,
usage
,
dib
.
dsBm
.
bmBitsPixel
,
bmi
);
}
/* Create XImage */
if
(
dib
&&
physBitmap
)
{
/* create pixmap and X image */
wine_tsx11_lock
();
physBitmap
->
pixmap_depth
=
(
dib
.
dsBm
.
bmBitsPixel
==
1
)
?
1
:
screen_depth
;
physBitmap
->
pixmap
=
XCreatePixmap
(
gdi_display
,
root_window
,
dib
.
dsBm
.
bmWidth
,
dib
.
dsBm
.
bmHeight
,
physBitmap
->
pixmap_depth
);
#ifdef HAVE_LIBXXSHM
if
(
XShmQueryExtension
(
gdi_display
)
&&
(
physBitmap
->
image
=
X11DRV_XShmCreateImage
(
bm
.
bmWidth
,
effHeight
,
physBitmap
->
pixmap_depth
,
&
physBitmap
->
shminfo
))
)
{
;
/* Created Image */
}
else
{
physBitmap
->
image
=
X11DRV_DIB_CreateXImage
(
bm
.
bmWidth
,
effHeight
,
physBitmap
->
pixmap_depth
);
physBitmap
->
shminfo
.
shmid
=
-
1
;
}
#else
physBitmap
->
image
=
X11DRV_DIB_CreateXImage
(
bm
.
bmWidth
,
effHeight
,
physBitmap
->
pixmap_depth
);
if
(
!
XShmQueryExtension
(
gdi_display
)
||
!
(
physBitmap
->
image
=
X11DRV_XShmCreateImage
(
dib
.
dsBm
.
bmWidth
,
dib
.
dsBm
.
bmHeight
,
physBitmap
->
pixmap_depth
,
&
physBitmap
->
shminfo
))
)
#endif
physBitmap
->
image
=
X11DRV_DIB_CreateXImage
(
dib
.
dsBm
.
bmWidth
,
dib
.
dsBm
.
bmHeight
,
physBitmap
->
pixmap_depth
);
wine_tsx11_unlock
();
}
if
(
!
physBitmap
->
pixmap
||
!
physBitmap
->
image
)
return
0
;
/* Clean up in case of errors */
if
(
!
res
||
!
physBitmap
||
!
dib
||
!
bm
.
bmBits
||
(
bm
.
bmBitsPixel
<=
8
&&
!
colorMap
))
{
TRACE
(
"got an error res=%p, bmp=%p, dib=%p, bm.bmBits=%p
\n
"
,
res
,
physBitmap
,
dib
,
bm
.
bmBits
);
if
(
bm
.
bmBits
)
{
if
(
section
)
UnmapViewOfFile
(
mapBits
),
bm
.
bmBits
=
NULL
;
else
if
(
!
offset
)
VirtualFree
(
bm
.
bmBits
,
0L
,
MEM_RELEASE
),
bm
.
bmBits
=
NULL
;
}
if
(
dib
&&
physBitmap
->
image
)
{
XDestroyImage
(
physBitmap
->
image
);
physBitmap
->
image
=
NULL
;
}
HeapFree
(
GetProcessHeap
(),
0
,
colorMap
);
colorMap
=
NULL
;
HeapFree
(
GetProcessHeap
(),
0
,
colorTable
);
colorTable
=
NULL
;
HeapFree
(
GetProcessHeap
(),
0
,
dib
);
dib
=
NULL
;
if
(
res
)
{
DeleteObject
(
res
);
res
=
0
;
}
}
else
if
(
bm
.
bmBits
)
{
extern
BOOL
VIRTUAL_SetFaultHandler
(
LPCVOID
addr
,
BOOL
(
*
proc
)(
LPVOID
,
LPCVOID
),
LPVOID
arg
);
/* Install fault handler, if possible */
InitializeCriticalSection
(
&
physBitmap
->
lock
);
if
(
VIRTUAL_SetFaultHandler
(
bm
.
bmBits
,
X11DRV_DIB_FaultHandler
,
physBitmap
))
/* install fault handler */
InitializeCriticalSection
(
&
physBitmap
->
lock
);
if
(
VIRTUAL_SetFaultHandler
(
dib
.
dsBm
.
bmBits
,
X11DRV_DIB_FaultHandler
,
physBitmap
))
{
X11DRV_DIB_DoProtectDIBSection
(
physBitmap
,
PAGE_READWRITE
);
physBitmap
->
status
=
DIB_Status_AppMod
;
}
}
/* Return BITMAP handle and storage location */
if
(
bm
.
bmBits
&&
bits
)
*
bits
=
bm
.
bmBits
;
return
res
;
return
hbitmap
;
}
/***********************************************************************
...
...
dlls/x11drv/x11drv.h
View file @
9591466a
...
...
@@ -409,8 +409,6 @@ extern INT X11DRV_CoerceDIBSection(X11DRV_PDEVICE *physDev,INT,BOOL);
extern
INT
X11DRV_LockDIBSection
(
X11DRV_PDEVICE
*
physDev
,
INT
,
BOOL
);
extern
void
X11DRV_UnlockDIBSection
(
X11DRV_PDEVICE
*
physDev
,
BOOL
);
extern
HBITMAP
X11DRV_DIB_CreateDIBSection
(
X11DRV_PDEVICE
*
physDev
,
const
BITMAPINFO
*
bmi
,
UINT
usage
,
VOID
**
bits
,
HANDLE
section
,
DWORD
offset
,
DWORD
ovr_pitch
);
extern
void
X11DRV_DIB_DeleteDIBSection
(
X_PHYSBITMAP
*
physBitmap
,
DIBSECTION
*
dib
);
void
X11DRV_DIB_CopyDIBSection
(
X11DRV_PDEVICE
*
physDevSrc
,
X11DRV_PDEVICE
*
physDevDst
,
DWORD
xSrc
,
DWORD
ySrc
,
DWORD
xDest
,
DWORD
yDest
,
...
...
dlls/x11drv/x11drv.spec
View file @
9591466a
...
...
@@ -7,7 +7,7 @@
@ cdecl Chord(ptr long long long long long long long long) X11DRV_Chord
@ cdecl CreateBitmap(ptr long) X11DRV_CreateBitmap
@ cdecl CreateDC(long ptr wstr wstr wstr ptr) X11DRV_CreateDC
@ cdecl CreateDIBSection(ptr
ptr long ptr long long long) X11DRV_DIB
_CreateDIBSection
@ cdecl CreateDIBSection(ptr
long ptr long) X11DRV
_CreateDIBSection
@ cdecl DeleteBitmap(long) X11DRV_DeleteBitmap
@ cdecl DeleteDC(ptr) X11DRV_DeleteDC
@ cdecl DescribePixelFormat(ptr long long ptr) X11DRV_DescribePixelFormat
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment