• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

animation/H12-Nov-2020-20,61915,604

base/H12-Nov-2020-13,0769,342

benchmarks/H12-Nov-2020-1,6591,185

debug/H12-Nov-2020-1,148815

input/H12-Nov-2020-10,7877,298

ipc/H12-Nov-2020-8353

layers/H03-May-2022-34,38624,677

metrics/H12-Nov-2020-9,7467,261

mojo_embedder/H12-Nov-2020-912687

mojom/H12-Nov-2020-5036

paint/H12-Nov-2020-31,27724,317

raster/H12-Nov-2020-8,0465,848

resources/H12-Nov-2020-2,6641,799

scheduler/H12-Nov-2020-11,1387,819

tiles/H12-Nov-2020-29,61421,891

trees/H03-May-2022-91,94867,601

BUILD.gnH A D03-May-202231.1 KiB878857

DEPSH A D07-Nov-20202.6 KiB8380

OWNERSH A D07-Nov-20201.1 KiB6448

PRESUBMIT.pyH A D07-Nov-202011.6 KiB312241

README.mdH A D07-Nov-20209 KiB204160

cc.gniH A D07-Nov-20201.5 KiB5849

cc_export.hH A D07-Nov-2020664 3020

memory.mdH A D07-Nov-202094 21

README.md

