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, fidl_fuchsia_math as fmath};
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 /// The destination frame on the display for the color layer.
18 display_destination: fmath::RectU,
19 },
20
21 /// A primary layer is draws its pixels from a sysmem buffer backed image and supports various
22 /// transofmations.
23 Primary {
24 /// The ID of the image that should be assigned to the primary layer. See the `image` mod
25 /// in this crate to negotiate an image buffer with the display driver that can be used in
26 /// this configuration.
27 image_id: ImageId,
28
29 /// Describes the dimensions, pixel format, and usage of the layer image.
30 image_metadata: fdisplay_types::ImageMetadata,
31
32 /// When present, the display driver will not apply the configuration until the client
33 /// signals this event.
34 unblock_event: Option<EventId>,
35 },
36}
37
38/// Represents an individual layer configuration.
39#[derive(Clone, Debug)]
40pub struct Layer {
41 /// The ID of the layer. A layer ID can be obtained from a `Controller` instance by creating
42 /// a layer.
43 pub id: LayerId,
44
45 /// Describes how the layer should be configured.
46 pub config: LayerConfig,
47}
48
49/// Represents an individual display configuration.
50#[derive(Clone, Debug)]
51pub struct DisplayConfig {
52 /// The ID of the display to configure.
53 pub id: DisplayId,
54
55 /// The list of layers in ascending z-order that should be assigned to the display.
56 pub layers: Vec<Layer>,
57}