// 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; using fuchsia.mem; // Commands that are used to modify the state of a |Session|. // TODO(SCN-237): reorder Command definitions to match the order in this union. union Command { CreateResourceCmd create_resource; ReleaseResourceCmd release_resource; ExportResourceCmd export_resource; ImportResourceCmd import_resource; // Tagging commands. SetTagCmd set_tag; // Grouping commands. DetachCmd detach; // Spatial commands. SetTranslationCmd set_translation; SetScaleCmd set_scale; SetRotationCmd set_rotation; SetAnchorCmd set_anchor; SetSizeCmd set_size; SetOpacityCmd set_opacity; SendSizeChangeHintCmdHACK send_size_change_hint_hack; // Node-specific commands. AddChildCmd add_child; // TODO: Should we require a DetachCmd before // re-parenting? AddPartCmd add_part; DetachChildrenCmd detach_children; SetShapeCmd set_shape; SetMaterialCmd set_material; SetClipCmd set_clip; SetHitTestBehaviorCmd set_hit_test_behavior; SetViewPropertiesCmd set_view_properties; TakeSnapshotCmdHACK take_snapshot_cmd; // Camera and lighting commands. SetCameraCmd set_camera; SetCameraTransformCmd set_camera_transform; SetCameraProjectionCmd set_camera_projection; SetStereoCameraProjectionCmd set_stereo_camera_projection; SetCameraPoseBufferCmd set_camera_pose_buffer; SetLightColorCmd set_light_color; SetLightDirectionCmd set_light_direction; AddLightCmd add_light; DetachLightCmd detach_light; DetachLightsCmd detach_lights; SetTextureCmd set_texture; SetColorCmd set_color; // Mesh commands. BindMeshBuffersCmd bind_mesh_buffers; // Layer and renderer commands. AddLayerCmd add_layer; RemoveLayerCmd remove_layer; RemoveAllLayersCmd remove_all_layers; SetLayerStackCmd set_layer_stack; SetRendererCmd set_renderer; SetRendererParamCmd set_renderer_param; // Events. SetEventMaskCmd set_event_mask; // Diagnostic commands. SetLabelCmd set_label; // Debugging commands. SetDisableClippingCmd set_disable_clipping; // TODO(SCN-1026): Remove this. SetImportFocusCmd set_import_focus; }; // Instructs the compositor to create the specified |Resource|, and to register // it in a table so that it can be referenced by subsequent commands. struct CreateResourceCmd { // An ID that is currently not used within the session. uint32 id; ResourceArgs resource; }; // Releases the client's reference to the resource; it is then illegal to use // the ID in subsequent Commands. Other references to the resource may exist, // so releasing the resource does not result in its immediate destruction; it is // only destroyed once the last reference is released. For example, the // resource may be required to render an in-progress frame, or it may be // referred to by another resource). However, the ID will be immediately // unregistered, and may be reused to create a new resource. struct ReleaseResourceCmd { // ID of the resource to be dereferenced. uint32 id; }; // Create an external reference to the specified resource, which can then be // imported into another Session by passing a handle to |token|'s peer to // ImportResourceCmd; see that comment for more details. // // The importing client is typically in a different process than the exporter. // No specific mechanism is provided for transferring a token from an exporter // to an importer; collaborators may choose any out-of-band API they wish to do // so. struct ExportResourceCmd { uint32 id; handle token; }; // Import a resource that was exported via ExportResourceCmd(). |token| is // a handle to the eventpair peer that was used to export the resource, and // |spec| describes the type of the imported resource, and the commands which // can legally be applied to it. Afterward, |id| can be used to refer to the // resource in an Command, similarly (but not identically: see below) to a // resource that was created in the session. For example, you can add children // to an imported EntityNode via AddChildCmd. // // However, note that the importer does not gain full access to the imported // resource, but rather to an attenuated subset of its capabilities. For // example, you cannot use a DetachCmd to detach an imported EntityNode from // its parent. // // Unlike ExportResourceCmd, there is no configurable timeout. There is an // expectation that the exported resource will become available in a short // amount of time. TODO: this needs elaboration... e.g. we might notify via the // SessionListener when we know that the link will never be made (e.g. if the // peer of the import token is destroyed). // // TODO: describe how the imported resource behaves if the exported resource // isn't yet available, or becomes unavailable (e.g. an imported Material might // act as a plain white texture). struct ImportResourceCmd { uint32 id; handle token; ImportSpec spec; }; // Maximum length for a resource label. const uint32 kLabelMaxLength = 32; // Sets/clears a label to help developers identify the purpose of the resource // when using diagnostic tools. // // The label serves no functional purpose in the scene graph. It exists only // to help developers understand its structure. The scene manager may truncate // or discard labels at will. // // Constraints: // - The label's maximum length is |kLabelMaxLength| characters. // - Setting the label to an empty string clears it. struct SetLabelCmd { uint32 id; string label; }; // Add a node as a child to another node. // // Constraints: // - |id| refs a Node with the has_children characteristic. // - |child_id| refs any Node. // // Discussion: // The child node is first removed from its existing parent, as if DetachCmd // was applied first. struct AddChildCmd { uint32 node_id; uint32 child_id; }; // Add a node as a part of another node. The implications of being a part // rather than a child differ based on the type of the part. However, one // implication is constant: removing all of a node's children (e.g. via // DetachChildrenCmd) does not affect its parts. This is similar to the // "shadow DOM" in a web browser: the controls of a