2025 年 3 月 27 日より、AOSP のビルドとコントリビューションには aosp-main
ではなく android-latest-release
を使用することをおすすめします。詳細については、AOSP の変更をご覧ください。
Hardware Composer HAL
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
Hardware Composer(HWC)HAL は、使用可能なハードウェアでバッファを合成する最も効率的な方法を特定します。HAL の実装はデバイス固有で、通常はディスプレイ ハードウェアの OEM が行います。
この方法のメリットは、GPU ではなくディスプレイ ハードウェアで複数のバッファを合成するオーバーレイ プレーンを思い浮かべるとわかりやすいでしょう。たとえば、上部にステータスバー、下部にナビゲーション バー、それ以外の場所にアプリのコンテンツが表示される、縦向きの一般的な Android スマートフォンについて考えてみましょう。各レイヤのコンテンツは別々のバッファにあります。次のいずれかの方法で合成を処理できます。
- アプリのコンテンツをスクラッチ バッファにレンダリングし、その上にステータスバー、さらにその上にナビゲーション バーをレンダリングして、最後にスクラッチ バッファをディスプレイ ハードウェアに渡します。
- 3 つのバッファをすべてディスプレイ ハードウェアに渡し、画面の部分ごとに異なるバッファからデータを読み取るように指示します。
後者の方がはるかに効率的です。
ディスプレイ プロセッサの機能には大きな差があります。オーバーレイの数、レイヤの回転またはブレンドの可否、配置とオーバーラップの制限を API で表現するのは困難です。これらのオプションに対応するため、HWC は次の計算を行います。
- SurfaceFlinger は HWC にレイヤの完全なリストを提供し、処理方法を確認します。
- HWC は、各レイヤにデバイス合成またはクライアント合成のマークを付けて応答します。
- SurfaceFlinger はクライアントをすべて処理して出力バッファを HWC に渡し、HWC が残りを処理できるようにします。
ハードウェア ベンダーは意思決定コードを要求に応じてカスタマイズできるため、すべてのデバイスから最大限のパフォーマンスを引き出すことができます。
画面上に変化がない場合、オーバーレイ プレーンは GL 合成よりも効率が下がる可能性があります。これは特に、オーバーレイ コンテンツに透明ピクセルがあり、オーバーラップ レイヤがブレンドされている場合に当てはまります。この場合、HWC は一部またはすべてのレイヤの GLES 合成をリクエストして合成バッファを保持できます。SurfaceFlinger から同じバッファセットの合成を要求された場合、HWC は以前合成したスクラッチ バッファを表示できます。これにより、アイドル状態のデバイスのバッテリー駆動時間を延ばせます。
Android デバイスは通常、4 つのオーバーレイ プレーンをサポートします。オーバーレイよりも多くのレイヤを合成しようとすると、一部のレイヤに GLES 合成が使用されます。つまり、アプリで使用するレイヤの数が消費電力とパフォーマンスに大きく影響する可能性があります。
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-04-04 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-04-04 UTC。"],[],[],null,["# Hardware Composer HAL\n\nThe Hardware Composer (HWC) HAL determines the most efficient\nway to composite buffers with the available hardware. As a HAL, its\nimplementation is device-specific and usually done by the display hardware OEM.\n\nThe value of this approach is easy to recognize when you consider *overlay\nplanes*, which composite multiple buffers in\nthe display hardware rather than the GPU. For example, consider a typical\nAndroid phone in portrait orientation, with the status bar on top, navigation\nbar at the bottom, and app content everywhere else. The contents for each layer\nare in separate buffers. You can handle composition using either of the\nfollowing methods:\n\n- Rendering the app content into a scratch buffer, then rendering the status bar over it, the navigation bar on top of that, and finally passing the scratch buffer to the display hardware.\n- Passing all three buffers to the display hardware and instructing it to read data from different buffers for different parts of the screen.\n\nThe latter approach can be significantly more efficient.\n\nDisplay processor capabilities vary significantly. The number of overlays,\nwhether layers can be rotated or blended, and restrictions on positioning and\noverlap can be difficult to express through an API. To accommodate these options, the HWC performs\nfollowing calculations:\n\n1. SurfaceFlinger provides HWC with a full list of layers and asks, \"How do you want to handle this?\"\n2. HWC responds by marking each layer as device or client composition.\n3. SurfaceFlinger takes care of any client, passing the output buffer to HWC, and lets HWC handle the rest.\n\nBecause hardware vendors can custom tailor decision-making code, it's possible\nto get the best performance out of every device.\n\nOverlay planes may be less efficient than GL composition when nothing on the\nscreen is changing. This is particularly true when overlay contents have\ntransparent pixels and overlapping layers are blended. In such cases,\nthe HWC can request GLES composition for some or all layers and retain\nthe composited buffer. If SurfaceFlinger asks to composite the same\nset of buffers, the HWC can show the previously composited scratch\nbuffer. This can improve the battery life of an idle device.\n\nAndroid devices typically support four overlay planes.\nAttempting to composite more layers than overlays causes the system to use GLES\ncomposition for some of them, meaning the number of layers used by an app can\nhave a measurable impact on power consumption and performance."]]