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
3b4d9ae1
Commit
3b4d9ae1
authored
Aug 26, 2010
by
Henri Verbeet
Committed by
Alexandre Julliard
Aug 27, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wined3d: Simplify wined3d_format_convert_from_float().
parent
38137d7c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
103 deletions
+46
-103
utils.c
dlls/wined3d/utils.c
+46
-103
No files found.
dlls/wined3d/utils.c
View file @
3b4d9ae1
...
...
@@ -2557,121 +2557,64 @@ BOOL getDepthStencilBits(const struct wined3d_format_desc *format_desc, short *d
return
TRUE
;
}
/* Note: It's the caller's responsibility to ensure values can be expressed
* in the requested format. UNORM formats for example can only express values
* in the range 0.0f -> 1.0f. */
DWORD
wined3d_format_convert_from_float
(
const
struct
wined3d_format_desc
*
format
,
const
WINED3DCOLORVALUE
*
color
)
{
enum
wined3d_format_id
destfmt
=
format
->
id
;
unsigned
int
r
,
g
,
b
,
a
;
DWORD
ret
;
static
const
struct
{
enum
wined3d_format_id
format_id
;
float
r_mul
;
float
g_mul
;
float
b_mul
;
float
a_mul
;
BYTE
r_shift
;
BYTE
g_shift
;
BYTE
b_shift
;
BYTE
a_shift
;
}
conv
[]
=
{
{
WINED3DFMT_B8G8R8A8_UNORM
,
255
.
0
f
,
255
.
0
f
,
255
.
0
f
,
255
.
0
f
,
16
,
8
,
0
,
24
},
{
WINED3DFMT_B8G8R8X8_UNORM
,
255
.
0
f
,
255
.
0
f
,
255
.
0
f
,
255
.
0
f
,
16
,
8
,
0
,
24
},
{
WINED3DFMT_B8G8R8_UNORM
,
255
.
0
f
,
255
.
0
f
,
255
.
0
f
,
255
.
0
f
,
16
,
8
,
0
,
24
},
{
WINED3DFMT_B5G6R5_UNORM
,
31
.
0
f
,
63
.
0
f
,
31
.
0
f
,
0
.
0
f
,
11
,
5
,
0
,
0
},
{
WINED3DFMT_B5G5R5A1_UNORM
,
31
.
0
f
,
31
.
0
f
,
31
.
0
f
,
1
.
0
f
,
10
,
5
,
0
,
15
},
{
WINED3DFMT_B5G5R5X1_UNORM
,
31
.
0
f
,
31
.
0
f
,
31
.
0
f
,
1
.
0
f
,
10
,
5
,
0
,
15
},
{
WINED3DFMT_A8_UNORM
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
255
.
0
f
,
0
,
0
,
0
,
0
},
{
WINED3DFMT_B4G4R4A4_UNORM
,
15
.
0
f
,
15
.
0
f
,
15
.
0
f
,
15
.
0
f
,
8
,
4
,
0
,
12
},
{
WINED3DFMT_B4G4R4X4_UNORM
,
15
.
0
f
,
15
.
0
f
,
15
.
0
f
,
15
.
0
f
,
8
,
4
,
0
,
12
},
{
WINED3DFMT_B2G3R3_UNORM
,
7
.
0
f
,
7
.
0
f
,
3
.
0
f
,
0
.
0
f
,
5
,
2
,
0
,
0
},
{
WINED3DFMT_R8G8B8A8_UNORM
,
255
.
0
f
,
255
.
0
f
,
255
.
0
f
,
255
.
0
f
,
0
,
8
,
16
,
24
},
{
WINED3DFMT_R8G8B8X8_UNORM
,
255
.
0
f
,
255
.
0
f
,
255
.
0
f
,
255
.
0
f
,
0
,
8
,
16
,
24
},
{
WINED3DFMT_B10G10R10A2_UNORM
,
1023
.
0
f
,
1023
.
0
f
,
1023
.
0
f
,
3
.
0
f
,
20
,
10
,
0
,
30
},
{
WINED3DFMT_R10G10B10A2_UNORM
,
1023
.
0
f
,
1023
.
0
f
,
1023
.
0
f
,
3
.
0
f
,
0
,
10
,
20
,
30
},
};
unsigned
int
i
;
TRACE
(
"Converting color {%.8e %.8e %.8e %.8e} to format %s.
\n
"
,
color
->
r
,
color
->
g
,
color
->
b
,
color
->
a
,
debug_d3dformat
(
destfmt
));
r
=
(
DWORD
)((
color
->
r
*
255
.
0
f
)
+
0
.
5
f
);
g
=
(
DWORD
)((
color
->
g
*
255
.
0
f
)
+
0
.
5
f
);
b
=
(
DWORD
)((
color
->
b
*
255
.
0
f
)
+
0
.
5
f
);
a
=
(
DWORD
)((
color
->
a
*
255
.
0
f
)
+
0
.
5
f
);
color
->
r
,
color
->
g
,
color
->
b
,
color
->
a
,
debug_d3dformat
(
format
->
id
));
switch
(
destfmt
)
for
(
i
=
0
;
i
<
sizeof
(
conv
)
/
sizeof
(
*
conv
);
++
i
)
{
case
WINED3DFMT_B8G8R8A8_UNORM
:
case
WINED3DFMT_B8G8R8X8_UNORM
:
case
WINED3DFMT_B8G8R8_UNORM
:
ret
=
b
;
ret
|=
g
<<
8
;
ret
|=
r
<<
16
;
ret
|=
a
<<
24
;
TRACE
(
"Returning 0x%08x.
\n
"
,
ret
);
return
ret
;
DWORD
ret
;
case
WINED3DFMT_B5G6R5_UNORM
:
if
(
r
==
0xff
&&
g
==
0xff
&&
b
==
0xff
)
return
0xffff
;
r
=
(
r
*
32
)
/
256
;
g
=
(
g
*
64
)
/
256
;
b
=
(
b
*
32
)
/
256
;
ret
=
r
<<
11
;
ret
|=
g
<<
5
;
ret
|=
b
;
TRACE
(
"Returning %08x
\n
"
,
ret
);
return
ret
;
if
(
format
->
id
!=
conv
[
i
].
format_id
)
continue
;
case
WINED3DFMT_B5G5R5X1_UNORM
:
case
WINED3DFMT_B5G5R5A1_UNORM
:
a
=
(
a
*
2
)
/
256
;
r
=
(
r
*
32
)
/
256
;
g
=
(
g
*
32
)
/
256
;
b
=
(
b
*
32
)
/
256
;
ret
=
a
<<
15
;
ret
|=
r
<<
10
;
ret
|=
g
<<
5
;
ret
|=
b
<<
0
;
TRACE
(
"Returning %08x
\n
"
,
ret
);
return
ret
;
case
WINED3DFMT_A8_UNORM
:
TRACE
(
"Returning %08x
\n
"
,
a
);
return
a
;
ret
=
((
DWORD
)((
color
->
r
*
conv
[
i
].
r_mul
)
+
0
.
5
f
))
<<
conv
[
i
].
r_shift
;
ret
|=
((
DWORD
)((
color
->
g
*
conv
[
i
].
g_mul
)
+
0
.
5
f
))
<<
conv
[
i
].
g_shift
;
ret
|=
((
DWORD
)((
color
->
b
*
conv
[
i
].
b_mul
)
+
0
.
5
f
))
<<
conv
[
i
].
b_shift
;
ret
|=
((
DWORD
)((
color
->
a
*
conv
[
i
].
a_mul
)
+
0
.
5
f
))
<<
conv
[
i
].
a_shift
;
case
WINED3DFMT_B4G4R4X4_UNORM
:
case
WINED3DFMT_B4G4R4A4_UNORM
:
a
=
(
a
*
16
)
/
256
;
r
=
(
r
*
16
)
/
256
;
g
=
(
g
*
16
)
/
256
;
b
=
(
b
*
16
)
/
256
;
ret
=
a
<<
12
;
ret
|=
r
<<
8
;
ret
|=
g
<<
4
;
ret
|=
b
<<
0
;
TRACE
(
"Returning %08x
\n
"
,
ret
);
return
ret
;
TRACE
(
"Returning 0x%08x.
\n
"
,
ret
);
case
WINED3DFMT_B2G3R3_UNORM
:
r
=
(
r
*
8
)
/
256
;
g
=
(
g
*
8
)
/
256
;
b
=
(
b
*
4
)
/
256
;
ret
=
r
<<
5
;
ret
|=
g
<<
2
;
ret
|=
b
<<
0
;
TRACE
(
"Returning %08x
\n
"
,
ret
);
return
ret
;
case
WINED3DFMT_R8G8B8X8_UNORM
:
case
WINED3DFMT_R8G8B8A8_UNORM
:
ret
=
a
<<
24
;
ret
|=
b
<<
16
;
ret
|=
g
<<
8
;
ret
|=
r
<<
0
;
TRACE
(
"Returning %08x
\n
"
,
ret
);
return
ret
;
return
ret
;
}
case
WINED3DFMT_B10G10R10A2_UNORM
:
a
=
(
a
*
4
)
/
256
;
r
=
(
r
*
1024
)
/
256
;
g
=
(
g
*
1024
)
/
256
;
b
=
(
b
*
1024
)
/
256
;
ret
=
a
<<
30
;
ret
|=
r
<<
20
;
ret
|=
g
<<
10
;
ret
|=
b
<<
0
;
TRACE
(
"Returning %08x
\n
"
,
ret
);
return
ret
;
case
WINED3DFMT_R10G10B10A2_UNORM
:
a
=
(
a
*
4
)
/
256
;
r
=
(
r
*
1024
)
/
256
;
g
=
(
g
*
1024
)
/
256
;
b
=
(
b
*
1024
)
/
256
;
ret
=
a
<<
30
;
ret
|=
b
<<
20
;
ret
|=
g
<<
10
;
ret
|=
r
<<
0
;
TRACE
(
"Returning %08x
\n
"
,
ret
);
return
ret
;
FIXME
(
"Conversion for format %s not implemented.
\n
"
,
debug_d3dformat
(
format
->
id
));
default:
FIXME
(
"Add a COLORFILL conversion for format %s
\n
"
,
debug_d3dformat
(
destfmt
));
return
0
;
}
return
0
;
}
/* DirectDraw stuff */
...
...
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