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
03204e99
Commit
03204e99
authored
Apr 26, 2011
by
Rico Schüller
Committed by
Alexandre Julliard
Apr 26, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d3dx9: Improve get_parameter_by_name().
parent
dbfc4dfc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
105 additions
and
110 deletions
+105
-110
effect.c
dlls/d3dx9_36/effect.c
+105
-110
No files found.
dlls/d3dx9_36/effect.c
View file @
03204e99
...
...
@@ -107,6 +107,11 @@ struct ID3DXEffectCompilerImpl
ID3DXBaseEffect
*
base_effect
;
};
static
struct
d3dx_parameter
*
get_parameter_by_name
(
struct
ID3DXBaseEffectImpl
*
base
,
struct
d3dx_parameter
*
parameter
,
LPCSTR
name
);
static
struct
d3dx_parameter
*
get_parameter_annotation_by_name
(
struct
ID3DXBaseEffectImpl
*
base
,
struct
d3dx_parameter
*
parameter
,
LPCSTR
name
);
static
inline
void
read_dword
(
const
char
**
ptr
,
DWORD
*
d
)
{
memcpy
(
d
,
*
ptr
,
sizeof
(
*
d
));
...
...
@@ -436,151 +441,141 @@ static void free_effect_compiler(struct ID3DXEffectCompilerImpl *compiler)
}
}
static
LPSTR
get_partial_string
(
LPCSTR
name
,
char
initial
,
char
final
)
static
struct
d3dx_parameter
*
get_parameter_element_by_name
(
struct
ID3DXBaseEffectImpl
*
base
,
struct
d3dx_parameter
*
parameter
,
LPCSTR
name
)
{
UINT
length
;
LPCSTR
begin
;
LPSTR
part
;
UINT
element
;
struct
d3dx_parameter
*
temp_parameter
;
LP
C
STR
part
;
TRACE
(
"
name %s, initial %c, final %c
\n
"
,
debugstr_a
(
name
),
initial
,
final
);
TRACE
(
"
base %p, parameter %p, name %s
\n
"
,
base
,
parameter
,
debugstr_a
(
name
)
);
begin
=
initial
?
(
strchr
(
name
,
initial
)
+
1
)
:
name
;
length
=
strchr
(
name
,
final
)
-
begin
;
if
(
length
<
1
)
{
WARN
(
"Invalied argument specified.
\n
"
);
return
NULL
;
}
if
(
!
name
||
!*
name
)
return
parameter
;
part
=
HeapAlloc
(
GetProcessHeap
(),
0
,
length
+
1
);
if
(
!
part
)
element
=
atoi
(
name
);
part
=
strchr
(
name
,
']'
)
+
1
;
if
(
parameter
->
element_count
>
element
)
{
ERR
(
"Out of memory
\n
"
);
return
NULL
;
temp_parameter
=
get_parameter_struct
(
parameter
->
member_handles
[
element
]);
switch
(
*
part
++
)
{
case
'.'
:
return
get_parameter_by_name
(
base
,
temp_parameter
,
part
);
case
'@'
:
return
get_parameter_annotation_by_name
(
base
,
temp_parameter
,
part
);
case
'\0'
:
TRACE
(
"Returning parameter %p
\n
"
,
temp_parameter
);
return
temp_parameter
;
default:
FIXME
(
"Unhandled case
\"
%c
\"\n
"
,
*--
part
);
break
;
}
}
memcpy
(
part
,
begin
,
length
);
part
[
length
]
=
0
;
TRACE
(
"
part %s
\n
"
,
debugstr_a
(
part
)
);
return
part
;
TRACE
(
"
Parameter not found
\n
"
);
return
NULL
;
}
static
struct
d3dx_parameter
*
get_parameter_by_name
(
struct
ID3DXBaseEffectImpl
*
base
,
struct
d3dx_parameter
*
parameter
,
LPCSTR
name
,
BOOL
is_annotation
)
static
struct
d3dx_parameter
*
get_parameter_annotation_by_name
(
struct
ID3DXBaseEffectImpl
*
base
,
struct
d3dx_parameter
*
parameter
,
LPCSTR
name
)
{
unsigned
int
i
;
UINT
i
,
length
;
struct
d3dx_parameter
*
temp_parameter
;
LPSTR
part
;
LPCSTR
part
;
TRACE
(
"base %p, parameter %p, name %s
\n
"
,
base
,
parameter
,
debugstr_a
(
name
));
TRACE
(
"base %p, parameter %p, name %s, is_annotation %s
\n
"
,
base
,
parameter
,
debugstr_a
(
name
),
is_annotation
?
"YES"
:
"NO"
)
;
if
(
!
name
||
!*
name
)
return
parameter
;
if
(
!
name
)
return
NULL
;
length
=
strcspn
(
name
,
"[.@"
);
part
=
name
+
length
;
/* members */
if
(
strchr
(
name
,
'.'
))
for
(
i
=
0
;
i
<
parameter
->
annotation_count
;
++
i
)
{
part
=
get_partial_string
(
name
,
0
,
'.'
);
temp_parameter
=
get_parameter_by_name
(
base
,
parameter
,
part
,
is_annotation
);
HeapFree
(
GetProcessHeap
(),
0
,
part
);
temp_parameter
=
get_parameter_struct
(
parameter
->
annotation_handles
[
i
]);
if
(
temp_parameter
)
if
(
!
strcmp
(
temp_parameter
->
name
,
name
)
)
{
temp_parameter
=
get_parameter_by_name
(
base
,
temp_parameter
,
strchr
(
name
,
'.'
)
+
1
,
FALSE
);
TRACE
(
"Returning sub parameter %p
\n
"
,
temp_parameter
);
TRACE
(
"Returning parameter %p
\n
"
,
temp_parameter
);
return
temp_parameter
;
}
else
if
(
strlen
(
temp_parameter
->
name
)
==
length
&&
!
strncmp
(
temp_parameter
->
name
,
name
,
length
))
{
switch
(
*
part
++
)
{
case
'.'
:
return
get_parameter_by_name
(
base
,
temp_parameter
,
part
);
TRACE
(
"Sub parameter not found
\n
"
);
return
NULL
;
}
/* annotations */
if
(
strchr
(
name
,
'@'
))
{
part
=
get_partial_string
(
name
,
0
,
'@'
);
temp_parameter
=
get_parameter_by_name
(
base
,
parameter
,
part
,
is_annotation
);
HeapFree
(
GetProcessHeap
(),
0
,
part
);
case
'['
:
return
get_parameter_element_by_name
(
base
,
temp_parameter
,
part
);
if
(
temp_parameter
)
{
temp_parameter
=
get_parameter_by_name
(
base
,
temp_parameter
,
strchr
(
name
,
'@'
)
+
1
,
TRUE
);
TRACE
(
"Returning sub parameter %p
\n
"
,
temp_parameter
);
return
temp_parameter
;
default:
FIXME
(
"Unhandled case
\"
%c
\"\n
"
,
*--
part
);
break
;
}
}
TRACE
(
"Sub parameter not found
\n
"
);
return
NULL
;
}
/* elements */
if
(
strchr
(
name
,
'['
))
{
part
=
get_partial_string
(
name
,
0
,
'['
);
temp_parameter
=
get_parameter_by_name
(
base
,
parameter
,
part
,
is_annotation
);
HeapFree
(
GetProcessHeap
(),
0
,
part
);
if
(
temp_parameter
)
{
unsigned
int
index
;
TRACE
(
"Parameter not found
\n
"
);
return
NULL
;
}
part
=
get_partial_string
(
name
,
'['
,
']'
);
index
=
atoi
(
part
);
HeapFree
(
GetProcessHeap
(),
0
,
part
);
static
struct
d3dx_parameter
*
get_parameter_by_name
(
struct
ID3DXBaseEffectImpl
*
base
,
struct
d3dx_parameter
*
parameter
,
LPCSTR
name
)
{
UINT
i
,
count
,
length
;
struct
d3dx_parameter
*
temp_parameter
;
D3DXHANDLE
*
handles
;
LPCSTR
part
;
if
(
index
<
temp_parameter
->
element_count
)
{
TRACE
(
"Returning sub parameter %p
\n
"
,
get_parameter_struct
(
temp_parameter
->
member_handles
[
index
]));
return
get_parameter_struct
(
temp_parameter
->
member_handles
[
index
]);
}
}
TRACE
(
"base %p, parameter %p, name %s
\n
"
,
base
,
parameter
,
debugstr_a
(
name
));
TRACE
(
"Sub parameter not found
\n
"
);
return
NULL
;
}
if
(
!
name
||
!*
name
)
return
parameter
;
if
(
!
parameter
)
{
for
(
i
=
0
;
i
<
base
->
parameter_count
;
i
++
)
{
temp_parameter
=
get_parameter_struct
(
base
->
parameter_handles
[
i
]);
if
(
!
strcmp
(
temp_parameter
->
name
,
name
))
{
TRACE
(
"Returning parameter %p
\n
"
,
temp_parameter
);
return
temp_parameter
;
}
}
count
=
base
->
parameter_count
;
handles
=
base
->
parameter_handles
;
}
else
{
if
(
is_annotation
)
{
for
(
i
=
0
;
i
<
parameter
->
annotation_count
;
i
++
)
{
temp_parameter
=
get_parameter_struct
(
parameter
->
annotation_handles
[
i
]);
count
=
parameter
->
member_count
;
handles
=
parameter
->
member_handles
;
}
if
(
!
strcmp
(
temp_parameter
->
name
,
name
))
{
TRACE
(
"Returning parameter %p
\n
"
,
temp_parameter
);
return
temp_parameter
;
}
}
length
=
strcspn
(
name
,
"[.@"
);
part
=
name
+
length
;
for
(
i
=
0
;
i
<
count
;
i
++
)
{
temp_parameter
=
get_parameter_struct
(
handles
[
i
]);
if
(
!
strcmp
(
temp_parameter
->
name
,
name
))
{
TRACE
(
"Returning parameter %p
\n
"
,
temp_parameter
);
return
temp_parameter
;
}
else
else
if
(
strlen
(
temp_parameter
->
name
)
==
length
&&
!
strncmp
(
temp_parameter
->
name
,
name
,
length
))
{
unsigned
int
count
;
switch
(
*
part
++
)
{
case
'.'
:
return
get_parameter_by_name
(
base
,
temp_parameter
,
part
);
if
(
parameter
->
element_count
)
count
=
parameter
->
element_count
;
else
count
=
parameter
->
member_count
;
case
'@'
:
return
get_parameter_annotation_by_name
(
base
,
temp_parameter
,
part
)
;
for
(
i
=
0
;
i
<
count
;
i
++
)
{
temp_parameter
=
get_parameter_struct
(
parameter
->
member_handles
[
i
]);
case
'['
:
return
get_parameter_element_by_name
(
base
,
temp_parameter
,
part
);
if
(
!
strcmp
(
temp_parameter
->
name
,
name
))
{
TRACE
(
"Returning parameter %p
\n
"
,
temp_parameter
);
return
temp_parameter
;
}
default:
FIXME
(
"Unhandled case
\"
%c
\"\n
"
,
*--
part
);
break
;
}
}
}
...
...
@@ -743,7 +738,7 @@ static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameter(ID3DXBaseEffect *iface
TRACE
(
"iface %p, parameter %p, index %u
\n
"
,
This
,
parameter
,
index
);
if
(
!
param
)
param
=
get_parameter_by_name
(
This
,
NULL
,
parameter
,
FALSE
);
if
(
!
param
)
param
=
get_parameter_by_name
(
This
,
NULL
,
parameter
);
if
(
!
parameter
)
{
...
...
@@ -775,7 +770,7 @@ static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterByName(ID3DXBaseEffect
TRACE
(
"iface %p, parameter %p, name %s
\n
"
,
This
,
parameter
,
debugstr_a
(
name
));
if
(
!
param
)
param
=
get_parameter_by_name
(
This
,
NULL
,
parameter
,
FALSE
);
if
(
!
param
)
param
=
get_parameter_by_name
(
This
,
NULL
,
parameter
);
if
(
!
name
)
{
...
...
@@ -784,7 +779,7 @@ static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterByName(ID3DXBaseEffect
return
handle
;
}
handle
=
get_parameter_handle
(
get_parameter_by_name
(
This
,
param
,
name
,
FALSE
));
handle
=
get_parameter_handle
(
get_parameter_by_name
(
This
,
param
,
name
));
TRACE
(
"Returning parameter %p
\n
"
,
handle
);
return
handle
;
...
...
@@ -806,7 +801,7 @@ static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterElement(ID3DXBaseEffect
TRACE
(
"iface %p, parameter %p, index %u
\n
"
,
This
,
parameter
,
index
);
if
(
!
param
)
param
=
get_parameter_by_name
(
This
,
NULL
,
parameter
,
FALSE
);
if
(
!
param
)
param
=
get_parameter_by_name
(
This
,
NULL
,
parameter
);
if
(
!
param
)
{
...
...
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