class DisplayCompositor
Defined at line 60 of file ../../src/ui/scenic/lib/flatland/engine/display_compositor.h
The `DisplayCompositor` is responsible for compositing Flatland render data onto the display(s).
It accomplishes this either by direct hardware compositing via the display coordinator
interface, or rendering on the GPU via a custom renderer API. It also handles the
registration of sysmem buffer collections and importation of images to both the
display coordinator and the renderer via the `BufferCollectionImporter` interface. The
`BufferCollectionImporter` interface is how Flatland sessions communicate with the
`DisplayCompositor`, providing it with the necessary data to render without exposing to Flatland
the `DisplayCoordinator` or other dependencies.
Public Methods
display::CoordinatorProxy * GetDisplayCoordinatorForTest ()
Defined at line 177 of file ../../src/ui/scenic/lib/flatland/engine/display_compositor.h
void DisplayCompositor (async_dispatcher_t *main_dispatcher,std::shared_ptr<display::CoordinatorProxy>coordinator_proxy,const std::shared_ptr<Renderer> &renderer,fidl::WireClient<fuchsia_sysmem2::Allocator>sysmem_allocator,const DisplayCompositorConfig &config)
TODO(https://fxbug.dev/42145655): The `DisplayCompositor` has multiple parts of its code where
usage of the display coordinator is protected by locks, because of the multithreaded
environment of flatland. Ideally, we'd want the `DisplayCompositor` to have sole ownership of
the display coordinator, i.e. it would require a `unique_ptr` instead of a `shared_ptr`.
But since access to the real display coordinator is provided to clients via a `shared_ptr`,
we take in a `shared_ptr` as a parameter here. However, this could cause problems with our
locking mechanisms, as other display-coordinator clients could be accessing the same functions
and/or state at the same time as the `DisplayCompositor` without making use of locks.
Defined at line 232 of file ../../src/ui/scenic/lib/flatland/engine/display_compositor.cc
void ~DisplayCompositor ()
Defined at line 250 of file ../../src/ui/scenic/lib/flatland/engine/display_compositor.cc
fpromise::promise<> ImportBufferCollection (allocation::GlobalBufferCollectionIdcollection_id,fidl::WireClient<fuchsia_sysmem2::Allocator> &sysmem_allocator,fidl::ClientEnd<fuchsia_sysmem2::BufferCollectionToken>token,BufferCollectionUsageusage,std::optional<fuchsia_math::SizeU>size)
`BufferCollectionImporter`
Only called from the main thread.
Defined at line 287 of file ../../src/ui/scenic/lib/flatland/engine/display_compositor.cc
void ReleaseBufferCollection (allocation::GlobalBufferCollectionId collection_id, BufferCollectionUsage usage_type)
`BufferCollectionImporter`
Only called from the main thread.
Defined at line 379 of file ../../src/ui/scenic/lib/flatland/engine/display_compositor.cc
fpromise::promise<> ImportBufferImage (const allocation::ImageMetadata & metadata, BufferCollectionUsage usage_type)
`BufferCollectionImporter`
Called from main thread or Flatland threads.
Defined at line 401 of file ../../src/ui/scenic/lib/flatland/engine/display_compositor.cc
void ReleaseBufferImage (allocation::GlobalImageId image_id)
`BufferCollectionImporter`
Called from main thread or Flatland threads.
Defined at line 481 of file ../../src/ui/scenic/lib/flatland/engine/display_compositor.cc
RenderFrameResult RenderFrame (uint64_tframe_number,zx::timepresentation_time,std::span<const RenderData>render_data_list,std::vector<zx::event>release_fences,std::vector<zx::counter>release_counters,std::vector<zx::counter>present_fences,scheduling::FramePresentedCallbackcallback,RenderFrameTestArgstest_args)
Generates frame and presents it to display. This may involve directly scanning out client
images, or it may involve first using the GPU to composite (some of) these images into a single
image which is then scanned out.
`args` can be used to customize behavior in tests. Production code should omit this arg; the
default values are correct for production use cases.
Only called from the main thread.
Defined at line 842 of file ../../src/ui/scenic/lib/flatland/engine/display_compositor.cc
fpromise::promise<> AddDisplay (display::Display *display,DisplayInfoinfo,uint32_tnum_render_targets,fuchsia_sysmem2::BufferCollectionInfo *out_collection_info)
Register a new display to the `DisplayCompositor`, which also generates the render targets to
be presented on the display when compositing on the GPU. If `num_render_targets` is 0, this
function will not create any render targets for GPU composition for that display. The buffer
collection info is also returned back to the caller via an output parameter
`num_render_targets` is 0. Otherwise, a valid handle to return the buffer collection data is
required.
TODO(https://fxbug.dev/42137737): We need to figure out exactly how we want the display to
anchor to the Flatland hierarchy. Only called from the main thread.
Defined at line 1016 of file ../../src/ui/scenic/lib/flatland/engine/display_compositor.cc
void SetColorConversionValues (const fidl::Array<float, 9> &coefficients,const fidl::Array<float, 3> &preoffsets,const fidl::Array<float, 3> &postoffsets)
Values needed to adjust the color of the framebuffer as a postprocessing effect.
Only called from the main thread.
Defined at line 1131 of file ../../src/ui/scenic/lib/flatland/engine/display_compositor.cc
bool SetMinimumRgb (uint8_t minimum_rgb)
Clamps the minimum value for all channels on all pixels on the display to this number.
Only called from the main thread.
Defined at line 1143 of file ../../src/ui/scenic/lib/flatland/engine/display_compositor.cc
zx_status_t SetDisplayPowerMode (display::DisplayId display_id, fuchsia_hardware_display_types::PowerMode mode)
Sets the power mode of `display_id`, synchronously. Returns `ZX_OK`, or one of the
errors of `fuchsia.ui.display.singleton/DisplayPower`:
- `ZX_ERR_NOT_FOUND` if this compositor or the coordinator does not have the display
- `ZX_ERR_NOT_SUPPORTED` if the driver or hardware cannot do `mode`
- `ZX_ERR_INTERNAL` for any other failure.
On `kOff`, frames applied before this call will never be acknowledged by a vsync, so
their release fences are signaled and their frame-presented callbacks invoked now;
then a solid black config is committed, so that the panel shows black rather than the
last frame when it is powered on again. The dropped configs and flushed fences are
shared by all displays.
Only called from the main thread.
Defined at line 1160 of file ../../src/ui/scenic/lib/flatland/engine/display_compositor.cc
bool IsDisplayDark (display::DisplayId display_id)
False for a display this compositor does not have. Only called from the main
thread.
Defined at line 1232 of file ../../src/ui/scenic/lib/flatland/engine/display_compositor.cc
Enumerations
enum class RenderFrameResult
| Name | Value |
|---|---|
| kDirectToDisplay | 0 |
| kGpuComposition | 1 |
| kFailure | 2 |
Describes the result of `RenderFrame()`. If it succeeds it is either by showing client images
directly on the display, or by first using the GPU to composite them into a single image.
Defined at line 65 of file ../../src/ui/scenic/lib/flatland/engine/display_compositor.h
Records
Friends
class DisplayCompositorTest
class DisplayCompositorPixelTest
class DisplayCompositorSmokeTest