carnelian/scene/
mod.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::drawing::path_for_corner_knockouts;
6use crate::render::{BlendMode, Context as RenderContext, FillRule, Layer, Raster};
7use crate::{Coord, Rect, Size};
8
9pub use crate::scene::scene::SceneOrder;
10
11/// Individual bits of UI
12pub mod facets;
13/// Grouping of facets
14pub mod group;
15/// Layout of facet groups
16pub mod layout;
17/// Rendering facets
18pub mod scene;
19
20struct Rendering {
21    size: Size,
22}
23
24impl Rendering {
25    fn new() -> Rendering {
26        Rendering { size: Size::zero() }
27    }
28}
29
30fn raster_for_corner_knockouts(
31    bounds: &Rect,
32    corner_radius: Coord,
33    render_context: &mut RenderContext,
34) -> Raster {
35    let path = path_for_corner_knockouts(bounds, corner_radius, render_context);
36    let mut raster_builder = render_context.raster_builder().expect("raster_builder");
37    raster_builder.add(&path, None);
38    raster_builder.build()
39}
40
41/// Trait used by facets to mutate layers.
42pub trait LayerGroup {
43    /// Clears the group, removing all layers.
44    fn clear(&mut self);
45
46    /// Insert a order-layer pair into the group.
47    fn insert(&mut self, order: SceneOrder, layer: Layer);
48
49    /// Removes a layer from the group.
50    fn remove(&mut self, order: SceneOrder);
51}