blob: 3bb56a4fc2b4df83502e4868ee00ffe7d4a825c5 [file] [log] [blame]
// Copyright 2017 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
library fuchsia.ui.gfx;
type vec2 = struct {
x float32;
y float32;
};
type vec3 = struct {
x float32;
y float32;
z float32;
};
type vec4 = struct {
x float32;
y float32;
z float32;
w float32;
};
type mat4 = struct {
/// Column major order.
matrix array<float32, 16>;
};
/// sRGB color space and nonlinear transfer function.
// TODO(fxbug.dev/23484): use float32s instead of uint8.
type ColorRgba = struct {
red uint8;
green uint8;
blue uint8;
alpha uint8;
};
type ColorRgb = struct {
red float32;
green float32;
blue float32;
};
type Quaternion = struct {
x float32;
y float32;
z float32;
w float32;
};
/// Oriented plane described by a normal vector and a distance
/// from the origin along that vector.
type Plane3 = struct {
dir vec3;
dist float32;
};
type FactoredTransform = struct {
translation vec3;
scale vec3;
/// Point around which rotation and scaling occur.
anchor vec3;
rotation Quaternion;
};
type Value = strict union {
1: vector1 float32;
2: vector2 vec2;
3: vector3 vec3;
4: vector4 vec4;
5: matrix4x4 mat4;
6: color_rgba ColorRgba;
7: color_rgb ColorRgb;
/// Degrees of counter-clockwise rotation in the XY plane.
8: degrees float32;
9: quaternion Quaternion;
10: transform FactoredTransform;
/// ID of a value-producing resource (an animation or an expression).
/// The type of this value matches the type produced by the named resource.
11: variable_id uint32;
};
/// A value that is specified explicitly by `value` if `variable_id` is zero,
/// or is the value produced by the resource identified by `variable_id`, e.g.
/// an animation or expression. In the latter case, the value produced by the
/// resource must be a float32, and `value` is ignored.
type FloatValue = struct {
value float32;
variable_id uint32;
};
/// A value that is specified explicitly by `value` if `variable_id` is zero,
/// or is the value produced by the resource identified by `variable_id`, e.g.
/// an animation or expression. In the latter case, the value produced by the
/// resource must be a vec2, and `value` is ignored.
type Vector2Value = struct {
value vec2;
variable_id uint32;
};
/// A value that is specified explicitly by `value` if `variable_id` is zero,
/// or is the value produced by the resource identified by `variable_id`, e.g.
/// an animation or expression. In the latter case, the value produced by the
/// resource must be a vec3, and `value` is ignored.
type Vector3Value = struct {
value vec3;
variable_id uint32;
};
/// A value that is specified explicitly by `value` if `variable_id` is zero,
/// or is the value produced by the resource identified by `variable_id`, e.g.
/// an animation or expression. In the latter case, the value produced by the
/// resource must be a vec4, and `value` is ignored.
type Vector4Value = struct {
value vec4;
variable_id uint32;
};
/// A value that is specified explicitly by `value` if `variable_id` is zero,
/// or is the value produced by the resource identified by `variable_id`, e.g.
/// an animation or expression. In the latter case, the value produced by the
/// resource must be a vec4, and `value` is ignored.
type Matrix4Value = struct {
value mat4;
variable_id uint32;
};
/// A value that is specified explicitly by `value` if `variable_id` is zero,
/// or is the value produced by the resource identified by `variable_id`, e.g.
/// an animation or expression. In the latter case, the value produced by the
/// resource must be a ColorRgb, and `value` is ignored.
type ColorRgbValue = struct {
value ColorRgb;
variable_id uint32;
};
/// A value that is specified explicitly by `value` if `variable_id` is zero,
/// or is the value produced by the resource identified by `variable_id`, e.g.
/// an animation or expression. In the latter case, the value produced by the
/// resource must be a ColorRgba, and `value` is ignored.
type ColorRgbaValue = struct {
value ColorRgba;
variable_id uint32;
};
/// A value that is specified explicitly by `value` if `variable_id` is zero,
/// or is the value produced by the resource identified by `variable_id`, e.g.
/// an animation or expression. In the latter case, the value produced by the
/// resource must be a Quaternion, and `value` is ignored.
type QuaternionValue = struct {
value Quaternion;
variable_id uint32;
};
type ValueType = strict enum {
kNone = 0;
kVector1 = 1;
kVector2 = 2;
kVector3 = 3;
kVector4 = 4;
kMatrix4 = 5;
kColorRgb = 6;
kColorRgba = 7;
kQuaternion = 8;
kFactoredTransform = 9;
};
/// Describes how nodes interact with hit testings.
type HitTestBehavior = strict enum {
/// Apply hit testing to the node's content, its parts, and its children.
kDefault = 0;
/// Suppress hit testing of the node and everything it contains.
kSuppress = 1;
};
/// Rendering target metrics associated with a node.
/// See also `MetricsEvent`.
type Metrics = struct {
/// The ratio between the size of one logical pixel within the node's local
/// coordinate system and the size of one physical pixel of the rendering
/// target.
///
/// This scale factors change in relation to the resolution of the rendering
/// target and the scale transformations applied by containing nodes.
/// They are always strictly positive and non-zero.
///
/// For example, suppose the rendering target is a high resolution display
/// with a device pixel ratio of 2.0 meaning that each logical pixel
/// within the model corresponds to two physical pixels of the display.
/// Assuming no scale transformations affect the node, then its metrics event
/// will report a scale factor of 2.0.
///
/// Building on this example, if instead the node's parent applies a
/// scale transformation of 0.25 to the node, then the node's metrics event
/// will report a scale factor of 0.5 indicating that the node should render
/// its content at a reduced resolution and level of detail since a smaller
/// area of physical pixels (half the size in each dimension) will be rendered.
scale_x float32;
scale_y float32;
scale_z float32;
};
/// Represents an axis-aligned bounding box.
///
/// If any of the dimensions has a negative extent (e.g. max.x < min.x) then the
/// bounding box is treated as empty. It is valid for a client to define an
/// empty bounding box.
///
/// An "empty bounding box" is one that does not admit a point inhabitant.
/// Note that a zero-volume, zero-area bounding box (e.g., a point like
/// (0,0,0)-(0,0,0), or a line like (0,0,0)-(1,0,0)) is thus not empty.
type BoundingBox = struct {
min vec3;
max vec3;
};
/// Represents the properties for a View.
type ViewProperties = struct {
/// The View's bounding box extents can be defined as:
/// { bounding_box.min, bounding_box.max }
/// Content contained within the View is clipped to this bounding box.
///
// TODO(fxbug.dev/24037): should we just have a vec3 extent instead of a bounding box
// with a potentially non-zero min?
bounding_box BoundingBox;
/// `insets_from_min` and `insets_from_max` specify the distances between the
/// view's bounding box and that of its parent.
///
/// These properties are not strictly enforced by Scenic, but only used
/// as hints for clients and other components that receives ViewProperties:
///
/// View clients can assume that anything drawn outside of
/// { bounding_box.min + inset_from_min, bounding_box.max - inset_from_max }
/// may be obscured by an ancestor view. The reason for obscuring, and the rules
/// surrounding it, is specific to each product.
inset_from_min vec3;
inset_from_max vec3;
/// Whether the View can receive a focus event; default is true. When
/// false, and this View is eligible to receive a focus event, no
/// focus/unfocus event is actually sent to any View.
@allow_deprecated_struct_defaults
focus_change bool = true;
/// Whether the View allows geometrically underlying Views to receive input;
/// default is true. When false, Scenic does not send input events to
/// underlying Views.
// TODO(fxbug.dev/24695): not implemented yet.
@allow_deprecated_struct_defaults
downward_input bool = true;
};
/// Represents the state of a View in Scenic.
type ViewState = struct {
/// Whether the View is rendering. Default is false. Delivered to the View's
/// corresponding ViewHolder after the View's first frame render request.
is_rendering bool;
};