class Flatland

Defined at line 53 of file ../../src/ui/scenic/lib/flatland/flatland.h

Implements the `fuchsia.ui.composition.Flatland` protocol. It is intended to run on its own

thread/dispatcher, and communicates with the main/render thread(s) via the UberStruct mechanism,

as well as other interfaces such as FlatlandPresenter. Because `fuchsia.ui.composition.Flatland`

is a stateful protocol, each client is connected to a different Flatland object.

Public Methods

void Flatland (const Flatland & )

Because this object captures its "this" pointer in internal closures, it is unsafe to copy or

move it. Disable all copy and move operations.

Defined at line 94 of file ../../src/ui/scenic/lib/flatland/flatland.h

Flatland & operator= (const Flatland & )

Defined at line 95 of file ../../src/ui/scenic/lib/flatland/flatland.h

void Flatland (Flatland && )

Defined at line 96 of file ../../src/ui/scenic/lib/flatland/flatland.h

Flatland & operator= (Flatland && )

Defined at line 97 of file ../../src/ui/scenic/lib/flatland/flatland.h

std::shared_ptr<Flatland> New (std::shared_ptr<utils::DispatcherHolder> dispatcher_holder, fidl::ServerEnd<fuchsia_ui_composition::Flatland> server_end, scheduling::SessionId session_id, std::function<void ()> destroy_instance_function, std::shared_ptr<FlatlandPresenter> flatland_presenter, std::shared_ptr<LinkSystem> link_system, std::shared_ptr<UberStructSystem::UberStructQueue> uber_struct_queue, const std::vector<std::shared_ptr<allocation::BufferCollectionImporter>> & buffer_collection_importers, fit::function<void (fidl::ServerEnd<fuchsia_ui_views::Focuser>, zx_koid_t)> register_view_focuser, fit::function<void (fidl::ServerEnd<fuchsia_ui_views::ViewRefFocused>, zx_koid_t)> register_view_ref_focused, fit::function<void (fidl::ServerEnd<fuchsia_ui_pointer::TouchSource>, zx_koid_t)> register_touch_source, fit::function<void (fidl::ServerEnd<fuchsia_ui_pointer::MouseSource>, zx_koid_t)> register_mouse_source, const FlatlandConfig & config)

Instantiates a new Flatland object and binds it to serve the Flatland protocol over the

`server_end` channel. Method invocations received on this channel will be serviced on

the thread managed by `dispatcher_holder`.

The `destroy_instance_function` is called to notify the instance's manager that the instance

should be destroyed. This function is invoked on the thread owned by `dispatcher_holder`. When

this function is invoked, the client FIDL connection has already been closed. There are two

situations that result in the invocation of `destroy_instance_function`:

- the client closes the FIDL channel

- the client makes illegal use of the API (or associated APIs like ChildViewWatcher)

`flatland_presenter`, `link_system`, `uber_struct_queue`, and `buffer_collection_importers`

allow this Flatland object to access resources shared by all Flatland instances for actions

like frame scheduling, linking, buffer allocation, and presentation to the global scene graph.

Defined at line 116 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void ReplaceChildren (TransformId parent_transform_id, std::initializer_list<TransformId> new_child_transform_ids)

Defined at line 167 of file ../../src/ui/scenic/lib/flatland/flatland.h

void ~Flatland ()

Defined at line 279 of file ../../src/ui/scenic/lib/flatland/flatland.cc

const FlatlandConfig & config ()

Allow others to see how this Flatland session is configured.

Defined at line 311 of file ../../src/ui/scenic/lib/flatland/flatland.h

void Present (PresentRequest & request, PresentCompleter::Sync & completer)

|fuchsia_ui_composition::Flatland|

Defined at line 331 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void Present (fuchsia_ui_composition::PresentArgs args)

Defined at line 335 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void CreateView (CreateViewRequest & request, CreateViewCompleter::Sync & completer)

|fuchsia_ui_composition::Flatland|

Defined at line 636 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void CreateView (fuchsia_ui_views::ViewCreationToken token, fidl::ServerEnd<fuchsia_ui_composition::ParentViewportWatcher> parent_viewport_watcher)

Defined at line 641 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void CreateView2 (CreateView2Request & request, CreateView2Completer::Sync & completer)

Defined at line 648 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void CreateView2 (fuchsia_ui_views::ViewCreationToken token, fuchsia_ui_views::ViewIdentityOnCreation view_identity, fuchsia_ui_composition::ViewBoundProtocols protocols, fidl::ServerEnd<fuchsia_ui_composition::ParentViewportWatcher> parent_viewport_watcher)

