Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: gpu/ipc/common/gpu_preferences_struct_traits.h

Issue 2599703002: gpu: Add mojom for GpuPreferences. (Closed)
Patch Set: fix win Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gpu/ipc/common/gpu_preferences.typemap ('k') | gpu/ipc/common/struct_traits_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef GPU_IPC_COMMON_GPU_PREFERENCES_STRUCT_TRAITS_H_
6 #define GPU_IPC_COMMON_GPU_PREFERENCES_STRUCT_TRAITS_H_
7
8 #include "gpu/ipc/common/gpu_preferences.mojom.h"
9
10 namespace mojo {
11
12 template <>
13 struct EnumTraits<gpu::mojom::VpxDecodeVendors,
14 gpu::GpuPreferences::VpxDecodeVendors> {
15 static gpu::mojom::VpxDecodeVendors ToMojom(
16 gpu::GpuPreferences::VpxDecodeVendors vpx) {
17 switch (vpx) {
18 case gpu::GpuPreferences::VPX_VENDOR_NONE:
19 return gpu::mojom::VpxDecodeVendors::VPX_VENDOR_NONE;
20 case gpu::GpuPreferences::VPX_VENDOR_MICROSOFT:
21 return gpu::mojom::VpxDecodeVendors::VPX_VENDOR_MICROSOFT;
22 case gpu::GpuPreferences::VPX_VENDOR_AMD:
23 return gpu::mojom::VpxDecodeVendors::VPX_VENDOR_AMD;
24 case gpu::GpuPreferences::VPX_VENDOR_ALL:
25 return gpu::mojom::VpxDecodeVendors::VPX_VENDOR_ALL;
26 }
27 NOTREACHED();
28 return gpu::mojom::VpxDecodeVendors::VPX_VENDOR_NONE;
29 }
30
31 static bool FromMojom(gpu::mojom::VpxDecodeVendors input,
32 gpu::GpuPreferences::VpxDecodeVendors* out) {
33 switch (input) {
34 case gpu::mojom::VpxDecodeVendors::VPX_VENDOR_NONE:
35 *out = gpu::GpuPreferences::VPX_VENDOR_NONE;
36 return true;
37 case gpu::mojom::VpxDecodeVendors::VPX_VENDOR_MICROSOFT:
38 *out = gpu::GpuPreferences::VPX_VENDOR_MICROSOFT;
39 return true;
40 case gpu::mojom::VpxDecodeVendors::VPX_VENDOR_AMD:
41 *out = gpu::GpuPreferences::VPX_VENDOR_AMD;
42 return true;
43 case gpu::mojom::VpxDecodeVendors::VPX_VENDOR_ALL:
44 *out = gpu::GpuPreferences::VPX_VENDOR_ALL;
45 return true;
46 }
47 return false;
48 }
49 };
50
51 template <>
52 struct StructTraits<gpu::mojom::GpuPreferencesDataView, gpu::GpuPreferences> {
53 static bool Read(gpu::mojom::GpuPreferencesDataView prefs,
54 gpu::GpuPreferences* out) {
55 out->single_process = prefs.single_process();
56 out->in_process_gpu = prefs.in_process_gpu();
57 out->ui_prioritize_in_gpu_process = prefs.ui_prioritize_in_gpu_process();
58 out->disable_accelerated_video_decode =
59 prefs.disable_accelerated_video_decode();
60
61 #if defined(OS_CHROMEOS)
62 out->disable_vaapi_accelerated_video_encode =
63 prefs.disable_vaapi_accelerated_video_encode();
64 #endif
65
66 #if BUILDFLAG(ENABLE_WEBRTC)
67 out->disable_web_rtc_hw_encoding = prefs.disable_web_rtc_hw_encoding();
68 #endif
69
70 #if defined(OS_WIN)
71 if (!prefs.ReadEnableAcceleratedVpxDecode(
72 &out->enable_accelerated_vpx_decode))
73 return false;
74 out->enable_low_latency_dxva = prefs.enable_low_latency_dxva();
75 out->enable_zero_copy_dxgi_video = prefs.enable_zero_copy_dxgi_video();
76 out->enable_nv12_dxgi_video = prefs.enable_nv12_dxgi_video();
77 #endif
78
79 out->compile_shader_always_succeeds =
80 prefs.compile_shader_always_succeeds();
81 out->disable_gl_error_limit = prefs.disable_gl_error_limit();
82 out->disable_glsl_translator = prefs.disable_glsl_translator();
83 out->disable_gpu_driver_bug_workarounds =
84 prefs.disable_gpu_driver_bug_workarounds();
85 out->disable_shader_name_hashing = prefs.disable_shader_name_hashing();
86 out->enable_gpu_command_logging = prefs.enable_gpu_command_logging();
87 out->enable_gpu_debugging = prefs.enable_gpu_debugging();
88 out->enable_gpu_service_logging_gpu =
89 prefs.enable_gpu_service_logging_gpu();
90 out->enable_gpu_driver_debug_logging =
91 prefs.enable_gpu_driver_debug_logging();
92 out->disable_gpu_program_cache = prefs.disable_gpu_program_cache();
93 out->enforce_gl_minimums = prefs.enforce_gl_minimums();
94 out->force_gpu_mem_available = prefs.force_gpu_mem_available();
95 out->gpu_program_cache_size = prefs.gpu_program_cache_size();
96 out->disable_gpu_shader_disk_cache = prefs.disable_gpu_shader_disk_cache();
97 out->enable_threaded_texture_mailboxes =
98 prefs.enable_threaded_texture_mailboxes();
99 out->gl_shader_interm_output = prefs.gl_shader_interm_output();
100 out->emulate_shader_precision = prefs.emulate_shader_precision();
101 out->enable_gpu_service_logging = prefs.enable_gpu_service_logging();
102 out->enable_gpu_service_tracing = prefs.enable_gpu_service_tracing();
103 out->enable_es3_apis = prefs.enable_es3_apis();
104 out->use_passthrough_cmd_decoder = prefs.use_passthrough_cmd_decoder();
105 return true;
106 }
107
108 static bool single_process(const gpu::GpuPreferences& prefs) {
109 return prefs.single_process;
110 }
111 static bool in_process_gpu(const gpu::GpuPreferences& prefs) {
112 return prefs.in_process_gpu;
113 }
114 static bool ui_prioritize_in_gpu_process(const gpu::GpuPreferences& prefs) {
115 return prefs.ui_prioritize_in_gpu_process;
116 }
117 static bool disable_accelerated_video_decode(
118 const gpu::GpuPreferences& prefs) {
119 return prefs.disable_accelerated_video_decode;
120 }
121
122 static bool disable_vaapi_accelerated_video_encode(
123 const gpu::GpuPreferences& prefs) {
124 #if defined(OS_CHROMEOS)
125 return prefs.disable_vaapi_accelerated_video_encode;
126 #else
127 return false;
128 #endif
129 }
130
131 static bool disable_web_rtc_hw_encoding(const gpu::GpuPreferences& prefs) {
132 #if BUILDFLAG(ENABLE_WEBRTC)
133 return prefs.disable_web_rtc_hw_encoding;
134 #else
135 return false;
136 #endif
137 }
138
139 static gpu::GpuPreferences::VpxDecodeVendors enable_accelerated_vpx_decode(
140 const gpu::GpuPreferences& prefs) {
141 #if defined(OS_WIN)
142 return prefs.enable_accelerated_vpx_decode;
143 #else
144 return gpu::GpuPreferences::VPX_VENDOR_MICROSOFT;
145 #endif
146 }
147 static bool enable_low_latency_dxva(const gpu::GpuPreferences& prefs) {
148 #if defined(OS_WIN)
149 return prefs.enable_low_latency_dxva;
150 #else
151 return false;
152 #endif
153 }
154 static bool enable_zero_copy_dxgi_video(const gpu::GpuPreferences& prefs) {
155 #if defined(OS_WIN)
156 return prefs.enable_zero_copy_dxgi_video;
157 #else
158 return false;
159 #endif
160 }
161 static bool enable_nv12_dxgi_video(const gpu::GpuPreferences& prefs) {
162 #if defined(OS_WIN)
163 return prefs.enable_nv12_dxgi_video;
164 #else
165 return false;
166 #endif
167 }
168 static bool compile_shader_always_succeeds(const gpu::GpuPreferences& prefs) {
169 return prefs.compile_shader_always_succeeds;
170 }
171 static bool disable_gl_error_limit(const gpu::GpuPreferences& prefs) {
172 return prefs.disable_gl_error_limit;
173 }
174 static bool disable_glsl_translator(const gpu::GpuPreferences& prefs) {
175 return prefs.disable_glsl_translator;
176 }
177 static bool disable_gpu_driver_bug_workarounds(
178 const gpu::GpuPreferences& prefs) {
179 return prefs.disable_gpu_driver_bug_workarounds;
180 }
181 static bool disable_shader_name_hashing(const gpu::GpuPreferences& prefs) {
182 return prefs.disable_shader_name_hashing;
183 }
184 static bool enable_gpu_command_logging(const gpu::GpuPreferences& prefs) {
185 return prefs.enable_gpu_command_logging;
186 }
187 static bool enable_gpu_debugging(const gpu::GpuPreferences& prefs) {
188 return prefs.enable_gpu_debugging;
189 }
190 static bool enable_gpu_service_logging_gpu(const gpu::GpuPreferences& prefs) {
191 return prefs.enable_gpu_service_logging_gpu;
192 }
193 static bool enable_gpu_driver_debug_logging(
194 const gpu::GpuPreferences& prefs) {
195 return prefs.enable_gpu_driver_debug_logging;
196 }
197 static bool disable_gpu_program_cache(const gpu::GpuPreferences& prefs) {
198 return prefs.disable_gpu_program_cache;
199 }
200 static bool enforce_gl_minimums(const gpu::GpuPreferences& prefs) {
201 return prefs.enforce_gl_minimums;
202 }
203 static uint32_t force_gpu_mem_available(const gpu::GpuPreferences& prefs) {
204 return prefs.force_gpu_mem_available;
205 }
206 static uint32_t gpu_program_cache_size(const gpu::GpuPreferences& prefs) {
207 return prefs.gpu_program_cache_size;
208 }
209 static bool disable_gpu_shader_disk_cache(const gpu::GpuPreferences& prefs) {
210 return prefs.disable_gpu_shader_disk_cache;
211 }
212 static bool enable_threaded_texture_mailboxes(
213 const gpu::GpuPreferences& prefs) {
214 return prefs.enable_threaded_texture_mailboxes;
215 }
216 static bool gl_shader_interm_output(const gpu::GpuPreferences& prefs) {
217 return prefs.gl_shader_interm_output;
218 }
219 static bool emulate_shader_precision(const gpu::GpuPreferences& prefs) {
220 return prefs.emulate_shader_precision;
221 }
222 static bool enable_gpu_service_logging(const gpu::GpuPreferences& prefs) {
223 return prefs.enable_gpu_service_logging;
224 }
225 static bool enable_gpu_service_tracing(const gpu::GpuPreferences& prefs) {
226 return prefs.enable_gpu_service_tracing;
227 }
228 static bool enable_es3_apis(const gpu::GpuPreferences& prefs) {
229 return prefs.enable_es3_apis;
230 }
231 static bool use_passthrough_cmd_decoder(const gpu::GpuPreferences& prefs) {
232 return prefs.use_passthrough_cmd_decoder;
233 }
234 };
235
236 } // namespace mojo
237
238 #endif // GPU_IPC_COMMON_GPU_PREFERENCES_STRUCT_TRAITS_H_
OLDNEW
« no previous file with comments | « gpu/ipc/common/gpu_preferences.typemap ('k') | gpu/ipc/common/struct_traits_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698