• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2018 The Chromium OS 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 use crate::generated::p_format;
6 
7 macro_rules! fourcc {
8     ($a:expr, $b:expr, $c:expr, $d:expr) => {
9         Some($a as u32 | ($b as u32) << 8 | ($c as u32) << 16 | ($d as u32) << 24)
10     };
11 }
12 
13 /// Gets the fourcc that corresponds to the given pipe format, or `None` if the format is
14 /// unrecognized.
pipe_format_fourcc(f: p_format::pipe_format) -> Option<u32>15 pub fn pipe_format_fourcc(f: p_format::pipe_format) -> Option<u32> {
16     match f {
17         p_format::PIPE_FORMAT_B8G8R8A8_UNORM => fourcc!('A', 'R', '2', '4'),
18         p_format::PIPE_FORMAT_B8G8R8X8_UNORM => fourcc!('X', 'R', '2', '4'),
19         p_format::PIPE_FORMAT_R8G8B8A8_UNORM => fourcc!('A', 'B', '2', '4'),
20         p_format::PIPE_FORMAT_R8G8B8X8_UNORM => fourcc!('X', 'B', '2', '4'),
21         p_format::PIPE_FORMAT_B5G6R5_UNORM => fourcc!('R', 'G', '1', '6'),
22         // p_format::PIPE_FORMAT_R8_UNORM => fourcc!('R', '8', ' ', ' '),
23         // p_format::PIPE_FORMAT_G8R8_UNORM => fourcc!('R', 'G', '8', '8'),
24         _ => None,
25     }
26 }
27