Defined at line 654 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void ReleaseView (ReleaseViewCompleter::Sync & completer)

|fuchsia_ui_composition::Flatland|

TODO(https://fxbug.dev/42162046): Consider returning tokens for re-linking.

Defined at line 767 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void ReleaseView ()

Defined at line 769 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void Clear (ClearCompleter::Sync & completer)

|fuchsia_ui_composition::Flatland|

Defined at line 798 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void Clear ()

Defined at line 800 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void CreateTransform (CreateTransformRequest & request, CreateTransformCompleter::Sync & completer)

|fuchsia_ui_composition::Flatland|

Defined at line 830 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void CreateTransform (TransformId transform_id)

Defined at line 835 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void SetTranslation (SetTranslationRequest & request, SetTranslationCompleter::Sync & completer)

|fuchsia_ui_composition::Flatland|

Defined at line 855 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void SetTranslation (TransformId transform_id, fuchsia_math::Vec translation)

Defined at line 860 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void SetOrientation (SetOrientationRequest & request, SetOrientationCompleter::Sync & completer)

|fuchsia_ui_composition::Flatland|

Defined at line 882 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void SetOrientation (TransformId transform_id, fuchsia_ui_composition::Orientation orientation)

Defined at line 887 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void SetScale (SetScaleRequest & request, SetScaleCompleter::Sync & completer)

|fuchsia_ui_composition::Flatland|

Defined at line 910 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void SetScale (TransformId transform_id, fuchsia_math::VecF scale)

Defined at line 914 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void SetOpacity (SetOpacityRequest & request, SetOpacityCompleter::Sync & completer)

|fuchsia_ui_composition::Flatland|

Defined at line 952 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void SetOpacity (TransformId transform_id, float value)

Defined at line 956 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void SetClipBoundary (SetClipBoundaryRequest & request, SetClipBoundaryCompleter::Sync & completer)

|fuchsia_ui_composition::Flatland|

Defined at line 994 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void SetClipBoundary (TransformId transform_id, fidl::Box<fuchsia_math::Rect> bounds)

Defined at line 999 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void AddChild (AddChildRequest & request, AddChildCompleter::Sync & completer)

|fuchsia_ui_composition::Flatland|

Defined at line 1072 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void AddChild (TransformId parent_transform_id, TransformId child_transform_id)

Defined at line 1076 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void RemoveChild (RemoveChildRequest & request, RemoveChildCompleter::Sync & completer)

|fuchsia_ui_composition::Flatland|

Defined at line 1110 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void RemoveChild (TransformId parent_transform_id, TransformId child_transform_id)

Defined at line 1115 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void ReplaceChildren (ReplaceChildrenRequest & request, ReplaceChildrenCompleter::Sync & completer)

|fuchsia_ui_composition::Flatland|

Defined at line 1151 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void ReplaceChildren (TransformId parent_transform_id, std::span<const TransformId> new_child_transform_ids)

Defined at line 1167 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void SetRootTransform (SetRootTransformRequest & request, SetRootTransformCompleter::Sync & completer)

|fuchsia_ui_composition::Flatland|

Defined at line 1226 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void SetRootTransform (TransformId transform_id)

Defined at line 1231 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void CreateViewport (CreateViewportRequest & request, CreateViewportCompleter::Sync & completer)

|fuchsia_ui_composition::Flatland|

Defined at line 1258 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void CreateViewport (ContentId viewport_id, fuchsia_ui_views::ViewportCreationToken token, fuchsia_ui_composition::ViewportProperties properties, fidl::ServerEnd<fuchsia_ui_composition::ChildViewWatcher> child_view_watcher)

Defined at line 1266 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void CreateImage (CreateImageRequest & request, CreateImageCompleter::Sync & completer)

|fuchsia_ui_composition::Flatland|

Defined at line 1358 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void CreateImage (ContentId image_id, fuchsia_ui_composition::BufferCollectionImportToken import_token, uint32_t vmo_index, fuchsia_ui_composition::ImageProperties properties)

Defined at line 1365 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void SetImageSampleRegion (SetImageSampleRegionRequest & request, SetImageSampleRegionCompleter::Sync & completer)

|fuchsia_ui_composition::Flatland|

Defined at line 1478 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void SetImageSampleRegion (ContentId image_id, types::RectangleF rect)

Defined at line 1483 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void SetImageDestinationSize (SetImageDestinationSizeRequest & request, SetImageDestinationSizeCompleter::Sync & completer)

|fuchsia_ui_composition::Flatland|

Defined at line 1537 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void SetImageDestinationSize (ContentId image_id, fuchsia_math::SizeU size)

Defined at line 1542 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void SetImageBlendingFunction (SetImageBlendingFunctionRequest & request, SetImageBlendingFunctionCompleter::Sync & completer)

|fuchsia_ui_composition::Flatland|

Defined at line 1569 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void SetImageBlendMode (SetImageBlendModeRequest & request, SetImageBlendModeCompleter::Sync & completer)

|fuchsia_ui_composition::Flatland|

Defined at line 1574 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void SetImageBlendMode (ContentId image_id, BlendMode blend_mode)

Defined at line 1579 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void SetImageFlip (SetImageFlipRequest & request, SetImageFlipCompleter::Sync & completer)

|fuchsia_ui_composition::Flatland|

Defined at line 1603 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void SetImageFlip (ContentId image_id, fuchsia_ui_composition::ImageFlip flip)

Defined at line 1607 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void CreateFilledRect (CreateFilledRectRequest & request, CreateFilledRectCompleter::Sync & completer)

|fuchsia_ui_composition::Flatland|

Defined at line 1631 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void CreateFilledRect (ContentId rect_id)

Defined at line 1636 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void SetSolidFill (SetSolidFillRequest & request, SetSolidFillCompleter::Sync & completer)

|fuchsia_ui_composition::Flatland|

Defined at line 1666 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void SetSolidFill (ContentId rect_id, fuchsia_ui_composition::ColorRgba color, fuchsia_math::SizeU size)

Defined at line 1670 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void ReleaseFilledRect (ReleaseFilledRectRequest & request, ReleaseFilledRectCompleter::Sync & completer)

|fuchsia_ui_composition::Flatland|

Defined at line 1717 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void ReleaseFilledRect (ContentId rect_id)

Defined at line 1722 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void SetImageOpacity (SetImageOpacityRequest & request, SetImageOpacityCompleter::Sync & completer)

|fuchsia_ui_composition::Flatland|

Defined at line 1755 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void SetImageOpacity (ContentId image_id, float opacity)

Defined at line 1760 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void SetHitRegions (SetHitRegionsRequest & request, SetHitRegionsCompleter::Sync & completer)

|fuchsia_ui_composition::Flatland|

Defined at line 1798 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void SetHitRegions (TransformId transform_id, std::vector<fuchsia_ui_composition::HitRegion> regions)

Defined at line 1803 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void SetInfiniteHitRegion (SetInfiniteHitRegionRequest & request, SetInfiniteHitRegionCompleter::Sync & completer)

|fuchsia_ui_composition::Flatland|

Defined at line 1841 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void SetInfiniteHitRegion (TransformId transform_id, fuchsia_ui_composition::HitTestInteraction hit_test)

Defined at line 1846 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void SetContent (SetContentRequest & request, SetContentCompleter::Sync & completer)

|fuchsia_ui_composition::Flatland|

Defined at line 1866 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void SetContent (TransformId transform_id, ContentId content_id)

Defined at line 1870 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void SetViewportProperties (SetViewportPropertiesRequest & request, SetViewportPropertiesCompleter::Sync & completer)

|fuchsia_ui_composition::Flatland|

Defined at line 1910 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void SetViewportProperties (ContentId viewport_id, fuchsia_ui_composition::ViewportProperties properties)

Defined at line 1915 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void ReleaseTransform (ReleaseTransformRequest & request, ReleaseTransformCompleter::Sync & completer)

|fuchsia_ui_composition::Flatland|

Defined at line 1972 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void ReleaseTransform (TransformId transform_id)

Defined at line 1977 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void ReleaseViewport (ReleaseViewportRequest & request, ReleaseViewportCompleter::Sync & completer)

|fuchsia_ui_composition::Flatland|

Defined at line 1998 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void ReleaseViewport (ContentId viewport_id, fit::function<void (fuchsia_ui_views::ViewportCreationToken)> completer)

Defined at line 2007 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void ReleaseImage (ReleaseImageRequest & request, ReleaseImageCompleter::Sync & completer)

|fuchsia_ui_composition::Flatland|

Defined at line 2071 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void ReleaseImage (ContentId image_id)

Defined at line 2075 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void SetDebugName (SetDebugNameRequest & request, SetDebugNameCompleter::Sync & completer)

|fuchsia_ui_composition::Flatland|

Defined at line 2112 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void SetDebugName (std::string name)

Defined at line 2121 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void ReleaseImageImmediately (ReleaseImageImmediatelyRequest & request, ReleaseImageImmediatelyCompleter::Sync & completer)

|fuchsia_ui_composition::TrustedFlatland|

Defined at line 2132 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void ReleaseImageImmediately (ContentId image_id)

Defined at line 2137 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void OnNextFrameBegin (uint32_t additional_present_credits, FuturePresentationInfos presentation_infos)

Called just before the FIDL client receives the event of the same name, indicating that this

Flatland instance should allow a |additional_present_credits| calls to Present().

Defined at line 2184 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void OnFramePresented (const std::map<scheduling::PresentId, zx::time> & latched_times, scheduling::PresentTimestamps present_times)

Called when this Flatland instance should send the OnFramePresented() event to the FIDL

client.

Defined at line 2205 of file ../../src/ui/scenic/lib/flatland/flatland.cc

TransformHandle GetRoot ()

For validating the transform hierarchy in tests only. For the sake of testing, the "root" will

always be the top-most TransformHandle from the TransformGraph owned by this Flatland. If

currently linked to a parent, that means the Link's child_transform_handle. If not, that means

the local_root_.

Defined at line 2239 of file ../../src/ui/scenic/lib/flatland/flatland.cc

std::optional<TransformHandle> GetContentHandle (ContentId content_id)

For validating properties associated with content in tests only. If |content_id| does not

exist for this Flatland instance, returns std::nullopt.

Defined at line 2243 of file ../../src/ui/scenic/lib/flatland/flatland.cc

std::optional<TransformHandle> GetTransformHandle (TransformId transform_id)

For validating properties associated with transforms in tests only. If |transform_id| does not

exist for this Flatland instance, returns std::nullopt.

Defined at line 2253 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void SetErrorReporter (std::unique_ptr<scenic_impl::ErrorReporter> error_reporter)

For validating logs in tests only.

Defined at line 2261 of file ../../src/ui/scenic/lib/flatland/flatland.cc

scheduling::SessionId GetSessionId ()

For using as a unique identifier in tests only.

Defined at line 2265 of file ../../src/ui/scenic/lib/flatland/flatland.cc

LayerHandle CreateLayerObject ()

TODO(https://fxbug.dev/523371761): public for tests. Later, revisit whether any can be

made private (if so, they'll be reordered in the file).

Consider using `friend class FlatlandTest`.

Defined at line 2350 of file ../../src/ui/scenic/lib/flatland/flatland.cc

allocation::GlobalImageId ReleaseLayerObject (LayerHandle handle)

Releases a reference to the internal layer. If this is the last reference

to the layer (ref_count reaches 0), the layer is destroyed.

Returns the ID of the bound image if the layer was destroyed AND it had

an image bound to it; otherwise returns kInvalidImageId.

The returned ID is primarily used by CleanupFlatland2StateForTest() to

verify correct image lifecycle behavior in unit tests.

Defined at line 2358 of file ../../src/ui/scenic/lib/flatland/flatland.cc

TransformHandle CreateLayerStackData (std::vector<LayerHandle> layers)

Defined at line 2394 of file ../../src/ui/scenic/lib/flatland/flatland.cc

std::vector<allocation::GlobalImageId> CleanupFlatland2StateForTest (const std::vector<TransformHandle> & dead_handles)

Test-only accessor/mutators

TODO(https://fxbug.dev/523371761): once everything lands, verify whether these are necessary

to keep, or whether they are well-covered by tests for production callers such as

`CreateImage()` and `ProcessDeadTransforms()`.

Defined at line 2410 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void SetLayerImageForTest (LayerHandle handle, allocation::GlobalImageId image)

Defined at line 2435 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void SetLayerSolidColorForTest (LayerHandle handle)

Defined at line 2448 of file ../../src/ui/scenic/lib/flatland/flatland.cc

const LayerObject * GetLayerObjectForTest (LayerHandle handle)

Defined at line 2460 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void ReleaseTransformForTest (TransformHandle handle)

Defined at line 2468 of file ../../src/ui/scenic/lib/flatland/flatland.cc

void SetPriorityChildForTest (TransformId parent, TransformHandle child)

Defined at line 2472 of file ../../src/ui/scenic/lib/flatland/flatland.cc