class RectangleCompositor
Defined at line 25 of file ../../src/ui/lib/escher/flatland/rectangle_compositor.h
|RectangleCompositor| provides an interface for rendering axis-aligned rectangles in 2D space,
to support the implementation of the `fuchsia.ui.composition/Flatland` API.
It composites opaque and (premultiplied/straight) images to generate a premultiplied output
image.
Public Members
static Flags kRenderTargetUsageFlags
static Flags kTextureUsageFlags
static const uint32_t kTransientTargetAttachmentIndex
static const uint32_t kOutputTargetAttachmentIndex
Public Methods
void ~RectangleCompositor ()
Defined at line 48 of file ../../src/ui/lib/escher/flatland/rectangle_compositor.h
void DrawBatch (CommandBuffer *cmd_buf,std::initializer_list<Rectangle2D>rectangles,std::initializer_list<TexturePtr>textures,std::initializer_list<ColorData>color_data,const impl::FramebufferPtr &framebuffer)
Helper to support braced-init-lists with Framebuffer.
Defined at line 89 of file ../../src/ui/lib/escher/flatland/rectangle_compositor.h
void RectangleCompositor (EscherWeakPtr escher)
RectangleCompositor constructor. Initializes the shader program and allocates
GPU buffers to store mesh data.
Defined at line 261 of file ../../src/ui/lib/escher/flatland/rectangle_compositor.cc
impl::FramebufferPtr CreateFramebuffer (ImageViewPtr output_image_view, TexturePtr depth_texture)
Draws a single batch of renderables into the provided output image.
Parameters:
- cmd_buf: The command buffer used to record commands.
- rectangles: geometry to be drawn.
- textures: must be 1-1 with rectangles, to which they are textured onto.
- color_data: must be 1-1 with rectangles and textures.
|color| is multiply_color to the texture used in the shader.
|opacity| determines use of opaque or transparent rendering.
- output_image: the render target the renderables will be rendered into.
- depth_buffer: The depth texture to be used for z-buffering.
Creates a standard 1-subpass Framebuffer suitable for use with DrawBatch().
Defined at line 267 of file ../../src/ui/lib/escher/flatland/rectangle_compositor.cc
impl::FramebufferPtr CreateColorConversionFramebuffer (ImageViewPtroutput_image_view,TexturePtrdepth_texture,ImagePtrtransient_image)
Creates a 2-subpass Framebuffer for color conversion. If |transient_image| is provided, it is
reused as the intermediate color attachment for the first subpass; if null, a new transient
image matching |output_image_view| is allocated.
Defined at line 291 of file ../../src/ui/lib/escher/flatland/rectangle_compositor.cc
ImagePtr GetTransientImage (const impl::FramebufferPtr & color_conversion_framebuffer)
Returns the transient image from a color-conversion framebuffer (attachment 0).
The framebuffer *MUST* have been created via `CreateColorConversionFramebuffer()`.
Defined at line 327 of file ../../src/ui/lib/escher/flatland/rectangle_compositor.cc
bool CanShareTransientImage (const ImagePtr & transient_image, const ImagePtr & target_image)
Returns true if |transient_image| has matching properties (dimensions, format, color space,
protected memory) to serve as the intermediate target for rendering into |target_image|.
Defined at line 336 of file ../../src/ui/lib/escher/flatland/rectangle_compositor.cc
void DrawBatch (CommandBuffer *cmd_buf,std::span<const Rectangle2D>rectangles,std::span<const TexturePtr>textures,std::span<const ColorData>color_data,const impl::FramebufferPtr &framebuffer)
Draws a batch of renderables into |framebuffer|. Whether color conversion is applied is
determined by |framebuffer|, i.e. by whether CreateColorConversionFramebuffer() was used.
Defined at line 348 of file ../../src/ui/lib/escher/flatland/rectangle_compositor.cc
void SetColorConversionParams (const ColorConversionParams & color_conversion_params)
This data is used to apply a color-conversion post processing effect over the entire
rendered output, when making a call to |DrawBatch|. The color conversion formula
used is matrix * (color + preoffsets) + postoffsets.
Defined at line 392 of file ../../src/ui/lib/escher/flatland/rectangle_compositor.cc
vk::ImageCreateInfo GetDefaultImageConstraints (const vk::Format & vk_format, vk::ImageUsageFlags usage)
Minimal image constraints to be set on textures and render targets passed into
DrawBatch. These are meant to also be compatible with AFBC
(Arm Framebuffer Compression).
Defined at line 443 of file ../../src/ui/lib/escher/flatland/rectangle_compositor.cc
void WarmPipelineCache (vk::Formatoutput_format,vk::ImageLayoutoutput_swapchain_layout,vk::Formatdepth_format,const std::vector<SamplerPtr> &immutable_samplers,booluse_protected_memory)
Pre-generate and cache Vulkan render passes and pipelines at startup to avoid subsequent
jank at runtime: when DrawBatch() looks for the renderpasses and pipelines in their respective
caches, they will already be there.
WarmPipelineCache() may be called several times with different parameters to accommodate
e.g. different framebuffer formats and layouts.
Args:
- |output_format| Describes the target framebuffer.
- |output_swapchain_layout| Describes the target framebuffer.
- |depth_format| Describes the target framebuffer.
- |depth_swapchain_layout| Describes the target framebuffer.
- |immutable_samplers| Support various types of YUV video.
- |use_protected_memory| If true, allows rendering protected (and unprotected) content into
a protected framebuffer. If false, only unprotected content can be
rendered by the generated pipelines.
Defined at line 543 of file ../../src/ui/lib/escher/flatland/rectangle_compositor.cc
Enumerations
enum class Opacity
| Name | Value |
|---|---|
| Opaque | 0 |
| Translucent | 1 |
| NonPremultipliedTranslucent | 2 |
Defined at line 30 of file ../../src/ui/lib/escher/flatland/rectangle_compositor.h