Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
53805720
Commit
53805720
authored
Mar 08, 2012
by
Henri Verbeet
Committed by
Alexandre Julliard
Mar 09, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d3dx9: Implement loading luminance/alpha data in D3DXLoadSurfaceFromMemory().
parent
fb799158
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
176 additions
and
51 deletions
+176
-51
d3dx9_36_private.h
dlls/d3dx9_36/d3dx9_36_private.h
+7
-0
surface.c
dlls/d3dx9_36/surface.c
+135
-32
util.c
dlls/d3dx9_36/util.c
+34
-19
No files found.
dlls/d3dx9_36/d3dx9_36_private.h
View file @
53805720
...
@@ -32,6 +32,11 @@
...
@@ -32,6 +32,11 @@
#define ARRAY_SIZE(array) (sizeof(array)/sizeof(*array))
#define ARRAY_SIZE(array) (sizeof(array)/sizeof(*array))
struct
vec4
{
float
x
,
y
,
z
,
w
;
};
/* for internal use */
/* for internal use */
typedef
enum
_FormatType
{
typedef
enum
_FormatType
{
FORMAT_ARGB
,
/* unsigned */
FORMAT_ARGB
,
/* unsigned */
...
@@ -44,6 +49,8 @@ typedef struct _PixelFormatDesc {
...
@@ -44,6 +49,8 @@ typedef struct _PixelFormatDesc {
BYTE
shift
[
4
];
BYTE
shift
[
4
];
UINT
bytes_per_pixel
;
UINT
bytes_per_pixel
;
FormatType
type
;
FormatType
type
;
void
(
*
from_rgba
)(
const
struct
vec4
*
src
,
struct
vec4
*
dst
);
void
(
*
to_rgba
)(
const
struct
vec4
*
src
,
struct
vec4
*
dst
);
}
PixelFormatDesc
;
}
PixelFormatDesc
;
HRESULT
map_view_of_file
(
LPCWSTR
filename
,
LPVOID
*
buffer
,
DWORD
*
length
)
DECLSPEC_HIDDEN
;
HRESULT
map_view_of_file
(
LPCWSTR
filename
,
LPVOID
*
buffer
,
DWORD
*
length
)
DECLSPEC_HIDDEN
;
...
...
dlls/d3dx9_36/surface.c
View file @
53805720
...
@@ -670,6 +670,57 @@ static DWORD make_argb_color(CONST struct argb_conversion_info *info, CONST DWOR
...
@@ -670,6 +670,57 @@ static DWORD make_argb_color(CONST struct argb_conversion_info *info, CONST DWOR
return
val
;
return
val
;
}
}
static
void
format_to_vec4
(
const
PixelFormatDesc
*
format
,
const
DWORD
*
src
,
struct
vec4
*
dst
)
{
DWORD
mask
;
if
(
format
->
bits
[
1
])
{
mask
=
(
1
<<
format
->
bits
[
1
])
-
1
;
dst
->
x
=
(
float
)((
*
src
>>
format
->
shift
[
1
])
&
mask
)
/
mask
;
}
else
dst
->
x
=
1
.
0
f
;
if
(
format
->
bits
[
2
])
{
mask
=
(
1
<<
format
->
bits
[
2
])
-
1
;
dst
->
y
=
(
float
)((
*
src
>>
format
->
shift
[
2
])
&
mask
)
/
mask
;
}
else
dst
->
y
=
1
.
0
f
;
if
(
format
->
bits
[
3
])
{
mask
=
(
1
<<
format
->
bits
[
3
])
-
1
;
dst
->
z
=
(
float
)((
*
src
>>
format
->
shift
[
3
])
&
mask
)
/
mask
;
}
else
dst
->
z
=
1
.
0
f
;
if
(
format
->
bits
[
0
])
{
mask
=
(
1
<<
format
->
bits
[
0
])
-
1
;
dst
->
w
=
(
float
)((
*
src
>>
format
->
shift
[
0
])
&
mask
)
/
mask
;
}
else
dst
->
w
=
1
.
0
f
;
}
static
void
format_from_vec4
(
const
PixelFormatDesc
*
format
,
const
struct
vec4
*
src
,
DWORD
*
dst
)
{
*
dst
=
0
;
if
(
format
->
bits
[
1
])
*
dst
|=
(
DWORD
)(
src
->
x
*
((
1
<<
format
->
bits
[
1
])
-
1
)
+
0
.
5
f
)
<<
format
->
shift
[
1
];
if
(
format
->
bits
[
2
])
*
dst
|=
(
DWORD
)(
src
->
y
*
((
1
<<
format
->
bits
[
2
])
-
1
)
+
0
.
5
f
)
<<
format
->
shift
[
2
];
if
(
format
->
bits
[
3
])
*
dst
|=
(
DWORD
)(
src
->
z
*
((
1
<<
format
->
bits
[
3
])
-
1
)
+
0
.
5
f
)
<<
format
->
shift
[
3
];
if
(
format
->
bits
[
0
])
*
dst
|=
(
DWORD
)(
src
->
w
*
((
1
<<
format
->
bits
[
0
])
-
1
)
+
0
.
5
f
)
<<
format
->
shift
[
0
];
}
/************************************************************
/************************************************************
* copy_simple_data
* copy_simple_data
*
*
...
@@ -685,6 +736,7 @@ static void copy_simple_data(CONST BYTE *src, UINT srcpitch, POINT srcsize,
...
@@ -685,6 +736,7 @@ static void copy_simple_data(CONST BYTE *src, UINT srcpitch, POINT srcsize,
D3DCOLOR
colorkey
)
D3DCOLOR
colorkey
)
{
{
struct
argb_conversion_info
conv_info
,
ck_conv_info
;
struct
argb_conversion_info
conv_info
,
ck_conv_info
;
const
PixelFormatDesc
*
ck_format
=
NULL
;
DWORD
channels
[
4
],
pixel
;
DWORD
channels
[
4
],
pixel
;
UINT
minwidth
,
minheight
;
UINT
minwidth
,
minheight
;
UINT
x
,
y
;
UINT
x
,
y
;
...
@@ -695,33 +747,58 @@ static void copy_simple_data(CONST BYTE *src, UINT srcpitch, POINT srcsize,
...
@@ -695,33 +747,58 @@ static void copy_simple_data(CONST BYTE *src, UINT srcpitch, POINT srcsize,
minwidth
=
(
srcsize
.
x
<
destsize
.
x
)
?
srcsize
.
x
:
destsize
.
x
;
minwidth
=
(
srcsize
.
x
<
destsize
.
x
)
?
srcsize
.
x
:
destsize
.
x
;
minheight
=
(
srcsize
.
y
<
destsize
.
y
)
?
srcsize
.
y
:
destsize
.
y
;
minheight
=
(
srcsize
.
y
<
destsize
.
y
)
?
srcsize
.
y
:
destsize
.
y
;
if
(
colorkey
)
{
if
(
colorkey
)
/* color keys are always represented in D3DFMT_A8R8G8B8 format */
{
const
PixelFormatDesc
*
ckformatdesc
;
/* Color keys are always represented in D3DFMT_A8R8G8B8 format. */
ck_format
=
get_format_info
(
D3DFMT_A8R8G8B8
);
ckformatdesc
=
get_format_info
(
D3DFMT_A8R8G8B8
);
init_argb_conversion_info
(
srcformat
,
ck_format
,
&
ck_conv_info
);
init_argb_conversion_info
(
srcformat
,
ckformatdesc
,
&
ck_conv_info
);
}
}
for
(
y
=
0
;
y
<
minheight
;
y
++
)
{
for
(
y
=
0
;
y
<
minheight
;
y
++
)
{
const
BYTE
*
srcptr
=
src
+
y
*
srcpitch
;
const
BYTE
*
srcptr
=
src
+
y
*
srcpitch
;
BYTE
*
destptr
=
dest
+
y
*
destpitch
;
BYTE
*
destptr
=
dest
+
y
*
destpitch
;
DWORD
val
=
0
;
DWORD
val
;
for
(
x
=
0
;
x
<
minwidth
;
x
++
)
{
for
(
x
=
0
;
x
<
minwidth
;
x
++
)
{
/* extract source color components */
/* extract source color components */
pixel
=
dword_from_bytes
(
srcptr
,
srcformat
->
bytes_per_pixel
);
pixel
=
dword_from_bytes
(
srcptr
,
srcformat
->
bytes_per_pixel
);
get_relevant_argb_components
(
&
conv_info
,
pixel
,
channels
);
/* recombine the components */
if
(
!
srcformat
->
to_rgba
&&
!
destformat
->
from_rgba
)
val
=
make_argb_color
(
&
conv_info
,
channels
);
{
get_relevant_argb_components
(
&
conv_info
,
pixel
,
channels
);
val
=
make_argb_color
(
&
conv_info
,
channels
);
if
(
colorkey
)
{
get_relevant_argb_components
(
&
ck_conv_info
,
pixel
,
channels
);
pixel
=
make_argb_color
(
&
ck_conv_info
,
channels
);
if
(
pixel
==
colorkey
)
val
&=
~
conv_info
.
destmask
[
0
];
}
}
else
{
struct
vec4
color
,
tmp
;
format_to_vec4
(
srcformat
,
&
pixel
,
&
color
);
if
(
srcformat
->
to_rgba
)
srcformat
->
to_rgba
(
&
color
,
&
tmp
);
else
tmp
=
color
;
if
(
ck_format
)
{
format_from_vec4
(
ck_format
,
&
tmp
,
&
pixel
);
if
(
pixel
==
colorkey
)
tmp
.
w
=
0
.
0
f
;
}
if
(
destformat
->
from_rgba
)
destformat
->
from_rgba
(
&
tmp
,
&
color
);
else
color
=
tmp
;
if
(
colorkey
)
{
format_from_vec4
(
destformat
,
&
color
,
&
val
);
get_relevant_argb_components
(
&
ck_conv_info
,
pixel
,
channels
);
pixel
=
make_argb_color
(
&
ck_conv_info
,
channels
);
if
(
pixel
==
colorkey
)
/* make this pixel transparent */
val
&=
~
conv_info
.
destmask
[
0
];
}
}
dword_to_bytes
(
destptr
,
val
,
destformat
->
bytes_per_pixel
);
dword_to_bytes
(
destptr
,
val
,
destformat
->
bytes_per_pixel
);
...
@@ -751,6 +828,7 @@ static void point_filter_simple_data(CONST BYTE *src, UINT srcpitch, POINT srcsi
...
@@ -751,6 +828,7 @@ static void point_filter_simple_data(CONST BYTE *src, UINT srcpitch, POINT srcsi
D3DCOLOR
colorkey
)
D3DCOLOR
colorkey
)
{
{
struct
argb_conversion_info
conv_info
,
ck_conv_info
;
struct
argb_conversion_info
conv_info
,
ck_conv_info
;
const
PixelFormatDesc
*
ck_format
=
NULL
;
DWORD
channels
[
4
],
pixel
;
DWORD
channels
[
4
],
pixel
;
UINT
x
,
y
;
UINT
x
,
y
;
...
@@ -758,12 +836,11 @@ static void point_filter_simple_data(CONST BYTE *src, UINT srcpitch, POINT srcsi
...
@@ -758,12 +836,11 @@ static void point_filter_simple_data(CONST BYTE *src, UINT srcpitch, POINT srcsi
ZeroMemory
(
channels
,
sizeof
(
channels
));
ZeroMemory
(
channels
,
sizeof
(
channels
));
init_argb_conversion_info
(
srcformat
,
destformat
,
&
conv_info
);
init_argb_conversion_info
(
srcformat
,
destformat
,
&
conv_info
);
if
(
colorkey
)
{
if
(
colorkey
)
/* color keys are always represented in D3DFMT_A8R8G8B8 format */
{
const
PixelFormatDesc
*
ckformatdesc
;
/* Color keys are always represented in D3DFMT_A8R8G8B8 format. */
ck_format
=
get_format_info
(
D3DFMT_A8R8G8B8
);
ckformatdesc
=
get_format_info
(
D3DFMT_A8R8G8B8
);
init_argb_conversion_info
(
srcformat
,
ck_format
,
&
ck_conv_info
);
init_argb_conversion_info
(
srcformat
,
ckformatdesc
,
&
ck_conv_info
);
}
}
for
(
y
=
0
;
y
<
destsize
.
y
;
y
++
)
{
for
(
y
=
0
;
y
<
destsize
.
y
;
y
++
)
{
...
@@ -772,21 +849,47 @@ static void point_filter_simple_data(CONST BYTE *src, UINT srcpitch, POINT srcsi
...
@@ -772,21 +849,47 @@ static void point_filter_simple_data(CONST BYTE *src, UINT srcpitch, POINT srcsi
for
(
x
=
0
;
x
<
destsize
.
x
;
x
++
)
{
for
(
x
=
0
;
x
<
destsize
.
x
;
x
++
)
{
const
BYTE
*
srcptr
=
bufptr
+
(
x
*
srcsize
.
x
/
destsize
.
x
)
*
srcformat
->
bytes_per_pixel
;
const
BYTE
*
srcptr
=
bufptr
+
(
x
*
srcsize
.
x
/
destsize
.
x
)
*
srcformat
->
bytes_per_pixel
;
DWORD
val
=
0
;
DWORD
val
;
/* extract source color components */
/* extract source color components */
pixel
=
dword_from_bytes
(
srcptr
,
srcformat
->
bytes_per_pixel
);
pixel
=
dword_from_bytes
(
srcptr
,
srcformat
->
bytes_per_pixel
);
get_relevant_argb_components
(
&
conv_info
,
pixel
,
channels
);
/* recombine the components */
if
(
!
srcformat
->
to_rgba
&&
!
destformat
->
from_rgba
)
val
=
make_argb_color
(
&
conv_info
,
channels
);
{
get_relevant_argb_components
(
&
conv_info
,
pixel
,
channels
);
val
=
make_argb_color
(
&
conv_info
,
channels
);
if
(
colorkey
)
{
get_relevant_argb_components
(
&
ck_conv_info
,
pixel
,
channels
);
pixel
=
make_argb_color
(
&
ck_conv_info
,
channels
);
if
(
pixel
==
colorkey
)
val
&=
~
conv_info
.
destmask
[
0
];
}
}
else
{
struct
vec4
color
,
tmp
;
format_to_vec4
(
srcformat
,
&
pixel
,
&
color
);
if
(
srcformat
->
to_rgba
)
srcformat
->
to_rgba
(
&
color
,
&
tmp
);
else
tmp
=
color
;
if
(
ck_format
)
{
format_from_vec4
(
ck_format
,
&
tmp
,
&
pixel
);
if
(
pixel
==
colorkey
)
tmp
.
w
=
0
.
0
f
;
}
if
(
destformat
->
from_rgba
)
destformat
->
from_rgba
(
&
tmp
,
&
color
);
else
color
=
tmp
;
if
(
colorkey
)
{
format_from_vec4
(
destformat
,
&
color
,
&
val
);
get_relevant_argb_components
(
&
ck_conv_info
,
pixel
,
channels
);
pixel
=
make_argb_color
(
&
ck_conv_info
,
channels
);
if
(
pixel
==
colorkey
)
/* make this pixel transparent */
val
&=
~
conv_info
.
destmask
[
0
];
}
}
dword_to_bytes
(
destptr
,
val
,
destformat
->
bytes_per_pixel
);
dword_to_bytes
(
destptr
,
val
,
destformat
->
bytes_per_pixel
);
...
...
dlls/d3dx9_36/util.c
View file @
53805720
...
@@ -22,6 +22,20 @@
...
@@ -22,6 +22,20 @@
WINE_DEFAULT_DEBUG_CHANNEL
(
d3dx
);
WINE_DEFAULT_DEBUG_CHANNEL
(
d3dx
);
static
void
la_from_rgba
(
const
struct
vec4
*
rgba
,
struct
vec4
*
la
)
{
la
->
x
=
rgba
->
x
*
0
.
2125
f
+
rgba
->
y
*
0
.
7154
f
+
rgba
->
z
*
0
.
0721
f
;
la
->
w
=
rgba
->
w
;
}
static
void
la_to_rgba
(
const
struct
vec4
*
la
,
struct
vec4
*
rgba
)
{
rgba
->
x
=
la
->
x
;
rgba
->
y
=
la
->
x
;
rgba
->
z
=
la
->
x
;
rgba
->
w
=
la
->
w
;
}
/************************************************************
/************************************************************
* pixel format table providing info about number of bytes per pixel,
* pixel format table providing info about number of bytes per pixel,
* number of bits per channel and format type.
* number of bits per channel and format type.
...
@@ -30,25 +44,26 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
...
@@ -30,25 +44,26 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
*/
*/
static
const
PixelFormatDesc
formats
[]
=
static
const
PixelFormatDesc
formats
[]
=
{
{
/* format bits per channel shifts per channel bpp type */
/* format bpc shifts bpp type from_rgba to_rgba */
{
D3DFMT_R8G8B8
,
{
0
,
8
,
8
,
8
},
{
0
,
16
,
8
,
0
},
3
,
FORMAT_ARGB
},
{
D3DFMT_R8G8B8
,
{
0
,
8
,
8
,
8
},
{
0
,
16
,
8
,
0
},
3
,
FORMAT_ARGB
,
NULL
,
NULL
},
{
D3DFMT_A8R8G8B8
,
{
8
,
8
,
8
,
8
},
{
24
,
16
,
8
,
0
},
4
,
FORMAT_ARGB
},
{
D3DFMT_A8R8G8B8
,
{
8
,
8
,
8
,
8
},
{
24
,
16
,
8
,
0
},
4
,
FORMAT_ARGB
,
NULL
,
NULL
},
{
D3DFMT_X8R8G8B8
,
{
0
,
8
,
8
,
8
},
{
0
,
16
,
8
,
0
},
4
,
FORMAT_ARGB
},
{
D3DFMT_X8R8G8B8
,
{
0
,
8
,
8
,
8
},
{
0
,
16
,
8
,
0
},
4
,
FORMAT_ARGB
,
NULL
,
NULL
},
{
D3DFMT_A8B8G8R8
,
{
8
,
8
,
8
,
8
},
{
24
,
0
,
8
,
16
},
4
,
FORMAT_ARGB
},
{
D3DFMT_A8B8G8R8
,
{
8
,
8
,
8
,
8
},
{
24
,
0
,
8
,
16
},
4
,
FORMAT_ARGB
,
NULL
,
NULL
},
{
D3DFMT_X8B8G8R8
,
{
0
,
8
,
8
,
8
},
{
0
,
0
,
8
,
16
},
4
,
FORMAT_ARGB
},
{
D3DFMT_X8B8G8R8
,
{
0
,
8
,
8
,
8
},
{
0
,
0
,
8
,
16
},
4
,
FORMAT_ARGB
,
NULL
,
NULL
},
{
D3DFMT_R5G6B5
,
{
0
,
5
,
6
,
5
},
{
0
,
11
,
5
,
0
},
2
,
FORMAT_ARGB
},
{
D3DFMT_R5G6B5
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G10B10
,
{
2
,
10
,
10
,
10
},
{
30
,
20
,
10
,
0
},
4
,
FORMAT_ARGB
},
{
D3DFMT_A2R10G10B10
,
{
2
,
10
,
10
,
10
},
{
30
,
20
,
10
,
0
},
4
,
FORMAT_ARGB
,
NULL
,
NULL
},
{
D3DFMT_A2B10G10R10
,
{
2
,
10
,
10
,
10
},
{
30
,
0
,
10
,
20
},
4
,
FORMAT_ARGB
},
{
D3DFMT_A2B10G10R10
,
{
2
,
10
,
10
,
10
},
{
30
,
0
,
10
,
20
},
4
,
FORMAT_ARGB
,
NULL
,
NULL
},
{
D3DFMT_G16R16
,
{
0
,
16
,
16
,
0
},
{
0
,
0
,
16
,
0
},
4
,
FORMAT_ARGB
},
{
D3DFMT_G16R16
,
{
0
,
16
,
16
,
0
},
{
0
,
0
,
16
,
0
},
4
,
FORMAT_ARGB
,
NULL
,
NULL
},
{
D3DFMT_A8
,
{
8
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
},
1
,
FORMAT_ARGB
},
{
D3DFMT_A8
,
{
8
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
},
1
,
FORMAT_ARGB
,
NULL
,
NULL
},
{
D3DFMT_A8L8
,
{
8
,
8
,
0
,
0
},
{
8
,
0
,
0
,
0
},
2
,
FORMAT_ARGB
,
la_from_rgba
,
la_to_rgba
},
{
D3DFMT_UNKNOWN
,
{
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
},
0
,
FORMAT_UNKNOWN
},
/* marks last element */
/* marks last element */
{
D3DFMT_UNKNOWN
,
{
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
},
0
,
FORMAT_UNKNOWN
,
NULL
,
NULL
},
};
};
...
...
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