class DisplayCompositor

Defined at line 62 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 instances 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 157 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, fuchsia::sysmem2::AllocatorSyncPtr 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 - meaning that 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 233 of file ../../src/ui/scenic/lib/flatland/engine/display_compositor.cc

void ~DisplayCompositor ()

Defined at line 251 of file ../../src/ui/scenic/lib/flatland/engine/display_compositor.cc

bool ImportBufferCollection (allocation::GlobalBufferCollectionId collection_id, fuchsia::sysmem2::Allocator_Sync * sysmem_allocator, fidl::InterfaceHandle<fuchsia::sysmem2::BufferCollectionToken> token, BufferCollectionUsage usage, std::optional<fuchsia::math::SizeU> size)

|BufferCollectionImporter|

Only called from the main thread.

Defined at line 288 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 369 of file ../../src/ui/scenic/lib/flatland/engine/display_compositor.cc

bool ImportBufferImage (const allocation::ImageMetadata & metadata, BufferCollectionUsage usage_type)

|BufferCollectionImporter|

Called from main thread or Flatland threads.

Defined at line 414 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 474 of file ../../src/ui/scenic/lib/flatland/engine/display_compositor.cc

RenderFrameResult RenderFrame (uint64_t frame_number, zx::time presentation_time, const std::vector<RenderData> & render_data_list, std::vector<zx::event> release_fences, scheduling::FramePresentedCallback callback, RenderFrameTestArgs test_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 784 of file ../../src/ui/scenic/lib/flatland/engine/display_compositor.cc

void AddDisplay (display::Display * display, DisplayInfo info, uint32_t num_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

|out_collection_info|. This out parameter is only allowed to be nullptr when

|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 949 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 1042 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 1054 of file ../../src/ui/scenic/lib/flatland/engine/display_compositor.cc

Enumerations

enum 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 67 of file ../../src/ui/scenic/lib/flatland/engine/display_compositor.h

Records

Friends

class DisplayCompositorTest
class DisplayCompositorPixelTest
class DisplayCompositorSmokeTest