CINXE.COM
Rendering Overview — Firefox Source Docs documentation
<!doctype html> <html class="writer-html5" lang="en" data-content_root="../"> <head> <base href="https://firefox-source-docs.mozilla.org/gfx/RenderingOverview.html"> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Rendering Overview — Firefox Source Docs documentation</title> <link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=fa44fd50"> <link rel="stylesheet" type="text/css" href="../_static/css/theme.css?v=19f00094"> <link rel="stylesheet" type="text/css" href="../_static/graphviz.css?v=fd3f3429"> <link rel="stylesheet" type="text/css" href="../_static/copybutton.css?v=76b2166b"> <link rel="stylesheet" type="text/css" href="../_static/custom_theme.css?v=dc5ed815"> <link rel="stylesheet" type="text/css" href="../_static/design-style.1e8bd061cd6da7fc9cf755528e8ffc24.min.css?v=0a3b3ea7"> <link rel="shortcut icon" href="../_static/firefox.ico"><!--[if lt IE 9]> <script src="../_static/js/html5shiv.min.js"></script> <![endif]--> <script src="../_static/jquery.js?v=5d32c60e"></script> <script src="../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script> <script src="../_static/documentation_options.js?v=5929fcd5"></script> <script src="../_static/doctools.js?v=9a2dae69"></script> <script src="../_static/sphinx_highlight.js?v=dc90522c"></script> <script src="../_static/clipboard.min.js?v=a7894cd8"></script> <script src="../_static/copybutton.js?v=30646c52"></script> <script src="../_static/design-tabs.js?v=36754332"></script> <script src="../_static/js/theme.js"></script> <link rel="index" title="Index" href="../genindex.html"> <link rel="search" title="Search" href="../search.html"> <link rel="next" title="Layers History" href="LayersHistory.html"> <link rel="prev" title="Graphics" href="index.html"> <meta http-equiv="X-Translated-By" content="Google"> <meta http-equiv="X-Translated-To" content="iw"> <script type="text/javascript" src="https://www.gstatic.com/_/translate_http/_/js/k=translate_http.tr.en_GB.tKc6KWkFf-8.O/am=gAE/d=1/rs=AN8SPfrf36LIV3DkhtRBGWFnLWWzaykPyw/m=corsproxy" data-sourceurl="https://firefox-source-docs.mozilla.org/gfx/RenderingOverview.html"></script> <link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200" rel="stylesheet"> <script type="text/javascript" src="https://www.gstatic.com/_/translate_http/_/js/k=translate_http.tr.en_GB.tKc6KWkFf-8.O/am=gAE/d=1/exm=corsproxy/ed=1/rs=AN8SPfrf36LIV3DkhtRBGWFnLWWzaykPyw/m=phishing_protection" data-phishing-protection-enabled="false" data-forms-warning-enabled="true" data-source-url="https://firefox-source-docs.mozilla.org/gfx/RenderingOverview.html"></script> <meta name="robots" content="none"> </head> <body class="wy-body-for-nav"> <script type="text/javascript" src="https://www.gstatic.com/_/translate_http/_/js/k=translate_http.tr.en_GB.tKc6KWkFf-8.O/am=gAE/d=1/exm=corsproxy,phishing_protection/ed=1/rs=AN8SPfrf36LIV3DkhtRBGWFnLWWzaykPyw/m=navigationui" data-environment="prod" data-proxy-url="https://firefox--source--docs-mozilla-org.translate.goog" data-proxy-full-url="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB" data-source-url="https://firefox-source-docs.mozilla.org/gfx/RenderingOverview.html" data-source-language="pl" data-target-language="iw" data-display-language="en-GB" data-detected-source-language="" data-is-source-untranslated="false" data-source-untranslated-url="https://translate.google.com/website?sl=pl&tl=iw&hl=en-GB&u=https://firefox-source-docs.mozilla.org/gfx/RenderingOverview.html&anno=2" data-client="tr"></script> <div class="wy-grid-for-nav"> <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search"><a href="https://firefox--source--docs-mozilla-org.translate.goog/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB" class="icon icon-home"> Firefox Source Docs <img src="../_static/firefox-wordmark.svg" class="logo" alt="Logo"> </a><!-- -- This code is governed by the BSD license ----> <div> <h3>Quick search</h3> <script> (function () { var cx = "dd12886298f75dbef"; var gcse = document.createElement("script"); gcse.async = true; gcse.src = "https://cse.google.com/cse.js?cx=" + cx; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(gcse, s); })(); </script><gcse:search></gcse:search> </div> </div> <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> <p class="caption" role="heading"><span class="caption-text">Overview</span></p> <ul> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/glossary/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">A Glossary of Common Terms</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/overview/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">A Quick Guide to Mozilla Applications</a></li> </ul> <p class="caption" role="heading"><span class="caption-text">Getting Started</span></p> <ul> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/setup/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Getting Set Up To Work On The Firefox Codebase</a></li> </ul> <p class="caption" role="heading"><span class="caption-text">Working On Firefox</span></p> <ul> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/contributing/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Working on Firefox</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/bug-mgmt/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Bug Handling</a></li> </ul> <p class="caption" role="heading"><span class="caption-text">Firefox User Guide</span></p> <ul> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/devtools-user/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Firefox DevTools User Docs</a></li> </ul> <p class="caption" role="heading"><span class="caption-text">Source Code Documentation</span></p> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/mots/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Governance</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/browser/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Firefox Front-end</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/dom/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">DOM</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/editor/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Editor</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/layout/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Style system (CSS) & Layout</a></li> <li class="toctree-l1 current"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Graphics</a> <ul class="current"> <li class="toctree-l2 current"><a class="current reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#">Rendering Overview</a> <ul> <li class="toctree-l3"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#high-level-overview">High level overview</a> <ul> <li class="toctree-l4"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#layout">Layout</a></li> <li class="toctree-l4"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#webrender">WebRender</a></li> <li class="toctree-l4"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#software">Software</a></li> <li class="toctree-l4"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#asynchronous-panning-and-zooming">Asynchronous Panning And Zooming</a></li> <li class="toctree-l4"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#a-few-more-details">A Few More Details</a></li> </ul></li> <li class="toctree-l3"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#webrender-in-detail">WebRender In Detail</a> <ul> <li class="toctree-l4"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#the-picture-tree">The Picture Tree</a></li> <li class="toctree-l4"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#the-spatial-tree">The Spatial Tree</a></li> <li class="toctree-l4"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#the-clip-tree">The Clip Tree</a></li> <li class="toctree-l4"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#rendertask-tree">RenderTask Tree</a></li> </ul></li> </ul></li> <li class="toctree-l2"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/LayersHistory.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Layers History</a></li> <li class="toctree-l2"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/AsyncPanZoom.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Asynchronous Panning and Zooming</a></li> <li class="toctree-l2"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/Silk.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Silk Overview</a></li> <li class="toctree-l2"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/Moz2D.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Moz2D</a></li> </ul></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/ipc/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Processes, Threads and IPC</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/devtools/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Firefox DevTools Contributor Docs</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/toolkit/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Toolkit</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/js/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">SpiderMonkey</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/jsloader/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">JS Loader</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/mobile/android/geckoview/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">GeckoView</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/mobile/android/fenix/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Fenix</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/mobile/android/focus-android/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Focus for Android</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/dom/bindings/webidl/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">WebIDL</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/modules/libpref/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">libpref</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/networking/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Networking</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/remote/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Remote Protocols</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/services/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Services</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/permissions/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Permissions</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/uriloader/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">File Handling</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/widget/cocoa/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Firefox on macOS</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/widget/windows/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Firefox on Windows</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/toolkit/components/ml/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Firefox AI Runtime</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/accessible/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Accessibility</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/media/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Media Playback</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/code-quality/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Code quality</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/writing-rust-code/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Writing Rust Code</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/rust-components/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Rust Components</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/tools/profiler/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Gecko Profiler</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/performance/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Performance</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/storage/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Database bindings (SQLite, KV, …)</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/xpcom/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">XPCOM</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/nspr/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">NSPR</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/security/nss/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Network Security Services (NSS)</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/content-security/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Web Security Checks in Gecko</a></li> </ul> <p class="caption" role="heading"><span class="caption-text">The Firefox Build System</span></p> <ul> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/mach/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Mach</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/tools/try/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Pushing to Try</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/build/buildsystem/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Build System</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/taskcluster/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Firefox CI and Taskgraph</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/tools/moztreedocs/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Managing Documentation</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/mozbuild/vendor/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Vendoring Third Party Components</a></li> </ul> <p class="caption" role="heading"><span class="caption-text">Testing & Test Infrastructure</span></p> <ul> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/testing/automated-testing/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Automated Testing</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/testing/treeherder-try/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Understanding Treeherder Results</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/testing/sheriffed-intermittents/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Sheriffed intermittent failures</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/testing/tests-for-new-config/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Turning on Firefox tests for a new configuration</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/testing/intermittent/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Avoiding intermittent tests</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/testing/testing-policy/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Testing Policy</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/testing/ci-configs/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Configuration Changes</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/testing/browser-chrome/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Browser chrome mochitests</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/testing/chrome-tests/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Chrome Tests</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/testing/marionette/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Marionette</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/testing/geckodriver/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">geckodriver</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/testing/test-verification/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Test Verification</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/testing/webrender/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">WebRender Tests</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/testing/mochitest-plain/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Mochitest</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/testing/xpcshell/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">XPCShell tests</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/testing/tps/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">TPS</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/web-platform/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">web-platform-tests</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/gtest/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">GTest</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/tools/fuzzing/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Fuzzing</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/tools/sanitizer/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Sanitizer</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/testing/perfdocs/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Performance Testing</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/tools/code-coverage/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Code coverage</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/testing-rust-code/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Testing & Debugging Rust Code</a></li> </ul> <p class="caption" role="heading"><span class="caption-text">Releases & Updates</span></p> <ul> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/update-infrastructure/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Mozilla Update Infrastructure</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/update-infrastructure/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#watershed-updates">Watershed Updates</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/update-infrastructure/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#desupport-updates">Desupport Updates</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/tools/update-verify/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Update Verify</a></li> </ul> <p class="caption" role="heading"><span class="caption-text">Localization & Internationalization</span></p> <ul> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/intl/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Internationalization</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/l10n/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Localization</a></li> </ul> <p class="caption" role="heading"><span class="caption-text">Firefox and Python</span></p> <ul> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/mozbase/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">mozbase</a></li> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/python/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Using third-party Python packages</a></li> </ul> <p class="caption" role="heading"><span class="caption-text">Metrics Collected in Firefox</span></p> <ul> <li class="toctree-l1"><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/metrics/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Metrics</a></li> </ul> </div> </div> </nav> <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> <nav class="wy-nav-top" aria-label="Mobile navigation menu"><i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="https://firefox--source--docs-mozilla-org.translate.goog/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Firefox Source Docs</a> </nav> <div class="wy-nav-content"> <div class="rst-content"><!-- This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this file, - You can obtain one at http://mozilla.org/MPL/2.0/. --> <div role="navigation" aria-label="Page navigation"> <ul class="wy-breadcrumbs"> <li><a href="https://firefox--source--docs-mozilla-org.translate.goog/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB" class="icon icon-home" aria-label="Home"></a></li> <li class="breadcrumb-item"><a href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB">Graphics</a></li> <li class="breadcrumb-item active">Rendering Overview</li> <li class="wy-breadcrumbs-aside"><a href="https://translate.google.com/website?sl=pl&tl=iw&hl=en-GB&u=https://bugzilla.mozilla.org/enter_bug.cgi?product%3DDeveloper%2BInfrastructure%26component%3DFirefox%2BSource%2BDocs%253A%2BContent%26short_desc%3DDocumentation%2Bissue%2Bon%2Bgfx/RenderingOverview%26comment%3DURL%2B%3D%2Bhttps://firefox-source-docs.mozilla.org/gfx/RenderingOverview.html%26bug_file_loc%3Dhttps://firefox-source-docs.mozilla.org/gfx/RenderingOverview.html" rel="nofollow">Report an issue</a> / <a href="https://firefox--source--docs-mozilla-org.translate.goog/_sources/gfx/RenderingOverview.rst.txt?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB" rel="nofollow"> View page source</a></li> </ul> <hr> </div> <div role="main" class="document" itemscope itemtype="http://schema.org/Article"> <div itemprop="articleBody"> <section id="rendering-overview"><span id="id1"></span> <h1><a class="toc-backref" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#id2" role="doc-backlink">Rendering Overview</a><a class="headerlink" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#rendering-overview" title="Link to this heading"></a></h1> <p>This document is an overview of the steps to render a webpage, and how HTML gets transformed and broken down, step by step, into commands that can execute on the GPU.</p> <p>If you’re coming into the graphics team with not a lot of background in browsers, start here :)</p> <nav class="contents" id="contents"> <p class="topic-title">Contents</p> <ul class="simple"> <li><p><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#rendering-overview" id="id2">Rendering Overview</a></p> <ul> <li><p><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#high-level-overview" id="id3">High level overview</a></p> <ul> <li><p><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#layout" id="id4">Layout</a></p></li> <li><p><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#webrender" id="id5">WebRender</a></p></li> <li><p><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#software" id="id6">Software</a></p></li> <li><p><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#asynchronous-panning-and-zooming" id="id7">Asynchronous Panning And Zooming</a></p></li> <li><p><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#a-few-more-details" id="id8">A Few More Details</a></p></li> </ul></li> <li><p><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#webrender-in-detail" id="id9">WebRender In Detail</a></p> <ul> <li><p><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#the-picture-tree" id="id10">The Picture Tree</a></p></li> <li><p><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#the-spatial-tree" id="id11">The Spatial Tree</a></p></li> <li><p><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#the-clip-tree" id="id12">The Clip Tree</a></p></li> <li><p><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#rendertask-tree" id="id13">RenderTask Tree</a></p> <ul> <li><p><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#caching" id="id14">Caching</a></p></li> <li><p><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#interning" id="id15">Interning</a></p></li> <li><p><a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#callbacks" id="id16">Callbacks</a></p></li> </ul></li> </ul></li> </ul></li> </ul> </nav> <section id="high-level-overview"> <h2><a class="toc-backref" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#id3" role="doc-backlink">High level overview</a><a class="headerlink" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#high-level-overview" title="Link to this heading"></a></h2><a class="reference internal image-reference" href="https://firefox--source--docs-mozilla-org.translate.goog/_images/RenderingOverviewSimple.png?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB"><img alt="../_images/RenderingOverviewSimple.png" src="../_images/RenderingOverviewSimple.png" style="width: 100%;"></a> <section id="layout"> <h3><a class="toc-backref" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#id4" role="doc-backlink">Layout</a><a class="headerlink" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#layout" title="Link to this heading"></a></h3> <p>Starting at the left in the above image, we have a document represented by a DOM - a Document Object Model. A Javascript engine will execute JS code, either to make changes to the DOM, or to respond to events generated by the DOM (or do both).</p> <p>The DOM is a high level description and we don’t know what to draw or where until it is combined with a Cascading Style Sheet (CSS). Combining these two and figuring out what, where and how to draw things is the responsibility of the Layout team. The DOM is converted into a hierarchical Frame Tree, which nests visual elements (boxes). Each element points to some node in a Style Tree that describes what it should look like – color, transparency, etc. The result is that now we know exactly what to render where, what goes on top of what (layering and blending) and at what pixel coordinate. This is the Display List.</p> <p>The Display List is a light-weight data structure because it’s shallow – it mostly points back to the Frame Tree. There are two problems with this. First, we want to cross process boundaries at this point. Everything up until now happens in a Content Process (of which there are several). Actual GPU rendering happens in a GPU Process (on some platforms). Second, everything up until now was written in C++; but WebRender is written in Rust. Thus the shallow Display List needs to be serialized in a completely self-contained binary blob that will survive Interprocess Communication (IPC) and a language switch (C++ to Rust). The result is the WebRender Display List.</p> </section> <section id="webrender"> <h3><a class="toc-backref" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#id5" role="doc-backlink">WebRender</a><a class="headerlink" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#webrender" title="Link to this heading"></a></h3> <p>The GPU process receives the WebRender Display List blob and de-serializes it into a Scene. This Scene contains more than the strictly visible elements; for example, to anticipate scrolling, we might have several paragraphs of text extending past the visible page.</p> <p>For a given viewport, the Scene gets culled and stripped down to a Frame. This is also where we start preparing data structures for GPU rendering, for example getting some font glyphs into an atlas for rasterizing text.</p> <p>The final step takes the Frame and submits commands to the GPU to actually render it. The GPU will execute the commands and composite the final page.</p> </section> <section id="software"> <h3><a class="toc-backref" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#id6" role="doc-backlink">Software</a><a class="headerlink" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#software" title="Link to this heading"></a></h3> <p>The above is the new WebRender-enabled way to do things. But in the schematic you’ll note a second branch towards the bottom: this is the legacy code path which does not use WebRender (nor Rust). In this case, the Display List is converted into a Layer Tree. The purpose of this Tree is to try and avoid having to re-render absolutely everything when the page needs to be refreshed. For example, when scrolling we should be able to redraw the page by mostly shifting things around. However that requires those ‘things’ to still be around from last time we drew the page. In other words, visual elements that are likely to be static and reusable need to be drawn into their own private “page” (a cache). Then we can recombine (composite) all of these when redrawing the actual page.</p> <p>Figuring out which elements would be good candidates for this, and striking a balance between good performance versus excessive memory use, is the purpose of the Layer Tree. Each ‘layer’ is a cached image of some element(s). This logic also takes occlusion into account, eg. don’t allocate and render a layer for elements that are known to be completely obscured by something in front of them.</p> <p>Redrawing the page by combining the Layer Tree with any newly rasterized elements is the job of the Compositor.</p> <p>Even when a layer cannot be reused in its entirety, it is likely that only a small part of it was invalidated. Thus there is an elaborate system for tracking dirty rectangles, starting an update by copying the area that can be salvaged, and then redrawing only what cannot.</p> <p>In fact, this idea can be extended to delta-tracking of display lists themselves. Traversing the layout tree and building a display list is also not cheap, so the code tries to partially invalidate and rebuild the display list incrementally when possible. This optimization is used both for non-WebRender and WebRender in fact.</p> </section> <section id="asynchronous-panning-and-zooming"> <h3><a class="toc-backref" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#id7" role="doc-backlink">Asynchronous Panning And Zooming</a><a class="headerlink" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#asynchronous-panning-and-zooming" title="Link to this heading"></a></h3> <p>Earlier we mentioned that a Scene might contain more elements than are strictly necessary for rendering what’s visible (the Frame). The reason for that is Asynchronous Panning and Zooming, or APZ for short. The browser will feel much more responsive if scrolling & zooming can short-circuit all of these data transformations and IPC boundaries, and instead directly update an offset of some layer and recomposite. (Think of late-latching in a VR context)</p> <p>This simple idea introduces a lot of complexity: how much extra do you rasterize, and in which direction? How much memory can we afford? What about Javascript that responds to scroll events and perhaps does something ‘interesting’ with the page in return? What about nested frames or nested scrollbars? What if we scroll so much that we go past the boundaries of the Scene that we know about?</p> <p>See <a class="reference internal" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/AsyncPanZoom.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#apz"><span class="std std-ref">Asynchronous Panning and Zooming</span></a> for all that and more.</p> </section> <section id="a-few-more-details"> <h3><a class="toc-backref" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#id8" role="doc-backlink">A Few More Details</a><a class="headerlink" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#a-few-more-details" title="Link to this heading"></a></h3> <p>Here’s another schematic which basically repeats the previous one, but showing a little bit more detail. Note that the direction is reversed – the data flow starts at the right. Sorry about that :)</p><a class="reference internal image-reference" href="https://firefox--source--docs-mozilla-org.translate.goog/_images/RenderingOverviewDetail.png?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB"><img alt="../_images/RenderingOverviewDetail.png" src="../_images/RenderingOverviewDetail.png" style="width: 100%;"></a> <p>Some things to note:</p> <ul class="simple"> <li><p>there are multiple content processes, currently 4 of them. This is for security reasons (sandboxing), stability (isolate crashes) and performance (multi-core machines);</p></li> <li><p>ideally each “webpage” would run in its own process for security; this is being developed under the term ‘fission’;</p></li> <li><p>there is only a single GPU process, if there is one at all; some platforms have it as part of the Parent;</p></li> <li><p>not shown here is the Extension process that isolates WebExtensions;</p></li> <li><p>for non-WebRender, rasterization happens in the Content Process, and we send entire Layers to the GPU/Compositor process (via shared memory, only using actual IPC for its metadata like width & height);</p></li> <li><p>if the GPU process crashes (a bug or a driver issue) we can simply restart it, resend the display list, and the browser itself doesn’t crash;</p></li> <li><p>the browser UI is just another set of DOM+JS, albeit one that runs with elevated privileges. That is, its JS can do things that normal JS cannot. It lives in the Parent Process, which then uses IPC to get it rendered, same as regular Content. (the IPC arrow also goes to WebRender Display List but is omitted to reduce clutter);</p></li> <li><p>UI events get routed to APZ first, to minimize latency. By running inside the GPU process, we may have access to data such as rasterized clipping masks that enables finer grained hit testing;</p></li> <li><p>the GPU process talks back to the content process; in particular, when APZ scrolls out of bounds, it asks Content to enlarge/shift the Scene with a new “display port”;</p></li> <li><p>we still use the GPU when we can for compositing even in the non-WebRender case;</p></li> </ul> </section> </section> <section id="webrender-in-detail"> <h2><a class="toc-backref" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#id9" role="doc-backlink">WebRender In Detail</a><a class="headerlink" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#webrender-in-detail" title="Link to this heading"></a></h2> <p>Converting a display list into GPU commands is broken down into a number of steps and intermediate data structures.</p><a class="reference internal image-reference" href="https://firefox--source--docs-mozilla-org.translate.goog/_images/RenderingOverviewTrees.png?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB"><img alt="../_images/RenderingOverviewTrees.png" class="align-center" src="../_images/RenderingOverviewTrees.png" style="width: 75%;"></a> <blockquote> <div> <p><em>Each element in the picture tree points to exactly one node in the spatial tree. Only a few of these links are shown for clarity (the dashed lines).</em></p> </div> </blockquote> <section id="the-picture-tree"> <h3><a class="toc-backref" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#id10" role="doc-backlink">The Picture Tree</a><a class="headerlink" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#the-picture-tree" title="Link to this heading"></a></h3> <p>The incoming display list uses “stacking contexts”. For example, to render some text with a drop shadow, a display list will contain three items:</p> <ul class="simple"> <li><p>“enable shadow” with some parameters such as shadow color, blur size, and offset;</p></li> <li><p>the text item;</p></li> <li><p>“pop all shadows” to deactivate shadows;</p></li> </ul> <p>WebRender will break this down into two distinct elements, or “pictures”. The first represents the shadow, so it contains a copy of the text item, but modified to use the shadow’s color, and to shift the text by the shadow’s offset. The second picture contains the original text to draw on top of the shadow.</p> <p>The fact that the first picture, the shadow, needs to be blurred, is a “compositing” property of the picture which we’ll deal with later.</p> <p>Thus, the stack-based display list gets converted into a list of pictures – or more generally, a hierarchy of pictures, since items are nested as per the original HTML.</p> <p>Example visual elements are a TextRun, a LineDecoration, or an Image (like a .png file).</p> <p>Compared to 3D rendering, the picture tree is similar to a scenegraph: it’s a parent/child hierarchy of all the drawable elements that make up the “scene”, in this case the webpage. One important difference is that the transformations are stored in a separate tree, the spatial tree.</p> </section> <section id="the-spatial-tree"> <h3><a class="toc-backref" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#id11" role="doc-backlink">The Spatial Tree</a><a class="headerlink" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#the-spatial-tree" title="Link to this heading"></a></h3> <p>The nodes in the spatial tree represent coordinate transforms. Every time the DOM hierarchy needs child elements to be transformed relative to their parent, we add a new Spatial Node to the tree. All those child elements will then point to this node as their “local space” reference (aka coordinate frame). In traditional 3D terms, it’s a scenegraph but only containing transform nodes.</p> <p>The nodes are called frames, as in “coordinate frame”:</p> <ul class="simple"> <li><p>a Reference Frame corresponds to a <code class="docutils literal notranslate"><span class="pre"><div></span></code>;</p></li> <li><p>a Scrolling Frame corresponds to a scrollable part of the page;</p></li> <li><p>a Sticky Frame corresponds to some fixed position CSS style.</p></li> </ul> <p>Each element in the picture tree then points to a spatial node inside this tree, so by walking up and down the tree we can find the absolute position of where each element should render (traversing down) and how large each element needs to be (traversing up). Originally the transform information was part of the picture tree, as in a traditional scenegraph, but visual elements and their transforms were split apart for technical reasons.</p> <p>Some of these nodes are dynamic. A scroll-frame can obviously scroll, but a Reference Frame might also use a property binding to enable a live link with JavaScript, for dynamic updates of (currently) the transform and opacity.</p> <p>Axis-aligned transformations (scales and translations) are considered “simple”, and are conceptually combined into a single “CoordinateSystem”. When we encounter a non-axis-aligned transform, we start a new CoordinateSystem. We start in CoordinateSystem 0 at the root, and would bump this to CoordinateSystem 1 when we encounter a Reference Frame with a rotation or 3D transform, for example. This would then be the CoordinateSystem index for all its children, until we run into another (nested) non-simple transform, and so on. Roughly speaking, as long as we’re in the same CoordinateSystem, the transform stack is simple enough that we have a reasonable chance of being able to flatten it. That lets us directly rasterize text at its final scale for example, optimizing away some of the intermediate pictures (offscreen textures).</p> <p>The layout code positions elements relative to their parent. Thus to position the element on the actual page, we need to walk the Spatial Tree all the way to the root and apply each transform; the result is a <code class="docutils literal notranslate"><span class="pre">LayoutToWorldTransform</span></code>.</p> <p>One final step transforms from World to Device coordinates, which deals with DPI scaling and such.</p> <table class="docutils align-default"> <thead> <tr class="row-odd"> <th class="head"><p>WebRender term</p></th> <th class="head"><p>Rough analogy</p></th> </tr> </thead> <tbody> <tr class="row-even"> <td><p>Spatial Tree</p></td> <td><p>Scenegraph – transforms only</p></td> </tr> <tr class="row-odd"> <td><p>Picture Tree</p></td> <td><p>Scenegraph – drawables only (grouping)</p></td> </tr> <tr class="row-even"> <td><p>Spatial Tree Rootnode</p></td> <td><p>World Space</p></td> </tr> <tr class="row-odd"> <td><p>Layout space</p></td> <td><p>Local/Object Space</p></td> </tr> <tr class="row-even"> <td><p>Picture</p></td> <td><p>RenderTarget (sort of; see RenderTask below)</p></td> </tr> <tr class="row-odd"> <td><p>Layout-To-World transform</p></td> <td><p>Local-To-World transform</p></td> </tr> <tr class="row-even"> <td><p>World-To-Device transform</p></td> <td><p>World-To-Clipspace transform</p></td> </tr> </tbody> </table> </section> <section id="the-clip-tree"> <h3><a class="toc-backref" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#id12" role="doc-backlink">The Clip Tree</a><a class="headerlink" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#the-clip-tree" title="Link to this heading"></a></h3> <p>Finally, we also have a Clip Tree, which contains Clip Shapes. For example, a rounded corner div will produce a clip shape, and since divs can be nested, you end up with another tree. By pointing at a Clip Shape, visual elements will be clipped against this shape plus all parent shapes above it in the Clip Tree.</p> <p>As with CoordinateSystems, a chain of simple 2D clip shapes can be collapsed into something that can be handled in the vertex shader, at very little extra cost. More complex clips must be rasterized into a mask first, which we then sample from to <code class="docutils literal notranslate"><span class="pre">discard</span></code> in the pixel shader as needed.</p> <p>In summary, at the end of scene building the display list turned into a picture tree, plus a spatial tree that tells us what goes where relative to what, plus a clip tree.</p> </section> <section id="rendertask-tree"> <h3><a class="toc-backref" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#id13" role="doc-backlink">RenderTask Tree</a><a class="headerlink" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#rendertask-tree" title="Link to this heading"></a></h3> <p>Now in a perfect world we could simply traverse the picture tree and start drawing things: one drawcall per picture to render its contents, plus one drawcall to draw the picture into its parent. However, recall that the first picture in our example is a “text shadow” that needs to be blurred. We can’t just rasterize blurry text directly, so we need a number of steps or “render passes” to get the intended effect:</p><a class="reference internal image-reference" href="https://firefox--source--docs-mozilla-org.translate.goog/_images/RenderingOverviewBlurTask.png?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB"><img alt="../_images/RenderingOverviewBlurTask.png" class="align-right" src="../_images/RenderingOverviewBlurTask.png" style="height: 400px;"></a> <ul class="simple"> <li><p>rasterize the text into an offscreen rendertarget;</p></li> <li><p>apply one or more downscaling passes until the blur radius is reasonable;</p></li> <li><p>apply a horizontal Gaussian blur;</p></li> <li><p>apply a vertical Gaussian blur;</p></li> <li><p>use the result as an input for whatever comes next, or blit it to its final position on the page (or more generally, on the containing parent surface/picture).</p></li> </ul> <p>In the general case, which passes we need and how many of them depends on how the picture is supposed to be composited (CSS filters, SVG filters, effects) and its parameters (very large vs. small blur radius, say).</p> <p>Thus, we walk the picture tree and build a render task tree: each high level abstraction like “blur me” gets broken down into the necessary render passes to get the effect. The result is again a tree because a render pass can have multiple input dependencies (eg. blending).</p> <p>(Cfr. games, this has echoes of the Frostbite Framegraph in that it dynamically builds up a renderpass DAG and dynamically allocates storage for the outputs).</p> <p>If there are complicated clip shapes that need to be rasterized first, so their output can be sampled as a texture for clip/discard operations, that would also end up in this tree as a dependency… (I think?).</p> <p>Once we have the entire tree of dependencies, we analyze it to see which tasks can be combined into a single pass for efficiency. We ping-pong rendertargets when we can, but sometimes the dependencies cut across more than one level of the rendertask tree, and some copying is necessary.</p> <p>Once we’ve figured out the passes and allocated storage for anything we wish to persist in the texture cache, we finally start rendering.</p> <p>When rasterizing the elements into the Picture’s offscreen texture, we’d position them by walking the transform hierarchy as far up as the picture’s transform node, resulting in a <code class="docutils literal notranslate"><span class="pre">Layout</span> <span class="pre">To</span> <span class="pre">Picture</span></code> transform. The picture would then go onto the page using a <code class="docutils literal notranslate"><span class="pre">Picture</span> <span class="pre">To</span> <span class="pre">World</span></code> coordinate transform.</p> <section id="caching"> <h4><a class="toc-backref" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#id14" role="doc-backlink">Caching</a><a class="headerlink" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#caching" title="Link to this heading"></a></h4> <p>Just as with layers in the software rasterizer, it is not always necessary to redraw absolutely everything when parts of a document change. The webrender equivalent of layers is Slices – a grouping of pictures that are expected to render and update together. Slices are automatically created based on heuristics and layout hints/flags.</p> <p>Implementation wise, slices reuse a lot of the existing machinery for Pictures; in fact they’re implemented as a “Virtual picture” of sorts. The similarities make sense: both need to allocate offscreen textures in a cache, both will position and render all their children into it, and both then draw themselves into their parent as part of the parent’s draw.</p> <p>If a slice isn’t expected to change much, we give it a TileCacheInstance. It is itself made up of Tiles, where each tile will track what’s in it, what’s changing, and if it needs to be invalidated and redrawn or not as a result. Thus the “damage” from changes can be localized to single tiles, while we salvage the rest of the cache. If tiles keep seeing a lot of invalidations, they will recursively divide themselves in a quad-tree like structure to try and localize the invalidations. (And conversely, they’ll recombine children if nothing is invalidating them “for a while”).</p> </section> <section id="interning"> <h4><a class="toc-backref" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#id15" role="doc-backlink">Interning</a><a class="headerlink" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#interning" title="Link to this heading"></a></h4> <p>To spot invalidated tiles, we need a fast way to compare its contents from the previous frame with the current frame. To speed this up, we use interning; similar to string-interning, this means that each <code class="docutils literal notranslate"><span class="pre">TextRun</span></code>, <code class="docutils literal notranslate"><span class="pre">Decoration</span></code>, <code class="docutils literal notranslate"><span class="pre">Image</span></code> and so on is registered in a repository (a <code class="docutils literal notranslate"><span class="pre">DataStore</span></code>) and consequently referred to by its unique ID. Cache contents can then be encoded as a list of IDs (one such list per internable element type). Diffing is then just a fast list comparison.</p> </section> <section id="callbacks"> <h4><a class="toc-backref" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#id16" role="doc-backlink">Callbacks</a><a class="headerlink" href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/RenderingOverview.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB#callbacks" title="Link to this heading"></a></h4> <p>GPU text rendering assumes that the individual font-glyphs are already available in a texture atlas. Likewise SVG is not being rendered on the GPU. Both inputs are prepared during scene building; glyph rasterization via a thread pool from within Rust itself, and SVG via opaque callbacks (back to C++) that produce blobs.</p> </section> </section> </section> </section> </div> </div> <footer> <div class="rst-footer-buttons" role="navigation" aria-label="Footer"><a href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/index.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB" class="btn btn-neutral float-left" title="Graphics" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> <a href="https://firefox--source--docs-mozilla-org.translate.goog/gfx/LayersHistory.html?_x_tr_sl=pl&_x_tr_tl=iw&_x_tr_hl=en-GB" class="btn btn-neutral float-right" title="Layers History" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> </div> <hr> <div role="contentinfo"> <p></p> </div> Built with <a href="https://translate.google.com/website?sl=pl&tl=iw&hl=en-GB&u=https://www.sphinx-doc.org/">Sphinx</a> using a <a href="https://translate.google.com/website?sl=pl&tl=iw&hl=en-GB&u=https://github.com/readthedocs/sphinx_rtd_theme">theme</a> provided by <a href="https://translate.google.com/website?sl=pl&tl=iw&hl=en-GB&u=https://readthedocs.org">Read the Docs</a>. </footer> </div> </div> </section> </div> <script> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); </script> <script>function gtElInit() {var lib = new google.translate.TranslateService();lib.translatePage('pl', 'iw', function () {});}</script> <script src="https://translate.google.com/translate_a/element.js?cb=gtElInit&hl=en-GB&client=wt" type="text/javascript"></script> </body> </html>