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 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453
|
// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef GPU_IPC_COMMON_GPU_INFO_MOJOM_TRAITS_H_
#define GPU_IPC_COMMON_GPU_INFO_MOJOM_TRAITS_H_
#include <optional>
#include "base/time/time.h"
#include "build/build_config.h"
#include "gpu/config/gpu_info.h"
#include "gpu/config/gpu_preferences.h"
#include "gpu/ipc/common/gpu_info.mojom.h"
#include "gpu/ipc/common/gpu_ipc_common_export.h"
#include "ui/gfx/buffer_types.h"
#include "ui/gfx/geometry/mojom/geometry_mojom_traits.h"
#if BUILDFLAG(IS_WIN)
#include "base/win/windows_types.h"
#endif
namespace mojo {
template <>
struct GPU_IPC_COMMON_EXPORT StructTraits<gpu::mojom::GpuDeviceDataView,
gpu::GPUInfo::GPUDevice> {
static bool Read(gpu::mojom::GpuDeviceDataView data,
gpu::GPUInfo::GPUDevice* out);
static uint32_t vendor_id(const gpu::GPUInfo::GPUDevice& input) {
return input.vendor_id;
}
static uint32_t device_id(const gpu::GPUInfo::GPUDevice& input) {
return input.device_id;
}
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_CHROMEOS)
static uint32_t revision(const gpu::GPUInfo::GPUDevice& input) {
return input.revision;
}
#endif
#if BUILDFLAG(IS_WIN)
static uint32_t sub_sys_id(const gpu::GPUInfo::GPUDevice& input) {
return input.sub_sys_id;
}
static const CHROME_LUID luid(const gpu::GPUInfo::GPUDevice& input) {
return input.luid;
}
#endif // BUILDFLAG(IS_WIN)
static bool active(const gpu::GPUInfo::GPUDevice& input) {
return input.active;
}
static const std::string& vendor_string(
const gpu::GPUInfo::GPUDevice& input) {
return input.vendor_string;
}
static const std::string& device_string(
const gpu::GPUInfo::GPUDevice& input) {
return input.device_string;
}
static const std::string& driver_vendor(
const gpu::GPUInfo::GPUDevice& input) {
return input.driver_vendor;
}
static const std::string& driver_version(
const gpu::GPUInfo::GPUDevice& input) {
return input.driver_version;
}
static gl::GpuPreference gpu_preference(
const gpu::GPUInfo::GPUDevice& input) {
return input.gpu_preference;
}
};
template <>
struct GPU_IPC_COMMON_EXPORT EnumTraits<gpu::mojom::SkiaBackendType,
gpu::SkiaBackendType> {
static gpu::mojom::SkiaBackendType ToMojom(gpu::SkiaBackendType type);
static bool FromMojom(gpu::mojom::SkiaBackendType input,
gpu::SkiaBackendType* out);
};
template <>
struct GPU_IPC_COMMON_EXPORT EnumTraits<gpu::mojom::VideoCodecProfile,
gpu::VideoCodecProfile> {
static gpu::mojom::VideoCodecProfile ToMojom(
gpu::VideoCodecProfile video_codec_profile);
static bool FromMojom(gpu::mojom::VideoCodecProfile input,
gpu::VideoCodecProfile* out);
};
template <>
struct GPU_IPC_COMMON_EXPORT StructTraits<
gpu::mojom::VideoDecodeAcceleratorSupportedProfileDataView,
gpu::VideoDecodeAcceleratorSupportedProfile> {
static bool Read(
gpu::mojom::VideoDecodeAcceleratorSupportedProfileDataView data,
gpu::VideoDecodeAcceleratorSupportedProfile* out);
static gpu::VideoCodecProfile profile(
const gpu::VideoDecodeAcceleratorSupportedProfile& input) {
return input.profile;
}
static const gfx::Size& max_resolution(
const gpu::VideoDecodeAcceleratorSupportedProfile& input) {
return input.max_resolution;
}
static const gfx::Size& min_resolution(
const gpu::VideoDecodeAcceleratorSupportedProfile& input) {
return input.min_resolution;
}
static bool encrypted_only(
const gpu::VideoDecodeAcceleratorSupportedProfile& input) {
return input.encrypted_only;
}
};
template <>
struct GPU_IPC_COMMON_EXPORT StructTraits<
gpu::mojom::VideoDecodeAcceleratorCapabilitiesDataView,
gpu::VideoDecodeAcceleratorCapabilities> {
static bool Read(gpu::mojom::VideoDecodeAcceleratorCapabilitiesDataView data,
gpu::VideoDecodeAcceleratorCapabilities* out);
static uint32_t flags(const gpu::VideoDecodeAcceleratorCapabilities& input) {
return input.flags;
}
static std::vector<gpu::VideoDecodeAcceleratorSupportedProfile>
supported_profiles(const gpu::VideoDecodeAcceleratorCapabilities& input) {
return input.supported_profiles;
}
};
template <>
struct GPU_IPC_COMMON_EXPORT StructTraits<
gpu::mojom::VideoEncodeAcceleratorSupportedProfileDataView,
gpu::VideoEncodeAcceleratorSupportedProfile> {
static bool Read(
gpu::mojom::VideoEncodeAcceleratorSupportedProfileDataView data,
gpu::VideoEncodeAcceleratorSupportedProfile* out);
static gpu::VideoCodecProfile profile(
const gpu::VideoEncodeAcceleratorSupportedProfile& input) {
return input.profile;
}
static const gfx::Size& min_resolution(
const gpu::VideoEncodeAcceleratorSupportedProfile& input) {
return input.min_resolution;
}
static const gfx::Size& max_resolution(
const gpu::VideoEncodeAcceleratorSupportedProfile& input) {
return input.max_resolution;
}
static uint32_t max_framerate_numerator(
const gpu::VideoEncodeAcceleratorSupportedProfile& input) {
return input.max_framerate_numerator;
}
static uint32_t max_framerate_denominator(
const gpu::VideoEncodeAcceleratorSupportedProfile& input) {
return input.max_framerate_denominator;
}
};
template <>
struct GPU_IPC_COMMON_EXPORT EnumTraits<gpu::mojom::ImageDecodeAcceleratorType,
gpu::ImageDecodeAcceleratorType> {
static gpu::mojom::ImageDecodeAcceleratorType ToMojom(
gpu::ImageDecodeAcceleratorType image_type);
static bool FromMojom(gpu::mojom::ImageDecodeAcceleratorType input,
gpu::ImageDecodeAcceleratorType* out);
};
template <>
struct GPU_IPC_COMMON_EXPORT EnumTraits<
gpu::mojom::ImageDecodeAcceleratorSubsampling,
gpu::ImageDecodeAcceleratorSubsampling> {
static gpu::mojom::ImageDecodeAcceleratorSubsampling ToMojom(
gpu::ImageDecodeAcceleratorSubsampling subsampling);
static bool FromMojom(gpu::mojom::ImageDecodeAcceleratorSubsampling input,
gpu::ImageDecodeAcceleratorSubsampling* out);
};
template <>
struct GPU_IPC_COMMON_EXPORT StructTraits<
gpu::mojom::ImageDecodeAcceleratorSupportedProfileDataView,
gpu::ImageDecodeAcceleratorSupportedProfile> {
static bool Read(
gpu::mojom::ImageDecodeAcceleratorSupportedProfileDataView data,
gpu::ImageDecodeAcceleratorSupportedProfile* out);
static gpu::ImageDecodeAcceleratorType image_type(
const gpu::ImageDecodeAcceleratorSupportedProfile& input) {
return input.image_type;
}
static const gfx::Size& min_encoded_dimensions(
const gpu::ImageDecodeAcceleratorSupportedProfile& input) {
return input.min_encoded_dimensions;
}
static const gfx::Size& max_encoded_dimensions(
const gpu::ImageDecodeAcceleratorSupportedProfile& input) {
return input.max_encoded_dimensions;
}
static std::vector<gpu::ImageDecodeAcceleratorSubsampling> subsamplings(
const gpu::ImageDecodeAcceleratorSupportedProfile& input) {
return input.subsamplings;
}
};
#if BUILDFLAG(IS_WIN)
template <>
struct GPU_IPC_COMMON_EXPORT EnumTraits<gpu::mojom::OverlaySupport,
gpu::OverlaySupport> {
static gpu::mojom::OverlaySupport ToMojom(gpu::OverlaySupport support);
static bool FromMojom(gpu::mojom::OverlaySupport input,
gpu::OverlaySupport* out);
};
template <>
struct GPU_IPC_COMMON_EXPORT StructTraits<gpu::mojom::OverlayInfoDataView,
gpu::OverlayInfo> {
static bool Read(gpu::mojom::OverlayInfoDataView data, gpu::OverlayInfo* out);
static bool direct_composition(const gpu::OverlayInfo& input) {
return input.direct_composition;
}
static bool supports_overlays(const gpu::OverlayInfo& input) {
return input.supports_overlays;
}
static gpu::OverlaySupport yuy2_overlay_support(
const gpu::OverlayInfo& input) {
return input.yuy2_overlay_support;
}
static gpu::OverlaySupport nv12_overlay_support(
const gpu::OverlayInfo& input) {
return input.nv12_overlay_support;
}
static gpu::OverlaySupport bgra8_overlay_support(
const gpu::OverlayInfo& input) {
return input.bgra8_overlay_support;
}
static gpu::OverlaySupport rgb10a2_overlay_support(
const gpu::OverlayInfo& input) {
return input.rgb10a2_overlay_support;
}
static gpu::OverlaySupport p010_overlay_support(
const gpu::OverlayInfo& input) {
return input.p010_overlay_support;
}
};
#endif
template <>
struct GPU_IPC_COMMON_EXPORT StructTraits<gpu::mojom::GpuInfoDataView,
gpu::GPUInfo> {
static bool Read(gpu::mojom::GpuInfoDataView data, gpu::GPUInfo* out);
static base::TimeDelta initialization_time(const gpu::GPUInfo& input) {
return input.initialization_time;
}
static bool optimus(const gpu::GPUInfo& input) { return input.optimus; }
static bool amd_switchable(const gpu::GPUInfo& input) {
return input.amd_switchable;
}
static const gpu::GPUInfo::GPUDevice& gpu(const gpu::GPUInfo& input) {
return input.gpu;
}
static const std::vector<gpu::GPUInfo::GPUDevice>& secondary_gpus(
const gpu::GPUInfo& input) {
return input.secondary_gpus;
}
static const std::vector<gpu::GPUInfo::GPUDevice>& npus(
const gpu::GPUInfo& input) {
return input.npus;
}
static const std::string& pixel_shader_version(const gpu::GPUInfo& input) {
return input.pixel_shader_version;
}
static const std::string& vertex_shader_version(const gpu::GPUInfo& input) {
return input.vertex_shader_version;
}
static const std::string& max_msaa_samples(const gpu::GPUInfo& input) {
return input.max_msaa_samples;
}
static const std::string& machine_model_name(const gpu::GPUInfo& input) {
return input.machine_model_name;
}
static const std::string& machine_model_version(const gpu::GPUInfo& input) {
return input.machine_model_version;
}
static const std::string& display_type(const gpu::GPUInfo& input) {
return input.display_type;
}
static gpu::SkiaBackendType skia_backend_type(const gpu::GPUInfo& input) {
return input.skia_backend_type;
}
static const std::string& gl_version(const gpu::GPUInfo& input) {
return input.gl_version;
}
static const std::string& gl_vendor(const gpu::GPUInfo& input) {
return input.gl_vendor;
}
static const std::string& gl_renderer(const gpu::GPUInfo& input) {
return input.gl_renderer;
}
static const std::string& gl_extensions(const gpu::GPUInfo& input) {
return input.gl_extensions;
}
static const std::string& gl_ws_vendor(const gpu::GPUInfo& input) {
return input.gl_ws_vendor;
}
static const std::string& gl_ws_version(const gpu::GPUInfo& input) {
return input.gl_ws_version;
}
static const std::string& gl_ws_extensions(const gpu::GPUInfo& input) {
return input.gl_ws_extensions;
}
static uint32_t gl_reset_notification_strategy(const gpu::GPUInfo& input) {
return input.gl_reset_notification_strategy;
}
static const gl::GLImplementationParts gl_implementation_parts(
const gpu::GPUInfo& input) {
return input.gl_implementation_parts;
}
static const std::string& direct_rendering_version(
const gpu::GPUInfo& input) {
return input.direct_rendering_version;
}
static bool sandboxed(const gpu::GPUInfo& input) { return input.sandboxed; }
static bool in_process_gpu(const gpu::GPUInfo& input) {
return input.in_process_gpu;
}
static bool passthrough_cmd_decoder(const gpu::GPUInfo& input) {
return input.passthrough_cmd_decoder;
}
static bool can_support_threaded_texture_mailbox(const gpu::GPUInfo& input) {
return input.can_support_threaded_texture_mailbox;
}
#if BUILDFLAG(IS_WIN)
static uint32_t directml_feature_level(const gpu::GPUInfo& input) {
return input.directml_feature_level;
}
static uint32_t d3d12_feature_level(const gpu::GPUInfo& input) {
return input.d3d12_feature_level;
}
static uint32_t vulkan_version(const gpu::GPUInfo& input) {
return input.vulkan_version;
}
static const gpu::OverlayInfo& overlay_info(const gpu::GPUInfo& input) {
return input.overlay_info;
}
static bool shared_image_d3d(const gpu::GPUInfo& input) {
return input.shared_image_d3d;
}
#endif
static const gpu::VideoDecodeAcceleratorSupportedProfiles&
video_decode_accelerator_supported_profiles(const gpu::GPUInfo& input) {
return input.video_decode_accelerator_supported_profiles;
}
static std::vector<gpu::VideoEncodeAcceleratorSupportedProfile>
video_encode_accelerator_supported_profiles(const gpu::GPUInfo& input) {
return input.video_encode_accelerator_supported_profiles;
}
static bool jpeg_decode_accelerator_supported(const gpu::GPUInfo& input) {
return input.jpeg_decode_accelerator_supported;
}
static std::vector<gpu::ImageDecodeAcceleratorSupportedProfile>
image_decode_accelerator_supported_profiles(const gpu::GPUInfo& input) {
return input.image_decode_accelerator_supported_profiles;
}
static bool subpixel_font_rendering(const gpu::GPUInfo& input) {
return input.subpixel_font_rendering;
}
static uint32_t visibility_callback_call_count(const gpu::GPUInfo& input) {
return input.visibility_callback_call_count;
}
#if BUILDFLAG(ENABLE_VULKAN)
static bool hardware_supports_vulkan(const gpu::GPUInfo& input) {
return input.hardware_supports_vulkan;
}
static const std::optional<gpu::VulkanInfo>& vulkan_info(
const gpu::GPUInfo& input) {
return input.vulkan_info;
}
#endif
};
} // namespace mojo
#endif // GPU_IPC_COMMON_GPU_INFO_MOJOM_TRAITS_H_
|