| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 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 SERVICES_UI_GPU_INTERFACES_CONTEXT_LOST_REASON_TRAITS_H_ |
| 6 #define SERVICES_UI_GPU_INTERFACES_CONTEXT_LOST_REASON_TRAITS_H_ |
| 7 |
| 8 #include "gpu/command_buffer/common/constants.h" |
| 9 #include "services/ui/gpu/interfaces/context_lost_reason.mojom.h" |
| 10 |
| 11 namespace mojo { |
| 12 |
| 13 template <> |
| 14 struct EnumTraits<ui::mojom::ContextLostReason, gpu::error::ContextLostReason> { |
| 15 static ui::mojom::ContextLostReason ToMojom( |
| 16 gpu::error::ContextLostReason reason) { |
| 17 switch (reason) { |
| 18 case gpu::error::kGuilty: |
| 19 return ui::mojom::ContextLostReason::GUILTY; |
| 20 case gpu::error::kInnocent: |
| 21 return ui::mojom::ContextLostReason::INNOCENT; |
| 22 case gpu::error::kUnknown: |
| 23 return ui::mojom::ContextLostReason::UNKNOWN; |
| 24 case gpu::error::kOutOfMemory: |
| 25 return ui::mojom::ContextLostReason::OUT_OF_MEMORY; |
| 26 case gpu::error::kMakeCurrentFailed: |
| 27 return ui::mojom::ContextLostReason::MAKE_CURRENT_FAILED; |
| 28 case gpu::error::kGpuChannelLost: |
| 29 return ui::mojom::ContextLostReason::GPU_CHANNEL_LOST; |
| 30 case gpu::error::kInvalidGpuMessage: |
| 31 return ui::mojom::ContextLostReason::INVALID_GPU_MESSAGE; |
| 32 } |
| 33 NOTREACHED(); |
| 34 return ui::mojom::ContextLostReason::UNKNOWN; |
| 35 } |
| 36 |
| 37 static bool FromMojom(ui::mojom::ContextLostReason reason, |
| 38 gpu::error::ContextLostReason* out) { |
| 39 switch (reason) { |
| 40 case ui::mojom::ContextLostReason::GUILTY: |
| 41 *out = gpu::error::kGuilty; |
| 42 return true; |
| 43 case ui::mojom::ContextLostReason::INNOCENT: |
| 44 *out = gpu::error::kInnocent; |
| 45 return true; |
| 46 case ui::mojom::ContextLostReason::UNKNOWN: |
| 47 *out = gpu::error::kUnknown; |
| 48 return true; |
| 49 case ui::mojom::ContextLostReason::OUT_OF_MEMORY: |
| 50 *out = gpu::error::kOutOfMemory; |
| 51 return true; |
| 52 case ui::mojom::ContextLostReason::MAKE_CURRENT_FAILED: |
| 53 *out = gpu::error::kMakeCurrentFailed; |
| 54 return true; |
| 55 case ui::mojom::ContextLostReason::GPU_CHANNEL_LOST: |
| 56 *out = gpu::error::kGpuChannelLost; |
| 57 return true; |
| 58 case ui::mojom::ContextLostReason::INVALID_GPU_MESSAGE: |
| 59 *out = gpu::error::kInvalidGpuMessage; |
| 60 return true; |
| 61 } |
| 62 return false; |
| 63 } |
| 64 }; |
| 65 |
| 66 } // namespace mojo |
| 67 |
| 68 #endif // SERVICES_UI_GPU_INTERFACES_CONTEXT_LOST_REASON_TRAITS_H_ |
| OLD | NEW |