Skip to content

Commit 5541f12

Browse files
committed
Add API to retrieve max layer picture profiles
Bug: 337330263 Test: atest SurfaceControlPictureProfileTest Flag: com.android.graphics.libgui.flags.apply_picture_profiles Change-Id: Idcfc3acd2e9eb89dd72baf0270d5d2a003d1f996
1 parent f5fdff8 commit 5541f12

6 files changed

Lines changed: 58 additions & 0 deletions

File tree

libs/gui/SurfaceComposerClient.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3056,6 +3056,14 @@ void SurfaceComposerClient::setDisplayPowerMode(const sp<IBinder>& token,
30563056
ComposerServiceAIDL::getComposerService()->setPowerMode(token, mode);
30573057
}
30583058

3059+
status_t SurfaceComposerClient::getMaxLayerPictureProfiles(const sp<IBinder>& token,
3060+
int32_t* outMaxProfiles) {
3061+
binder::Status status =
3062+
ComposerServiceAIDL::getComposerService()->getMaxLayerPictureProfiles(token,
3063+
outMaxProfiles);
3064+
return statusTFromBinderStatus(status);
3065+
}
3066+
30593067
status_t SurfaceComposerClient::getCompositionPreference(
30603068
ui::Dataspace* defaultDataspace, ui::PixelFormat* defaultPixelFormat,
30613069
ui::Dataspace* wideColorGamutDataspace, ui::PixelFormat* wideColorGamutPixelFormat) {

libs/gui/aidl/android/gui/ISurfaceComposer.aidl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,11 @@ interface ISurfaceComposer {
228228
*/
229229
void setGameContentType(IBinder display, boolean on);
230230

231+
/**
232+
* Gets the maximum number of picture profiles supported by the display.
233+
*/
234+
int getMaxLayerPictureProfiles(IBinder display);
235+
231236
/**
232237
* Capture the specified screen. This requires READ_FRAME_BUFFER
233238
* permission. This function will fail if there is a secure window on

libs/gui/include/gui/SurfaceComposerClient.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,15 @@ class SurfaceComposerClient : public RefBase
345345

346346
static bool flagEdgeExtensionEffectUseShader();
347347

348+
/**
349+
* Returns how many picture profiles are supported by the display.
350+
*
351+
* displayToken
352+
* The token of the display.
353+
*/
354+
static status_t getMaxLayerPictureProfiles(const sp<IBinder>& displayToken,
355+
int32_t* outMaxProfiles);
356+
348357
// ------------------------------------------------------------------------
349358
// surface creation / destruction
350359

libs/gui/tests/Surface_test.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,6 +1020,11 @@ class FakeSurfaceComposerAIDL : public gui::ISurfaceComposer {
10201020
return binder::Status::ok();
10211021
}
10221022

1023+
binder::Status getMaxLayerPictureProfiles(const sp<IBinder>& /*display*/,
1024+
int32_t* /*outMaxProfiles*/) {
1025+
return binder::Status::ok();
1026+
}
1027+
10231028
protected:
10241029
IBinder* onAsBinder() override { return nullptr; }
10251030

services/surfaceflinger/SurfaceFlinger.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1840,6 +1840,24 @@ void SurfaceFlinger::setGameContentType(const sp<IBinder>& displayToken, bool on
18401840
}));
18411841
}
18421842

1843+
status_t SurfaceFlinger::getMaxLayerPictureProfiles(const sp<IBinder>& displayToken,
1844+
int32_t* outMaxProfiles) {
1845+
const char* const whence = __func__;
1846+
auto future = mScheduler->schedule([=, this]() FTL_FAKE_GUARD(mStateLock) {
1847+
const ssize_t index = mCurrentState.displays.indexOfKey(displayToken);
1848+
if (index < 0) {
1849+
ALOGE("%s: Invalid display token %p", whence, displayToken.get());
1850+
return 0;
1851+
}
1852+
const DisplayDeviceState& state = mCurrentState.displays.valueAt(index);
1853+
return state.maxLayerPictureProfiles > 0 ? state.maxLayerPictureProfiles
1854+
: state.hasPictureProcessing ? 1
1855+
: 0;
1856+
});
1857+
*outMaxProfiles = future.get();
1858+
return NO_ERROR;
1859+
}
1860+
18431861
status_t SurfaceFlinger::overrideHdrTypes(const sp<IBinder>& displayToken,
18441862
const std::vector<ui::Hdr>& hdrTypes) {
18451863
Mutex::Autolock lock(mStateLock);
@@ -8759,6 +8777,16 @@ binder::Status SurfaceComposerAIDL::setGameContentType(const sp<IBinder>& displa
87598777
return binder::Status::ok();
87608778
}
87618779

8780+
binder::Status SurfaceComposerAIDL::getMaxLayerPictureProfiles(const sp<IBinder>& display,
8781+
int32_t* outMaxProfiles) {
8782+
status_t status = checkAccessPermission();
8783+
if (status != OK) {
8784+
return binderStatusFromStatusT(status);
8785+
}
8786+
mFlinger->getMaxLayerPictureProfiles(display, outMaxProfiles);
8787+
return binder::Status::ok();
8788+
}
8789+
87628790
binder::Status SurfaceComposerAIDL::captureDisplay(
87638791
const DisplayCaptureArgs& args, const sp<IScreenCaptureListener>& captureListener) {
87648792
mFlinger->captureDisplay(args, captureListener);

services/surfaceflinger/SurfaceFlinger.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,7 @@ class SurfaceFlinger : public BnSurfaceComposer,
596596
status_t getHdrOutputConversionSupport(bool* outSupport) const;
597597
void setAutoLowLatencyMode(const sp<IBinder>& displayToken, bool on);
598598
void setGameContentType(const sp<IBinder>& displayToken, bool on);
599+
status_t getMaxLayerPictureProfiles(const sp<IBinder>& displayToken, int32_t* outMaxProfiles);
599600
void setPowerMode(const sp<IBinder>& displayToken, int mode);
600601
status_t overrideHdrTypes(const sp<IBinder>& displayToken,
601602
const std::vector<ui::Hdr>& hdrTypes);
@@ -1533,6 +1534,8 @@ class SurfaceComposerAIDL : public gui::BnSurfaceComposer {
15331534
binder::Status getHdrOutputConversionSupport(bool* outSupport) override;
15341535
binder::Status setAutoLowLatencyMode(const sp<IBinder>& display, bool on) override;
15351536
binder::Status setGameContentType(const sp<IBinder>& display, bool on) override;
1537+
binder::Status getMaxLayerPictureProfiles(const sp<IBinder>& display,
1538+
int32_t* outMaxProfiles) override;
15361539
binder::Status captureDisplay(const DisplayCaptureArgs&,
15371540
const sp<IScreenCaptureListener>&) override;
15381541
binder::Status captureDisplayById(int64_t, const CaptureArgs&,

0 commit comments

Comments
 (0)