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
127
128
129
130
131
132
133
134
gpu / ipc / common / device_perf_info_mojom_traits.cc [blame]
// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "gpu/ipc/common/device_perf_info_mojom_traits.h"
#include "build/build_config.h"
namespace mojo {
#if BUILDFLAG(IS_WIN)
// static
gpu::mojom::Direct3DFeatureLevel
EnumTraits<gpu::mojom::Direct3DFeatureLevel, D3D_FEATURE_LEVEL>::ToMojom(
D3D_FEATURE_LEVEL d3d_feature_level) {
switch (d3d_feature_level) {
case D3D_FEATURE_LEVEL_1_0_CORE:
return gpu::mojom::Direct3DFeatureLevel::k1_0_Core;
case D3D_FEATURE_LEVEL_9_1:
return gpu::mojom::Direct3DFeatureLevel::k9_1;
case D3D_FEATURE_LEVEL_9_2:
return gpu::mojom::Direct3DFeatureLevel::k9_2;
case D3D_FEATURE_LEVEL_9_3:
return gpu::mojom::Direct3DFeatureLevel::k9_3;
case D3D_FEATURE_LEVEL_10_0:
return gpu::mojom::Direct3DFeatureLevel::k10_0;
case D3D_FEATURE_LEVEL_10_1:
return gpu::mojom::Direct3DFeatureLevel::k10_1;
case D3D_FEATURE_LEVEL_11_0:
return gpu::mojom::Direct3DFeatureLevel::k11_0;
case D3D_FEATURE_LEVEL_11_1:
return gpu::mojom::Direct3DFeatureLevel::k11_1;
case D3D_FEATURE_LEVEL_12_0:
return gpu::mojom::Direct3DFeatureLevel::k12_0;
case D3D_FEATURE_LEVEL_12_1:
return gpu::mojom::Direct3DFeatureLevel::k12_1;
case D3D_FEATURE_LEVEL_12_2:
return gpu::mojom::Direct3DFeatureLevel::k12_2;
}
NOTREACHED() << "Invalid D3D_FEATURE_LEVEL:" << d3d_feature_level;
}
// static
bool EnumTraits<gpu::mojom::Direct3DFeatureLevel, D3D_FEATURE_LEVEL>::FromMojom(
gpu::mojom::Direct3DFeatureLevel input,
D3D_FEATURE_LEVEL* out) {
switch (input) {
case gpu::mojom::Direct3DFeatureLevel::k1_0_Core:
*out = D3D_FEATURE_LEVEL_1_0_CORE;
return true;
case gpu::mojom::Direct3DFeatureLevel::k9_1:
*out = D3D_FEATURE_LEVEL_9_1;
return true;
case gpu::mojom::Direct3DFeatureLevel::k9_2:
*out = D3D_FEATURE_LEVEL_9_2;
return true;
case gpu::mojom::Direct3DFeatureLevel::k9_3:
*out = D3D_FEATURE_LEVEL_9_3;
return true;
case gpu::mojom::Direct3DFeatureLevel::k10_0:
*out = D3D_FEATURE_LEVEL_10_0;
return true;
case gpu::mojom::Direct3DFeatureLevel::k10_1:
*out = D3D_FEATURE_LEVEL_10_1;
return true;
case gpu::mojom::Direct3DFeatureLevel::k11_0:
*out = D3D_FEATURE_LEVEL_11_0;
return true;
case gpu::mojom::Direct3DFeatureLevel::k11_1:
*out = D3D_FEATURE_LEVEL_11_1;
return true;
case gpu::mojom::Direct3DFeatureLevel::k12_0:
*out = D3D_FEATURE_LEVEL_12_0;
return true;
case gpu::mojom::Direct3DFeatureLevel::k12_1:
*out = D3D_FEATURE_LEVEL_12_1;
return true;
case gpu::mojom::Direct3DFeatureLevel::k12_2:
*out = D3D_FEATURE_LEVEL_12_2;
return true;
}
NOTREACHED() << "Invalid D3D_FEATURE_LEVEL: " << input;
}
#endif // BUILDFLAG(IS_WIN)
gpu::mojom::HasDiscreteGpu
EnumTraits<gpu::mojom::HasDiscreteGpu, gpu::HasDiscreteGpu>::ToMojom(
gpu::HasDiscreteGpu has_discrete_gpu) {
switch (has_discrete_gpu) {
case gpu::HasDiscreteGpu::kUnknown:
return gpu::mojom::HasDiscreteGpu::kUnknown;
case gpu::HasDiscreteGpu::kNo:
return gpu::mojom::HasDiscreteGpu::kNo;
case gpu::HasDiscreteGpu::kYes:
return gpu::mojom::HasDiscreteGpu::kYes;
}
NOTREACHED() << "Invalid gpu::HasDiscreteGpu: "
<< static_cast<int>(has_discrete_gpu);
}
// static
bool EnumTraits<gpu::mojom::HasDiscreteGpu, gpu::HasDiscreteGpu>::FromMojom(
gpu::mojom::HasDiscreteGpu input,
gpu::HasDiscreteGpu* out) {
switch (input) {
case gpu::mojom::HasDiscreteGpu::kUnknown:
*out = gpu::HasDiscreteGpu::kUnknown;
return true;
case gpu::mojom::HasDiscreteGpu::kNo:
*out = gpu::HasDiscreteGpu::kNo;
return true;
case gpu::mojom::HasDiscreteGpu::kYes:
*out = gpu::HasDiscreteGpu::kYes;
return true;
}
NOTREACHED() << "Invalid gpu::mojom::HasDiscreteGpu: " << input;
}
// static
bool StructTraits<gpu::mojom::DevicePerfInfoDataView, gpu::DevicePerfInfo>::
Read(gpu::mojom::DevicePerfInfoDataView data, gpu::DevicePerfInfo* out) {
out->total_physical_memory_mb = data.total_physical_memory_mb();
out->total_disk_space_mb = data.total_disk_space_mb();
out->hardware_concurrency = data.hardware_concurrency();
bool rt = true;
#if BUILDFLAG(IS_WIN)
out->system_commit_limit_mb = data.system_commit_limit_mb();
rt &= data.ReadD3d11FeatureLevel(&out->d3d11_feature_level);
rt &= data.ReadHasDiscreteGpu(&out->has_discrete_gpu);
#endif // BUILDFLAG(IS_WIN)
return rt;
}
} // namespace mojo