---
# System prepended metadata

title: PrimaryPlane
tags: [Chromium-Graphics, elkurin-daily-note]

---

# PrimaryPlane
Primary Plane is the word I heard during the discussion in the context of delegated compositing.  
This note is a survey not for what is Primary Plane.

## Overlay Strategy
Delegated compositing is one of the overlay and it uses the strategy implemented as [OvelayProcessorStrategy](https://source.chromium.org/chromium/chromium/src/+/main:components/viz/service/display/overlay_processor_strategy.h;l=23;drc=8e78783dc1f7007bad46d657c9f332614e240fd8).  
[OvelayProcessorStrategy](https://source.chromium.org/chromium/chromium/src/+/main:components/viz/service/display/overlay_processor_strategy.h;l=23;drc=8e78783dc1f7007bad46d657c9f332614e240fd8) describes each strategy for promoting a DrawQuad to overlays.  
There are OverlayStrategyFullscreen, OverlayStrategySingleOnTop and OverlayStrategyUnderlay.  
Each strategy implements following APIs
- [Propose](https://source.chromium.org/chromium/chromium/src/+/main:components/viz/service/display/overlay_processor_strategy.h;l=32;drc=8e78783dc1f7007bad46d657c9f332614e240fd8): Appends all legitimate overlay candidates
- [Attemp](https://source.chromium.org/chromium/chromium/src/+/main:components/viz/service/display/overlay_processor_strategy.h;l=49;drc=8e78783dc1f7007bad46d657c9f332614e240fd8): Checks each `proposed_candidate` can make it work with the render pass.
- [CommitCandidate](https://source.chromium.org/chromium/chromium/src/+/main:components/viz/service/display/overlay_processor_strategy.h;l=64;drc=8e78783dc1f7007bad46d657c9f332614e240fd8): Commits the proposed candidate by updating `render_pass` when presented in overlay plane

And some others.

Here, we have concept of PrimaryPlane.  
Each strategy can return the display rect for primary plane via [GetPrimaryPlaneDisplayRect](https://source.chromium.org/chromium/chromium/src/+/main:components/viz/service/display/overlay_processor_strategy.h;l=84;drc=8e78783dc1f7007bad46d657c9f332614e240fd8).

## PrimaryPlane
[PrimaryPlane](https://source.chromium.org/chromium/chromium/src/+/main:components/viz/service/display/overlay_processor_strategy.h;l=26;drc=8e78783dc1f7007bad46d657c9f332614e240fd8) is [OutputSurfaceOverlayPlane](https://source.chromium.org/chromium/chromium/src/+/main:components/viz/service/display/overlay_processor_interface.h;l=73;drc=8e78783dc1f7007bad46d657c9f332614e240fd8), the data needed to represent OutputSurface as an overlay plane.  
OutputSurfaceOverlayPlane seems to correspond to one overlay candidate.  
It contains a info such as display_rect, rounded_corners, transform, damage_rect...  
It also has [OverlayPriorityHint](https://source.chromium.org/chromium/chromium/src/+/main:ui/gfx/overlay_priority_hint.h;l=14;drc=8e78783dc1f7007bad46d657c9f332614e240fd8) which is used to compute which overlay candidate should be prioritized to the overlay.

Primary plane fisrt constructed inside [DirectRenderer::DrawFrame](https://source.chromium.org/chromium/chromium/src/+/main:components/viz/service/display/direct_renderer.cc;l=307;drc=8e78783dc1f7007bad46d657c9f332614e240fd8).  
It [ProcessOutputSurfaceAsOverlay](https://source.chromium.org/chromium/chromium/src/+/main:components/viz/service/display/direct_renderer.cc;l=303;drc=8e78783dc1f7007bad46d657c9f332614e240fd8) and set it as `output_surface_plane` and this value is the one passed to each processor as `primary_plane`.  
Assuming from this usage, `primary_plane` is assigned per frame.

There are no critical documentation, but I guess primary plane is just a unique plane where the overlay candidates will be drawn.  
It looks like it can take null, and not really sure whether what it actually is resonsible for.  
TODO(elkurin): More survey

## Note: damage rect
[DrawFrame](https://source.chromium.org/chromium/chromium/src/+/main:components/viz/service/display/direct_renderer.cc;l=217;drc=8e78783dc1f7007bad46d657c9f332614e240fd8) poassed `surface_damage_rect_list` as [vector of gfx::Rect](https://source.chromium.org/chromium/chromium/src/+/main:components/viz/service/display/aggregated_frame.h;l=21;drc=8e78783dc1f7007bad46d657c9f332614e240fd8).  

But not related to that, the root_damage_rect of the frame takes the [intersection with device_viewport_size](https://source.chromium.org/chromium/chromium/src/+/main:components/viz/service/display/direct_renderer.cc;l=253;drc=8e78783dc1f7007bad46d657c9f332614e240fd8).  
This does not check whether there is a surface outside of the device viewport size, so we need to be careful.