Loading libs/gui/ISurfaceComposer.cpp +85 −2 Original line number Diff line number Diff line Loading @@ -66,7 +66,8 @@ public: virtual void setTransactionState(const Vector<ComposerState>& state, const Vector<DisplayState>& displays, uint32_t flags, const sp<IBinder>& applyToken, const InputWindowCommands& commands) { const InputWindowCommands& commands, int64_t desiredPresentTime) { Parcel data, reply; data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); Loading @@ -83,6 +84,7 @@ public: data.writeUint32(flags); data.writeStrongBinder(applyToken); commands.write(data); data.writeInt64(desiredPresentTime); remote()->transact(BnSurfaceComposer::SET_TRANSACTION_STATE, data, &reply); } Loading Loading @@ -693,6 +695,42 @@ public: } return err; } virtual status_t cacheBuffer(const sp<IBinder>& token, const sp<GraphicBuffer>& buffer, int32_t* outBufferId) { Parcel data, reply; data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); data.writeStrongBinder(token); if (buffer) { data.writeBool(true); data.write(*buffer); } else { data.writeBool(false); } status_t result = remote()->transact(BnSurfaceComposer::CACHE_BUFFER, data, &reply); if (result != NO_ERROR) { return result; } int32_t id = -1; result = reply.readInt32(&id); if (result == NO_ERROR) { *outBufferId = id; } return result; } virtual status_t uncacheBuffer(const sp<IBinder>& token, int32_t bufferId) { Parcel data, reply; data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); data.writeStrongBinder(token); data.writeInt32(bufferId); return remote()->transact(BnSurfaceComposer::UNCACHE_BUFFER, data, &reply); } }; // Out-of-line virtual method definition to trigger vtable emission in this Loading Loading @@ -748,7 +786,10 @@ status_t BnSurfaceComposer::onTransact( sp<IBinder> applyToken = data.readStrongBinder(); InputWindowCommands inputWindowCommands; inputWindowCommands.read(data); setTransactionState(state, displays, stateFlags, applyToken, inputWindowCommands); int64_t desiredPresentTime = data.readInt64(); setTransactionState(state, displays, stateFlags, applyToken, inputWindowCommands, desiredPresentTime); return NO_ERROR; } case BOOT_FINISHED: { Loading Loading @@ -1131,6 +1172,48 @@ status_t BnSurfaceComposer::onTransact( } return error; } case CACHE_BUFFER: { CHECK_INTERFACE(ISurfaceComposer, data, reply); sp<IBinder> token; status_t result = data.readStrongBinder(&token); if (result != NO_ERROR) { ALOGE("cache buffer failure in reading token: %d", result); return result; } sp<GraphicBuffer> buffer = new GraphicBuffer(); if (data.readBool()) { result = data.read(*buffer); if (result != NO_ERROR) { ALOGE("cache buffer failure in reading buffer: %d", result); return result; } } int32_t bufferId = -1; status_t error = cacheBuffer(token, buffer, &bufferId); if (error == NO_ERROR) { reply->writeInt32(bufferId); } return error; } case UNCACHE_BUFFER: { CHECK_INTERFACE(ISurfaceComposer, data, reply); sp<IBinder> token; status_t result = data.readStrongBinder(&token); if (result != NO_ERROR) { ALOGE("uncache buffer failure in reading token: %d", result); return result; } int32_t bufferId = -1; result = data.readInt32(&bufferId); if (result != NO_ERROR) { ALOGE("uncache buffer failure in reading buffer id: %d", result); return result; } return uncacheBuffer(token, bufferId); } default: { return BBinder::onTransact(code, data, reply, flags); } Loading libs/gui/LayerState.cpp +10 −0 Original line number Diff line number Diff line Loading @@ -94,6 +94,9 @@ status_t layer_state_t::write(Parcel& output) const } } output.writeStrongBinder(cachedBuffer.token); output.writeInt32(cachedBuffer.bufferId); return NO_ERROR; } Loading Loading @@ -164,6 +167,9 @@ status_t layer_state_t::read(const Parcel& input) listenerCallbacks.emplace_back(listener, callbackIds); } cachedBuffer.token = input.readStrongBinder(); cachedBuffer.bufferId = input.readInt32(); return NO_ERROR; } Loading Loading @@ -372,6 +378,10 @@ void layer_state_t::merge(const layer_state_t& other) { } #endif if (other.what & eCachedBufferChanged) { what |= eCachedBufferChanged; cachedBuffer = other.cachedBuffer; } if ((other.what & what) != other.what) { ALOGE("Unmerged SurfaceComposer Transaction properties. LayerState::merge needs updating? " "other.what=0x%" PRIu64 " what=0x%" PRIu64, Loading libs/gui/SurfaceComposerClient.cpp +50 −7 Original line number Diff line number Diff line Loading @@ -159,11 +159,12 @@ void TransactionCompletedListener::onTransactionCompleted(ListenerStats listener // --------------------------------------------------------------------------- SurfaceComposerClient::Transaction::Transaction(const Transaction& other) : mForceSynchronous(other.mForceSynchronous), SurfaceComposerClient::Transaction::Transaction(const Transaction& other) : mForceSynchronous(other.mForceSynchronous), mTransactionNestCount(other.mTransactionNestCount), mAnimation(other.mAnimation), mEarlyWakeup(other.mEarlyWakeup) { mEarlyWakeup(other.mEarlyWakeup), mDesiredPresentTime(other.mDesiredPresentTime) { mDisplayStates = other.mDisplayStates; mComposerStates = other.mComposerStates; mInputWindowCommands = other.mInputWindowCommands; Loading Loading @@ -218,7 +219,7 @@ void SurfaceComposerClient::doDropReferenceTransaction(const sp<IBinder>& handle s.state.parentHandleForChild = nullptr; composerStates.add(s); sf->setTransactionState(composerStates, displayStates, 0, nullptr, {}); sf->setTransactionState(composerStates, displayStates, 0, nullptr, {}, -1); } status_t SurfaceComposerClient::Transaction::apply(bool synchronous) { Loading Loading @@ -284,7 +285,8 @@ status_t SurfaceComposerClient::Transaction::apply(bool synchronous) { mEarlyWakeup = false; sp<IBinder> applyToken = IInterface::asBinder(TransactionCompletedListener::getIInstance()); sf->setTransactionState(composerStates, displayStates, flags, applyToken, mInputWindowCommands); sf->setTransactionState(composerStates, displayStates, flags, applyToken, mInputWindowCommands, mDesiredPresentTime); mInputWindowCommands.clear(); mStatus = NO_ERROR; return NO_ERROR; Loading Loading @@ -658,6 +660,21 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setBuffe return *this; } SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setCachedBuffer( const sp<SurfaceControl>& sc, int32_t bufferId) { layer_state_t* s = getLayerState(sc); if (!s) { mStatus = BAD_INDEX; return *this; } s->what |= layer_state_t::eCachedBufferChanged; s->cachedBuffer.token = IInterface::asBinder(TransactionCompletedListener::getIInstance()); s->cachedBuffer.bufferId = bufferId; registerSurfaceControlForCallback(sc); return *this; } SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setAcquireFence( const sp<SurfaceControl>& sc, const sp<Fence>& fence) { layer_state_t* s = getLayerState(sc); Loading Loading @@ -742,6 +759,12 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setSideb return *this; } SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setDesiredPresentTime( nsecs_t desiredPresentTime) { mDesiredPresentTime = desiredPresentTime; return *this; } SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::addTransactionCompletedCallback( TransactionCompletedCallbackTakesContext callback, void* callbackContext) { Loading Loading @@ -1049,6 +1072,26 @@ status_t SurfaceComposerClient::getLayerFrameStats(const sp<IBinder>& token, // ---------------------------------------------------------------------------- status_t SurfaceComposerClient::cacheBuffer(const sp<GraphicBuffer>& buffer, int32_t* outBufferId) { sp<ISurfaceComposer> sf(ComposerService::getComposerService()); if (buffer == nullptr || outBufferId == nullptr) { return BAD_VALUE; } return sf->cacheBuffer(IInterface::asBinder(TransactionCompletedListener::getIInstance()), buffer, outBufferId); } status_t SurfaceComposerClient::uncacheBuffer(int32_t bufferId) { sp<ISurfaceComposer> sf(ComposerService::getComposerService()); if (bufferId < 0) { return BAD_VALUE; } return sf->uncacheBuffer(IInterface::asBinder(TransactionCompletedListener::getIInstance()), bufferId); } // ---------------------------------------------------------------------------- status_t SurfaceComposerClient::enableVSyncInjections(bool enable) { sp<ISurfaceComposer> sf(ComposerService::getComposerService()); return sf->enableVSyncInjections(enable); Loading libs/gui/include/gui/ISurfaceComposer.h +9 −1 Original line number Diff line number Diff line Loading @@ -116,7 +116,8 @@ public: virtual void setTransactionState(const Vector<ComposerState>& state, const Vector<DisplayState>& displays, uint32_t flags, const sp<IBinder>& applyToken, const InputWindowCommands& inputWindowCommands) = 0; const InputWindowCommands& inputWindowCommands, int64_t desiredPresentTime) = 0; /* signal that we're done booting. * Requires ACCESS_SURFACE_FLINGER permission Loading Loading @@ -315,6 +316,11 @@ public: * Requires the ACCESS_SURFACE_FLINGER permission. */ virtual status_t getProtectedContentSupport(bool* outSupported) const = 0; virtual status_t cacheBuffer(const sp<IBinder>& token, const sp<GraphicBuffer>& buffer, int32_t* outBufferId) = 0; virtual status_t uncacheBuffer(const sp<IBinder>& token, int32_t bufferId) = 0; }; // ---------------------------------------------------------------------------- Loading Loading @@ -357,6 +363,8 @@ public: SET_DISPLAY_CONTENT_SAMPLING_ENABLED, GET_DISPLAYED_CONTENT_SAMPLE, GET_PROTECTED_CONTENT_SUPPORT, CACHE_BUFFER, UNCACHE_BUFFER, }; virtual status_t onTransact(uint32_t code, const Parcel& data, Loading libs/gui/include/gui/LayerState.h +7 −0 Original line number Diff line number Diff line Loading @@ -84,6 +84,7 @@ struct layer_state_t { eInputInfoChanged = 0x40000000, eCornerRadiusChanged = 0x80000000, eFrameChanged = 0x1'00000000, eCachedBufferChanged = 0x2'00000000, }; layer_state_t() Loading Loading @@ -125,6 +126,10 @@ struct layer_state_t { float dtdy{0}; float dsdy{0}; }; struct cached_buffer_t { sp<IBinder> token = nullptr; int32_t bufferId = -1; }; sp<IBinder> surface; uint64_t what; float x; Loading Loading @@ -173,6 +178,8 @@ struct layer_state_t { #ifndef NO_INPUT InputWindowInfo inputInfo; #endif cached_buffer_t cachedBuffer; }; struct ComposerState { Loading Loading
libs/gui/ISurfaceComposer.cpp +85 −2 Original line number Diff line number Diff line Loading @@ -66,7 +66,8 @@ public: virtual void setTransactionState(const Vector<ComposerState>& state, const Vector<DisplayState>& displays, uint32_t flags, const sp<IBinder>& applyToken, const InputWindowCommands& commands) { const InputWindowCommands& commands, int64_t desiredPresentTime) { Parcel data, reply; data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); Loading @@ -83,6 +84,7 @@ public: data.writeUint32(flags); data.writeStrongBinder(applyToken); commands.write(data); data.writeInt64(desiredPresentTime); remote()->transact(BnSurfaceComposer::SET_TRANSACTION_STATE, data, &reply); } Loading Loading @@ -693,6 +695,42 @@ public: } return err; } virtual status_t cacheBuffer(const sp<IBinder>& token, const sp<GraphicBuffer>& buffer, int32_t* outBufferId) { Parcel data, reply; data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); data.writeStrongBinder(token); if (buffer) { data.writeBool(true); data.write(*buffer); } else { data.writeBool(false); } status_t result = remote()->transact(BnSurfaceComposer::CACHE_BUFFER, data, &reply); if (result != NO_ERROR) { return result; } int32_t id = -1; result = reply.readInt32(&id); if (result == NO_ERROR) { *outBufferId = id; } return result; } virtual status_t uncacheBuffer(const sp<IBinder>& token, int32_t bufferId) { Parcel data, reply; data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); data.writeStrongBinder(token); data.writeInt32(bufferId); return remote()->transact(BnSurfaceComposer::UNCACHE_BUFFER, data, &reply); } }; // Out-of-line virtual method definition to trigger vtable emission in this Loading Loading @@ -748,7 +786,10 @@ status_t BnSurfaceComposer::onTransact( sp<IBinder> applyToken = data.readStrongBinder(); InputWindowCommands inputWindowCommands; inputWindowCommands.read(data); setTransactionState(state, displays, stateFlags, applyToken, inputWindowCommands); int64_t desiredPresentTime = data.readInt64(); setTransactionState(state, displays, stateFlags, applyToken, inputWindowCommands, desiredPresentTime); return NO_ERROR; } case BOOT_FINISHED: { Loading Loading @@ -1131,6 +1172,48 @@ status_t BnSurfaceComposer::onTransact( } return error; } case CACHE_BUFFER: { CHECK_INTERFACE(ISurfaceComposer, data, reply); sp<IBinder> token; status_t result = data.readStrongBinder(&token); if (result != NO_ERROR) { ALOGE("cache buffer failure in reading token: %d", result); return result; } sp<GraphicBuffer> buffer = new GraphicBuffer(); if (data.readBool()) { result = data.read(*buffer); if (result != NO_ERROR) { ALOGE("cache buffer failure in reading buffer: %d", result); return result; } } int32_t bufferId = -1; status_t error = cacheBuffer(token, buffer, &bufferId); if (error == NO_ERROR) { reply->writeInt32(bufferId); } return error; } case UNCACHE_BUFFER: { CHECK_INTERFACE(ISurfaceComposer, data, reply); sp<IBinder> token; status_t result = data.readStrongBinder(&token); if (result != NO_ERROR) { ALOGE("uncache buffer failure in reading token: %d", result); return result; } int32_t bufferId = -1; result = data.readInt32(&bufferId); if (result != NO_ERROR) { ALOGE("uncache buffer failure in reading buffer id: %d", result); return result; } return uncacheBuffer(token, bufferId); } default: { return BBinder::onTransact(code, data, reply, flags); } Loading
libs/gui/LayerState.cpp +10 −0 Original line number Diff line number Diff line Loading @@ -94,6 +94,9 @@ status_t layer_state_t::write(Parcel& output) const } } output.writeStrongBinder(cachedBuffer.token); output.writeInt32(cachedBuffer.bufferId); return NO_ERROR; } Loading Loading @@ -164,6 +167,9 @@ status_t layer_state_t::read(const Parcel& input) listenerCallbacks.emplace_back(listener, callbackIds); } cachedBuffer.token = input.readStrongBinder(); cachedBuffer.bufferId = input.readInt32(); return NO_ERROR; } Loading Loading @@ -372,6 +378,10 @@ void layer_state_t::merge(const layer_state_t& other) { } #endif if (other.what & eCachedBufferChanged) { what |= eCachedBufferChanged; cachedBuffer = other.cachedBuffer; } if ((other.what & what) != other.what) { ALOGE("Unmerged SurfaceComposer Transaction properties. LayerState::merge needs updating? " "other.what=0x%" PRIu64 " what=0x%" PRIu64, Loading
libs/gui/SurfaceComposerClient.cpp +50 −7 Original line number Diff line number Diff line Loading @@ -159,11 +159,12 @@ void TransactionCompletedListener::onTransactionCompleted(ListenerStats listener // --------------------------------------------------------------------------- SurfaceComposerClient::Transaction::Transaction(const Transaction& other) : mForceSynchronous(other.mForceSynchronous), SurfaceComposerClient::Transaction::Transaction(const Transaction& other) : mForceSynchronous(other.mForceSynchronous), mTransactionNestCount(other.mTransactionNestCount), mAnimation(other.mAnimation), mEarlyWakeup(other.mEarlyWakeup) { mEarlyWakeup(other.mEarlyWakeup), mDesiredPresentTime(other.mDesiredPresentTime) { mDisplayStates = other.mDisplayStates; mComposerStates = other.mComposerStates; mInputWindowCommands = other.mInputWindowCommands; Loading Loading @@ -218,7 +219,7 @@ void SurfaceComposerClient::doDropReferenceTransaction(const sp<IBinder>& handle s.state.parentHandleForChild = nullptr; composerStates.add(s); sf->setTransactionState(composerStates, displayStates, 0, nullptr, {}); sf->setTransactionState(composerStates, displayStates, 0, nullptr, {}, -1); } status_t SurfaceComposerClient::Transaction::apply(bool synchronous) { Loading Loading @@ -284,7 +285,8 @@ status_t SurfaceComposerClient::Transaction::apply(bool synchronous) { mEarlyWakeup = false; sp<IBinder> applyToken = IInterface::asBinder(TransactionCompletedListener::getIInstance()); sf->setTransactionState(composerStates, displayStates, flags, applyToken, mInputWindowCommands); sf->setTransactionState(composerStates, displayStates, flags, applyToken, mInputWindowCommands, mDesiredPresentTime); mInputWindowCommands.clear(); mStatus = NO_ERROR; return NO_ERROR; Loading Loading @@ -658,6 +660,21 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setBuffe return *this; } SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setCachedBuffer( const sp<SurfaceControl>& sc, int32_t bufferId) { layer_state_t* s = getLayerState(sc); if (!s) { mStatus = BAD_INDEX; return *this; } s->what |= layer_state_t::eCachedBufferChanged; s->cachedBuffer.token = IInterface::asBinder(TransactionCompletedListener::getIInstance()); s->cachedBuffer.bufferId = bufferId; registerSurfaceControlForCallback(sc); return *this; } SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setAcquireFence( const sp<SurfaceControl>& sc, const sp<Fence>& fence) { layer_state_t* s = getLayerState(sc); Loading Loading @@ -742,6 +759,12 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setSideb return *this; } SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setDesiredPresentTime( nsecs_t desiredPresentTime) { mDesiredPresentTime = desiredPresentTime; return *this; } SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::addTransactionCompletedCallback( TransactionCompletedCallbackTakesContext callback, void* callbackContext) { Loading Loading @@ -1049,6 +1072,26 @@ status_t SurfaceComposerClient::getLayerFrameStats(const sp<IBinder>& token, // ---------------------------------------------------------------------------- status_t SurfaceComposerClient::cacheBuffer(const sp<GraphicBuffer>& buffer, int32_t* outBufferId) { sp<ISurfaceComposer> sf(ComposerService::getComposerService()); if (buffer == nullptr || outBufferId == nullptr) { return BAD_VALUE; } return sf->cacheBuffer(IInterface::asBinder(TransactionCompletedListener::getIInstance()), buffer, outBufferId); } status_t SurfaceComposerClient::uncacheBuffer(int32_t bufferId) { sp<ISurfaceComposer> sf(ComposerService::getComposerService()); if (bufferId < 0) { return BAD_VALUE; } return sf->uncacheBuffer(IInterface::asBinder(TransactionCompletedListener::getIInstance()), bufferId); } // ---------------------------------------------------------------------------- status_t SurfaceComposerClient::enableVSyncInjections(bool enable) { sp<ISurfaceComposer> sf(ComposerService::getComposerService()); return sf->enableVSyncInjections(enable); Loading
libs/gui/include/gui/ISurfaceComposer.h +9 −1 Original line number Diff line number Diff line Loading @@ -116,7 +116,8 @@ public: virtual void setTransactionState(const Vector<ComposerState>& state, const Vector<DisplayState>& displays, uint32_t flags, const sp<IBinder>& applyToken, const InputWindowCommands& inputWindowCommands) = 0; const InputWindowCommands& inputWindowCommands, int64_t desiredPresentTime) = 0; /* signal that we're done booting. * Requires ACCESS_SURFACE_FLINGER permission Loading Loading @@ -315,6 +316,11 @@ public: * Requires the ACCESS_SURFACE_FLINGER permission. */ virtual status_t getProtectedContentSupport(bool* outSupported) const = 0; virtual status_t cacheBuffer(const sp<IBinder>& token, const sp<GraphicBuffer>& buffer, int32_t* outBufferId) = 0; virtual status_t uncacheBuffer(const sp<IBinder>& token, int32_t bufferId) = 0; }; // ---------------------------------------------------------------------------- Loading Loading @@ -357,6 +363,8 @@ public: SET_DISPLAY_CONTENT_SAMPLING_ENABLED, GET_DISPLAYED_CONTENT_SAMPLE, GET_PROTECTED_CONTENT_SUPPORT, CACHE_BUFFER, UNCACHE_BUFFER, }; virtual status_t onTransact(uint32_t code, const Parcel& data, Loading
libs/gui/include/gui/LayerState.h +7 −0 Original line number Diff line number Diff line Loading @@ -84,6 +84,7 @@ struct layer_state_t { eInputInfoChanged = 0x40000000, eCornerRadiusChanged = 0x80000000, eFrameChanged = 0x1'00000000, eCachedBufferChanged = 0x2'00000000, }; layer_state_t() Loading Loading @@ -125,6 +126,10 @@ struct layer_state_t { float dtdy{0}; float dsdy{0}; }; struct cached_buffer_t { sp<IBinder> token = nullptr; int32_t bufferId = -1; }; sp<IBinder> surface; uint64_t what; float x; Loading Loading @@ -173,6 +178,8 @@ struct layer_state_t { #ifndef NO_INPUT InputWindowInfo inputInfo; #endif cached_buffer_t cachedBuffer; }; struct ComposerState { Loading