1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
use crate::*;
#[derive(Clone, Debug)]
pub enum Profile {
Common(ProfileCommon),
CG(ProfileCG),
GLES(ProfileGLES),
GLSL(ProfileGLSL),
}
impl Profile {
pub fn parse(e: &Element) -> Result<Option<Self>> {
Ok(Some(match e.name() {
ProfileCommon::NAME => Self::Common(ProfileCommon::parse(e)?),
ProfileCG::NAME => Self::CG(ProfileCG::parse(e)?),
ProfileGLES::NAME => Self::GLES(ProfileGLES::parse(e)?),
ProfileGLSL::NAME => Self::GLSL(ProfileGLSL::parse(e)?),
_ => return Ok(None),
}))
}
}
#[derive(Clone, Debug)]
pub struct ProfileCommon {
pub asset: Option<Box<Asset>>,
pub image: Vec<Image>,
pub new_param: Vec<NewParam>,
pub technique: TechniqueFx<CommonData>,
pub extra: Vec<Extra>,
}
impl XNode for ProfileCommon {
const NAME: &'static str = "profile_COMMON";
fn parse(element: &Element) -> Result<Self> {
debug_assert_eq!(element.name(), Self::NAME);
let mut it = element.children().peekable();
let asset = Asset::parse_opt_box(&mut it)?;
let image_param = ImageParam::parse_list(&mut it)?;
let mut image = vec![];
let mut new_param = vec![];
for ip in image_param {
match ip {
ImageParam::Image(e) => image.push(e),
ImageParam::NewParam(e) => new_param.push(e),
}
}
Ok(ProfileCommon {
asset,
image,
new_param,
technique: TechniqueFx::parse_one(&mut it)?,
extra: Extra::parse_many(it)?,
})
}
}
#[derive(Clone, Default, Debug)]
pub struct CommonData {
pub image_param: Vec<ImageParam>,
pub shaders: Vec<Shader>,
}
impl ProfileData for CommonData {
fn parse(it: &mut ElementIter<'_>) -> Result<Self> {
Ok(CommonData {
image_param: ImageParam::parse_list(it)?,
shaders: parse_list_many(it, Shader::parse)?,
})
}
}
#[derive(Clone, Debug)]
pub struct ProfileCG(pub Element);
impl XNode for ProfileCG {
const NAME: &'static str = "profile_CG";
fn parse(element: &Element) -> Result<Self> {
Ok(ProfileCG(element.clone()))
}
}
#[derive(Clone, Debug)]
pub struct ProfileGLES(pub Element);
impl ProfileGLES {
const NAME: &'static str = "profile_GLES";
fn parse(element: &Element) -> Result<Self> {
Ok(ProfileGLES(element.clone()))
}
}
#[derive(Clone, Debug)]
pub struct ProfileGLSL(pub Element);
impl ProfileGLSL {
const NAME: &'static str = "profile_GLSL";
fn parse(element: &Element) -> Result<Self> {
Ok(ProfileGLSL(element.clone()))
}
}