summary refs log tree commit diff
path: root/gpu_renderer/src/pipe_format_fourcc.rs
blob: 769397311255270e6eef281ca91ed1e1c7c02f68 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Copyright 2018 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

use generated::p_format;

macro_rules! fourcc {
    ($a:expr, $b:expr, $c:expr, $d:expr) => (
        Some($a as u32 | ($b as u32) << 8 | ($c as u32) << 16 | ($d as u32) << 24)
    )
}

/// Gets the fourcc that corresponds to the given pipe format, or `None` if the format is
/// unrecognized.
pub fn pipe_format_fourcc(f: p_format::pipe_format) -> Option<u32> {
    match f {
        p_format::PIPE_FORMAT_B8G8R8X8_UNORM => fourcc!('X', 'R', '2', '4'),
        _ => None,
    }
}