Merge "Only check noteOp in SensorService if AppOp >= 0" into qt-dev
diff --git a/libs/gui/ISurfaceComposer.cpp b/libs/gui/ISurfaceComposer.cpp
index 4372e16..6c9d81a 100644
--- a/libs/gui/ISurfaceComposer.cpp
+++ b/libs/gui/ISurfaceComposer.cpp
@@ -955,6 +955,27 @@
}
return NO_ERROR;
}
+
+ virtual status_t notifyPowerHint(int32_t hintId) {
+ Parcel data, reply;
+ status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
+ if (error != NO_ERROR) {
+ ALOGE("notifyPowerHint: failed to write interface token: %d", error);
+ return error;
+ }
+ error = data.writeInt32(hintId);
+ if (error != NO_ERROR) {
+ ALOGE("notifyPowerHint: failed to write hintId: %d", error);
+ return error;
+ }
+ error = remote()->transact(BnSurfaceComposer::NOTIFY_POWER_HINT, data, &reply,
+ IBinder::FLAG_ONEWAY);
+ if (error != NO_ERROR) {
+ ALOGE("notifyPowerHint: failed to transact: %d", error);
+ return error;
+ }
+ return NO_ERROR;
+ }
};
// Out-of-line virtual method definition to trigger vtable emission in this
@@ -1556,6 +1577,16 @@
}
return setDisplayBrightness(displayToken, brightness);
}
+ case NOTIFY_POWER_HINT: {
+ CHECK_INTERFACE(ISurfaceComposer, data, reply);
+ int32_t hintId;
+ status_t error = data.readInt32(&hintId);
+ if (error != NO_ERROR) {
+ ALOGE("notifyPowerHint: failed to read hintId: %d", error);
+ return error;
+ }
+ return notifyPowerHint(hintId);
+ }
default: {
return BBinder::onTransact(code, data, reply, flags);
}
diff --git a/libs/gui/LayerState.cpp b/libs/gui/LayerState.cpp
index 075bb52..6066421 100644
--- a/libs/gui/LayerState.cpp
+++ b/libs/gui/LayerState.cpp
@@ -245,6 +245,7 @@
}
if (other.what & eLayerChanged) {
what |= eLayerChanged;
+ what &= ~eRelativeLayerChanged;
z = other.z;
}
if (other.what & eSizeChanged) {
@@ -303,6 +304,7 @@
}
if (other.what & eRelativeLayerChanged) {
what |= eRelativeLayerChanged;
+ what &= ~eLayerChanged;
z = other.z;
relativeLayerHandle = other.relativeLayerHandle;
}
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index 5d4367d..d6f88fc 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -611,6 +611,7 @@
return *this;
}
s->what |= layer_state_t::eLayerChanged;
+ s->what &= ~layer_state_t::eRelativeLayerChanged;
s->z = z;
registerSurfaceControlForCallback(sc);
@@ -624,6 +625,7 @@
mStatus = BAD_INDEX;
}
s->what |= layer_state_t::eRelativeLayerChanged;
+ s->what &= ~layer_state_t::eLayerChanged;
s->relativeLayerHandle = relativeTo;
s->z = z;
@@ -1543,6 +1545,10 @@
return ComposerService::getComposerService()->setDisplayBrightness(displayToken, brightness);
}
+status_t SurfaceComposerClient::notifyPowerHint(int32_t hintId) {
+ return ComposerService::getComposerService()->notifyPowerHint(hintId);
+}
+
// ----------------------------------------------------------------------------
status_t ScreenshotClient::capture(const sp<IBinder>& display, const ui::Dataspace reqDataSpace,
diff --git a/libs/gui/include/gui/ISurfaceComposer.h b/libs/gui/include/gui/ISurfaceComposer.h
index fd67754..e2f7736 100644
--- a/libs/gui/include/gui/ISurfaceComposer.h
+++ b/libs/gui/include/gui/ISurfaceComposer.h
@@ -425,6 +425,16 @@
*/
virtual status_t setDisplayBrightness(const sp<IBinder>& displayToken,
float brightness) const = 0;
+
+ /*
+ * Sends a power hint to the composer. This function is asynchronous.
+ *
+ * hintId
+ * hint id according to android::hardware::power::V1_0::PowerHint
+ *
+ * Returns NO_ERROR upon success.
+ */
+ virtual status_t notifyPowerHint(int32_t hintId) = 0;
};
// ----------------------------------------------------------------------------
@@ -477,6 +487,7 @@
GET_DISPLAY_BRIGHTNESS_SUPPORT,
SET_DISPLAY_BRIGHTNESS,
CAPTURE_SCREEN_BY_ID,
+ NOTIFY_POWER_HINT,
// Always append new enum to the end.
};
diff --git a/libs/gui/include/gui/SurfaceComposerClient.h b/libs/gui/include/gui/SurfaceComposerClient.h
index a038838..0e17c7b 100644
--- a/libs/gui/include/gui/SurfaceComposerClient.h
+++ b/libs/gui/include/gui/SurfaceComposerClient.h
@@ -201,6 +201,16 @@
*/
static status_t setDisplayBrightness(const sp<IBinder>& displayToken, float brightness);
+ /*
+ * Sends a power hint to the composer. This function is asynchronous.
+ *
+ * hintId
+ * hint id according to android::hardware::power::V1_0::PowerHint
+ *
+ * Returns NO_ERROR upon success.
+ */
+ static status_t notifyPowerHint(int32_t hintId);
+
// ------------------------------------------------------------------------
// surface creation / destruction
diff --git a/libs/gui/tests/Surface_test.cpp b/libs/gui/tests/Surface_test.cpp
index db97fae..960cf18 100644
--- a/libs/gui/tests/Surface_test.cpp
+++ b/libs/gui/tests/Surface_test.cpp
@@ -704,6 +704,7 @@
std::vector<int32_t>* /*outAllowedConfigs*/) override {
return NO_ERROR;
}
+ status_t notifyPowerHint(int32_t /*hintId*/) override { return NO_ERROR; }
protected:
IBinder* onAsBinder() override { return nullptr; }
diff --git a/libs/ui/FenceTime.cpp b/libs/ui/FenceTime.cpp
index 340231d..bdfe04b 100644
--- a/libs/ui/FenceTime.cpp
+++ b/libs/ui/FenceTime.cpp
@@ -279,8 +279,8 @@
}
void FenceTimeline::updateSignalTimes() {
+ std::lock_guard<std::mutex> lock(mMutex);
while (!mQueue.empty()) {
- std::lock_guard<std::mutex> lock(mMutex);
std::shared_ptr<FenceTime> fence = mQueue.front().lock();
if (!fence) {
// The shared_ptr no longer exists and no one cares about the
diff --git a/libs/ui/include/ui/FenceTime.h b/libs/ui/include/ui/FenceTime.h
index a5a1fcb..ecba7f7 100644
--- a/libs/ui/include/ui/FenceTime.h
+++ b/libs/ui/include/ui/FenceTime.h
@@ -19,6 +19,7 @@
#include <ui/Fence.h>
#include <utils/Flattenable.h>
+#include <utils/Mutex.h>
#include <utils/Timers.h>
#include <atomic>
@@ -159,7 +160,7 @@
private:
mutable std::mutex mMutex;
- std::queue<std::weak_ptr<FenceTime>> mQueue;
+ std::queue<std::weak_ptr<FenceTime>> mQueue GUARDED_BY(mMutex);
};
// Used by test code to create or get FenceTimes for a given Fence.
diff --git a/services/surfaceflinger/BufferLayer.cpp b/services/surfaceflinger/BufferLayer.cpp
index 06caf1e..a2b6ab6 100644
--- a/services/surfaceflinger/BufferLayer.cpp
+++ b/services/surfaceflinger/BufferLayer.cpp
@@ -97,8 +97,11 @@
}
bool BufferLayer::isVisible() const {
- return !(isHiddenByPolicy()) && getAlpha() > 0.0f &&
+ bool visible = !(isHiddenByPolicy()) && getAlpha() > 0.0f &&
(mActiveBuffer != nullptr || mSidebandStream != nullptr);
+ mFlinger->mScheduler->setLayerVisibility(mSchedulerLayerHandle, visible);
+
+ return visible;
}
bool BufferLayer::isFixedSize() const {
@@ -427,7 +430,7 @@
sp<GraphicBuffer> oldBuffer = mActiveBuffer;
if (!allTransactionsSignaled()) {
- mFlinger->signalLayerUpdate();
+ mFlinger->setTransactionFlags(eTraversalNeeded);
return false;
}
diff --git a/services/surfaceflinger/BufferQueueLayer.cpp b/services/surfaceflinger/BufferQueueLayer.cpp
index 3d51ec3..bd0b55f 100644
--- a/services/surfaceflinger/BufferQueueLayer.cpp
+++ b/services/surfaceflinger/BufferQueueLayer.cpp
@@ -443,7 +443,8 @@
{ // Autolock scope
if (mFlinger->mUseSmart90ForVideo) {
const nsecs_t presentTime = item.mIsAutoTimestamp ? 0 : item.mTimestamp;
- mFlinger->mScheduler->addLayerPresentTime(mSchedulerLayerHandle, presentTime);
+ mFlinger->mScheduler->addLayerPresentTimeAndHDR(mSchedulerLayerHandle, presentTime,
+ item.mHdrMetadata.validTypes != 0);
}
Mutex::Autolock lock(mQueueItemLock);
diff --git a/services/surfaceflinger/BufferStateLayer.cpp b/services/surfaceflinger/BufferStateLayer.cpp
index a740afb..05c721f 100644
--- a/services/surfaceflinger/BufferStateLayer.cpp
+++ b/services/surfaceflinger/BufferStateLayer.cpp
@@ -227,7 +227,8 @@
if (mFlinger->mUseSmart90ForVideo) {
const nsecs_t presentTime = (mDesiredPresentTime == -1) ? 0 : mDesiredPresentTime;
- mFlinger->mScheduler->addLayerPresentTime(mSchedulerLayerHandle, presentTime);
+ mFlinger->mScheduler->addLayerPresentTimeAndHDR(mSchedulerLayerHandle, presentTime,
+ mCurrentState.hdrMetadata.validTypes != 0);
}
return true;
diff --git a/services/surfaceflinger/Scheduler/DispSync.cpp b/services/surfaceflinger/Scheduler/DispSync.cpp
index abf7b71..cd6fa41 100644
--- a/services/surfaceflinger/Scheduler/DispSync.cpp
+++ b/services/surfaceflinger/Scheduler/DispSync.cpp
@@ -64,6 +64,7 @@
DispSyncThread(const char* name, bool showTraceDetailedInfo)
: mName(name),
mStop(false),
+ mModelLocked(false),
mPeriod(0),
mPhase(0),
mReferenceTime(0),
@@ -78,6 +79,11 @@
Mutex::Autolock lock(mMutex);
mPhase = phase;
+ if (mReferenceTime != referenceTime) {
+ for (auto& eventListener : mEventListeners) {
+ eventListener.mHasFired = false;
+ }
+ }
mReferenceTime = referenceTime;
if (mPeriod != 0 && mPeriod != period && mReferenceTime != 0) {
// Inflate the reference time to be the most recent predicted
@@ -106,6 +112,16 @@
mCond.signal();
}
+ void lockModel() {
+ Mutex::Autolock lock(mMutex);
+ mModelLocked = true;
+ }
+
+ void unlockModel() {
+ Mutex::Autolock lock(mMutex);
+ mModelLocked = false;
+ }
+
virtual bool threadLoop() {
status_t err;
nsecs_t now = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -288,6 +304,7 @@
nsecs_t mLastEventTime;
nsecs_t mLastCallbackTime;
DispSync::Callback* mCallback;
+ bool mHasFired = false;
};
struct CallbackInvocation {
@@ -335,6 +352,12 @@
eventListener.mName);
continue;
}
+ if (eventListener.mHasFired && !mModelLocked) {
+ eventListener.mLastEventTime = t;
+ ALOGV("[%s] [%s] Skipping event due to already firing", mName,
+ eventListener.mName);
+ continue;
+ }
CallbackInvocation ci;
ci.mCallback = eventListener.mCallback;
ci.mEventTime = t;
@@ -343,6 +366,7 @@
callbackInvocations.push_back(ci);
eventListener.mLastEventTime = t;
eventListener.mLastCallbackTime = now;
+ eventListener.mHasFired = true;
}
}
@@ -410,6 +434,7 @@
const char* const mName;
bool mStop;
+ bool mModelLocked;
nsecs_t mPeriod;
nsecs_t mPhase;
@@ -497,6 +522,7 @@
mNumResyncSamples = 0;
mFirstResyncSample = 0;
mNumResyncSamplesSincePresent = 0;
+ mThread->unlockModel();
resetErrorLocked();
}
@@ -519,6 +545,7 @@
void DispSync::beginResync() {
Mutex::Autolock lock(mMutex);
ALOGV("[%s] beginResync", mName);
+ mThread->unlockModel();
mModelUpdated = false;
mNumResyncSamples = 0;
}
@@ -581,10 +608,15 @@
// resync again
bool modelLocked = mModelUpdated && mError < (kErrorThreshold / 2) && mPendingPeriod == 0;
ALOGV("[%s] addResyncSample returning %s", mName, modelLocked ? "locked" : "unlocked");
+ if (modelLocked) {
+ mThread->lockModel();
+ }
return !modelLocked;
}
-void DispSync::endResync() {}
+void DispSync::endResync() {
+ mThread->lockModel();
+}
status_t DispSync::addEventListener(const char* name, nsecs_t phase, Callback* callback,
nsecs_t lastCallbackTime) {
diff --git a/services/surfaceflinger/Scheduler/EventThread.cpp b/services/surfaceflinger/Scheduler/EventThread.cpp
index a6c7e6c..05bad4d 100644
--- a/services/surfaceflinger/Scheduler/EventThread.cpp
+++ b/services/surfaceflinger/Scheduler/EventThread.cpp
@@ -107,10 +107,8 @@
} // namespace
EventThreadConnection::EventThreadConnection(EventThread* eventThread,
- ResyncCallback resyncCallback,
- ResetIdleTimerCallback resetIdleTimerCallback)
+ ResyncCallback resyncCallback)
: resyncCallback(std::move(resyncCallback)),
- resetIdleTimerCallback(std::move(resetIdleTimerCallback)),
mEventThread(eventThread),
mChannel(gui::BitTube::DefaultSize) {}
@@ -136,12 +134,7 @@
void EventThreadConnection::requestNextVsync() {
ATRACE_NAME("requestNextVsync");
- mEventThread->requestNextVsync(this, true);
-}
-
-void EventThreadConnection::requestNextVsyncForHWC() {
- ATRACE_NAME("requestNextVsyncForHWC");
- mEventThread->requestNextVsync(this, false);
+ mEventThread->requestNextVsync(this);
}
status_t EventThreadConnection::postEvent(const DisplayEventReceiver::Event& event) {
@@ -210,10 +203,8 @@
mVSyncSource->setPhaseOffset(phaseOffset);
}
-sp<EventThreadConnection> EventThread::createEventConnection(
- ResyncCallback resyncCallback, ResetIdleTimerCallback resetIdleTimerCallback) const {
- return new EventThreadConnection(const_cast<EventThread*>(this), std::move(resyncCallback),
- std::move(resetIdleTimerCallback));
+sp<EventThreadConnection> EventThread::createEventConnection(ResyncCallback resyncCallback) const {
+ return new EventThreadConnection(const_cast<EventThread*>(this), std::move(resyncCallback));
}
status_t EventThread::registerDisplayEventConnection(const sp<EventThreadConnection>& connection) {
@@ -255,12 +246,7 @@
}
}
-void EventThread::requestNextVsync(const sp<EventThreadConnection>& connection, bool reset) {
- if (connection->resetIdleTimerCallback && reset) {
- ATRACE_NAME("resetIdleTimer");
- connection->resetIdleTimerCallback();
- }
-
+void EventThread::requestNextVsync(const sp<EventThreadConnection>& connection) {
if (connection->resyncCallback) {
connection->resyncCallback();
}
diff --git a/services/surfaceflinger/Scheduler/EventThread.h b/services/surfaceflinger/Scheduler/EventThread.h
index 7107d63..61530c6 100644
--- a/services/surfaceflinger/Scheduler/EventThread.h
+++ b/services/surfaceflinger/Scheduler/EventThread.h
@@ -45,7 +45,6 @@
// ---------------------------------------------------------------------------
using ResyncCallback = std::function<void()>;
-using ResetIdleTimerCallback = std::function<void()>;
enum class VSyncRequest {
None = -1,
@@ -70,7 +69,7 @@
class EventThreadConnection : public BnDisplayEventConnection {
public:
- EventThreadConnection(EventThread*, ResyncCallback, ResetIdleTimerCallback);
+ EventThreadConnection(EventThread*, ResyncCallback);
virtual ~EventThreadConnection();
virtual status_t postEvent(const DisplayEventReceiver::Event& event);
@@ -78,13 +77,9 @@
status_t stealReceiveChannel(gui::BitTube* outChannel) override;
status_t setVsyncRate(uint32_t rate) override;
void requestNextVsync() override; // asynchronous
- // Requesting Vsync for HWC does not reset the idle timer, since HWC requires a refresh
- // in order to update the configs.
- void requestNextVsyncForHWC();
// Called in response to requestNextVsync.
const ResyncCallback resyncCallback;
- const ResetIdleTimerCallback resetIdleTimerCallback;
VSyncRequest vsyncRequest = VSyncRequest::None;
@@ -98,8 +93,7 @@
public:
virtual ~EventThread();
- virtual sp<EventThreadConnection> createEventConnection(ResyncCallback,
- ResetIdleTimerCallback) const = 0;
+ virtual sp<EventThreadConnection> createEventConnection(ResyncCallback) const = 0;
// called before the screen is turned off from main thread
virtual void onScreenReleased() = 0;
@@ -120,8 +114,7 @@
const sp<EventThreadConnection>& connection) = 0;
virtual void setVsyncRate(uint32_t rate, const sp<EventThreadConnection>& connection) = 0;
// Requests the next vsync. If resetIdleTimer is set to true, it resets the idle timer.
- virtual void requestNextVsync(const sp<EventThreadConnection>& connection,
- bool resetIdleTimer) = 0;
+ virtual void requestNextVsync(const sp<EventThreadConnection>& connection) = 0;
};
namespace impl {
@@ -135,13 +128,11 @@
EventThread(std::unique_ptr<VSyncSource>, InterceptVSyncsCallback, const char* threadName);
~EventThread();
- sp<EventThreadConnection> createEventConnection(ResyncCallback,
- ResetIdleTimerCallback) const override;
+ sp<EventThreadConnection> createEventConnection(ResyncCallback) const override;
status_t registerDisplayEventConnection(const sp<EventThreadConnection>& connection) override;
void setVsyncRate(uint32_t rate, const sp<EventThreadConnection>& connection) override;
- void requestNextVsync(const sp<EventThreadConnection>& connection,
- bool resetIdleTimer) override;
+ void requestNextVsync(const sp<EventThreadConnection>& connection) override;
// called before the screen is turned off from main thread
void onScreenReleased() override;
diff --git a/services/surfaceflinger/Scheduler/IdleTimer.cpp b/services/surfaceflinger/Scheduler/IdleTimer.cpp
index b28b1aa..37fdfc7 100644
--- a/services/surfaceflinger/Scheduler/IdleTimer.cpp
+++ b/services/surfaceflinger/Scheduler/IdleTimer.cpp
@@ -84,8 +84,11 @@
constexpr auto zero = std::chrono::steady_clock::duration::zero();
auto waitTime = triggerTime - std::chrono::steady_clock::now();
if (waitTime > zero) mCondition.wait_for(mMutex, waitTime);
- if (mState == TimerState::WAITING &&
- (triggerTime - std::chrono::steady_clock::now()) <= zero) {
+ if (mState == TimerState::RESET) {
+ triggerTime = std::chrono::steady_clock::now() + mInterval;
+ mState = TimerState::WAITING;
+ } else if (mState == TimerState::WAITING &&
+ (triggerTime - std::chrono::steady_clock::now()) <= zero) {
triggerTimeout = true;
mState = TimerState::IDLE;
}
diff --git a/services/surfaceflinger/Scheduler/IdleTimer.h b/services/surfaceflinger/Scheduler/IdleTimer.h
index 19f1267..2646688 100644
--- a/services/surfaceflinger/Scheduler/IdleTimer.h
+++ b/services/surfaceflinger/Scheduler/IdleTimer.h
@@ -39,13 +39,31 @@
const TimeoutCallback& timeoutCallback);
~IdleTimer();
+ // Initializes and turns on the idle timer.
void start();
+ // Stops the idle timer and any held resources.
void stop();
+ // Resets the wakeup time and fires the reset callback.
void reset();
private:
// Enum to track in what state is the timer.
- enum class TimerState { STOPPED = 0, RESET = 1, WAITING = 2, IDLE = 3 };
+ enum class TimerState {
+ // The internal timer thread has been destroyed, and no state is
+ // tracked.
+ // Possible state transitions: RESET
+ STOPPED = 0,
+ // An external thread has just reset this timer.
+ // If there is a reset callback, then that callback is fired.
+ // Possible state transitions: STOPPED, WAITING
+ RESET = 1,
+ // This timer is waiting for the timeout interval to expire.
+ // Possible state transaitions: STOPPED, RESET, IDLE
+ WAITING = 2,
+ // The timeout interval has expired, so we are sleeping now.
+ // Possible state transaitions: STOPPED, RESET
+ IDLE = 3
+ };
// Function that loops until the condition for stopping is met.
void loop();
@@ -59,6 +77,7 @@
// Lock used for synchronizing the waiting thread with the application thread.
std::mutex mMutex;
+ // Current timer state
TimerState mState GUARDED_BY(mMutex) = TimerState::RESET;
// Interval after which timer expires.
diff --git a/services/surfaceflinger/Scheduler/LayerHistory.cpp b/services/surfaceflinger/Scheduler/LayerHistory.cpp
index 8e36ae9..1db43a3 100644
--- a/services/surfaceflinger/Scheduler/LayerHistory.cpp
+++ b/services/surfaceflinger/Scheduler/LayerHistory.cpp
@@ -67,7 +67,8 @@
}
}
-void LayerHistory::insert(const std::unique_ptr<LayerHandle>& layerHandle, nsecs_t presentTime) {
+void LayerHistory::insert(const std::unique_ptr<LayerHandle>& layerHandle, nsecs_t presentTime,
+ bool isHdr) {
std::shared_ptr<LayerInfo> layerInfo;
{
std::lock_guard lock(mLock);
@@ -88,9 +89,36 @@
}
}
layerInfo->setLastPresentTime(presentTime);
+ layerInfo->setHDRContent(isHdr);
}
-float LayerHistory::getDesiredRefreshRate() {
+void LayerHistory::setVisibility(const std::unique_ptr<LayerHandle>& layerHandle, bool visible) {
+ std::shared_ptr<LayerInfo> layerInfo;
+ {
+ std::lock_guard lock(mLock);
+ auto layerInfoIterator = mInactiveLayerInfos.find(layerHandle->mId);
+ if (layerInfoIterator != mInactiveLayerInfos.end()) {
+ layerInfo = layerInfoIterator->second;
+ if (visible) {
+ mInactiveLayerInfos.erase(layerInfoIterator);
+ mActiveLayerInfos.insert({layerHandle->mId, layerInfo});
+ }
+ } else {
+ layerInfoIterator = mActiveLayerInfos.find(layerHandle->mId);
+ if (layerInfoIterator != mActiveLayerInfos.end()) {
+ layerInfo = layerInfoIterator->second;
+ } else {
+ ALOGW("Inserting information about layer that is not registered: %" PRId64,
+ layerHandle->mId);
+ return;
+ }
+ }
+ }
+ layerInfo->setVisibility(visible);
+}
+
+std::pair<float, bool> LayerHistory::getDesiredRefreshRateAndHDR() {
+ bool isHDR = false;
float newRefreshRate = 0.f;
std::lock_guard lock(mLock);
@@ -108,12 +136,13 @@
if (layerInfo->isRecentlyActive() && layerRefreshRate > newRefreshRate) {
newRefreshRate = layerRefreshRate;
}
+ isHDR |= layerInfo->getHDRContent();
}
if (mTraceEnabled) {
ALOGD("LayerHistory DesiredRefreshRate: %.2f", newRefreshRate);
}
- return newRefreshRate;
+ return {newRefreshRate, isHDR};
}
void LayerHistory::removeIrrelevantLayers() {
@@ -122,7 +151,9 @@
auto it = mActiveLayerInfos.begin();
while (it != mActiveLayerInfos.end()) {
// If last updated was before the obsolete time, remove it.
- if (it->second->getLastUpdatedTime() < obsoleteEpsilon) {
+ // Keep HDR layer around as long as they are visible.
+ if (!it->second->isVisible() ||
+ (!it->second->getHDRContent() && it->second->getLastUpdatedTime() < obsoleteEpsilon)) {
// erase() function returns the iterator of the next
// to last deleted element.
if (mTraceEnabled) {
diff --git a/services/surfaceflinger/Scheduler/LayerHistory.h b/services/surfaceflinger/Scheduler/LayerHistory.h
index 39061e7..adc5ce5 100644
--- a/services/surfaceflinger/Scheduler/LayerHistory.h
+++ b/services/surfaceflinger/Scheduler/LayerHistory.h
@@ -56,10 +56,13 @@
std::unique_ptr<LayerHandle> createLayer(const std::string name, float maxRefreshRate);
// Method for inserting layers and their requested present time into the unordered map.
- void insert(const std::unique_ptr<LayerHandle>& layerHandle, nsecs_t presentTime);
+ void insert(const std::unique_ptr<LayerHandle>& layerHandle, nsecs_t presentTime, bool isHdr);
+ // Method for setting layer visibility
+ void setVisibility(const std::unique_ptr<LayerHandle>& layerHandle, bool visible);
+
// Returns the desired refresh rate, which is a max refresh rate of all the current
// layers. See go/content-fps-detection-in-scheduler for more information.
- float getDesiredRefreshRate();
+ std::pair<float, bool> getDesiredRefreshRateAndHDR();
// Removes the handle and the object from the map.
void destroyLayer(const int64_t id);
diff --git a/services/surfaceflinger/Scheduler/LayerInfo.h b/services/surfaceflinger/Scheduler/LayerInfo.h
index 1970a47..02b6aef 100644
--- a/services/surfaceflinger/Scheduler/LayerInfo.h
+++ b/services/surfaceflinger/Scheduler/LayerInfo.h
@@ -115,6 +115,16 @@
// updated time, the updated time is the present time.
void setLastPresentTime(nsecs_t lastPresentTime);
+ void setHDRContent(bool isHdr) {
+ std::lock_guard lock(mLock);
+ mIsHDR = isHdr;
+ }
+
+ void setVisibility(bool visible) {
+ std::lock_guard lock(mLock);
+ mIsVisible = visible;
+ }
+
// Checks the present time history to see whether the layer is relevant.
bool isRecentlyActive() const {
std::lock_guard lock(mLock);
@@ -127,6 +137,16 @@
return mRefreshRateHistory.getRefreshRateAvg();
}
+ bool getHDRContent() {
+ std::lock_guard lock(mLock);
+ return mIsHDR;
+ }
+
+ bool isVisible() {
+ std::lock_guard lock(mLock);
+ return mIsVisible;
+ }
+
// Return the last updated time. If the present time is farther in the future than the
// updated time, the updated time is the present time.
nsecs_t getLastUpdatedTime() {
@@ -150,6 +170,8 @@
nsecs_t mLastPresentTime GUARDED_BY(mLock) = 0;
RefreshRateHistory mRefreshRateHistory GUARDED_BY(mLock);
PresentTimeHistory mPresentTimeHistory GUARDED_BY(mLock);
+ bool mIsHDR GUARDED_BY(mLock) = false;
+ bool mIsVisible GUARDED_BY(mLock) = false;
};
} // namespace scheduler
diff --git a/services/surfaceflinger/Scheduler/MessageQueue.cpp b/services/surfaceflinger/Scheduler/MessageQueue.cpp
index 1f18ead..baf900d 100644
--- a/services/surfaceflinger/Scheduler/MessageQueue.cpp
+++ b/services/surfaceflinger/Scheduler/MessageQueue.cpp
@@ -96,8 +96,7 @@
}
mEventThread = eventThread;
- mEvents =
- eventThread->createEventConnection(std::move(resyncCallback), ResetIdleTimerCallback());
+ mEvents = eventThread->createEventConnection(std::move(resyncCallback));
mEvents->stealReceiveChannel(&mEventTube);
mLooper->addFd(mEventTube.getFd(), 0, Looper::EVENT_INPUT, MessageQueue::cb_eventReceiver,
this);
@@ -150,10 +149,6 @@
mEvents->requestNextVsync();
}
-void MessageQueue::invalidateForHWC() {
- mEvents->requestNextVsyncForHWC();
-}
-
void MessageQueue::refresh() {
mHandler->dispatchRefresh();
}
diff --git a/services/surfaceflinger/Scheduler/MessageQueue.h b/services/surfaceflinger/Scheduler/MessageQueue.h
index 245a8ac..0b2206d 100644
--- a/services/surfaceflinger/Scheduler/MessageQueue.h
+++ b/services/surfaceflinger/Scheduler/MessageQueue.h
@@ -91,7 +91,6 @@
virtual void waitMessage() = 0;
virtual status_t postMessage(const sp<MessageBase>& message, nsecs_t reltime = 0) = 0;
virtual void invalidate() = 0;
- virtual void invalidateForHWC() = 0;
virtual void refresh() = 0;
};
@@ -136,8 +135,6 @@
// sends INVALIDATE message at next VSYNC
void invalidate() override;
- // sends INVALIDATE message at next VSYNC, without resetting the idle timer in the Scheduler
- void invalidateForHWC();
// sends REFRESH message at next VSYNC
void refresh() override;
};
diff --git a/services/surfaceflinger/Scheduler/Scheduler.cpp b/services/surfaceflinger/Scheduler/Scheduler.cpp
index 88d2638..513436a 100644
--- a/services/surfaceflinger/Scheduler/Scheduler.cpp
+++ b/services/surfaceflinger/Scheduler/Scheduler.cpp
@@ -73,6 +73,9 @@
mEventControlThread = std::make_unique<impl::EventControlThread>(function);
mSetIdleTimerMs = set_idle_timer_ms(0);
+ mSupportKernelTimer = support_kernel_idle_timer(false);
+
+ mSetTouchTimerMs = set_touch_timer_ms(0);
char value[PROPERTY_VALUE_MAX];
property_get("debug.sf.set_idle_timer_ms", value, "0");
@@ -82,16 +85,36 @@
}
if (mSetIdleTimerMs > 0) {
- mIdleTimer =
- std::make_unique<scheduler::IdleTimer>(std::chrono::milliseconds(mSetIdleTimerMs),
- [this] { resetTimerCallback(); },
- [this] { expiredTimerCallback(); });
+ if (mSupportKernelTimer) {
+ mIdleTimer =
+ std::make_unique<scheduler::IdleTimer>(std::chrono::milliseconds(
+ mSetIdleTimerMs),
+ [this] { resetKernelTimerCallback(); },
+ [this] {
+ expiredKernelTimerCallback();
+ });
+ } else {
+ mIdleTimer = std::make_unique<scheduler::IdleTimer>(std::chrono::milliseconds(
+ mSetIdleTimerMs),
+ [this] { resetTimerCallback(); },
+ [this] { expiredTimerCallback(); });
+ }
mIdleTimer->start();
}
+
+ if (mSetTouchTimerMs > 0) {
+ // Touch events are coming to SF every 100ms, so the timer needs to be higher than that
+ mTouchTimer =
+ std::make_unique<scheduler::IdleTimer>(std::chrono::milliseconds(mSetTouchTimerMs),
+ [this] { resetTouchTimerCallback(); },
+ [this] { expiredTouchTimerCallback(); });
+ mTouchTimer->start();
+ }
}
Scheduler::~Scheduler() {
// Ensure the IdleTimer thread is joined before we start destroying state.
+ mTouchTimer.reset();
mIdleTimer.reset();
}
@@ -125,8 +148,7 @@
sp<EventThreadConnection> Scheduler::createConnectionInternal(EventThread* eventThread,
ResyncCallback&& resyncCallback) {
- return eventThread->createEventConnection(std::move(resyncCallback),
- [this] { resetIdleTimer(); });
+ return eventThread->createEventConnection(std::move(resyncCallback));
}
sp<IDisplayEventConnection> Scheduler::createDisplayEventConnection(
@@ -306,10 +328,15 @@
return mLayerHistory.createLayer(name, fps);
}
-void Scheduler::addLayerPresentTime(
+void Scheduler::addLayerPresentTimeAndHDR(
const std::unique_ptr<scheduler::LayerHistory::LayerHandle>& layerHandle,
- nsecs_t presentTime) {
- mLayerHistory.insert(layerHandle, presentTime);
+ nsecs_t presentTime, bool isHDR) {
+ mLayerHistory.insert(layerHandle, presentTime, isHDR);
+}
+
+void Scheduler::setLayerVisibility(
+ const std::unique_ptr<scheduler::LayerHistory::LayerHandle>& layerHandle, bool visible) {
+ mLayerHistory.setVisibility(layerHandle, visible);
}
void Scheduler::withPrimaryDispSync(std::function<void(DispSync&)> const& fn) {
@@ -317,18 +344,23 @@
}
void Scheduler::updateFpsBasedOnContent() {
- uint32_t refreshRate = std::round(mLayerHistory.getDesiredRefreshRate());
+ auto [refreshRate, isHDR] = mLayerHistory.getDesiredRefreshRateAndHDR();
+ const uint32_t refreshRateRound = std::round(refreshRate);
RefreshRateType newRefreshRateType;
{
std::lock_guard<std::mutex> lock(mFeatureStateLock);
- if (mContentRefreshRate == refreshRate) {
+ if (mContentRefreshRate == refreshRateRound && mIsHDRContent == isHDR) {
return;
}
- mContentRefreshRate = refreshRate;
+ mContentRefreshRate = refreshRateRound;
ATRACE_INT("ContentFPS", mContentRefreshRate);
- mCurrentContentFeatureState = refreshRate > 0 ? ContentFeatureState::CONTENT_DETECTION_ON
- : ContentFeatureState::CONTENT_DETECTION_OFF;
+ mIsHDRContent = isHDR;
+ ATRACE_INT("ContentHDR", mIsHDRContent);
+
+ mCurrentContentFeatureState = refreshRateRound > 0
+ ? ContentFeatureState::CONTENT_DETECTION_ON
+ : ContentFeatureState::CONTENT_DETECTION_OFF;
newRefreshRateType = calculateRefreshRateType();
if (mRefreshRateType == newRefreshRateType) {
return;
@@ -344,6 +376,11 @@
mChangeRefreshRateCallback = changeRefreshRateCallback;
}
+void Scheduler::setGetVsyncPeriodCallback(const GetVsyncPeriod&& getVsyncPeriod) {
+ std::lock_guard<std::mutex> lock(mCallbackLock);
+ mGetVsyncPeriod = getVsyncPeriod;
+}
+
void Scheduler::updateFrameSkipping(const int64_t skipCount) {
ATRACE_INT("FrameSkipCount", skipCount);
if (mSkipCount != skipCount) {
@@ -359,21 +396,57 @@
}
}
+void Scheduler::notifyTouchEvent() {
+ if (mTouchTimer) {
+ mTouchTimer->reset();
+ }
+
+ if (mSupportKernelTimer) {
+ resetIdleTimer();
+ }
+}
+
void Scheduler::resetTimerCallback() {
- // We do not notify the applications about config changes when idle timer is reset.
timerChangeRefreshRate(IdleTimerState::RESET);
ATRACE_INT("ExpiredIdleTimer", 0);
}
+void Scheduler::resetKernelTimerCallback() {
+ ATRACE_INT("ExpiredKernelIdleTimer", 0);
+ std::lock_guard<std::mutex> lock(mCallbackLock);
+ if (mGetVsyncPeriod) {
+ resyncToHardwareVsync(false, mGetVsyncPeriod());
+ }
+}
+
void Scheduler::expiredTimerCallback() {
- // We do not notify the applications about config changes when idle timer expires.
timerChangeRefreshRate(IdleTimerState::EXPIRED);
ATRACE_INT("ExpiredIdleTimer", 1);
}
+void Scheduler::resetTouchTimerCallback() {
+ // We do not notify the applications about config changes when idle timer is reset.
+ touchChangeRefreshRate(TouchState::ACTIVE);
+ ATRACE_INT("TouchState", 1);
+}
+
+void Scheduler::expiredTouchTimerCallback() {
+ // We do not notify the applications about config changes when idle timer expires.
+ touchChangeRefreshRate(TouchState::INACTIVE);
+ ATRACE_INT("TouchState", 0);
+}
+
+void Scheduler::expiredKernelTimerCallback() {
+ ATRACE_INT("ExpiredKernelIdleTimer", 1);
+ // Disable HW Vsync if the timer expired, as we don't need it
+ // enabled if we're not pushing frames.
+ disableHardwareVsync(false);
+}
+
std::string Scheduler::doDump() {
std::ostringstream stream;
stream << "+ Idle timer interval: " << mSetIdleTimerMs << " ms" << std::endl;
+ stream << "+ Touch timer interval: " << mSetTouchTimerMs << " ms" << std::endl;
return stream.str();
}
@@ -394,8 +467,40 @@
changeRefreshRate(newRefreshRateType, ConfigEvent::None);
}
+void Scheduler::touchChangeRefreshRate(TouchState touchState) {
+ ConfigEvent event = ConfigEvent::None;
+ RefreshRateType newRefreshRateType;
+ {
+ std::lock_guard<std::mutex> lock(mFeatureStateLock);
+ if (mCurrentTouchState == touchState) {
+ return;
+ }
+ mCurrentTouchState = touchState;
+ newRefreshRateType = calculateRefreshRateType();
+ if (mRefreshRateType == newRefreshRateType) {
+ return;
+ }
+ mRefreshRateType = newRefreshRateType;
+ // Send an event in case that content detection is on as touch has a higher priority
+ if (mCurrentContentFeatureState == ContentFeatureState::CONTENT_DETECTION_ON) {
+ event = ConfigEvent::Changed;
+ }
+ }
+ changeRefreshRate(newRefreshRateType, event);
+}
+
Scheduler::RefreshRateType Scheduler::calculateRefreshRateType() {
- // First check if timer has expired as it means there is no new content on the screen
+ // HDR content is not supported on PERFORMANCE mode
+ if (mForceHDRContentToDefaultRefreshRate && mIsHDRContent) {
+ return RefreshRateType::DEFAULT;
+ }
+
+ // As long as touch is active we want to be in performance mode
+ if (mCurrentTouchState == TouchState::ACTIVE) {
+ return RefreshRateType::PERFORMANCE;
+ }
+
+ // If timer has expired as it means there is no new content on the screen
if (mCurrentIdleTimerState == IdleTimerState::EXPIRED) {
return RefreshRateType::DEFAULT;
}
diff --git a/services/surfaceflinger/Scheduler/Scheduler.h b/services/surfaceflinger/Scheduler/Scheduler.h
index 34327b5..96d4bd5 100644
--- a/services/surfaceflinger/Scheduler/Scheduler.h
+++ b/services/surfaceflinger/Scheduler/Scheduler.h
@@ -150,17 +150,27 @@
int windowType);
// Stores present time for a layer.
- void addLayerPresentTime(
+ void addLayerPresentTimeAndHDR(
const std::unique_ptr<scheduler::LayerHistory::LayerHandle>& layerHandle,
- nsecs_t presentTime);
+ nsecs_t presentTime, bool isHDR);
+ // Stores visibility for a layer.
+ void setLayerVisibility(
+ const std::unique_ptr<scheduler::LayerHistory::LayerHandle>& layerHandle, bool visible);
// Updates FPS based on the most content presented.
void updateFpsBasedOnContent();
// Callback that gets invoked when Scheduler wants to change the refresh rate.
void setChangeRefreshRateCallback(const ChangeRefreshRateCallback& changeRefreshRateCallback);
+ void setGetVsyncPeriodCallback(const GetVsyncPeriod&& getVsyncPeriod);
// Returns whether idle timer is enabled or not
bool isIdleTimerEnabled() { return mSetIdleTimerMs > 0; }
+ // Function that resets the idle timer.
+ void resetIdleTimer();
+
+ // Function that resets the touch timer.
+ void notifyTouchEvent();
+
// Returns relevant information about Scheduler for dumpsys purposes.
std::string doDump();
@@ -179,22 +189,36 @@
// to keep track which feature requested the config change.
enum class ContentFeatureState { CONTENT_DETECTION_ON, CONTENT_DETECTION_OFF };
enum class IdleTimerState { EXPIRED, RESET };
+ enum class TouchState { INACTIVE, ACTIVE };
// Creates a connection on the given EventThread and forwards the given callbacks.
sp<EventThreadConnection> createConnectionInternal(EventThread*, ResyncCallback&&);
nsecs_t calculateAverage() const;
void updateFrameSkipping(const int64_t skipCount);
- // Function that resets the idle timer.
- void resetIdleTimer();
+
// Function that is called when the timer resets.
void resetTimerCallback();
// Function that is called when the timer expires.
void expiredTimerCallback();
+ // Function that is called when the timer resets when paired with a display
+ // driver timeout in the kernel. This enables hardware vsync when we move
+ // out from idle.
+ void resetKernelTimerCallback();
+ // Function that is called when the timer expires when paired with a display
+ // driver timeout in the kernel. This disables hardware vsync when we move
+ // into idle.
+ void expiredKernelTimerCallback();
+ // Function that is called when the touch timer resets.
+ void resetTouchTimerCallback();
+ // Function that is called when the touch timer expires.
+ void expiredTouchTimerCallback();
// Sets vsync period.
void setVsyncPeriod(const nsecs_t period);
// Idle timer feature's function to change the refresh rate.
void timerChangeRefreshRate(IdleTimerState idleTimerState);
+ // Touch timer feature's function to change the refresh rate.
+ void touchChangeRefreshRate(TouchState touchState);
// Calculate the new refresh rate type
RefreshRateType calculateRefreshRateType() REQUIRES(mFeatureStateLock);
// Acquires a lock and calls the ChangeRefreshRateCallback() with given parameters.
@@ -242,9 +266,17 @@
// interval, a callback is fired. Set this variable to >0 to use this feature.
int64_t mSetIdleTimerMs = 0;
std::unique_ptr<scheduler::IdleTimer> mIdleTimer;
+ // Enables whether to use idle timer callbacks that support the kernel
+ // timer.
+ bool mSupportKernelTimer;
+
+ // Timer used to monitor touch events.
+ int64_t mSetTouchTimerMs = 0;
+ std::unique_ptr<scheduler::IdleTimer> mTouchTimer;
std::mutex mCallbackLock;
ChangeRefreshRateCallback mChangeRefreshRateCallback GUARDED_BY(mCallbackLock);
+ GetVsyncPeriod mGetVsyncPeriod GUARDED_BY(mCallbackLock);
// In order to make sure that the features don't override themselves, we need a state machine
// to keep track which feature requested the config change.
@@ -252,10 +284,15 @@
ContentFeatureState mCurrentContentFeatureState GUARDED_BY(mFeatureStateLock) =
ContentFeatureState::CONTENT_DETECTION_OFF;
IdleTimerState mCurrentIdleTimerState GUARDED_BY(mFeatureStateLock) = IdleTimerState::RESET;
+ TouchState mCurrentTouchState GUARDED_BY(mFeatureStateLock) = TouchState::INACTIVE;
uint32_t mContentRefreshRate GUARDED_BY(mFeatureStateLock);
RefreshRateType mRefreshRateType GUARDED_BY(mFeatureStateLock);
+ bool mIsHDRContent GUARDED_BY(mFeatureStateLock) = false;
const scheduler::RefreshRateConfigs& mRefreshRateConfigs;
+
+ // Global config to force HDR content to work on DEFAULT refreshRate
+ static constexpr bool mForceHDRContentToDefaultRefreshRate = true;
};
} // namespace android
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 4d885fb..820ccc5 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -113,6 +113,7 @@
#include <android/hardware/configstore/1.0/ISurfaceFlingerConfigs.h>
#include <android/hardware/configstore/1.1/ISurfaceFlingerConfigs.h>
#include <android/hardware/configstore/1.1/types.h>
+#include <android/hardware/power/1.0/IPower.h>
#include <configstore/Utils.h>
#include <layerproto/LayerProtoParser.h>
@@ -124,6 +125,7 @@
using namespace android::hardware::configstore::V1_0;
using namespace android::sysprop;
+using android::hardware::power::V1_0::PowerHint;
using base::StringAppendF;
using ui::ColorMode;
using ui::Dataspace;
@@ -704,6 +706,10 @@
Mutex::Autolock lock(mStateLock);
setRefreshRateTo(type, event);
});
+ mScheduler->setGetVsyncPeriodCallback([this] {
+ Mutex::Autolock lock(mStateLock);
+ return getVsyncPeriod();
+ });
mRefreshRateConfigs.populate(getHwComposer().getConfigs(*display->getId()));
mRefreshRateStats.setConfigMode(getHwComposer().getActiveConfigIndex(*display->getId()));
@@ -981,7 +987,7 @@
if (mCheckPendingFence) {
if (previousFrameMissed()) {
// fence has not signaled yet. wait for the next invalidate
- mEventQueue->invalidateForHWC();
+ mEventQueue->invalidate();
return true;
}
@@ -1032,7 +1038,7 @@
// we need to submit an empty frame to HWC to start the process
mCheckPendingFence = true;
- mEventQueue->invalidateForHWC();
+ mEventQueue->invalidate();
return false;
}
@@ -1328,6 +1334,16 @@
return getHwComposer().setDisplayBrightness(*displayId, brightness);
}
+status_t SurfaceFlinger::notifyPowerHint(int32_t hintId) {
+ PowerHint powerHint = static_cast<PowerHint>(hintId);
+
+ if (powerHint == PowerHint::INTERACTION) {
+ mScheduler->notifyTouchEvent();
+ }
+
+ return NO_ERROR;
+}
+
// ----------------------------------------------------------------------------
sp<IDisplayEventConnection> SurfaceFlinger::createDisplayEventConnection(
@@ -1350,10 +1366,12 @@
}
void SurfaceFlinger::signalTransaction() {
+ mScheduler->resetIdleTimer();
mEventQueue->invalidate();
}
void SurfaceFlinger::signalLayerUpdate() {
+ mScheduler->resetIdleTimer();
mEventQueue->invalidate();
}
@@ -5030,7 +5048,8 @@
case SET_POWER_MODE:
case GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES:
case SET_DISPLAY_CONTENT_SAMPLING_ENABLED:
- case GET_DISPLAYED_CONTENT_SAMPLE: {
+ case GET_DISPLAYED_CONTENT_SAMPLE:
+ case NOTIFY_POWER_HINT: {
if (!callingThreadHasUnscopedSurfaceFlingerAccess()) {
IPCThreadState* ipc = IPCThreadState::self();
ALOGE("Permission Denial: can't access SurfaceFlinger pid=%d, uid=%d",
@@ -5100,7 +5119,7 @@
case CAPTURE_SCREEN_BY_ID: {
IPCThreadState* ipc = IPCThreadState::self();
const int uid = ipc->getCallingUid();
- if ((uid == AID_GRAPHICS) || (uid == AID_SYSTEM) || (uid == AID_SHELL)) {
+ if (uid == AID_ROOT || uid == AID_GRAPHICS || uid == AID_SYSTEM || uid == AID_SHELL) {
return OK;
}
return PERMISSION_DENIED;
@@ -5469,7 +5488,7 @@
void SurfaceFlinger::repaintEverythingForHWC() {
mRepaintEverything = true;
- mEventQueue->invalidateForHWC();
+ mEventQueue->invalidate();
}
// A simple RAII class to disconnect from an ANativeWindow* when it goes out of scope
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index d9de07b..ddfe88c 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -460,6 +460,7 @@
status_t getDisplayBrightnessSupport(const sp<IBinder>& displayToken,
bool* outSupport) const override;
status_t setDisplayBrightness(const sp<IBinder>& displayToken, float brightness) const override;
+ status_t notifyPowerHint(int32_t hintId) override;
/* ------------------------------------------------------------------------
* DeathRecipient interface
diff --git a/services/surfaceflinger/SurfaceFlingerProperties.cpp b/services/surfaceflinger/SurfaceFlingerProperties.cpp
index 3522429..4f352ff 100644
--- a/services/surfaceflinger/SurfaceFlingerProperties.cpp
+++ b/services/surfaceflinger/SurfaceFlingerProperties.cpp
@@ -230,6 +230,14 @@
return defaultValue;
}
+int32_t set_touch_timer_ms(int32_t defaultValue) {
+ auto temp = SurfaceFlingerProperties::set_touch_timer_ms();
+ if (temp.has_value()) {
+ return *temp;
+ }
+ return defaultValue;
+}
+
bool use_smart_90_for_video(bool defaultValue) {
auto temp = SurfaceFlingerProperties::use_smart_90_for_video();
if (temp.has_value()) {
@@ -246,6 +254,14 @@
return defaultValue;
}
+bool support_kernel_idle_timer(bool defaultValue) {
+ auto temp = SurfaceFlingerProperties::support_kernel_idle_timer();
+ if (temp.has_value()) {
+ return *temp;
+ }
+ return defaultValue;
+}
+
#define DISPLAY_PRIMARY_SIZE 3
constexpr float kSrgbRedX = 0.4123f;
diff --git a/services/surfaceflinger/SurfaceFlingerProperties.h b/services/surfaceflinger/SurfaceFlingerProperties.h
index 1864290..1964ccd 100644
--- a/services/surfaceflinger/SurfaceFlingerProperties.h
+++ b/services/surfaceflinger/SurfaceFlingerProperties.h
@@ -72,10 +72,14 @@
int32_t set_idle_timer_ms(int32_t defaultValue);
+int32_t set_touch_timer_ms(int32_t defaultValue);
+
bool use_smart_90_for_video(bool defaultValue);
bool enable_protected_contents(bool defaultValue);
+bool support_kernel_idle_timer(bool defaultValue);
+
android::ui::DisplayPrimaries getDisplayNativePrimaries();
} // namespace sysprop
} // namespace android
diff --git a/services/surfaceflinger/sysprop/SurfaceFlingerProperties.sysprop b/services/surfaceflinger/sysprop/SurfaceFlingerProperties.sysprop
index d369096..decabd5 100644
--- a/services/surfaceflinger/sysprop/SurfaceFlingerProperties.sysprop
+++ b/services/surfaceflinger/sysprop/SurfaceFlingerProperties.sysprop
@@ -298,6 +298,17 @@
prop_name: "ro.surface_flinger.set_idle_timer_ms"
}
+# setTouchTimerMs indicates what is considered a timeout in milliseconds for Scheduler.
+# This value is used by the Scheduler to trigger touch inactivity callbacks that will switch the
+# display to a lower refresh rate. Setting this property to 0 means there is no timer.
+prop {
+ api_name: "set_touch_timer_ms"
+ type: Integer
+ scope: System
+ access: Readonly
+ prop_name: "ro.surface_flinger.set_touch_timer_ms"
+}
+
# useSmart90ForVideo indicates whether Scheduler should detect content FPS, and try to adjust the
# screen refresh rate based on that.
prop {
@@ -315,3 +326,13 @@
access: Readonly
prop_name: "ro.surface_flinger.protected_contents"
}
+
+# Indicates whether Scheduler's idle timer should support a display driver timeout in the kernel.
+# The value of set_idle_timer_ms should be shorter in time than the timeout duration in the kernel.
+prop {
+ api_name: "support_kernel_idle_timer"
+ type: Boolean
+ scope: System
+ access: Readonly
+ prop_name: "ro.surface_flinger.support_kernel_idle_timer"
+}
diff --git a/services/surfaceflinger/sysprop/api/system-current.txt b/services/surfaceflinger/sysprop/api/system-current.txt
index 3c39b51..6ae3ac1 100644
--- a/services/surfaceflinger/sysprop/api/system-current.txt
+++ b/services/surfaceflinger/sysprop/api/system-current.txt
@@ -18,7 +18,9 @@
method public static java.util.Optional<android.sysprop.SurfaceFlingerProperties.primary_display_orientation_values> primary_display_orientation();
method public static java.util.Optional<java.lang.Boolean> running_without_sync_framework();
method public static java.util.Optional<java.lang.Integer> set_idle_timer_ms();
+ method public static java.util.Optional<java.lang.Integer> set_touch_timer_ms();
method public static java.util.Optional<java.lang.Boolean> start_graphics_allocator_service();
+ method public static java.util.Optional<java.lang.Boolean> support_kernel_idle_timer();
method public static java.util.Optional<java.lang.Boolean> use_color_management();
method public static java.util.Optional<java.lang.Boolean> use_context_priority();
method public static java.util.Optional<java.lang.Boolean> use_smart_90_for_video();
diff --git a/services/surfaceflinger/tests/Transaction_test.cpp b/services/surfaceflinger/tests/Transaction_test.cpp
index d03c25d..ec1ac4b 100644
--- a/services/surfaceflinger/tests/Transaction_test.cpp
+++ b/services/surfaceflinger/tests/Transaction_test.cpp
@@ -1056,6 +1056,53 @@
screenshot->expectColor(Rect(0, 0, 32, 32), Color::BLUE);
}
+TEST_P(LayerTypeTransactionTest, SetLayerAndRelative) {
+ sp<SurfaceControl> parent =
+ LayerTransactionTest::createLayer("Parent", 0 /* buffer width */, 0 /* buffer height */,
+ ISurfaceComposerClient::eFXSurfaceColor);
+
+ sp<SurfaceControl> childLayer;
+ ASSERT_NO_FATAL_FAILURE(
+ childLayer = LayerTransactionTest::createLayer("childLayer", 0 /* buffer width */,
+ 0 /* buffer height */,
+ ISurfaceComposerClient::eFXSurfaceColor,
+ parent.get()));
+ Transaction()
+ .setColor(childLayer, half3{1.0f, 0.0f, 0.0f})
+ .setColor(parent, half3{0.0f, 0.0f, 0.0f})
+ .show(childLayer)
+ .show(parent)
+ .setCrop_legacy(parent, Rect(0, 0, mDisplayWidth, mDisplayHeight))
+ .setCrop_legacy(childLayer, Rect(0, 0, 20, 30))
+ .apply();
+
+ Transaction()
+ .setRelativeLayer(childLayer, parent->getHandle(), -1)
+ .setLayer(childLayer, 1)
+ .apply();
+
+ {
+ SCOPED_TRACE("setLayer above");
+ // Set layer should get applied and place the child above.
+ std::unique_ptr<ScreenCapture> screenshot;
+ ScreenCapture::captureScreen(&screenshot);
+ screenshot->expectColor(Rect(0, 0, 20, 30), Color::RED);
+ }
+
+ Transaction()
+ .setLayer(childLayer, 1)
+ .setRelativeLayer(childLayer, parent->getHandle(), -1)
+ .apply();
+
+ {
+ SCOPED_TRACE("setRelative below");
+ // Set relative layer should get applied and place the child below.
+ std::unique_ptr<ScreenCapture> screenshot;
+ ScreenCapture::captureScreen(&screenshot);
+ screenshot->expectColor(Rect(0, 0, 20, 30), Color::BLACK);
+ }
+}
+
void LayerRenderTypeTransactionTest::setRelativeZGroupHelper(uint32_t layerType) {
sp<SurfaceControl> layerR;
sp<SurfaceControl> layerG;
diff --git a/services/surfaceflinger/tests/unittests/EventThreadTest.cpp b/services/surfaceflinger/tests/unittests/EventThreadTest.cpp
index 83a92c8..ea908a9 100644
--- a/services/surfaceflinger/tests/unittests/EventThreadTest.cpp
+++ b/services/surfaceflinger/tests/unittests/EventThreadTest.cpp
@@ -55,10 +55,8 @@
class MockEventThreadConnection : public EventThreadConnection {
public:
MockEventThreadConnection(android::impl::EventThread* eventThread,
- ResyncCallback&& resyncCallback,
- ResetIdleTimerCallback&& resetIdleTimerCallback)
- : EventThreadConnection(eventThread, std::move(resyncCallback),
- std::move(resetIdleTimerCallback)) {}
+ ResyncCallback&& resyncCallback)
+ : EventThreadConnection(eventThread, std::move(resyncCallback)) {}
MOCK_METHOD1(postEvent, status_t(const DisplayEventReceiver::Event& event));
};
@@ -88,7 +86,6 @@
AsyncCallRecorder<void (*)(VSyncSource::Callback*)> mVSyncSetCallbackCallRecorder;
AsyncCallRecorder<void (*)(nsecs_t)> mVSyncSetPhaseOffsetCallRecorder;
AsyncCallRecorder<void (*)()> mResyncCallRecorder;
- AsyncCallRecorder<void (*)()> mResetIdleTimerCallRecorder;
AsyncCallRecorder<void (*)(nsecs_t)> mInterceptVSyncCallRecorder;
ConnectionEventRecorder mConnectionEventCallRecorder{0};
@@ -143,8 +140,7 @@
sp<EventThreadTest::MockEventThreadConnection> EventThreadTest::createConnection(
ConnectionEventRecorder& recorder) {
sp<MockEventThreadConnection> connection =
- new MockEventThreadConnection(mThread.get(), mResyncCallRecorder.getInvocable(),
- mResetIdleTimerCallRecorder.getInvocable());
+ new MockEventThreadConnection(mThread.get(), mResyncCallRecorder.getInvocable());
EXPECT_CALL(*connection, postEvent(_)).WillRepeatedly(Invoke(recorder.getInvocable()));
return connection;
}
@@ -225,7 +221,6 @@
EXPECT_FALSE(mVSyncSetCallbackCallRecorder.waitForCall(0us).has_value());
EXPECT_FALSE(mVSyncSetPhaseOffsetCallRecorder.waitForCall(0us).has_value());
EXPECT_FALSE(mResyncCallRecorder.waitForCall(0us).has_value());
- EXPECT_FALSE(mResetIdleTimerCallRecorder.waitForCall(0us).has_value());
EXPECT_FALSE(mInterceptVSyncCallRecorder.waitForCall(0us).has_value());
EXPECT_FALSE(mConnectionEventCallRecorder.waitForCall(0us).has_value());
}
@@ -235,7 +230,7 @@
expectHotplugEventReceivedByConnection(INTERNAL_DISPLAY_ID, false);
// Signal that we want the next vsync event to be posted to the connection.
- mThread->requestNextVsync(mConnection, false);
+ mThread->requestNextVsync(mConnection);
// EventThread should not enable vsync callbacks.
EXPECT_FALSE(mVSyncSetEnabledCallRecorder.waitForUnexpectedCall().has_value());
@@ -243,10 +238,9 @@
TEST_F(EventThreadTest, requestNextVsyncPostsASingleVSyncEventToTheConnection) {
// Signal that we want the next vsync event to be posted to the connection
- mThread->requestNextVsync(mConnection, true);
+ mThread->requestNextVsync(mConnection);
- // EventThread should immediately reset the idle timer and request a resync.
- EXPECT_TRUE(mResetIdleTimerCallRecorder.waitForCall().has_value());
+ // EventThread should immediately request a resync.
EXPECT_TRUE(mResyncCallRecorder.waitForCall().has_value());
// EventThread should enable vsync callbacks.
diff --git a/services/surfaceflinger/tests/unittests/IdleTimerTest.cpp b/services/surfaceflinger/tests/unittests/IdleTimerTest.cpp
index ea39bf5..eff22b6 100644
--- a/services/surfaceflinger/tests/unittests/IdleTimerTest.cpp
+++ b/services/surfaceflinger/tests/unittests/IdleTimerTest.cpp
@@ -111,19 +111,19 @@
EXPECT_TRUE(mResetTimerCallback.waitForCall().has_value());
mIdleTimer->reset();
- EXPECT_TRUE(mResetTimerCallback.waitForCall().has_value());
+ EXPECT_FALSE(mResetTimerCallback.waitForCall(1ms).has_value());
EXPECT_FALSE(mExpiredTimerCallback.waitForCall(waitTimeForUnexpected3msCallback).has_value());
mIdleTimer->reset();
- EXPECT_TRUE(mResetTimerCallback.waitForCall().has_value());
+ EXPECT_FALSE(mResetTimerCallback.waitForCall(1ms).has_value());
EXPECT_FALSE(mExpiredTimerCallback.waitForCall(waitTimeForUnexpected3msCallback).has_value());
mIdleTimer->reset();
- EXPECT_TRUE(mResetTimerCallback.waitForCall().has_value());
+ EXPECT_FALSE(mResetTimerCallback.waitForCall(1ms).has_value());
EXPECT_FALSE(mExpiredTimerCallback.waitForCall(waitTimeForUnexpected3msCallback).has_value());
mIdleTimer->reset();
- EXPECT_TRUE(mResetTimerCallback.waitForCall().has_value());
+ EXPECT_FALSE(mResetTimerCallback.waitForCall(1ms).has_value());
EXPECT_FALSE(mExpiredTimerCallback.waitForCall(waitTimeForUnexpected3msCallback).has_value());
// A single callback should be generated after 30ms
diff --git a/services/surfaceflinger/tests/unittests/LayerHistoryTest.cpp b/services/surfaceflinger/tests/unittests/LayerHistoryTest.cpp
index e51121f..2b1dfa8 100644
--- a/services/surfaceflinger/tests/unittests/LayerHistoryTest.cpp
+++ b/services/surfaceflinger/tests/unittests/LayerHistoryTest.cpp
@@ -37,74 +37,93 @@
TEST_F(LayerHistoryTest, oneLayer) {
std::unique_ptr<LayerHistory::LayerHandle> testLayer =
mLayerHistory->createLayer("TestLayer", MAX_REFRESH_RATE);
+ mLayerHistory->setVisibility(testLayer, true);
- mLayerHistory->insert(testLayer, 0);
- EXPECT_FLOAT_EQ(0.f, mLayerHistory->getDesiredRefreshRate());
+ mLayerHistory->insert(testLayer, 0, false /*isHDR*/);
+ EXPECT_FLOAT_EQ(0.f, mLayerHistory->getDesiredRefreshRateAndHDR().first);
- mLayerHistory->insert(testLayer, 0);
- mLayerHistory->insert(testLayer, 0);
- mLayerHistory->insert(testLayer, 0);
+ mLayerHistory->insert(testLayer, 0, false /*isHDR*/);
+ mLayerHistory->insert(testLayer, 0, false /*isHDR*/);
+ mLayerHistory->insert(testLayer, 0, false /*isHDR*/);
// This is still 0, because the layer is not considered recently active if it
// has been present in less than 10 frames.
- EXPECT_FLOAT_EQ(0.f, mLayerHistory->getDesiredRefreshRate());
- mLayerHistory->insert(testLayer, 0);
- mLayerHistory->insert(testLayer, 0);
- mLayerHistory->insert(testLayer, 0);
- mLayerHistory->insert(testLayer, 0);
- mLayerHistory->insert(testLayer, 0);
- mLayerHistory->insert(testLayer, 0);
+ EXPECT_FLOAT_EQ(0.f, mLayerHistory->getDesiredRefreshRateAndHDR().first);
+ mLayerHistory->insert(testLayer, 0, false /*isHDR*/);
+ mLayerHistory->insert(testLayer, 0, false /*isHDR*/);
+ mLayerHistory->insert(testLayer, 0, false /*isHDR*/);
+ mLayerHistory->insert(testLayer, 0, false /*isHDR*/);
+ mLayerHistory->insert(testLayer, 0, false /*isHDR*/);
+ mLayerHistory->insert(testLayer, 0, false /*isHDR*/);
// This should be MAX_REFRESH_RATE as we have more than 10 samples
- EXPECT_FLOAT_EQ(MAX_REFRESH_RATE, mLayerHistory->getDesiredRefreshRate());
+ EXPECT_FLOAT_EQ(MAX_REFRESH_RATE, mLayerHistory->getDesiredRefreshRateAndHDR().first);
+}
+
+TEST_F(LayerHistoryTest, oneHDRLayer) {
+ std::unique_ptr<LayerHistory::LayerHandle> testLayer =
+ mLayerHistory->createLayer("TestHDRLayer", MAX_REFRESH_RATE);
+ mLayerHistory->setVisibility(testLayer, true);
+
+ mLayerHistory->insert(testLayer, 0, true /*isHDR*/);
+ EXPECT_FLOAT_EQ(0.0f, mLayerHistory->getDesiredRefreshRateAndHDR().first);
+ EXPECT_EQ(true, mLayerHistory->getDesiredRefreshRateAndHDR().second);
+
+ mLayerHistory->setVisibility(testLayer, false);
+ EXPECT_FLOAT_EQ(0.0f, mLayerHistory->getDesiredRefreshRateAndHDR().first);
+ EXPECT_EQ(false, mLayerHistory->getDesiredRefreshRateAndHDR().second);
}
TEST_F(LayerHistoryTest, explicitTimestamp) {
std::unique_ptr<LayerHistory::LayerHandle> test30FpsLayer =
mLayerHistory->createLayer("30FpsLayer", MAX_REFRESH_RATE);
+ mLayerHistory->setVisibility(test30FpsLayer, true);
nsecs_t startTime = systemTime();
for (int i = 0; i < 31; i++) {
- mLayerHistory->insert(test30FpsLayer, startTime + (i * 33333333));
+ mLayerHistory->insert(test30FpsLayer, startTime + (i * 33333333), false /*isHDR*/);
}
- EXPECT_FLOAT_EQ(30.f, mLayerHistory->getDesiredRefreshRate());
+ EXPECT_FLOAT_EQ(30.f, mLayerHistory->getDesiredRefreshRateAndHDR().first);
}
TEST_F(LayerHistoryTest, multipleLayers) {
std::unique_ptr<LayerHistory::LayerHandle> testLayer =
mLayerHistory->createLayer("TestLayer", MAX_REFRESH_RATE);
+ mLayerHistory->setVisibility(testLayer, true);
std::unique_ptr<LayerHistory::LayerHandle> test30FpsLayer =
mLayerHistory->createLayer("30FpsLayer", MAX_REFRESH_RATE);
+ mLayerHistory->setVisibility(test30FpsLayer, true);
std::unique_ptr<LayerHistory::LayerHandle> testLayer2 =
mLayerHistory->createLayer("TestLayer2", MAX_REFRESH_RATE);
+ mLayerHistory->setVisibility(testLayer2, true);
nsecs_t startTime = systemTime();
for (int i = 0; i < 10; i++) {
- mLayerHistory->insert(testLayer, 0);
+ mLayerHistory->insert(testLayer, 0, false /*isHDR*/);
}
- EXPECT_FLOAT_EQ(MAX_REFRESH_RATE, mLayerHistory->getDesiredRefreshRate());
+ EXPECT_FLOAT_EQ(MAX_REFRESH_RATE, mLayerHistory->getDesiredRefreshRateAndHDR().first);
startTime = systemTime();
for (int i = 0; i < 10; i++) {
- mLayerHistory->insert(test30FpsLayer, startTime + (i * 33333333));
+ mLayerHistory->insert(test30FpsLayer, startTime + (i * 33333333), false /*isHDR*/);
}
- EXPECT_FLOAT_EQ(MAX_REFRESH_RATE, mLayerHistory->getDesiredRefreshRate());
+ EXPECT_FLOAT_EQ(MAX_REFRESH_RATE, mLayerHistory->getDesiredRefreshRateAndHDR().first);
for (int i = 10; i < 30; i++) {
- mLayerHistory->insert(test30FpsLayer, startTime + (i * 33333333));
+ mLayerHistory->insert(test30FpsLayer, startTime + (i * 33333333), false /*isHDR*/);
}
- EXPECT_FLOAT_EQ(MAX_REFRESH_RATE, mLayerHistory->getDesiredRefreshRate());
+ EXPECT_FLOAT_EQ(MAX_REFRESH_RATE, mLayerHistory->getDesiredRefreshRateAndHDR().first);
// This frame is only around for 9 occurrences, so it doesn't throw
// anything off.
for (int i = 0; i < 9; i++) {
- mLayerHistory->insert(testLayer2, 0);
+ mLayerHistory->insert(testLayer2, 0, false /*isHDR*/);
}
- EXPECT_FLOAT_EQ(MAX_REFRESH_RATE, mLayerHistory->getDesiredRefreshRate());
+ EXPECT_FLOAT_EQ(MAX_REFRESH_RATE, mLayerHistory->getDesiredRefreshRateAndHDR().first);
// After 100 ms frames become obsolete.
std::this_thread::sleep_for(std::chrono::milliseconds(500));
// Insert the 31st frame.
- mLayerHistory->insert(test30FpsLayer, startTime + (30 * 33333333));
- EXPECT_FLOAT_EQ(30.f, mLayerHistory->getDesiredRefreshRate());
+ mLayerHistory->insert(test30FpsLayer, startTime + (30 * 33333333), false /*isHDR*/);
+ EXPECT_FLOAT_EQ(30.f, mLayerHistory->getDesiredRefreshRateAndHDR().first);
}
} // namespace
diff --git a/services/surfaceflinger/tests/unittests/SchedulerTest.cpp b/services/surfaceflinger/tests/unittests/SchedulerTest.cpp
index b960bdf..1f8b111 100644
--- a/services/surfaceflinger/tests/unittests/SchedulerTest.cpp
+++ b/services/surfaceflinger/tests/unittests/SchedulerTest.cpp
@@ -25,7 +25,7 @@
class MockEventThreadConnection : public android::EventThreadConnection {
public:
explicit MockEventThreadConnection(EventThread* eventThread)
- : EventThreadConnection(eventThread, ResyncCallback(), ResetIdleTimerCallback()) {}
+ : EventThreadConnection(eventThread, ResyncCallback()) {}
~MockEventThreadConnection() = default;
MOCK_METHOD1(stealReceiveChannel, status_t(gui::BitTube* outChannel));
@@ -81,7 +81,7 @@
// createConnection call to scheduler makes a createEventConnection call to EventThread. Make
// sure that call gets executed and returns an EventThread::Connection object.
- EXPECT_CALL(*mEventThread, createEventConnection(_, _))
+ EXPECT_CALL(*mEventThread, createEventConnection(_))
.WillRepeatedly(Return(mEventThreadConnection));
mConnectionHandle = mScheduler->createConnection("appConnection", 16, ResyncCallback(),
diff --git a/services/surfaceflinger/tests/unittests/TestableScheduler.h b/services/surfaceflinger/tests/unittests/TestableScheduler.h
index 1c397d8..c3d2b8d 100644
--- a/services/surfaceflinger/tests/unittests/TestableScheduler.h
+++ b/services/surfaceflinger/tests/unittests/TestableScheduler.h
@@ -34,8 +34,7 @@
// Scheduler::Connection. This allows plugging in mock::EventThread.
sp<Scheduler::ConnectionHandle> addConnection(std::unique_ptr<EventThread> eventThread) {
sp<EventThreadConnection> eventThreadConnection =
- new EventThreadConnection(eventThread.get(), ResyncCallback(),
- ResetIdleTimerCallback());
+ new EventThreadConnection(eventThread.get(), ResyncCallback());
const int64_t id = sNextId++;
mConnections.emplace(id,
std::make_unique<Scheduler::Connection>(new ConnectionHandle(id),
diff --git a/services/surfaceflinger/tests/unittests/mock/MockEventThread.h b/services/surfaceflinger/tests/unittests/mock/MockEventThread.h
index cb4a300..5b5f8e7 100644
--- a/services/surfaceflinger/tests/unittests/mock/MockEventThread.h
+++ b/services/surfaceflinger/tests/unittests/mock/MockEventThread.h
@@ -28,8 +28,7 @@
EventThread();
~EventThread() override;
- MOCK_CONST_METHOD2(createEventConnection,
- sp<EventThreadConnection>(ResyncCallback, ResetIdleTimerCallback));
+ MOCK_CONST_METHOD1(createEventConnection, sp<EventThreadConnection>(ResyncCallback));
MOCK_METHOD0(onScreenReleased, void());
MOCK_METHOD0(onScreenAcquired, void());
MOCK_METHOD2(onHotplugReceived, void(PhysicalDisplayId, bool));
@@ -39,7 +38,7 @@
MOCK_METHOD1(registerDisplayEventConnection,
status_t(const sp<android::EventThreadConnection> &));
MOCK_METHOD2(setVsyncRate, void(uint32_t, const sp<android::EventThreadConnection> &));
- MOCK_METHOD2(requestNextVsync, void(const sp<android::EventThreadConnection> &, bool));
+ MOCK_METHOD1(requestNextVsync, void(const sp<android::EventThreadConnection> &));
MOCK_METHOD1(pauseVsyncCallback, void(bool));
};
diff --git a/services/surfaceflinger/tests/unittests/mock/MockMessageQueue.h b/services/surfaceflinger/tests/unittests/mock/MockMessageQueue.h
index e22d3e8..1b1c1a7 100644
--- a/services/surfaceflinger/tests/unittests/mock/MockMessageQueue.h
+++ b/services/surfaceflinger/tests/unittests/mock/MockMessageQueue.h
@@ -35,7 +35,6 @@
MOCK_METHOD0(waitMessage, void());
MOCK_METHOD2(postMessage, status_t(const sp<MessageBase>&, nsecs_t));
MOCK_METHOD0(invalidate, void());
- MOCK_METHOD0(invalidateForHWC, void());
MOCK_METHOD0(refresh, void());
};
diff --git a/vulkan/libvulkan/swapchain.cpp b/vulkan/libvulkan/swapchain.cpp
index a22f60e..e5f40aa 100644
--- a/vulkan/libvulkan/swapchain.cpp
+++ b/vulkan/libvulkan/swapchain.cpp
@@ -1171,7 +1171,9 @@
}
uint32_t min_undequeued_buffers = static_cast<uint32_t>(query_value);
uint32_t num_images =
- (create_info->minImageCount - 1) + min_undequeued_buffers;
+ (swap_interval ? create_info->minImageCount
+ : std::max(3u, create_info->minImageCount)) -
+ 1 + min_undequeued_buffers;
// Lower layer insists that we have at least two buffers. This is wasteful
// and we'd like to relax it in the shared case, but not all the pieces are