summaryrefslogtreecommitdiff
path: root/libs/gui/SurfaceComposerClient.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libs/gui/SurfaceComposerClient.cpp')
-rw-r--r--libs/gui/SurfaceComposerClient.cpp844
1 files changed, 320 insertions, 524 deletions
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index 96da8efd19..78d932cc81 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -39,9 +39,7 @@
#include <gui/LayerState.h>
#include <gui/Surface.h>
#include <gui/SurfaceComposerClient.h>
-#include <private/gui/ParcelUtils.h>
-#include <ui/DisplayMode.h>
-#include <ui/DynamicDisplayInfo.h>
+#include <ui/DisplayConfig.h>
#ifndef NO_INPUT
#include <input/InputWindow.h>
@@ -65,12 +63,12 @@ ComposerService::ComposerService()
connectLocked();
}
-bool ComposerService::connectLocked() {
+void ComposerService::connectLocked() {
const String16 name("SurfaceFlinger");
- mComposerService = waitForService<ISurfaceComposer>(name);
- if (mComposerService == nullptr) {
- return false; // fatal error or permission problem
+ while (getService(name, &mComposerService) != NO_ERROR) {
+ usleep(250000);
}
+ assert(mComposerService != nullptr);
// Create the death listener.
class DeathObserver : public IBinder::DeathRecipient {
@@ -86,16 +84,15 @@ bool ComposerService::connectLocked() {
mDeathObserver = new DeathObserver(*const_cast<ComposerService*>(this));
IInterface::asBinder(mComposerService)->linkToDeath(mDeathObserver);
- return true;
}
/*static*/ sp<ISurfaceComposer> ComposerService::getComposerService() {
ComposerService& instance = ComposerService::getInstance();
Mutex::Autolock _l(instance.mLock);
if (instance.mComposerService == nullptr) {
- if (ComposerService::getInstance().connectLocked()) {
- ALOGD("ComposerService reconnected");
- }
+ ComposerService::getInstance().connectLocked();
+ assert(instance.mComposerService != nullptr);
+ ALOGD("ComposerService reconnected");
}
return instance.mComposerService;
}
@@ -128,9 +125,6 @@ sp<SurfaceComposerClient> SurfaceComposerClient::getDefault() {
return DefaultComposerClient::getComposerClient();
}
-JankDataListener::~JankDataListener() {
-}
-
// ---------------------------------------------------------------------------
// TransactionCompletedListener does not use ANDROID_SINGLETON_STATIC_INSTANCE because it needs
@@ -140,7 +134,7 @@ JankDataListener::~JankDataListener() {
// 0 is an invalid callback id
TransactionCompletedListener::TransactionCompletedListener() : mCallbackIdCounter(1) {}
-int64_t TransactionCompletedListener::getNextIdLocked() {
+CallbackId TransactionCompletedListener::getNextIdLocked() {
return mCallbackIdCounter++;
}
@@ -164,13 +158,13 @@ void TransactionCompletedListener::startListeningLocked() {
CallbackId TransactionCompletedListener::addCallbackFunction(
const TransactionCompletedCallback& callbackFunction,
const std::unordered_set<sp<SurfaceControl>, SurfaceComposerClient::SCHash>&
- surfaceControls,
- CallbackId::Type callbackType) {
+ surfaceControls) {
std::lock_guard<std::mutex> lock(mMutex);
startListeningLocked();
- CallbackId callbackId(getNextIdLocked(), callbackType);
+ CallbackId callbackId = getNextIdLocked();
mCallbacks[callbackId].callbackFunction = callbackFunction;
+
auto& callbackSurfaceControls = mCallbacks[callbackId].surfaceControls;
for (const auto& surfaceControl : surfaceControls) {
@@ -180,57 +174,9 @@ CallbackId TransactionCompletedListener::addCallbackFunction(
return callbackId;
}
-void TransactionCompletedListener::addJankListener(const sp<JankDataListener>& listener,
- sp<SurfaceControl> surfaceControl) {
- std::lock_guard<std::mutex> lock(mMutex);
- mJankListeners.insert({surfaceControl->getHandle(), listener});
-}
-
-void TransactionCompletedListener::removeJankListener(const sp<JankDataListener>& listener) {
- std::lock_guard<std::mutex> lock(mMutex);
- for (auto it = mJankListeners.begin(); it != mJankListeners.end();) {
- if (it->second == listener) {
- it = mJankListeners.erase(it);
- } else {
- it++;
- }
- }
-}
-
-void TransactionCompletedListener::setReleaseBufferCallback(const ReleaseCallbackId& callbackId,
- ReleaseBufferCallback listener) {
- std::scoped_lock<std::mutex> lock(mMutex);
- mReleaseBufferCallbacks[callbackId] = listener;
-}
-
-void TransactionCompletedListener::removeReleaseBufferCallback(
- const ReleaseCallbackId& callbackId) {
- std::scoped_lock<std::mutex> lock(mMutex);
- mReleaseBufferCallbacks.erase(callbackId);
-}
-
-void TransactionCompletedListener::addSurfaceStatsListener(void* context, void* cookie,
- sp<SurfaceControl> surfaceControl, SurfaceStatsCallback listener) {
- std::scoped_lock<std::recursive_mutex> lock(mSurfaceStatsListenerMutex);
- mSurfaceStatsListeners.insert({surfaceControl->getHandle(),
- SurfaceStatsCallbackEntry(context, cookie, listener)});
-}
-
-void TransactionCompletedListener::removeSurfaceStatsListener(void* context, void* cookie) {
- std::scoped_lock<std::recursive_mutex> lock(mSurfaceStatsListenerMutex);
- for (auto it = mSurfaceStatsListeners.begin(); it != mSurfaceStatsListeners.end();) {
- auto [itContext, itCookie, itListener] = it->second;
- if (itContext == context && itCookie == cookie) {
- it = mSurfaceStatsListeners.erase(it);
- } else {
- it++;
- }
- }
-}
-
void TransactionCompletedListener::addSurfaceControlToCallbacks(
const sp<SurfaceControl>& surfaceControl,
- const std::unordered_set<CallbackId, CallbackIdHash>& callbackIds) {
+ const std::unordered_set<CallbackId>& callbackIds) {
std::lock_guard<std::mutex> lock(mMutex);
for (auto callbackId : callbackIds) {
@@ -242,8 +188,7 @@ void TransactionCompletedListener::addSurfaceControlToCallbacks(
}
void TransactionCompletedListener::onTransactionCompleted(ListenerStats listenerStats) {
- std::unordered_map<CallbackId, CallbackTranslation, CallbackIdHash> callbacksMap;
- std::multimap<sp<IBinder>, sp<JankDataListener>> jankListenersMap;
+ std::unordered_map<CallbackId, CallbackTranslation> callbacksMap;
{
std::lock_guard<std::mutex> lock(mMutex);
@@ -259,7 +204,6 @@ void TransactionCompletedListener::onTransactionCompleted(ListenerStats listener
* sp<SurfaceControl> that could possibly exist for the callbacks.
*/
callbacksMap = mCallbacks;
- jankListenersMap = mJankListeners;
for (const auto& transactionStats : listenerStats.transactionStats) {
for (auto& callbackId : transactionStats.callbackIds) {
mCallbacks.erase(callbackId);
@@ -267,36 +211,7 @@ void TransactionCompletedListener::onTransactionCompleted(ListenerStats listener
}
}
for (const auto& transactionStats : listenerStats.transactionStats) {
- // handle on commit callbacks
for (auto callbackId : transactionStats.callbackIds) {
- if (callbackId.type != CallbackId::Type::ON_COMMIT) {
- continue;
- }
- auto& [callbackFunction, callbackSurfaceControls] = callbacksMap[callbackId];
- if (!callbackFunction) {
- ALOGE("cannot call null callback function, skipping");
- continue;
- }
- std::vector<SurfaceControlStats> surfaceControlStats;
- for (const auto& surfaceStats : transactionStats.surfaceStats) {
- surfaceControlStats
- .emplace_back(callbacksMap[callbackId]
- .surfaceControls[surfaceStats.surfaceControl],
- transactionStats.latchTime, surfaceStats.acquireTime,
- transactionStats.presentFence,
- surfaceStats.previousReleaseFence, surfaceStats.transformHint,
- surfaceStats.eventStats);
- }
-
- callbackFunction(transactionStats.latchTime, transactionStats.presentFence,
- surfaceControlStats);
- }
-
- // handle on complete callbacks
- for (auto callbackId : transactionStats.callbackIds) {
- if (callbackId.type != CallbackId::Type::ON_COMPLETE) {
- continue;
- }
auto& [callbackFunction, callbackSurfaceControls] = callbacksMap[callbackId];
if (!callbackFunction) {
ALOGE("cannot call null callback function, skipping");
@@ -316,80 +231,12 @@ void TransactionCompletedListener::onTransactionCompleted(ListenerStats listener
.surfaceControls[surfaceStats.surfaceControl]
->setTransformHint(surfaceStats.transformHint);
}
- // If there is buffer id set, we look up any pending client release buffer callbacks
- // and call them. This is a performance optimization when we have a transaction
- // callback and a release buffer callback happening at the same time to avoid an
- // additional ipc call from the server.
- if (surfaceStats.previousReleaseCallbackId != ReleaseCallbackId::INVALID_ID) {
- ReleaseBufferCallback callback;
- {
- std::scoped_lock<std::mutex> lock(mMutex);
- callback = popReleaseBufferCallbackLocked(
- surfaceStats.previousReleaseCallbackId);
- }
- if (callback) {
- callback(surfaceStats.previousReleaseCallbackId,
- surfaceStats.previousReleaseFence
- ? surfaceStats.previousReleaseFence
- : Fence::NO_FENCE,
- surfaceStats.transformHint,
- surfaceStats.currentMaxAcquiredBufferCount);
- }
- }
}
callbackFunction(transactionStats.latchTime, transactionStats.presentFence,
surfaceControlStats);
}
- for (const auto& surfaceStats : transactionStats.surfaceStats) {
- {
- // Acquire surface stats listener lock such that we guarantee that after calling
- // unregister, there won't be any further callback.
- std::scoped_lock<std::recursive_mutex> lock(mSurfaceStatsListenerMutex);
- auto listenerRange = mSurfaceStatsListeners.equal_range(
- surfaceStats.surfaceControl);
- for (auto it = listenerRange.first; it != listenerRange.second; it++) {
- auto entry = it->second;
- entry.callback(entry.context, transactionStats.latchTime,
- transactionStats.presentFence, surfaceStats);
- }
- }
-
- if (surfaceStats.jankData.empty()) continue;
- auto jankRange = jankListenersMap.equal_range(surfaceStats.surfaceControl);
- for (auto it = jankRange.first; it != jankRange.second; it++) {
- it->second->onJankDataAvailable(surfaceStats.jankData);
- }
- }
- }
-}
-
-void TransactionCompletedListener::onReleaseBuffer(ReleaseCallbackId callbackId,
- sp<Fence> releaseFence, uint32_t transformHint,
- uint32_t currentMaxAcquiredBufferCount) {
- ReleaseBufferCallback callback;
- {
- std::scoped_lock<std::mutex> lock(mMutex);
- callback = popReleaseBufferCallbackLocked(callbackId);
}
- if (!callback) {
- ALOGE("Could not call release buffer callback, buffer not found %s",
- callbackId.to_string().c_str());
- return;
- }
- callback(callbackId, releaseFence, transformHint, currentMaxAcquiredBufferCount);
-}
-
-ReleaseBufferCallback TransactionCompletedListener::popReleaseBufferCallbackLocked(
- const ReleaseCallbackId& callbackId) {
- ReleaseBufferCallback callback;
- auto itr = mReleaseBufferCallbacks.find(callbackId);
- if (itr == mReleaseBufferCallbacks.end()) {
- return nullptr;
- }
- callback = itr->second;
- mReleaseBufferCallbacks.erase(itr);
- return callback;
}
// ---------------------------------------------------------------------------
@@ -501,26 +348,15 @@ void removeDeadBufferCallback(void* /*context*/, uint64_t graphicBufferId) {
// ---------------------------------------------------------------------------
-// Initialize transaction id counter used to generate transaction ids
-// Transactions will start counting at 1, 0 is used for invalid transactions
-std::atomic<uint32_t> SurfaceComposerClient::Transaction::idCounter = 1;
-
-SurfaceComposerClient::Transaction::Transaction() {
- mId = generateId();
-}
-
SurfaceComposerClient::Transaction::Transaction(const Transaction& other)
- : mId(other.mId),
- mForceSynchronous(other.mForceSynchronous),
+ : mForceSynchronous(other.mForceSynchronous),
mTransactionNestCount(other.mTransactionNestCount),
mAnimation(other.mAnimation),
- mEarlyWakeupStart(other.mEarlyWakeupStart),
- mEarlyWakeupEnd(other.mEarlyWakeupEnd),
+ mEarlyWakeup(other.mEarlyWakeup),
+ mExplicitEarlyWakeupStart(other.mExplicitEarlyWakeupStart),
+ mExplicitEarlyWakeupEnd(other.mExplicitEarlyWakeupEnd),
mContainsBuffer(other.mContainsBuffer),
- mDesiredPresentTime(other.mDesiredPresentTime),
- mIsAutoTimestamp(other.mIsAutoTimestamp),
- mFrameTimelineInfo(other.mFrameTimelineInfo),
- mApplyToken(other.mApplyToken) {
+ mDesiredPresentTime(other.mDesiredPresentTime) {
mDisplayStates = other.mDisplayStates;
mComposerStates = other.mComposerStates;
mInputWindowCommands = other.mInputWindowCommands;
@@ -536,24 +372,16 @@ SurfaceComposerClient::Transaction::createFromParcel(const Parcel* parcel) {
return nullptr;
}
-int64_t SurfaceComposerClient::Transaction::generateId() {
- return (((int64_t)getpid()) << 32) | idCounter++;
-}
-
status_t SurfaceComposerClient::Transaction::readFromParcel(const Parcel* parcel) {
const uint32_t forceSynchronous = parcel->readUint32();
const uint32_t transactionNestCount = parcel->readUint32();
const bool animation = parcel->readBool();
- const bool earlyWakeupStart = parcel->readBool();
- const bool earlyWakeupEnd = parcel->readBool();
+ const bool earlyWakeup = parcel->readBool();
+ const bool explicitEarlyWakeupStart = parcel->readBool();
+ const bool explicitEarlyWakeupEnd = parcel->readBool();
const bool containsBuffer = parcel->readBool();
const int64_t desiredPresentTime = parcel->readInt64();
- const bool isAutoTimestamp = parcel->readBool();
- FrameTimelineInfo frameTimelineInfo;
- SAFE_PARCEL(frameTimelineInfo.read, *parcel);
- sp<IBinder> applyToken;
- parcel->readNullableStrongBinder(&applyToken);
size_t count = static_cast<size_t>(parcel->readUint32());
if (count > parcel->dataSize()) {
return BAD_VALUE;
@@ -582,9 +410,7 @@ status_t SurfaceComposerClient::Transaction::readFromParcel(const Parcel* parcel
return BAD_VALUE;
}
for (size_t j = 0; j < numCallbackIds; j++) {
- CallbackId id;
- parcel->readParcelable(&id);
- listenerCallbacks[listener].callbackIds.insert(id);
+ listenerCallbacks[listener].callbackIds.insert(parcel->readInt64());
}
size_t numSurfaces = parcel->readUint32();
if (numSurfaces > parcel->dataSize()) {
@@ -592,7 +418,7 @@ status_t SurfaceComposerClient::Transaction::readFromParcel(const Parcel* parcel
}
for (size_t j = 0; j < numSurfaces; j++) {
sp<SurfaceControl> surface;
- SAFE_PARCEL(SurfaceControl::readFromParcel, *parcel, &surface);
+ surface = SurfaceControl::readFromParcel(parcel);
listenerCallbacks[listener].surfaceControls.insert(surface);
}
}
@@ -604,14 +430,12 @@ status_t SurfaceComposerClient::Transaction::readFromParcel(const Parcel* parcel
std::unordered_map<sp<IBinder>, ComposerState, IBinderHash> composerStates;
composerStates.reserve(count);
for (size_t i = 0; i < count; i++) {
- sp<IBinder> surfaceControlHandle;
- SAFE_PARCEL(parcel->readStrongBinder, &surfaceControlHandle);
+ sp<IBinder> surfaceControlHandle = parcel->readStrongBinder();
ComposerState composerState;
if (composerState.read(*parcel) == BAD_VALUE) {
return BAD_VALUE;
}
-
composerStates[surfaceControlHandle] = composerState;
}
@@ -622,17 +446,15 @@ status_t SurfaceComposerClient::Transaction::readFromParcel(const Parcel* parcel
mForceSynchronous = forceSynchronous;
mTransactionNestCount = transactionNestCount;
mAnimation = animation;
- mEarlyWakeupStart = earlyWakeupStart;
- mEarlyWakeupEnd = earlyWakeupEnd;
+ mEarlyWakeup = earlyWakeup;
+ mExplicitEarlyWakeupStart = explicitEarlyWakeupStart;
+ mExplicitEarlyWakeupEnd = explicitEarlyWakeupEnd;
mContainsBuffer = containsBuffer;
mDesiredPresentTime = desiredPresentTime;
- mIsAutoTimestamp = isAutoTimestamp;
- mFrameTimelineInfo = frameTimelineInfo;
mDisplayStates = displayStates;
mListenerCallbacks = listenerCallbacks;
mComposerStates = composerStates;
mInputWindowCommands = inputWindowCommands;
- mApplyToken = applyToken;
return NO_ERROR;
}
@@ -653,13 +475,11 @@ status_t SurfaceComposerClient::Transaction::writeToParcel(Parcel* parcel) const
parcel->writeUint32(mForceSynchronous);
parcel->writeUint32(mTransactionNestCount);
parcel->writeBool(mAnimation);
- parcel->writeBool(mEarlyWakeupStart);
- parcel->writeBool(mEarlyWakeupEnd);
+ parcel->writeBool(mEarlyWakeup);
+ parcel->writeBool(mExplicitEarlyWakeupStart);
+ parcel->writeBool(mExplicitEarlyWakeupEnd);
parcel->writeBool(mContainsBuffer);
parcel->writeInt64(mDesiredPresentTime);
- parcel->writeBool(mIsAutoTimestamp);
- SAFE_PARCEL(mFrameTimelineInfo.write, *parcel);
- parcel->writeStrongBinder(mApplyToken);
parcel->writeUint32(static_cast<uint32_t>(mDisplayStates.size()));
for (auto const& displayState : mDisplayStates) {
displayState.write(*parcel);
@@ -670,17 +490,17 @@ status_t SurfaceComposerClient::Transaction::writeToParcel(Parcel* parcel) const
parcel->writeStrongBinder(ITransactionCompletedListener::asBinder(listener));
parcel->writeUint32(static_cast<uint32_t>(callbackInfo.callbackIds.size()));
for (auto callbackId : callbackInfo.callbackIds) {
- parcel->writeParcelable(callbackId);
+ parcel->writeInt64(callbackId);
}
parcel->writeUint32(static_cast<uint32_t>(callbackInfo.surfaceControls.size()));
for (auto surfaceControl : callbackInfo.surfaceControls) {
- SAFE_PARCEL(surfaceControl->writeToParcel, *parcel);
+ surfaceControl->writeToParcel(parcel);
}
}
parcel->writeUint32(static_cast<uint32_t>(mComposerStates.size()));
- for (auto const& [handle, composerState] : mComposerStates) {
- SAFE_PARCEL(parcel->writeStrongBinder, handle);
+ for (auto const& [surfaceHandle, composerState] : mComposerStates) {
+ parcel->writeStrongBinder(surfaceHandle);
composerState.write(*parcel);
}
@@ -689,11 +509,11 @@ status_t SurfaceComposerClient::Transaction::writeToParcel(Parcel* parcel) const
}
SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::merge(Transaction&& other) {
- for (auto const& [handle, composerState] : other.mComposerStates) {
- if (mComposerStates.count(handle) == 0) {
- mComposerStates[handle] = composerState;
+ for (auto const& [surfaceHandle, composerState] : other.mComposerStates) {
+ if (mComposerStates.count(surfaceHandle) == 0) {
+ mComposerStates[surfaceHandle] = composerState;
} else {
- mComposerStates[handle].state.merge(composerState.state);
+ mComposerStates[surfaceHandle].state.merge(composerState.state);
}
}
@@ -732,12 +552,9 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::merge(Tr
mInputWindowCommands.merge(other.mInputWindowCommands);
mContainsBuffer |= other.mContainsBuffer;
- mEarlyWakeupStart = mEarlyWakeupStart || other.mEarlyWakeupStart;
- mEarlyWakeupEnd = mEarlyWakeupEnd || other.mEarlyWakeupEnd;
- mApplyToken = other.mApplyToken;
-
- mFrameTimelineInfo.merge(other.mFrameTimelineInfo);
-
+ mEarlyWakeup = mEarlyWakeup || other.mEarlyWakeup;
+ mExplicitEarlyWakeupStart = mExplicitEarlyWakeupStart || other.mExplicitEarlyWakeupStart;
+ mExplicitEarlyWakeupEnd = mExplicitEarlyWakeupEnd || other.mExplicitEarlyWakeupEnd;
other.clear();
return *this;
}
@@ -751,12 +568,10 @@ void SurfaceComposerClient::Transaction::clear() {
mForceSynchronous = 0;
mTransactionNestCount = 0;
mAnimation = false;
- mEarlyWakeupStart = false;
- mEarlyWakeupEnd = false;
- mDesiredPresentTime = 0;
- mIsAutoTimestamp = true;
- mFrameTimelineInfo.clear();
- mApplyToken = nullptr;
+ mEarlyWakeup = false;
+ mExplicitEarlyWakeupStart = false;
+ mExplicitEarlyWakeupEnd = false;
+ mDesiredPresentTime = -1;
}
void SurfaceComposerClient::doUncacheBufferTransaction(uint64_t cacheId) {
@@ -767,8 +582,7 @@ void SurfaceComposerClient::doUncacheBufferTransaction(uint64_t cacheId) {
uncacheBuffer.id = cacheId;
sp<IBinder> applyToken = IInterface::asBinder(TransactionCompletedListener::getIInstance());
- sf->setTransactionState(FrameTimelineInfo{}, {}, {}, 0, applyToken, {}, systemTime(), true,
- uncacheBuffer, false, {}, 0 /* Undefined transactionId */);
+ sf->setTransactionState({}, {}, 0, applyToken, {}, -1, uncacheBuffer, false, {});
}
void SurfaceComposerClient::Transaction::cacheBuffers() {
@@ -778,7 +592,7 @@ void SurfaceComposerClient::Transaction::cacheBuffers() {
size_t count = 0;
for (auto& [handle, cs] : mComposerStates) {
- layer_state_t* s = &(mComposerStates[handle].state);
+ layer_state_t* s = getLayerState(handle);
if (!(s->what & layer_state_t::eBufferChanged)) {
continue;
} else if (s->what & layer_state_t::eCachedBufferChanged) {
@@ -851,6 +665,8 @@ status_t SurfaceComposerClient::Transaction::apply(bool synchronous) {
}
}
+ mListenerCallbacks.clear();
+
cacheBuffers();
Vector<ComposerState> composerStates;
@@ -863,7 +679,10 @@ status_t SurfaceComposerClient::Transaction::apply(bool synchronous) {
composerStates.add(kv.second);
}
- displayStates = std::move(mDisplayStates);
+ mComposerStates.clear();
+
+ displayStates = mDisplayStates;
+ mDisplayStates.clear();
if (mForceSynchronous) {
flags |= ISurfaceComposer::eSynchronous;
@@ -871,29 +690,31 @@ status_t SurfaceComposerClient::Transaction::apply(bool synchronous) {
if (mAnimation) {
flags |= ISurfaceComposer::eAnimation;
}
+ if (mEarlyWakeup) {
+ flags |= ISurfaceComposer::eEarlyWakeup;
+ }
- // If both mEarlyWakeupStart and mEarlyWakeupEnd are set
+ // If both mExplicitEarlyWakeupStart and mExplicitEarlyWakeupEnd are set
// it is equivalent for none
- if (mEarlyWakeupStart && !mEarlyWakeupEnd) {
- flags |= ISurfaceComposer::eEarlyWakeupStart;
+ if (mExplicitEarlyWakeupStart && !mExplicitEarlyWakeupEnd) {
+ flags |= ISurfaceComposer::eExplicitEarlyWakeupStart;
}
- if (mEarlyWakeupEnd && !mEarlyWakeupStart) {
- flags |= ISurfaceComposer::eEarlyWakeupEnd;
+ if (mExplicitEarlyWakeupEnd && !mExplicitEarlyWakeupStart) {
+ flags |= ISurfaceComposer::eExplicitEarlyWakeupEnd;
}
- sp<IBinder> applyToken = mApplyToken
- ? mApplyToken
- : IInterface::asBinder(TransactionCompletedListener::getIInstance());
+ mForceSynchronous = false;
+ mAnimation = false;
+ mEarlyWakeup = false;
+ mExplicitEarlyWakeupStart = false;
+ mExplicitEarlyWakeupEnd = false;
- sf->setTransactionState(mFrameTimelineInfo, composerStates, displayStates, flags, applyToken,
- mInputWindowCommands, mDesiredPresentTime, mIsAutoTimestamp,
+ sp<IBinder> applyToken = IInterface::asBinder(TransactionCompletedListener::getIInstance());
+ sf->setTransactionState(composerStates, displayStates, flags, applyToken, mInputWindowCommands,
+ mDesiredPresentTime,
{} /*uncacheBuffer - only set in doUncacheBufferTransaction*/,
- hasListenerCallbacks, listenerCallbacks, mId);
- mId = generateId();
-
- // Clear the current states and flags
- clear();
-
+ hasListenerCallbacks, listenerCallbacks);
+ mInputWindowCommands.clear();
mStatus = NO_ERROR;
return NO_ERROR;
}
@@ -929,24 +750,23 @@ void SurfaceComposerClient::Transaction::setAnimationTransaction() {
mAnimation = true;
}
-void SurfaceComposerClient::Transaction::setEarlyWakeupStart() {
- mEarlyWakeupStart = true;
+void SurfaceComposerClient::Transaction::setEarlyWakeup() {
+ mEarlyWakeup = true;
}
-void SurfaceComposerClient::Transaction::setEarlyWakeupEnd() {
- mEarlyWakeupEnd = true;
+void SurfaceComposerClient::Transaction::setExplicitEarlyWakeupStart() {
+ mExplicitEarlyWakeupStart = true;
}
-layer_state_t* SurfaceComposerClient::Transaction::getLayerState(const sp<SurfaceControl>& sc) {
- auto handle = sc->getLayerStateHandle();
+void SurfaceComposerClient::Transaction::setExplicitEarlyWakeupEnd() {
+ mExplicitEarlyWakeupEnd = true;
+}
+layer_state_t* SurfaceComposerClient::Transaction::getLayerState(const sp<IBinder>& handle) {
if (mComposerStates.count(handle) == 0) {
// we don't have it, add an initialized layer_state to our list
ComposerState s;
-
s.state.surface = handle;
- s.state.layerId = sc->getLayerId();
-
mComposerStates[handle] = s;
}
@@ -1017,8 +837,8 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setLayer
return *this;
}
-SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setRelativeLayer(
- const sp<SurfaceControl>& sc, const sp<SurfaceControl>& relativeTo, int32_t z) {
+SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setRelativeLayer(const sp<SurfaceControl>& sc, const sp<IBinder>& relativeTo,
+ int32_t z) {
layer_state_t* s = getLayerState(sc);
if (!s) {
mStatus = BAD_INDEX;
@@ -1026,7 +846,7 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setRelat
}
s->what |= layer_state_t::eRelativeLayerChanged;
s->what &= ~layer_state_t::eLayerChanged;
- s->relativeLayerSurfaceControl = relativeTo;
+ s->relativeLayerHandle = relativeTo;
s->z = z;
registerSurfaceControlForCallback(sc);
@@ -1041,9 +861,9 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setFlags
mStatus = BAD_INDEX;
return *this;
}
- if ((mask & layer_state_t::eLayerOpaque) || (mask & layer_state_t::eLayerHidden) ||
- (mask & layer_state_t::eLayerSecure) || (mask & layer_state_t::eLayerSkipScreenshot) ||
- (mask & layer_state_t::eEnableBackpressure)) {
+ if ((mask & layer_state_t::eLayerOpaque) ||
+ (mask & layer_state_t::eLayerHidden) ||
+ (mask & layer_state_t::eLayerSecure)) {
s->what |= layer_state_t::eFlagsChanged;
}
s->flags &= ~mask;
@@ -1132,15 +952,15 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setMatri
return *this;
}
-SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setCrop(
+SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setCrop_legacy(
const sp<SurfaceControl>& sc, const Rect& crop) {
layer_state_t* s = getLayerState(sc);
if (!s) {
mStatus = BAD_INDEX;
return *this;
}
- s->what |= layer_state_t::eCropChanged;
- s->crop = crop;
+ s->what |= layer_state_t::eCropChanged_legacy;
+ s->crop_legacy = crop;
registerSurfaceControlForCallback(sc);
return *this;
@@ -1170,30 +990,65 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setBackg
return *this;
}
-SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setBlurRegions(
- const sp<SurfaceControl>& sc, const std::vector<BlurRegion>& blurRegions) {
+SurfaceComposerClient::Transaction&
+SurfaceComposerClient::Transaction::deferTransactionUntil_legacy(const sp<SurfaceControl>& sc,
+ const sp<IBinder>& handle,
+ uint64_t frameNumber) {
layer_state_t* s = getLayerState(sc);
if (!s) {
mStatus = BAD_INDEX;
return *this;
}
- s->what |= layer_state_t::eBlurRegionsChanged;
- s->blurRegions = blurRegions;
+ s->what |= layer_state_t::eDeferTransaction_legacy;
+ s->barrierHandle_legacy = handle;
+ s->frameNumber_legacy = frameNumber;
+
+ registerSurfaceControlForCallback(sc);
return *this;
}
-SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::reparent(
- const sp<SurfaceControl>& sc, const sp<SurfaceControl>& newParent) {
+SurfaceComposerClient::Transaction&
+SurfaceComposerClient::Transaction::deferTransactionUntil_legacy(const sp<SurfaceControl>& sc,
+ const sp<Surface>& barrierSurface,
+ uint64_t frameNumber) {
+ layer_state_t* s = getLayerState(sc);
+ if (!s) {
+ mStatus = BAD_INDEX;
+ return *this;
+ }
+ s->what |= layer_state_t::eDeferTransaction_legacy;
+ s->barrierGbp_legacy = barrierSurface->getIGraphicBufferProducer();
+ s->frameNumber_legacy = frameNumber;
+
+ registerSurfaceControlForCallback(sc);
+ return *this;
+}
+
+SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::reparentChildren(
+ const sp<SurfaceControl>& sc,
+ const sp<IBinder>& newParentHandle) {
layer_state_t* s = getLayerState(sc);
if (!s) {
mStatus = BAD_INDEX;
return *this;
}
- if (SurfaceControl::isSameSurface(sc, newParent)) {
+ s->what |= layer_state_t::eReparentChildren;
+ s->reparentHandle = newParentHandle;
+
+ registerSurfaceControlForCallback(sc);
+ return *this;
+}
+
+SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::reparent(
+ const sp<SurfaceControl>& sc,
+ const sp<IBinder>& newParentHandle) {
+ layer_state_t* s = getLayerState(sc);
+ if (!s) {
+ mStatus = BAD_INDEX;
return *this;
}
s->what |= layer_state_t::eReparent;
- s->parentSurfaceControlForChild = newParent ? newParent->getParentingLayer() : nullptr;
+ s->parentHandleForChild = newParentHandle;
registerSurfaceControlForCallback(sc);
return *this;
@@ -1260,58 +1115,48 @@ SurfaceComposerClient::Transaction::setTransformToDisplayInverse(const sp<Surfac
return *this;
}
-SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setBuffer(
- const sp<SurfaceControl>& sc, const sp<GraphicBuffer>& buffer, const ReleaseCallbackId& id,
- ReleaseBufferCallback callback) {
+SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setCrop(
+ const sp<SurfaceControl>& sc, const Rect& crop) {
layer_state_t* s = getLayerState(sc);
if (!s) {
mStatus = BAD_INDEX;
return *this;
}
- removeReleaseBufferCallback(s);
- s->what |= layer_state_t::eBufferChanged;
- s->buffer = buffer;
- if (mIsAutoTimestamp) {
- mDesiredPresentTime = systemTime();
- }
- setReleaseBufferCallback(s, id, callback);
+ s->what |= layer_state_t::eCropChanged;
+ s->crop = crop;
registerSurfaceControlForCallback(sc);
-
- mContainsBuffer = true;
return *this;
}
-void SurfaceComposerClient::Transaction::removeReleaseBufferCallback(layer_state_t* s) {
- if (!s->releaseBufferListener) {
- return;
+SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setFrame(
+ const sp<SurfaceControl>& sc, const Rect& frame) {
+ layer_state_t* s = getLayerState(sc);
+ if (!s) {
+ mStatus = BAD_INDEX;
+ return *this;
}
+ s->what |= layer_state_t::eFrameChanged;
+ s->frame = frame;
- s->what &= ~static_cast<uint64_t>(layer_state_t::eReleaseBufferListenerChanged);
- s->releaseBufferListener = nullptr;
- auto listener = TransactionCompletedListener::getInstance();
- listener->removeReleaseBufferCallback(s->releaseCallbackId);
- s->releaseCallbackId = ReleaseCallbackId::INVALID_ID;
+ registerSurfaceControlForCallback(sc);
+ return *this;
}
-void SurfaceComposerClient::Transaction::setReleaseBufferCallback(layer_state_t* s,
- const ReleaseCallbackId& id,
- ReleaseBufferCallback callback) {
- if (!callback) {
- return;
+SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setBuffer(
+ const sp<SurfaceControl>& sc, const sp<GraphicBuffer>& buffer) {
+ layer_state_t* s = getLayerState(sc);
+ if (!s) {
+ mStatus = BAD_INDEX;
+ return *this;
}
+ s->what |= layer_state_t::eBufferChanged;
+ s->buffer = buffer;
- if (!s->buffer) {
- ALOGW("Transaction::setReleaseBufferCallback"
- "ignored trying to set a callback on a null buffer.");
- return;
- }
+ registerSurfaceControlForCallback(sc);
- s->what |= layer_state_t::eReleaseBufferListenerChanged;
- s->releaseBufferListener = TransactionCompletedListener::getIInstance();
- s->releaseCallbackId = id;
- auto listener = TransactionCompletedListener::getInstance();
- listener->setReleaseBufferCallback(id, callback);
+ mContainsBuffer = true;
+ return *this;
}
SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setAcquireFence(
@@ -1401,7 +1246,6 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setSideb
SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setDesiredPresentTime(
nsecs_t desiredPresentTime) {
mDesiredPresentTime = desiredPresentTime;
- mIsAutoTimestamp = false;
return *this;
}
@@ -1435,9 +1279,9 @@ SurfaceComposerClient::Transaction::setFrameRateSelectionPriority(const sp<Surfa
return *this;
}
-SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::addTransactionCallback(
- TransactionCompletedCallbackTakesContext callback, void* callbackContext,
- CallbackId::Type callbackType) {
+SurfaceComposerClient::Transaction&
+SurfaceComposerClient::Transaction::addTransactionCompletedCallback(
+ TransactionCompletedCallbackTakesContext callback, void* callbackContext) {
auto listener = TransactionCompletedListener::getInstance();
auto callbackWithContext = std::bind(callback, callbackContext, std::placeholders::_1,
@@ -1445,49 +1289,64 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::addTrans
const auto& surfaceControls =
mListenerCallbacks[TransactionCompletedListener::getIInstance()].surfaceControls;
- CallbackId callbackId =
- listener->addCallbackFunction(callbackWithContext, surfaceControls, callbackType);
+ CallbackId callbackId = listener->addCallbackFunction(callbackWithContext, surfaceControls);
mListenerCallbacks[TransactionCompletedListener::getIInstance()].callbackIds.emplace(
callbackId);
return *this;
}
-SurfaceComposerClient::Transaction&
-SurfaceComposerClient::Transaction::addTransactionCompletedCallback(
- TransactionCompletedCallbackTakesContext callback, void* callbackContext) {
- return addTransactionCallback(callback, callbackContext, CallbackId::Type::ON_COMPLETE);
-}
+SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::notifyProducerDisconnect(
+ const sp<SurfaceControl>& sc) {
+ layer_state_t* s = getLayerState(sc);
+ if (!s) {
+ mStatus = BAD_INDEX;
+ return *this;
+ }
-SurfaceComposerClient::Transaction&
-SurfaceComposerClient::Transaction::addTransactionCommittedCallback(
- TransactionCompletedCallbackTakesContext callback, void* callbackContext) {
- return addTransactionCallback(callback, callbackContext, CallbackId::Type::ON_COMMIT);
+ s->what |= layer_state_t::eProducerDisconnect;
+ return *this;
}
-SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::notifyProducerDisconnect(
+SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::detachChildren(
const sp<SurfaceControl>& sc) {
layer_state_t* s = getLayerState(sc);
if (!s) {
mStatus = BAD_INDEX;
return *this;
}
+ s->what |= layer_state_t::eDetachChildren;
- s->what |= layer_state_t::eProducerDisconnect;
+ registerSurfaceControlForCallback(sc);
return *this;
}
-SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setFrameNumber(
- const sp<SurfaceControl>& sc, uint64_t frameNumber) {
+SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setOverrideScalingMode(
+ const sp<SurfaceControl>& sc, int32_t overrideScalingMode) {
layer_state_t* s = getLayerState(sc);
if (!s) {
mStatus = BAD_INDEX;
return *this;
}
- s->what |= layer_state_t::eFrameNumberChanged;
- s->frameNumber = frameNumber;
+ switch (overrideScalingMode) {
+ case NATIVE_WINDOW_SCALING_MODE_FREEZE:
+ case NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW:
+ case NATIVE_WINDOW_SCALING_MODE_SCALE_CROP:
+ case NATIVE_WINDOW_SCALING_MODE_NO_SCALE_CROP:
+ case -1:
+ break;
+ default:
+ ALOGE("unknown scaling mode: %d",
+ overrideScalingMode);
+ mStatus = BAD_VALUE;
+ return *this;
+ }
+ s->what |= layer_state_t::eOverrideScalingModeChanged;
+ s->overrideScalingMode = overrideScalingMode;
+
+ registerSurfaceControlForCallback(sc);
return *this;
}
@@ -1500,17 +1359,11 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setInput
mStatus = BAD_INDEX;
return *this;
}
- s->inputHandle = new InputWindowHandle(info);
+ s->inputInfo = info;
s->what |= layer_state_t::eInputInfoChanged;
return *this;
}
-SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setFocusedWindow(
- const FocusRequest& request) {
- mInputWindowCommands.focusRequests.push_back(request);
- return *this;
-}
-
SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::syncInputWindows() {
mInputWindowCommands.syncInputWindows = true;
return *this;
@@ -1534,7 +1387,7 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setColor
SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setGeometry(
const sp<SurfaceControl>& sc, const Rect& source, const Rect& dst, int transform) {
- setCrop(sc, source);
+ setCrop_legacy(sc, source);
int x = dst.left;
int y = dst.top;
@@ -1599,25 +1452,19 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setShado
}
SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setFrameRate(
- const sp<SurfaceControl>& sc, float frameRate, int8_t compatibility,
- int8_t changeFrameRateStrategy) {
+ const sp<SurfaceControl>& sc, float frameRate, int8_t compatibility) {
layer_state_t* s = getLayerState(sc);
if (!s) {
mStatus = BAD_INDEX;
return *this;
}
- // Allow privileged values as well here, those will be ignored by SF if
- // the caller is not privileged
- if (!ValidateFrameRate(frameRate, compatibility, changeFrameRateStrategy,
- "Transaction::setFrameRate",
- /*privileged=*/true)) {
+ if (!ValidateFrameRate(frameRate, compatibility, "Transaction::setFrameRate")) {
mStatus = BAD_VALUE;
return *this;
}
s->what |= layer_state_t::eFrameRateChanged;
s->frameRate = frameRate;
s->frameRateCompatibility = compatibility;
- s->changeFrameRateStrategy = changeFrameRateStrategy;
return *this;
}
@@ -1637,25 +1484,6 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setFixed
return *this;
}
-SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setFrameTimelineInfo(
- const FrameTimelineInfo& frameTimelineInfo) {
- mFrameTimelineInfo.merge(frameTimelineInfo);
- return *this;
-}
-
-SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setAutoRefresh(
- const sp<SurfaceControl>& sc, bool autoRefresh) {
- layer_state_t* s = getLayerState(sc);
- if (!s) {
- mStatus = BAD_INDEX;
- return *this;
- }
-
- s->what |= layer_state_t::eAutoRefreshChanged;
- s->autoRefresh = autoRefresh;
- return *this;
-}
-
SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setTrustedOverlay(
const sp<SurfaceControl>& sc, bool isTrustedOverlay) {
layer_state_t* s = getLayerState(sc);
@@ -1669,55 +1497,6 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setTrust
return *this;
}
-SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setApplyToken(
- const sp<IBinder>& applyToken) {
- mApplyToken = applyToken;
- return *this;
-}
-
-SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setStretchEffect(
- const sp<SurfaceControl>& sc, const StretchEffect& stretchEffect) {
- layer_state_t* s = getLayerState(sc);
- if (!s) {
- mStatus = BAD_INDEX;
- return *this;
- }
-
- s->what |= layer_state_t::eStretchChanged;
- s->stretchEffect = stretchEffect;
- return *this;
-}
-
-SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setBufferCrop(
- const sp<SurfaceControl>& sc, const Rect& bufferCrop) {
- layer_state_t* s = getLayerState(sc);
- if (!s) {
- mStatus = BAD_INDEX;
- return *this;
- }
-
- s->what |= layer_state_t::eBufferCropChanged;
- s->bufferCrop = bufferCrop;
-
- registerSurfaceControlForCallback(sc);
- return *this;
-}
-
-SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setDestinationFrame(
- const sp<SurfaceControl>& sc, const Rect& destinationFrame) {
- layer_state_t* s = getLayerState(sc);
- if (!s) {
- mStatus = BAD_INDEX;
- return *this;
- }
-
- s->what |= layer_state_t::eDestinationFrameChanged;
- s->destinationFrame = destinationFrame;
-
- registerSurfaceControlForCallback(sc);
- return *this;
-}
-
// ---------------------------------------------------------------------------
DisplayState& SurfaceComposerClient::Transaction::getDisplayState(const sp<IBinder>& token) {
@@ -1764,8 +1543,8 @@ void SurfaceComposerClient::Transaction::setDisplayProjection(const sp<IBinder>&
const Rect& displayRect) {
DisplayState& s(getDisplayState(token));
s.orientation = orientation;
- s.layerStackSpaceRect = layerStackRect;
- s.orientedDisplaySpaceRect = displayRect;
+ s.viewport = layerStackRect;
+ s.frame = displayRect;
s.what |= DisplayState::eDisplayProjectionChanged;
mForceSynchronous = true; // TODO: do we actually still need this?
}
@@ -1833,11 +1612,11 @@ void SurfaceComposerClient::dispose() {
sp<SurfaceControl> SurfaceComposerClient::createSurface(const String8& name, uint32_t w, uint32_t h,
PixelFormat format, uint32_t flags,
- const sp<IBinder>& parentHandle,
+ SurfaceControl* parent,
LayerMetadata metadata,
uint32_t* outTransformHint) {
sp<SurfaceControl> s;
- createSurfaceChecked(name, w, h, format, &s, flags, parentHandle, std::move(metadata),
+ createSurfaceChecked(name, w, h, format, &s, flags, parent, std::move(metadata),
outTransformHint);
return s;
}
@@ -1856,16 +1635,14 @@ sp<SurfaceControl> SurfaceComposerClient::createWithSurfaceParent(const String8&
sp<IGraphicBufferProducer> gbp;
uint32_t transformHint = 0;
- int32_t id = -1;
err = mClient->createWithSurfaceParent(name, w, h, format, flags, parentGbp,
- std::move(metadata), &handle, &gbp, &id,
- &transformHint);
+ std::move(metadata), &handle, &gbp, &transformHint);
if (outTransformHint) {
*outTransformHint = transformHint;
}
ALOGE_IF(err, "SurfaceComposerClient::createWithSurfaceParent error %s", strerror(-err));
if (err == NO_ERROR) {
- return new SurfaceControl(this, handle, gbp, id, transformHint);
+ return new SurfaceControl(this, handle, gbp, transformHint);
}
}
return nullptr;
@@ -1874,28 +1651,29 @@ sp<SurfaceControl> SurfaceComposerClient::createWithSurfaceParent(const String8&
status_t SurfaceComposerClient::createSurfaceChecked(const String8& name, uint32_t w, uint32_t h,
PixelFormat format,
sp<SurfaceControl>* outSurface, uint32_t flags,
- const sp<IBinder>& parentHandle,
- LayerMetadata metadata,
+ SurfaceControl* parent, LayerMetadata metadata,
uint32_t* outTransformHint) {
sp<SurfaceControl> sur;
status_t err = mStatus;
if (mStatus == NO_ERROR) {
sp<IBinder> handle;
+ sp<IBinder> parentHandle;
sp<IGraphicBufferProducer> gbp;
+ if (parent != nullptr) {
+ parentHandle = parent->getHandle();
+ }
+
uint32_t transformHint = 0;
- int32_t id = -1;
err = mClient->createSurface(name, w, h, format, flags, parentHandle, std::move(metadata),
- &handle, &gbp, &id, &transformHint);
-
+ &handle, &gbp, &transformHint);
if (outTransformHint) {
*outTransformHint = transformHint;
}
ALOGE_IF(err, "SurfaceComposerClient::createSurface error %s", strerror(-err));
if (err == NO_ERROR) {
- *outSurface =
- new SurfaceControl(this, handle, gbp, id, w, h, format, transformHint, flags);
+ *outSurface = new SurfaceControl(this, handle, gbp, transformHint);
}
}
return err;
@@ -1908,10 +1686,9 @@ sp<SurfaceControl> SurfaceComposerClient::mirrorSurface(SurfaceControl* mirrorFr
sp<IBinder> handle;
sp<IBinder> mirrorFromHandle = mirrorFromSurface->getHandle();
- int32_t layer_id = -1;
- status_t err = mClient->mirrorSurface(mirrorFromHandle, &handle, &layer_id);
+ status_t err = mClient->mirrorSurface(mirrorFromHandle, &handle);
if (err == NO_ERROR) {
- return new SurfaceControl(this, handle, nullptr, layer_id, true /* owned */);
+ return new SurfaceControl(this, handle, nullptr, true /* owned */);
}
return nullptr;
}
@@ -1948,54 +1725,64 @@ status_t SurfaceComposerClient::getDisplayState(const sp<IBinder>& display,
return ComposerService::getComposerService()->getDisplayState(display, state);
}
-status_t SurfaceComposerClient::getStaticDisplayInfo(const sp<IBinder>& display,
- ui::StaticDisplayInfo* info) {
- return ComposerService::getComposerService()->getStaticDisplayInfo(display, info);
+status_t SurfaceComposerClient::getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info) {
+ return ComposerService::getComposerService()->getDisplayInfo(display, info);
}
-status_t SurfaceComposerClient::getDynamicDisplayInfo(const sp<IBinder>& display,
- ui::DynamicDisplayInfo* info) {
- return ComposerService::getComposerService()->getDynamicDisplayInfo(display, info);
+status_t SurfaceComposerClient::getDisplayConfigs(const sp<IBinder>& display,
+ Vector<DisplayConfig>* configs) {
+ return ComposerService::getComposerService()->getDisplayConfigs(display, configs);
}
-status_t SurfaceComposerClient::getActiveDisplayMode(const sp<IBinder>& display,
- ui::DisplayMode* mode) {
- ui::DynamicDisplayInfo info;
- status_t result = getDynamicDisplayInfo(display, &info);
+status_t SurfaceComposerClient::getActiveDisplayConfig(const sp<IBinder>& display,
+ DisplayConfig* config) {
+ Vector<DisplayConfig> configs;
+ status_t result = getDisplayConfigs(display, &configs);
if (result != NO_ERROR) {
return result;
}
- if (const auto activeMode = info.getActiveDisplayMode()) {
- *mode = *activeMode;
- return NO_ERROR;
+ int activeId = getActiveConfig(display);
+ if (activeId < 0) {
+ ALOGE("No active configuration found");
+ return NAME_NOT_FOUND;
}
- ALOGE("Active display mode not found.");
- return NAME_NOT_FOUND;
+ *config = configs[static_cast<size_t>(activeId)];
+ return NO_ERROR;
+}
+
+int SurfaceComposerClient::getActiveConfig(const sp<IBinder>& display) {
+ return ComposerService::getComposerService()->getActiveConfig(display);
}
-status_t SurfaceComposerClient::setDesiredDisplayModeSpecs(
- const sp<IBinder>& displayToken, ui::DisplayModeId defaultMode, bool allowGroupSwitching,
- float primaryRefreshRateMin, float primaryRefreshRateMax, float appRequestRefreshRateMin,
- float appRequestRefreshRateMax) {
+status_t SurfaceComposerClient::setDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken,
+ int32_t defaultConfig,
+ float primaryRefreshRateMin,
+ float primaryRefreshRateMax,
+ float appRequestRefreshRateMin,
+ float appRequestRefreshRateMax) {
return ComposerService::getComposerService()
- ->setDesiredDisplayModeSpecs(displayToken, defaultMode, allowGroupSwitching,
- primaryRefreshRateMin, primaryRefreshRateMax,
- appRequestRefreshRateMin, appRequestRefreshRateMax);
-}
-
-status_t SurfaceComposerClient::getDesiredDisplayModeSpecs(const sp<IBinder>& displayToken,
- ui::DisplayModeId* outDefaultMode,
- bool* outAllowGroupSwitching,
- float* outPrimaryRefreshRateMin,
- float* outPrimaryRefreshRateMax,
- float* outAppRequestRefreshRateMin,
- float* outAppRequestRefreshRateMax) {
+ ->setDesiredDisplayConfigSpecs(displayToken, defaultConfig, primaryRefreshRateMin,
+ primaryRefreshRateMax, appRequestRefreshRateMin,
+ appRequestRefreshRateMax);
+}
+
+status_t SurfaceComposerClient::getDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken,
+ int32_t* outDefaultConfig,
+ float* outPrimaryRefreshRateMin,
+ float* outPrimaryRefreshRateMax,
+ float* outAppRequestRefreshRateMin,
+ float* outAppRequestRefreshRateMax) {
return ComposerService::getComposerService()
- ->getDesiredDisplayModeSpecs(displayToken, outDefaultMode, outAllowGroupSwitching,
- outPrimaryRefreshRateMin, outPrimaryRefreshRateMax,
- outAppRequestRefreshRateMin, outAppRequestRefreshRateMax);
+ ->getDesiredDisplayConfigSpecs(displayToken, outDefaultConfig, outPrimaryRefreshRateMin,
+ outPrimaryRefreshRateMax, outAppRequestRefreshRateMin,
+ outAppRequestRefreshRateMax);
+}
+
+status_t SurfaceComposerClient::getDisplayColorModes(const sp<IBinder>& display,
+ Vector<ColorMode>* outColorModes) {
+ return ComposerService::getComposerService()->getDisplayColorModes(display, outColorModes);
}
status_t SurfaceComposerClient::getDisplayNativePrimaries(const sp<IBinder>& display,
@@ -2003,15 +1790,31 @@ status_t SurfaceComposerClient::getDisplayNativePrimaries(const sp<IBinder>& dis
return ComposerService::getComposerService()->getDisplayNativePrimaries(display, outPrimaries);
}
+ColorMode SurfaceComposerClient::getActiveColorMode(const sp<IBinder>& display) {
+ return ComposerService::getComposerService()->getActiveColorMode(display);
+}
+
status_t SurfaceComposerClient::setActiveColorMode(const sp<IBinder>& display,
ColorMode colorMode) {
return ComposerService::getComposerService()->setActiveColorMode(display, colorMode);
}
+bool SurfaceComposerClient::getAutoLowLatencyModeSupport(const sp<IBinder>& display) {
+ bool supported = false;
+ ComposerService::getComposerService()->getAutoLowLatencyModeSupport(display, &supported);
+ return supported;
+}
+
void SurfaceComposerClient::setAutoLowLatencyMode(const sp<IBinder>& display, bool on) {
ComposerService::getComposerService()->setAutoLowLatencyMode(display, on);
}
+bool SurfaceComposerClient::getGameContentTypeSupport(const sp<IBinder>& display) {
+ bool supported = false;
+ ComposerService::getComposerService()->getGameContentTypeSupport(display, &supported);
+ return supported;
+}
+
void SurfaceComposerClient::setGameContentType(const sp<IBinder>& display, bool on) {
ComposerService::getComposerService()->setGameContentType(display, on);
}
@@ -2043,14 +1846,10 @@ status_t SurfaceComposerClient::getAnimationFrameStats(FrameStats* outStats) {
return ComposerService::getComposerService()->getAnimationFrameStats(outStats);
}
-status_t SurfaceComposerClient::overrideHdrTypes(const sp<IBinder>& display,
- const std::vector<ui::Hdr>& hdrTypes) {
- return ComposerService::getComposerService()->overrideHdrTypes(display, hdrTypes);
-}
-
-status_t SurfaceComposerClient::onPullAtom(const int32_t atomId, std::string* outData,
- bool* success) {
- return ComposerService::getComposerService()->onPullAtom(atomId, outData, success);
+status_t SurfaceComposerClient::getHdrCapabilities(const sp<IBinder>& display,
+ HdrCapabilities* outCapabilities) {
+ return ComposerService::getComposerService()->getHdrCapabilities(display,
+ outCapabilities);
}
status_t SurfaceComposerClient::getDisplayedContentSamplingAttributes(const sp<IBinder>& display,
@@ -2096,25 +1895,6 @@ status_t SurfaceComposerClient::removeRegionSamplingListener(
return ComposerService::getComposerService()->removeRegionSamplingListener(listener);
}
-status_t SurfaceComposerClient::addFpsListener(int32_t taskId,
- const sp<gui::IFpsListener>& listener) {
- return ComposerService::getComposerService()->addFpsListener(taskId, listener);
-}
-
-status_t SurfaceComposerClient::removeFpsListener(const sp<gui::IFpsListener>& listener) {
- return ComposerService::getComposerService()->removeFpsListener(listener);
-}
-
-status_t SurfaceComposerClient::addTunnelModeEnabledListener(
- const sp<gui::ITunnelModeEnabledListener>& listener) {
- return ComposerService::getComposerService()->addTunnelModeEnabledListener(listener);
-}
-
-status_t SurfaceComposerClient::removeTunnelModeEnabledListener(
- const sp<gui::ITunnelModeEnabledListener>& listener) {
- return ComposerService::getComposerService()->removeTunnelModeEnabledListener(listener);
-}
-
bool SurfaceComposerClient::getDisplayBrightnessSupport(const sp<IBinder>& displayToken) {
bool support = false;
ComposerService::getComposerService()->getDisplayBrightnessSupport(displayToken, &support);
@@ -2122,23 +1902,12 @@ bool SurfaceComposerClient::getDisplayBrightnessSupport(const sp<IBinder>& displ
}
status_t SurfaceComposerClient::setDisplayBrightness(const sp<IBinder>& displayToken,
- const gui::DisplayBrightness& brightness) {
+ float brightness) {
return ComposerService::getComposerService()->setDisplayBrightness(displayToken, brightness);
}
-status_t SurfaceComposerClient::addHdrLayerInfoListener(
- const sp<IBinder>& displayToken, const sp<gui::IHdrLayerInfoListener>& listener) {
- return ComposerService::getComposerService()->addHdrLayerInfoListener(displayToken, listener);
-}
-
-status_t SurfaceComposerClient::removeHdrLayerInfoListener(
- const sp<IBinder>& displayToken, const sp<gui::IHdrLayerInfoListener>& listener) {
- return ComposerService::getComposerService()->removeHdrLayerInfoListener(displayToken,
- listener);
-}
-
-status_t SurfaceComposerClient::notifyPowerBoost(int32_t boostId) {
- return ComposerService::getComposerService()->notifyPowerBoost(boostId);
+status_t SurfaceComposerClient::notifyPowerHint(int32_t hintId) {
+ return ComposerService::getComposerService()->notifyPowerHint(hintId);
}
status_t SurfaceComposerClient::setGlobalShadowSettings(const half4& ambientColor,
@@ -2149,34 +1918,61 @@ status_t SurfaceComposerClient::setGlobalShadowSettings(const half4& ambientColo
lightRadius);
}
-int SurfaceComposerClient::getGPUContextPriority() {
- return ComposerService::getComposerService()->getGPUContextPriority();
-}
-
// ----------------------------------------------------------------------------
-status_t ScreenshotClient::captureDisplay(const DisplayCaptureArgs& captureArgs,
- const sp<IScreenCaptureListener>& captureListener) {
+status_t ScreenshotClient::capture(const sp<IBinder>& display, ui::Dataspace reqDataSpace,
+ ui::PixelFormat reqPixelFormat, const Rect& sourceCrop,
+ uint32_t reqWidth, uint32_t reqHeight, bool useIdentityTransform,
+ ui::Rotation rotation, bool captureSecureLayers,
+ sp<GraphicBuffer>* outBuffer, bool& outCapturedSecureLayers) {
sp<ISurfaceComposer> s(ComposerService::getComposerService());
if (s == nullptr) return NO_INIT;
+ status_t ret = s->captureScreen(display, outBuffer, outCapturedSecureLayers, reqDataSpace,
+ reqPixelFormat, sourceCrop, reqWidth, reqHeight,
+ useIdentityTransform, rotation, captureSecureLayers);
+ if (ret != NO_ERROR) {
+ return ret;
+ }
+ return ret;
+}
- return s->captureDisplay(captureArgs, captureListener);
+status_t ScreenshotClient::capture(const sp<IBinder>& display, ui::Dataspace reqDataSpace,
+ ui::PixelFormat reqPixelFormat, const Rect& sourceCrop,
+ uint32_t reqWidth, uint32_t reqHeight, bool useIdentityTransform,
+ ui::Rotation rotation, sp<GraphicBuffer>* outBuffer) {
+ bool ignored;
+ return capture(display, reqDataSpace, reqPixelFormat, sourceCrop, reqWidth, reqHeight,
+ useIdentityTransform, rotation, false, outBuffer, ignored);
}
-status_t ScreenshotClient::captureDisplay(uint64_t displayOrLayerStack,
- const sp<IScreenCaptureListener>& captureListener) {
+status_t ScreenshotClient::capture(uint64_t displayOrLayerStack, ui::Dataspace* outDataspace,
+ sp<GraphicBuffer>* outBuffer) {
sp<ISurfaceComposer> s(ComposerService::getComposerService());
if (s == nullptr) return NO_INIT;
-
- return s->captureDisplay(displayOrLayerStack, captureListener);
+ return s->captureScreen(displayOrLayerStack, outDataspace, outBuffer);
}
-status_t ScreenshotClient::captureLayers(const LayerCaptureArgs& captureArgs,
- const sp<IScreenCaptureListener>& captureListener) {
+status_t ScreenshotClient::captureLayers(const sp<IBinder>& layerHandle, ui::Dataspace reqDataSpace,
+ ui::PixelFormat reqPixelFormat, const Rect& sourceCrop,
+ float frameScale, sp<GraphicBuffer>* outBuffer) {
sp<ISurfaceComposer> s(ComposerService::getComposerService());
if (s == nullptr) return NO_INIT;
+ status_t ret = s->captureLayers(layerHandle, outBuffer, reqDataSpace, reqPixelFormat,
+ sourceCrop, {}, frameScale, false /* childrenOnly */);
+ return ret;
+}
- return s->captureLayers(captureArgs, captureListener);
+status_t ScreenshotClient::captureChildLayers(
+ const sp<IBinder>& layerHandle, ui::Dataspace reqDataSpace, ui::PixelFormat reqPixelFormat,
+ const Rect& sourceCrop,
+ const std::unordered_set<sp<IBinder>, ISurfaceComposer::SpHash<IBinder>>& excludeHandles,
+ float frameScale, sp<GraphicBuffer>* outBuffer) {
+ sp<ISurfaceComposer> s(ComposerService::getComposerService());
+ if (s == nullptr) return NO_INIT;
+ status_t ret =
+ s->captureLayers(layerHandle, outBuffer, reqDataSpace, reqPixelFormat, sourceCrop,
+ excludeHandles, frameScale, true /* childrenOnly */);
+ return ret;
}
} // namespace android