| // gpu/ipc/common/gpu_peak_memory.mojom-shared.cc is auto generated by mojom_bindings_generator.py, do not edit |
| |
| // Copyright 2016 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #include "gpu/ipc/common/gpu_peak_memory.mojom-shared.h" |
| |
| // Used to support stream output operator for enums. |
| // TODO(dcheng): Consider omitting this somehow if not needed. |
| #include <ostream> |
| #include <utility> |
| |
| #include "base/strings/stringprintf.h" |
| #include "mojo/public/cpp/bindings/lib/validate_params.h" |
| #include "mojo/public/cpp/bindings/lib/validation_errors.h" |
| #include "mojo/public/cpp/bindings/lib/validation_util.h" |
| #include "third_party/perfetto/include/perfetto/tracing/traced_value.h" |
| |
| #include "gpu/ipc/common/gpu_peak_memory.mojom-params-data.h" |
| namespace gpu { |
| namespace mojom { |
| |
| static NOINLINE const char* GpuPeakMemoryAllocationSourceToStringHelper(GpuPeakMemoryAllocationSource value) { |
| // Defined in a helper function to ensure that Clang generates a lookup table. |
| switch(value) { |
| case GpuPeakMemoryAllocationSource::UNKNOWN: |
| return "UNKNOWN"; |
| case GpuPeakMemoryAllocationSource::COMMAND_BUFFER: |
| return "COMMAND_BUFFER"; |
| case GpuPeakMemoryAllocationSource::SHARED_CONTEXT_STATE: |
| return "SHARED_CONTEXT_STATE"; |
| case GpuPeakMemoryAllocationSource::SHARED_IMAGE_STUB: |
| return "SHARED_IMAGE_STUB"; |
| case GpuPeakMemoryAllocationSource::SKIA: |
| return "SKIA"; |
| default: |
| return nullptr; |
| } |
| } |
| |
| std::string GpuPeakMemoryAllocationSourceToString(GpuPeakMemoryAllocationSource value) { |
| const char *str = GpuPeakMemoryAllocationSourceToStringHelper(value); |
| if (!str) { |
| return base::StringPrintf("Unknown GpuPeakMemoryAllocationSource value: %i", static_cast<int32_t>(value)); |
| } |
| return str; |
| } |
| |
| std::ostream& operator<<(std::ostream& os, GpuPeakMemoryAllocationSource value) { |
| return os << GpuPeakMemoryAllocationSourceToString(value); |
| } |
| |
| namespace internal { |
| |
| } // namespace internal |
| } // namespace mojom |
| } // namespace gpu |
| |
| namespace perfetto { |
| |
| // static |
| void TraceFormatTraits<::gpu::mojom::GpuPeakMemoryAllocationSource>::WriteIntoTrace( |
| perfetto::TracedValue context, ::gpu::mojom::GpuPeakMemoryAllocationSource value) { |
| return std::move(context).WriteString(::gpu::mojom::GpuPeakMemoryAllocationSourceToString(value)); |
| } |
| |
| } // namespace perfetto |