1# cc/
2
3This directory contains a compositor, used in both the renderer and the
4browser.  In the renderer, Blink is the client.  In the browser, both
5ui and Android browser compositor are the clients.
6
7The public API of the compositor is LayerTreeHost and Layer and its
8derived types.  Embedders create a LayerTreeHost (single, multithreaded,
9or synchronous) and then attach a tree of Layers to it.
10
11When Layers are updated they request a commit, which takes the structure
12of the tree of Layers, the data on each Layer, and the data of its host and
13atomically pushes it all to a tree of LayerImpls and a LayerTreeHostImpl
14and LayerTreeImpl.  The main thread (which owns the tree of Layers
15and the embedder) is blocked during this commit operation.
16
17The commit is from the main thread Layer tree to the pending tree in
18multithreaded mode.  The pending tree is a staging tree for
19rasterization.  When enough rasterization has completed for
20invalidations, the pending tree is ready to activate.  Activate is an
21analogous operation to commit, and pushes data from the pending tree to
22the active tree.  The pending tree exists so that all of the updates
23from the main thread can be displayed to the user atomically while
24the previous frame can be scrolled or animated.
25
26The single threaded compositor commits directly to the active
27tree and then stops drawing until the content is ready to be drawn.
28
29The active tree is responsible for drawing.  The Scheduler and its
30SchedulerStateMachine decide when to draw (along with when to commit,
31etc etc).  "Drawing" in a compositor consists of LayerImpl::AppendQuads
32which batches up a set of DrawQuads and RenderPasses into a
33CompositorFrame which is sent via a CompositorFrameSink.
34
35CompositorFrames from individual compositors are sent to the
36SurfaceManager (currently in the browser process).  The
37SurfaceAggregator combines all CompositorFrames together and asks
38the Display to finally draw the frame via Renderer, which is either
39a viz::GLRenderer or a SoftwareRenderer, which finally draws the entire
40composited browser contents into a backbuffer or a bitmap, respectively.
41
42Design documents for the graphics stack can be found at
43[chromium-graphics](https://www.chromium.org/developers/design-documents/chromium-graphics).
44
45## Other Docs
46
47* [How cc Works](../docs/how_cc_works.md)
48
49## Glossaries
50
51### Active CompositorFrame
52
53### Active Tree
54The set of layers and property trees that was/will be used to submit a
55CompositorFrame from the layer compositor. Composited effects such as scrolling,
56pinch, and animations are done by modifying the active tree, which allows for
57producing and submitting a new CompositorFrame.
58
59### CompositorFrame
60A set of RenderPasses (which are a list of DrawQuads) along with metadata.
61Conceptually this is the instructions (transforms, texture ids, etc) for how to
62draw an entire scene which will be presented in a surface.
63
64### CopyOutputRequest (or Copy Request)
65A request for a texture (or bitmap) copy of some part of the compositor's
66output. Such requests force the compositor to use a separate RenderPass for the
67content to be copied, which allows it to do the copy operation once the
68RenderPass has been drawn to.
69
70### ElementID
71Chosen by cc's clients and can be used as a stable identifier across updates.
72For example, blink uses ElementIDs as a stable id for the object (opaque to cc)
73that is responsible for a composited animation. Some additional information in
74[element_id.h](https://codesearch.chromium.org/chromium/src/cc/paint/element_id.h)
75
76### DirectRenderer
77An abstraction that provides an API for the Display to draw a fully-aggregated
78CompositorFrame to a physical output. Subclasses of it provide implementations
79for various backends, currently GL or Software.
80
81### Layer
82A conceptual piece of content that can appear on screen and has some known
83position with respect to the viewport.  The Layer class only is used on the
84main thread.  This, along with LayerTreeHost, is the main API for the
85compositor.
86
87### LayerImpl
88The same as Layer, but on the compositor thread.
89
90### LayerTree
91
92### Occlusion Culling
93Avoiding work by skipping over things which are not visible due to being
94occluded (hidden from sight by other opaque things in front of them). Most
95commonly refers to skipping drawing (ie culling) of DrawQuads when other
96DrawQuads will be in front and occluding them.
97
98### Property Trees
99
100See also presentations on [Compositor Property Trees](https://docs.google.com/presentation/d/1V7gCqKR-edNdRDv0bDnJa_uEs6iARAU2h5WhgxHyejQ/preview)
101and [Blink Property Trees](https://docs.google.com/presentation/u/1/d/1ak7YVrJITGXxqQ7tyRbwOuXB1dsLJlfpgC4wP7lykeo/preview).
102
103### Display
104A controller class that takes CompositorFrames for each surface and draws them
105to a physical output.
106
107### Draw
108Filling pixels in a physical output (technically could be to an offscreen
109texture), but this is the final output of the display compositor.
110
111### DrawQuad
112A unit of work for drawing. Each DrawQuad has its own texture id, transform,
113offset, etc.
114
115### Shared Quad State
116A shared set of states used by multiple draw quads. DrawQuads that are linked to
117the same shared quad state will all use the same properties from it, with the
118addition of things found on their individual DrawQuad structures.
119
120### Render Pass
121A list of DrawQuads which will all be drawn together into the same render target
122(either a texture or physical output). Most times all DrawQuads are part of a
123single RenderPass. Additional RenderPasses are used for effects that require a
124set of DrawQuads to be drawn together into a buffer first, with the effect
125applied then to the buffer instead of each individual DrawQuad.
126
127### Render Surface
128Synonym for RenderPass now. Historically part of the Layer tree data structures,
129with a 1:1 mapping to RenderPasses. RenderSurfaceImpl is a legacy piece that
130remains.
131
132### Surface
133
134### Record
135
136### Raster
137
138### Paint
139
140### Pending CompositorFrame
141
142### Pending Tree
143The set of layers and property trees that is generated from a main frame (or
144BeginMainFrame, or commit). The pending tree exists to do raster work in the
145layer compositor without clobbering the active tree until it is done. This
146allows the active tree to be used in the meantime.
147
148### Composite
149To produce a single graphical output from multiple inputs. In practice, the
150layer compositor does raster from recordings and manages memory, performs
151composited effects such as scrolling, pinch, animations, producing a
152CompositorFrame. The display compositor does an actual "composite" to draw the
153final output into a single physical output.
154
155### Invalidation
156Invalidation is a unit of content update.  Any content updates from
157Blink or ui must be accompanied by an invalidation to tell the compositor
158that a piece of content must be rerasterized.  For example, if a 10x10
159div with a background color has its width increased by 5 pixels, then
160there will be a 5x10 invalidation (at least) for the new space covered
161by the larger div.
162
163Ideally, invalidations represent the minimum amount of content that must
164be rerastered from the previous frame.  They are passed to the compositor
165via Layer::SetNeedsDisplay(Rect).  Invalidation is tracked both to
166minimize the amount of raster work needed, but also to allow for
167partial raster of Tiles.  Invalidations also eventually become damage.
168
169### Damage
170Damage is the equivalent of invalidation, but for the final display.
171As invalidation is the difference between two frames worth of content,
172damage is the difference between two CompositorFrames.  Damage is
173tracked via the DamageTracker.  This allows for partial swap, where
174only the parts of the final CompositorFrame that touch the screen
175are drawn, and only that drawn portion is swapped, which saves quite
176a bit of power for small bits of damage.
177
178Invalidation creates damage, in that if a piece of content updates, then
179that content invalidation creates damage on screen.  Other things that
180cause damage are analogous operations to invalidations, but on Layers.
181For example, moving a Layer around, changing properties of Layers (e.g.
182opacity), and adding/removing/reordering Layers will all create damage
183(aka screen updates) but do not create invalidations (aka raster work).
184
185### Tiles
186An abstraction of a piece of content of a Layer.  A tile may be
187rasterized or not.  It may be known to be a solid color or not.
188A PictureLayerImpl indirectly owns a sparse set of Tiles to
189represent its rasterizable content.  When tiles are invalidated,
190they are replaced with new tiles.
191
192### Prepare Tiles
193Prioritize and schedule needed tiles for raster. This is the entry point to a
194system that converts painting (raster sources / recording sources) into
195rasterized resources that live on tiles. This also kicks off any dependent image
196decodes for images that need to be decode for the raster to take place.
197
198### Device Scale Factor
199The scale at which we want to display content on the output device. For very
200high resolution monitors, everything would become too small if just presented
2011:1 with the pixels. So we use a larger number of physical pixels per logical
202pixels. This ratio is the device scale factor. 1 or 2 is the most common on
203ChromeOS. Values between 1 and 2 are common on Windows.
204