Skip to content

Commit 1a4ffd8

Browse files
committed
Compose a layer with a picture profile passed in by an app
Forwards the picture profile to Composer HAL during composition. The priority of a layer's profile, passed in by an app, plays a role in deciding which requested profile actually get sent to Composer HAL when limited picture processing hardware resources come into play. Bug: 337330263 Test: atest OutputLayerWriteStateToHWCTest Test: atest OutputUpdateAndWriteCompositionStateTest Flag: com.android.graphics.libgui.flags.apply_picture_profiles Change-Id: I396d4928c46002844df3c707421974f30cb8d98b
1 parent 2c6de79 commit 1a4ffd8

19 files changed

Lines changed: 447 additions & 46 deletions

services/surfaceflinger/CompositionEngine/Android.bp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ cc_defaults {
4242
"libutils",
4343
],
4444
static_libs: [
45+
"libguiflags",
4546
"libmath",
4647
"librenderengine",
4748
"libtimestats",

services/surfaceflinger/CompositionEngine/include/compositionengine/DisplayCreationArgs.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ struct DisplayCreationArgs {
4646
// content.
4747
bool isProtected = false;
4848

49+
// True if this display has picture processing hardware and pipelines.
50+
bool hasPictureProcessing = false;
51+
52+
// The number of layer-specific picture-processing pipelines.
53+
int32_t maxLayerPictureProfiles = 0;
54+
4955
// Optional pointer to the power advisor interface, if one is needed for
5056
// this display.
5157
adpf::PowerAdvisor* powerAdvisor = nullptr;
@@ -82,6 +88,16 @@ class DisplayCreationArgsBuilder {
8288
return *this;
8389
}
8490

91+
DisplayCreationArgsBuilder& setHasPictureProcessing(bool hasPictureProcessing) {
92+
mArgs.hasPictureProcessing = hasPictureProcessing;
93+
return *this;
94+
}
95+
96+
DisplayCreationArgsBuilder& setMaxLayerPictureProfiles(int32_t maxLayerPictureProfiles) {
97+
mArgs.maxLayerPictureProfiles = maxLayerPictureProfiles;
98+
return *this;
99+
}
100+
85101
DisplayCreationArgsBuilder& setPowerAdvisor(adpf::PowerAdvisor* powerAdvisor) {
86102
mArgs.powerAdvisor = powerAdvisor;
87103
return *this;

services/surfaceflinger/CompositionEngine/include/compositionengine/LayerFECompositionState.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <ui/BlurRegion.h>
2626
#include <ui/FloatRect.h>
2727
#include <ui/LayerStack.h>
28+
#include <ui/PictureProfileHandle.h>
2829
#include <ui/Rect.h>
2930
#include <ui/Region.h>
3031
#include <ui/ShadowSettings.h>
@@ -219,6 +220,14 @@ struct LayerFECompositionState {
219220
float currentHdrSdrRatio = 1.f;
220221
float desiredHdrSdrRatio = 1.f;
221222

223+
// A picture profile handle refers to a PictureProfile configured on the display, which is a
224+
// set of parameters that configures the picture processing hardware that is used to enhance
225+
// the quality of buffer contents.
226+
PictureProfileHandle pictureProfileHandle{PictureProfileHandle::NONE};
227+
228+
// A layer's priority in terms of limited picture processing pipeline utilization.
229+
int64_t pictureProfilePriority;
230+
222231
gui::CachingHint cachingHint = gui::CachingHint::Enabled;
223232

224233
std::shared_ptr<gui::DisplayLuts> luts;

services/surfaceflinger/CompositionEngine/include/compositionengine/Output.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
#pragma once
1818

19+
#include <ftl/future.h>
20+
#include <ftl/optional.h>
1921
#include <cstdint>
2022
#include <iterator>
2123
#include <optional>
@@ -26,18 +28,18 @@
2628
#include <vector>
2729

2830
#include <compositionengine/LayerFE.h>
29-
#include <ftl/future.h>
3031
#include <renderengine/LayerSettings.h>
32+
#include <ui/DisplayIdentification.h>
3133
#include <ui/Fence.h>
3234
#include <ui/FenceTime.h>
3335
#include <ui/GraphicTypes.h>
3436
#include <ui/LayerStack.h>
37+
#include <ui/PictureProfileHandle.h>
3538
#include <ui/Region.h>
3639
#include <ui/Transform.h>
3740
#include <utils/StrongPointer.h>
3841
#include <utils/Vector.h>
3942

40-
#include <ui/DisplayIdentification.h>
4143
#include "DisplayHardware/HWComposer.h"
4244

4345
namespace android {
@@ -167,7 +169,7 @@ class Output {
167169
virtual bool isValid() const = 0;
168170

169171
// Returns the DisplayId the output represents, if it has one
170-
virtual std::optional<DisplayId> getDisplayId() const = 0;
172+
virtual ftl::Optional<DisplayId> getDisplayId() const = 0;
171173

172174
// Enables (or disables) composition on this output
173175
virtual void setCompositionEnabled(bool) = 0;
@@ -331,6 +333,9 @@ class Output {
331333
virtual bool canPredictCompositionStrategy(const CompositionRefreshArgs&) = 0;
332334
virtual const aidl::android::hardware::graphics::composer3::OverlayProperties*
333335
getOverlaySupport() = 0;
336+
virtual bool hasPictureProcessing() const = 0;
337+
virtual int32_t getMaxLayerPictureProfiles() const = 0;
338+
virtual void applyPictureProfile() = 0;
334339
};
335340

336341
} // namespace compositionengine

services/surfaceflinger/CompositionEngine/include/compositionengine/OutputLayer.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <string>
2222
#include <vector>
2323

24+
#include <ui/PictureProfileHandle.h>
2425
#include <ui/Transform.h>
2526
#include <utils/StrongPointer.h>
2627

@@ -86,6 +87,16 @@ class OutputLayer {
8687
// longer cares about.
8788
virtual void uncacheBuffers(const std::vector<uint64_t>& bufferIdsToUncache) = 0;
8889

90+
// Get the relative priority of the layer's picture profile with respect to the importance of
91+
// the visual content to the user experience. Lower is higher priority.
92+
virtual int64_t getPictureProfilePriority() const = 0;
93+
94+
// The picture profile handle for the layer.
95+
virtual const PictureProfileHandle& getPictureProfileHandle() const = 0;
96+
97+
// Commit the picture profile to the composition state.
98+
virtual void commitPictureProfileToCompositionState() = 0;
99+
89100
// Recalculates the state of the output layer from the output-independent
90101
// layer. If includeGeometry is false, the geometry state can be skipped.
91102
// internalDisplayRotationFlags must be set to the rotation flags for the

services/surfaceflinger/CompositionEngine/include/compositionengine/impl/Display.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class Display : public compositionengine::impl::Output, public virtual compositi
4545
virtual ~Display();
4646

4747
// compositionengine::Output overrides
48-
std::optional<DisplayId> getDisplayId() const override;
48+
ftl::Optional<DisplayId> getDisplayId() const override;
4949
bool isValid() const override;
5050
void dump(std::string&) const override;
5151
using compositionengine::impl::Output::setReleasedLayers;
@@ -100,11 +100,16 @@ class Display : public compositionengine::impl::Output, public virtual compositi
100100
void setHintSessionGpuStart(TimePoint startTime) override;
101101
void setHintSessionGpuFence(std::unique_ptr<FenceTime>&& gpuFence) override;
102102
void setHintSessionRequiresRenderEngine(bool requiresRenderEngine) override;
103+
const aidl::android::hardware::graphics::composer3::OverlayProperties* getOverlaySupport()
104+
override;
105+
bool hasPictureProcessing() const override;
106+
int32_t getMaxLayerPictureProfiles() const override;
107+
103108
DisplayId mId;
104109
bool mIsDisconnected = false;
105110
adpf::PowerAdvisor* mPowerAdvisor = nullptr;
106-
const aidl::android::hardware::graphics::composer3::OverlayProperties* getOverlaySupport()
107-
override;
111+
bool mHasPictureProcessing = false;
112+
int32_t mMaxLayerPictureProfiles = 0;
108113
};
109114

110115
// This template factory function standardizes the implementation details of the

services/surfaceflinger/CompositionEngine/include/compositionengine/impl/Output.h

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616

1717
#pragma once
1818

19+
#include <ftl/optional.h>
20+
#include <memory>
21+
#include <utility>
22+
#include <vector>
23+
1924
#include <compositionengine/CompositionEngine.h>
2025
#include <compositionengine/LayerFECompositionState.h>
2126
#include <compositionengine/Output.h>
@@ -28,10 +33,6 @@
2833
#include <renderengine/DisplaySettings.h>
2934
#include <renderengine/LayerSettings.h>
3035

31-
#include <memory>
32-
#include <utility>
33-
#include <vector>
34-
3536
namespace android::compositionengine::impl {
3637

3738
// The implementation class contains the common implementation, but does not
@@ -43,7 +44,7 @@ class Output : public virtual compositionengine::Output {
4344

4445
// compositionengine::Output overrides
4546
bool isValid() const override;
46-
std::optional<DisplayId> getDisplayId() const override;
47+
ftl::Optional<DisplayId> getDisplayId() const override;
4748
void setCompositionEnabled(bool) override;
4849
void setLayerCachingEnabled(bool) override;
4950
void setLayerCachingTexturePoolEnabled(bool) override;
@@ -84,13 +85,14 @@ class Output : public virtual compositionengine::Output {
8485
bool supportsOffloadPresent() const override { return false; }
8586
void offloadPresentNextFrame() override;
8687

87-
void uncacheBuffers(const std::vector<uint64_t>& bufferIdsToUncache) override;
8888
void rebuildLayerStacks(const CompositionRefreshArgs&, LayerFESet&) override;
8989
void collectVisibleLayers(const CompositionRefreshArgs&,
9090
compositionengine::Output::CoverageState&) override;
9191
void ensureOutputLayerIfVisible(sp<compositionengine::LayerFE>&,
9292
compositionengine::Output::CoverageState&) override;
9393
void setReleasedLayers(const compositionengine::CompositionRefreshArgs&) override;
94+
void uncacheBuffers(const std::vector<uint64_t>& bufferIdsToUncache) override;
95+
void commitPictureProfilesToCompositionState();
9496

9597
void updateCompositionState(const compositionengine::CompositionRefreshArgs&) override;
9698
void planComposition() override;
@@ -151,6 +153,9 @@ class Output : public virtual compositionengine::Output {
151153
void setHintSessionRequiresRenderEngine(bool requiresRenderEngine) override;
152154
bool isPowerHintSessionEnabled() override;
153155
bool isPowerHintSessionGpuReportingEnabled() override;
156+
bool hasPictureProcessing() const override;
157+
int32_t getMaxLayerPictureProfiles() const override;
158+
void applyPictureProfile() override;
154159
void dumpBase(std::string&) const;
155160

156161
// Implemented by the final implementation for the final state it uses.

services/surfaceflinger/CompositionEngine/include/compositionengine/impl/OutputCompositionState.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include <compositionengine/CompositionRefreshArgs.h>
3636
#include <compositionengine/ProjectionSpace.h>
3737
#include <ui/LayerStack.h>
38+
#include <ui/PictureProfileHandle.h>
3839
#include <ui/Rect.h>
3940
#include <ui/Region.h>
4041
#include <ui/Transform.h>
@@ -170,6 +171,8 @@ struct OutputCompositionState {
170171

171172
ICEPowerCallback* powerCallback = nullptr;
172173

174+
PictureProfileHandle pictureProfileHandle;
175+
173176
// Debugging
174177
void dump(std::string& result) const;
175178
};

services/surfaceflinger/CompositionEngine/include/compositionengine/impl/OutputLayer.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <compositionengine/LayerFE.h>
2626
#include <compositionengine/OutputLayer.h>
2727
#include <ui/FloatRect.h>
28+
#include <ui/PictureProfileHandle.h>
2829
#include <ui/Rect.h>
2930

3031
#include <ui/DisplayIdentification.h>
@@ -48,6 +49,9 @@ class OutputLayer : public virtual compositionengine::OutputLayer {
4849
void setHwcLayer(std::shared_ptr<HWC2::Layer>) override;
4950

5051
void uncacheBuffers(const std::vector<uint64_t>& bufferIdsToUncache) override;
52+
int64_t getPictureProfilePriority() const override;
53+
const PictureProfileHandle& getPictureProfileHandle() const override;
54+
void commitPictureProfileToCompositionState() override;
5155

5256
void updateCompositionState(bool includeGeometry, bool forceClientComposition,
5357
ui::Transform::RotationFlags,

services/surfaceflinger/CompositionEngine/include/compositionengine/impl/OutputLayerCompositionState.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <renderengine/ExternalTexture.h>
2323
#include <ui/FloatRect.h>
2424
#include <ui/GraphicTypes.h>
25+
#include <ui/PictureProfileHandle.h>
2526
#include <ui/Rect.h>
2627
#include <ui/Region.h>
2728

@@ -101,6 +102,9 @@ struct OutputLayerCompositionState {
101102
// order to save power.
102103
Region outputSpaceBlockingRegionHint;
103104

105+
// The picture profile for this layer.
106+
PictureProfileHandle pictureProfileHandle;
107+
104108
// Overrides the buffer, acquire fence, and display frame stored in LayerFECompositionState
105109
struct {
106110
std::shared_ptr<renderengine::ExternalTexture> buffer = nullptr;

0 commit comments

Comments
 (0)