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 ASH_MUS_ACCELERATORS_ACCELERATOR_IDS_H_ |
| 6 #define ASH_MUS_ACCELERATORS_ACCELERATOR_IDS_H_ |
| 7 |
| 8 namespace ash { |
| 9 namespace mus { |
| 10 |
| 11 // Accelerator ids consist of two parts: |
| 12 // . Upper 16 bits identifies source (namespace part). |
| 13 // . Lower 16 supplied from client (local part). |
| 14 constexpr uint16_t kLocalIdMask = 0xFFFF; |
| 15 |
| 16 inline uint32_t ComputeAcceleratorId(uint16_t accelerator_namespace, |
| 17 uint16_t local_id) { |
| 18 return (accelerator_namespace << 16) | local_id; |
| 19 } |
| 20 |
| 21 inline uint16_t GetAcceleratorLocalId(uint32_t accelerator_id) { |
| 22 return static_cast<uint16_t>(accelerator_id & kLocalIdMask); |
| 23 } |
| 24 |
| 25 inline uint16_t GetAcceleratorNamespaceId(uint32_t accelerator_id) { |
| 26 return static_cast<uint16_t>((accelerator_id >> 16) & kLocalIdMask); |
| 27 } |
| 28 |
| 29 } // namespace mus |
| 30 } // namespace ash |
| 31 |
| 32 #endif // ASH_MUS_ACCELERATORS_ACCELERATOR_IDS_H_ |
OLD | NEW |