Merge 888e8c73e6b2781bde41f327108f396100274d34 on remote branch
Change-Id: Ie42da717b30a3a485145cffa678ed52e03a9988b
diff --git a/services/surfaceflinger/Android.bp b/services/surfaceflinger/Android.bp
index 12484a1..13eeb85 100644
--- a/services/surfaceflinger/Android.bp
+++ b/services/surfaceflinger/Android.bp
@@ -69,7 +69,7 @@
],
shared_libs: [
"libbinder_ndk",
- "vendor.qti.hardware.display.config-V4-ndk_platform",
+ "vendor.qti.hardware.display.config-V5-ndk_platform",
],
}
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index ce8cd52..b7d174f 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -701,10 +701,15 @@
}
bool Layer::isScreenshot() const {
- return ((getName().find("ScreenshotSurface") != std::string::npos) ||
- (getName().find("RotationLayer") != std::string::npos) ||
- (getName().find("BackColorSurface") != std::string::npos));
+ return (isScreenshotName(getName()));
}
+
+bool Layer::isScreenshotName(std::string layer_name) {
+ return ((layer_name.find("ScreenshotSurface") != std::string::npos) ||
+ (layer_name.find("RotationLayer") != std::string::npos) ||
+ (layer_name.find("BackColorSurface") != std::string::npos));
+}
+
// ----------------------------------------------------------------------------
// transaction
// ----------------------------------------------------------------------------
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index 652b1a6..1e89f99 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -672,6 +672,7 @@
bool isSecureCamera() const;
bool isSecureDisplay() const;
bool isScreenshot() const;
+ static bool isScreenshotName(std::string layer_name);
/*
* isHiddenByPolicy - true if this layer has been forced invisible.
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 8f7d293..0848ac8 100755
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -199,6 +199,7 @@
using aidl::vendor::qti::hardware::display::config::BnDisplayConfigCallback;
using aidl::vendor::qti::hardware::display::config::Attributes;
using aidl::vendor::qti::hardware::display::config::CameraSmoothOp;
+using aidl::vendor::qti::hardware::display::config::Concurrency;
namespace hal = android::hardware::graphics::composer::hal;
@@ -340,6 +341,10 @@
mFlinger.NotifyResolutionSwitch(displayId, attr.xRes, attr.yRes, attr.vsyncPeriod);
return ndk::ScopedAStatus::ok();
}
+ virtual ndk::ScopedAStatus notifyFpsMitigation(int32_t displayId, const Attributes& attr,
+ Concurrency concurrency) {
+ return ndk::ScopedAStatus::ok();
+ }
private:
SurfaceFlinger& mFlinger;
};
@@ -1551,6 +1556,7 @@
mScheduler->setModeChangePending(true);
}
setContentFps(static_cast<uint32_t>(refreshRate.getFps().getValue()));
+ mUiLayerFrameCount = 0;
}
status_t SurfaceFlinger::setActiveMode(const sp<IBinder>& displayToken, int modeId) {
@@ -2899,13 +2905,17 @@
if (!IsDisplayExternalOrVirtual(displayDevice)) {
continue;
}
- uint32_t hwcDisplayId;
- getHwcDisplayId(displayDevice, &hwcDisplayId);
+ uint32_t hwcDisplayId = 0;
+ if (!getHwcDisplayId(displayDevice, &hwcDisplayId)) {
+ ALOGW("Rot-anim failed to get HWC DisplayID for display '%s'.",
+ displayDevice->getDebugName().c_str());
+ continue;
+ }
if (mDisplayConfigIntf && (hasScreenshot != mHasScreenshot)) {
mDisplayConfigIntf->SetDisplayAnimating(hwcDisplayId, hasScreenshot);
- mHasScreenshot = hasScreenshot;
}
}
+ mHasScreenshot = hasScreenshot;
#endif
}
@@ -3103,7 +3113,8 @@
mTransactionCallbackInvoker.addPresentFence(mPreviousPresentFences[0].fence);
mTransactionCallbackInvoker.sendCallbacks();
- if (display && display->isPrimary() && display->getPowerMode() == hal::PowerMode::ON &&
+ if (vSyncSource && vSyncSource == getCurrentVsyncSource() &&
+ vSyncSource->getPowerMode() == hal::PowerMode::ON &&
mPreviousPresentFences[0].fenceTime->isValid()) {
mScheduler->addPresentFence(mPreviousPresentFences[0].fenceTime);
}
@@ -3225,11 +3236,16 @@
int content_fps = mSmoMo->GetFrameRate();
bool is_valid_content_fps = false;
- if ((content_fps > 0) && (mLayersWithQueuedFrames.size() == 1)) {
- is_valid_content_fps = mSmomoContentFpsEnabled;
- mSmomoContentFpsEnabled = true;
+ if (content_fps > 0) {
+ if (mLayersWithQueuedFrames.size() > 1) {
+ mUiLayerFrameCount++;
+ } else {
+ mUiLayerFrameCount = 0;
+ }
+
+ is_valid_content_fps = (mUiLayerFrameCount < fps) ? true : false;
} else {
- mSmomoContentFpsEnabled = false;
+ mUiLayerFrameCount = 0;
}
setContentFps(is_valid_content_fps ? content_fps : fps);
@@ -3776,7 +3792,6 @@
}
mDisplays.erase(displayToken);
-
if (display && display->isVirtual()) {
static_cast<void>(schedule([display = std::move(display)] {
// Destroy the display without holding the mStateLock.
@@ -5396,6 +5411,35 @@
"Expected only one of parentLayer or parentHandle to be non-null. "
"Programmer error?");
+#ifdef QTI_DISPLAY_CONFIG_ENABLED
+ // Flag rotation animation as early as possible.
+ if (Layer::isScreenshotName(std::string(name))) {
+ // Rotation animation present.
+ bool signal_refresh = true;
+ Mutex::Autolock lock(mStateLock); // Needed for mDisplays and signalRefresh().
+ for (const auto& [token, displayDevice] : mDisplays) {
+ if (!IsDisplayExternalOrVirtual(displayDevice)) {
+ continue;
+ }
+ uint32_t hwcDisplayId = 0;
+ if (mDisplayConfigIntf && (true != mHasScreenshot)) {
+ if (!getHwcDisplayId(displayDevice, &hwcDisplayId)) {
+ ALOGW("Rot-anim failed to get HWC DisplayID for display '%s'.",
+ displayDevice->getDebugName().c_str());
+ continue;
+ }
+ mDisplayConfigIntf->SetDisplayAnimating(hwcDisplayId, true);
+ if (signal_refresh) {
+ // Request composition cycle once.
+ signalRefresh();
+ }
+ signal_refresh = false;
+ }
+ }
+ mHasScreenshot = true;
+ }
+#endif
+
status_t result = NO_ERROR;
sp<Layer> layer;
@@ -5873,6 +5917,8 @@
if (!lock.locked()) {
StringAppendF(&result, "Dumping without lock after timeout: %s (%d)\n",
strerror(-lock.status), lock.status);
+ ALOGW("Dumping without lock after timeout: %s (%d)",
+ strerror(-lock.status), lock.status);
}
if (const auto it = dumpers.find(flag); it != dumpers.end()) {
@@ -7760,6 +7806,16 @@
}).get();
}
+ // Surface flinger captures individual screen shot for each display
+ // This will lead consumption of high GPU secure memory in case
+ // of secure video use cases and cause out of memory.
+ {
+ Mutex::Autolock lock(mStateLock);
+ if(mDisplays.size() > 1) {
+ hasProtectedLayer = false;
+ }
+ }
+
const uint32_t usage = GRALLOC_USAGE_HW_COMPOSER | GRALLOC_USAGE_HW_RENDER |
GRALLOC_USAGE_HW_TEXTURE |
(hasProtectedLayer && allowProtected && supportsProtected
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 8db2463..6ad3142 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -1703,7 +1703,6 @@
bool mDynamicSfIdleEnabled = false;
bool wakeUpPresentationDisplays = false;
bool mInternalPresentationDisplays = false;
- bool mSmomoContentFpsEnabled = false;
composer::ComposerExtnIntf *mComposerExtnIntf = nullptr;
composer::FrameSchedulerIntf *mFrameSchedulerExtnIntf = nullptr;
@@ -1719,6 +1718,7 @@
int mRETid = 0;
int mSFTid = 0;
bool mTidSentSuccessfully = false;
+ int mUiLayerFrameCount = 0;
};
} // namespace android