1 // Copyright 2019 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 UI_GFX_MOJOM_GPU_EXTRA_INFO_MOJOM_TRAITS_H_ 6 #define UI_GFX_MOJOM_GPU_EXTRA_INFO_MOJOM_TRAITS_H_ 7 8 #include "base/component_export.h" 9 #include "ui/gfx/gpu_extra_info.h" 10 #include "ui/gfx/mojom/buffer_types_mojom_traits.h" 11 #include "ui/gfx/mojom/gpu_extra_info.mojom-shared.h" 12 13 namespace mojo { 14 15 template <> COMPONENT_EXPORT(GFX_SHARED_MOJOM_TRAITS)16struct COMPONENT_EXPORT(GFX_SHARED_MOJOM_TRAITS) 17 StructTraits<gfx::mojom::ANGLEFeatureDataView, gfx::ANGLEFeature> { 18 static bool Read(gfx::mojom::ANGLEFeatureDataView data, 19 gfx::ANGLEFeature* out); 20 21 static const std::string& name(const gfx::ANGLEFeature& input) { 22 return input.name; 23 } 24 25 static const std::string& category(const gfx::ANGLEFeature& input) { 26 return input.category; 27 } 28 29 static const std::string& description(const gfx::ANGLEFeature& input) { 30 return input.description; 31 } 32 33 static const std::string& bug(const gfx::ANGLEFeature& input) { 34 return input.bug; 35 } 36 37 static const std::string& status(const gfx::ANGLEFeature& input) { 38 return input.status; 39 } 40 41 static const std::string& condition(const gfx::ANGLEFeature& input) { 42 return input.condition; 43 } 44 }; 45 46 template <> COMPONENT_EXPORT(GFX_SHARED_MOJOM_TRAITS)47struct COMPONENT_EXPORT(GFX_SHARED_MOJOM_TRAITS) 48 StructTraits<gfx::mojom::GpuExtraInfoDataView, gfx::GpuExtraInfo> { 49 static bool Read(gfx::mojom::GpuExtraInfoDataView data, 50 gfx::GpuExtraInfo* out); 51 52 static const std::vector<gfx::ANGLEFeature>& angle_features( 53 const gfx::GpuExtraInfo& input) { 54 return input.angle_features; 55 } 56 57 #if defined(USE_OZONE) || defined(USE_X11) 58 static uint64_t system_visual(const gfx::GpuExtraInfo& input) { 59 return input.system_visual; 60 } 61 62 static uint64_t rgba_visual(const gfx::GpuExtraInfo& input) { 63 return input.rgba_visual; 64 } 65 66 static const std::vector<gfx::BufferUsageAndFormat>& 67 gpu_memory_buffer_support_x11(const gfx::GpuExtraInfo& input) { 68 return input.gpu_memory_buffer_support_x11; 69 } 70 #endif 71 }; 72 73 } // namespace mojo 74 75 #endif // UI_GFX_MOJOM_GPU_EXTRA_INFO_MOJOM_TRAITS_H_ 76