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
gpu / ipc / common / gpu_peak_memory_mojom_traits.h [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.
#ifndef GPU_IPC_COMMON_GPU_PEAK_MEMORY_MOJOM_TRAITS_H_
#define GPU_IPC_COMMON_GPU_PEAK_MEMORY_MOJOM_TRAITS_H_
#include "base/notreached.h"
#include "gpu/gpu_export.h"
#include "gpu/ipc/common/gpu_peak_memory.h"
#include "gpu/ipc/common/gpu_peak_memory.mojom-shared.h"
namespace mojo {
template <>
struct GPU_EXPORT EnumTraits<gpu::mojom::GpuPeakMemoryAllocationSource,
gpu::GpuPeakMemoryAllocationSource> {
static gpu::mojom::GpuPeakMemoryAllocationSource ToMojom(
gpu::GpuPeakMemoryAllocationSource gpu_peak_memory_allocation_source) {
switch (gpu_peak_memory_allocation_source) {
case gpu::GpuPeakMemoryAllocationSource::UNKNOWN:
return gpu::mojom::GpuPeakMemoryAllocationSource::UNKNOWN;
case gpu::GpuPeakMemoryAllocationSource::COMMAND_BUFFER:
return gpu::mojom::GpuPeakMemoryAllocationSource::COMMAND_BUFFER;
case gpu::GpuPeakMemoryAllocationSource::SHARED_CONTEXT_STATE:
return gpu::mojom::GpuPeakMemoryAllocationSource::SHARED_CONTEXT_STATE;
case gpu::GpuPeakMemoryAllocationSource::SHARED_IMAGE_STUB:
return gpu::mojom::GpuPeakMemoryAllocationSource::SHARED_IMAGE_STUB;
case gpu::GpuPeakMemoryAllocationSource::SKIA:
return gpu::mojom::GpuPeakMemoryAllocationSource::SKIA;
}
NOTREACHED() << "Invalid GpuPeakMemoryAllocationSource:"
<< static_cast<int>(gpu_peak_memory_allocation_source);
}
static bool FromMojom(gpu::mojom::GpuPeakMemoryAllocationSource input,
gpu::GpuPeakMemoryAllocationSource* out) {
switch (input) {
case gpu::mojom::GpuPeakMemoryAllocationSource::UNKNOWN:
*out = gpu::GpuPeakMemoryAllocationSource::UNKNOWN;
return true;
case gpu::mojom::GpuPeakMemoryAllocationSource::COMMAND_BUFFER:
*out = gpu::GpuPeakMemoryAllocationSource::COMMAND_BUFFER;
return true;
case gpu::mojom::GpuPeakMemoryAllocationSource::SHARED_CONTEXT_STATE:
*out = gpu::GpuPeakMemoryAllocationSource::SHARED_CONTEXT_STATE;
return true;
case gpu::mojom::GpuPeakMemoryAllocationSource::SHARED_IMAGE_STUB:
*out = gpu::GpuPeakMemoryAllocationSource::SHARED_IMAGE_STUB;
return true;
case gpu::mojom::GpuPeakMemoryAllocationSource::SKIA:
*out = gpu::GpuPeakMemoryAllocationSource::SKIA;
return true;
}
NOTREACHED() << "Invalid GpuPeakMemoryAllocationSource: " << input;
}
};
} // namespace mojo
#endif // GPU_IPC_COMMON_GPU_PEAK_MEMORY_MOJOM_TRAITS_H_