| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 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_FEATURE_INFO_STRUCT_TRAITS_H_ |
| 6 #define GPU_IPC_COMMON_GPU_FEATURE_INFO_STRUCT_TRAITS_H_ |
| 7 |
| 8 #include "gpu/config/gpu_feature_info.h" |
| 9 |
| 10 namespace mojo { |
| 11 |
| 12 template <> |
| 13 struct EnumTraits<gpu::mojom::GpuFeatureStatus, gpu::GpuFeatureStatus> { |
| 14 static gpu::mojom::GpuFeatureStatus ToMojom(gpu::GpuFeatureStatus status) { |
| 15 switch (status) { |
| 16 case gpu::kGpuFeatureStatusEnabled: |
| 17 return gpu::mojom::GpuFeatureStatus::Enabled; |
| 18 case gpu::kGpuFeatureStatusBlacklisted: |
| 19 return gpu::mojom::GpuFeatureStatus::Blacklisted; |
| 20 case gpu::kGpuFeatureStatusDisabled: |
| 21 return gpu::mojom::GpuFeatureStatus::Disabled; |
| 22 case gpu::kGpuFeatureStatusUndefined: |
| 23 return gpu::mojom::GpuFeatureStatus::Undefined; |
| 24 case gpu::kGpuFeatureStatusMax: |
| 25 return gpu::mojom::GpuFeatureStatus::Max; |
| 26 } |
| 27 NOTREACHED(); |
| 28 return gpu::mojom::GpuFeatureStatus::Max; |
| 29 } |
| 30 |
| 31 static bool FromMojom(gpu::mojom::GpuFeatureStatus input, |
| 32 gpu::GpuFeatureStatus* out) { |
| 33 switch (input) { |
| 34 case gpu::mojom::GpuFeatureStatus::Enabled: |
| 35 *out = gpu::kGpuFeatureStatusEnabled; |
| 36 return true; |
| 37 case gpu::mojom::GpuFeatureStatus::Blacklisted: |
| 38 *out = gpu::kGpuFeatureStatusBlacklisted; |
| 39 return true; |
| 40 case gpu::mojom::GpuFeatureStatus::Disabled: |
| 41 *out = gpu::kGpuFeatureStatusDisabled; |
| 42 return true; |
| 43 case gpu::mojom::GpuFeatureStatus::Undefined: |
| 44 *out = gpu::kGpuFeatureStatusUndefined; |
| 45 return true; |
| 46 case gpu::mojom::GpuFeatureStatus::Max: |
| 47 *out = gpu::kGpuFeatureStatusMax; |
| 48 return true; |
| 49 } |
| 50 return false; |
| 51 } |
| 52 }; |
| 53 |
| 54 template <> |
| 55 struct StructTraits<gpu::mojom::GpuFeatureInfoDataView, gpu::GpuFeatureInfo> { |
| 56 static bool Read(gpu::mojom::GpuFeatureInfoDataView data, |
| 57 gpu::GpuFeatureInfo* out) { |
| 58 std::vector<gpu::GpuFeatureStatus> info_status; |
| 59 if (!data.ReadStatusValues(&info_status)) |
| 60 return false; |
| 61 if (info_status.size() != gpu::NUMBER_OF_GPU_FEATURE_TYPES) |
| 62 return false; |
| 63 std::copy(info_status.begin(), info_status.end(), out->status_values); |
| 64 return true; |
| 65 } |
| 66 |
| 67 static std::vector<gpu::GpuFeatureStatus> status_values( |
| 68 const gpu::GpuFeatureInfo& info) { |
| 69 return std::vector<gpu::GpuFeatureStatus>(info.status_values, |
| 70 std::end(info.status_values)); |
| 71 } |
| 72 }; |
| 73 |
| 74 } // namespace mojo |
| 75 |
| 76 #endif // GPU_IPC_COMMON_GPU_FEATURE_INFO_STRUCT_TRAITS_H_ |
| OLD | NEW |