display_utils/config.rs
1// Copyright 2021 The Fuchsia 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
5use crate::types::{Color, DisplayId, EventId, ImageId, LayerId};
6use fidl_fuchsia_hardware_display_types as fdisplay_types;
7
8/// LayerConfig is a variant type of the two distinct layer configuration types that are
9/// supported by the display driver: Primary and Color.
10// TODO(armansito): Complete the missing layer parameters.
11#[derive(Clone, Debug)]
12pub enum LayerConfig {
13 /// A color layer contains a single color.
14 Color {
15 /// The layer's color.
16 color: Color,
17 },
18
19 /// A primary layer is draws its pixels from a sysmem buffer backed image and supports various
20 /// transofmations.
21 Primary {
22 /// The ID of the image that should be assigned to the primary layer. See the `image` mod
23 /// in this crate to negotiate an image buffer with the display driver that can be used in
24 /// this configuration.
25 image_id: ImageId,
26
27 /// Describes the dimensions, pixel format, and usage of the layer image.
28 image_metadata: fdisplay_types::ImageMetadata,
29
30 /// When present, the display driver will not apply the configuration until the client
31 /// signals this event.
32 unblock_event: Option<EventId>,
33 },
34}
35
36/// Represents an individual layer configuration.
37#[derive(Clone, Debug)]
38pub struct Layer {
39 /// The ID of the layer. A layer ID can be obtained from a `Controller` instance by creating
40 /// a layer.
41 pub id: LayerId,
42
43 /// Describes how the layer should be configured.
44 pub config: LayerConfig,
45}
46
47/// Represents an individual display configuration.
48#[derive(Clone, Debug)]
49pub struct DisplayConfig {
50 /// The ID of the display to configure.
51 pub id: DisplayId,
52
53 /// The list of layers in ascending z-order that should be assigned to the display.
54 pub layers: Vec<Layer>,
55}