diff options
author | 2025-03-20 09:32:25 -0700 | |
---|---|---|
committer | 2025-03-20 09:32:25 -0700 | |
commit | d0aab34af40ba8a6355fd65c5c1bcdc45d85b511 (patch) | |
tree | d8139ba97bd551398a2916ace7eb918ac2e989d5 | |
parent | d02eebc6121546ca10d4e0a89dc5ca8a3208822a (diff) | |
parent | 0b7e13d9697bb2f13077489a534c29107dd3956a (diff) |
Merge "surfaceflinger formatting" into main
5 files changed, 88 insertions, 99 deletions
diff --git a/services/surfaceflinger/DisplayHardware/AidlComposerHal.cpp b/services/surfaceflinger/DisplayHardware/AidlComposerHal.cpp index d547af98ea..27ae18fac9 100644 --- a/services/surfaceflinger/DisplayHardware/AidlComposerHal.cpp +++ b/services/surfaceflinger/DisplayHardware/AidlComposerHal.cpp @@ -328,9 +328,7 @@ std::string AidlComposer::dumpDebugInfo() { std::string str; // Use other thread to read pipe to prevent // pipe is full, making HWC be blocked in writing. - std::thread t([&]() { - base::ReadFdToString(pipefds[0], &str); - }); + std::thread t([&]() { base::ReadFdToString(pipefds[0], &str); }); const auto status = mAidlComposer->dump(pipefds[1], /*args*/ nullptr, /*numArgs*/ 0); // Close the write-end of the pipe to make sure that when reading from the // read-end we will get eof instead of blocking forever diff --git a/services/surfaceflinger/DisplayHardware/ComposerHal.h b/services/surfaceflinger/DisplayHardware/ComposerHal.h index 018ee6e461..ab086e4b55 100644 --- a/services/surfaceflinger/DisplayHardware/ComposerHal.h +++ b/services/surfaceflinger/DisplayHardware/ComposerHal.h @@ -229,14 +229,13 @@ public: virtual std::vector<IComposerClient::PerFrameMetadataKey> getPerFrameMetadataKeys( Display display) = 0; virtual Error getRenderIntents(Display display, ColorMode colorMode, - std::vector<RenderIntent>* outRenderIntents) = 0; + std::vector<RenderIntent>* outRenderIntents) = 0; virtual Error getDataspaceSaturationMatrix(Dataspace dataspace, mat4* outMatrix) = 0; // Composer HAL 2.3 virtual Error getDisplayIdentificationData(Display display, uint8_t* outPort, std::vector<uint8_t>* outData) = 0; - virtual Error setLayerColorTransform(Display display, Layer layer, - const float* matrix) = 0; + virtual Error setLayerColorTransform(Display display, Layer layer, const float* matrix) = 0; virtual Error getDisplayedContentSamplingAttributes(Display display, PixelFormat* outFormat, Dataspace* outDataspace, uint8_t* outComponentMask) = 0; diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp index 14088a6428..787a64b089 100644 --- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp +++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp @@ -560,7 +560,7 @@ status_t HWComposer::getDeviceCompositionChanges( if (!hasChangesError(error)) { RETURN_IF_HWC_ERROR_FOR("presentOrValidate", error, displayId, UNKNOWN_ERROR); } - if (state == 1) { //Present Succeeded. + if (state == 1) { // Present Succeeded. std::unordered_map<HWC2::Layer*, sp<Fence>> releaseFences; error = hwcDisplay->getReleaseFences(&releaseFences); displayData.releaseFences = std::move(releaseFences); @@ -824,8 +824,8 @@ mat4 HWComposer::getDataspaceSaturationMatrix(HalDisplayId displayId, ui::Datasp RETURN_IF_INVALID_DISPLAY(displayId, {}); mat4 matrix; - auto error = mDisplayData[displayId].hwcDisplay->getDataspaceSaturationMatrix(dataspace, - &matrix); + auto error = + mDisplayData[displayId].hwcDisplay->getDataspaceSaturationMatrix(dataspace, &matrix); RETURN_IF_HWC_ERROR(error, displayId, {}); return matrix; } diff --git a/services/surfaceflinger/DisplayHardware/HidlComposerHal.cpp b/services/surfaceflinger/DisplayHardware/HidlComposerHal.cpp index a010353423..3321f51026 100644 --- a/services/surfaceflinger/DisplayHardware/HidlComposerHal.cpp +++ b/services/surfaceflinger/DisplayHardware/HidlComposerHal.cpp @@ -1230,15 +1230,16 @@ Error HidlComposer::getDisplayCapabilities(Display display, translate<DisplayCapability>(tmpCaps); }); } else { - mClient_2_3 - ->getDisplayCapabilities(display, [&](const auto& tmpError, const auto& tmpCaps) { - error = static_cast<V2_4::Error>(tmpError); - if (error != V2_4::Error::NONE) { - return; - } + mClient_2_3->getDisplayCapabilities(display, + [&](const auto& tmpError, const auto& tmpCaps) { + error = static_cast<V2_4::Error>(tmpError); + if (error != V2_4::Error::NONE) { + return; + } - *outCapabilities = translate<DisplayCapability>(tmpCaps); - }); + *outCapabilities = + translate<DisplayCapability>(tmpCaps); + }); } return static_cast<Error>(error); diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index ce7a720714..6b40c98d0a 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -19,7 +19,7 @@ #pragma clang diagnostic ignored "-Wconversion" #pragma clang diagnostic ignored "-Wextra" -//#define LOG_NDEBUG 0 +// #define LOG_NDEBUG 0 #define ATRACE_TAG ATRACE_TAG_GRAPHICS #include "SurfaceFlinger.h" @@ -361,7 +361,7 @@ bool isExpectedPresentWithinTimeout(TimePoint expectedPresentTime, return std::abs(expectedPresentTime.ns() - (lastExpectedPresentTimestamp.ns() + timeoutOpt->ns())) < threshold.ns(); } -} // namespace anonymous +} // namespace // --------------------------------------------------------------------------- @@ -393,7 +393,7 @@ ui::PixelFormat SurfaceFlinger::wideColorGamutCompositionPixelFormat = ui::Pixel LatchUnsignaledConfig SurfaceFlinger::enableLatchUnsignaledConfig; std::string decodeDisplayColorSetting(DisplayColorSetting displayColorSetting) { - switch(displayColorSetting) { + switch (displayColorSetting) { case DisplayColorSetting::kManaged: return std::string("Managed"); case DisplayColorSetting::kUnmanaged: @@ -401,8 +401,7 @@ std::string decodeDisplayColorSetting(DisplayColorSetting displayColorSetting) { case DisplayColorSetting::kEnhanced: return std::string("Enhanced"); default: - return std::string("Unknown ") + - std::to_string(static_cast<int>(displayColorSetting)); + return std::string("Unknown ") + std::to_string(static_cast<int>(displayColorSetting)); } } @@ -594,15 +593,14 @@ sp<IBinder> SurfaceFlinger::createVirtualDisplay( class DisplayToken : public BBinder { sp<SurfaceFlinger> flinger; virtual ~DisplayToken() { - // no more references, this display must be terminated - Mutex::Autolock _l(flinger->mStateLock); - flinger->mCurrentState.displays.removeItem(wp<IBinder>::fromExisting(this)); - flinger->setTransactionFlags(eDisplayTransactionNeeded); - } - public: - explicit DisplayToken(const sp<SurfaceFlinger>& flinger) - : flinger(flinger) { + // no more references, this display must be terminated + Mutex::Autolock _l(flinger->mStateLock); + flinger->mCurrentState.displays.removeItem(wp<IBinder>::fromExisting(this)); + flinger->setTransactionFlags(eDisplayTransactionNeeded); } + + public: + explicit DisplayToken(const sp<SurfaceFlinger>& flinger) : flinger(flinger) {} }; sp<BBinder> token = sp<DisplayToken>::make(sp<SurfaceFlinger>::fromExisting(this)); @@ -761,7 +759,7 @@ void SurfaceFlinger::bootFinished() { const nsecs_t now = systemTime(); const nsecs_t duration = now - mBootTime; - ALOGI("Boot is finished (%ld ms)", long(ns2ms(duration)) ); + ALOGI("Boot is finished (%ld ms)", long(ns2ms(duration))); mFrameTracer->initialize(); mFrameTimeline->onBootFinished(); @@ -780,8 +778,7 @@ void SurfaceFlinger::bootFinished() { property_set("service.bootanim.exit", "1"); const int LOGTAG_SF_STOP_BOOTANIM = 60110; - LOG_EVENT_LONG(LOGTAG_SF_STOP_BOOTANIM, - ns2ms(systemTime(SYSTEM_TIME_MONOTONIC))); + LOG_EVENT_LONG(LOGTAG_SF_STOP_BOOTANIM, ns2ms(systemTime(SYSTEM_TIME_MONOTONIC))); sp<IBinder> input(defaultServiceManager()->waitForService(String16("inputflinger"))); @@ -901,8 +898,8 @@ renderengine::RenderEngine::BlurAlgorithm chooseBlurAlgorithm(bool supportsBlur) void SurfaceFlinger::init() FTL_FAKE_GUARD(kMainThreadContext) { SFTRACE_CALL(); - ALOGI( "SurfaceFlinger's main thread ready to run. " - "Initializing graphics H/W..."); + ALOGI("SurfaceFlinger's main thread ready to run. " + "Initializing graphics H/W..."); addTransactionReadyFilters(); Mutex::Autolock lock(mStateLock); @@ -1125,17 +1122,16 @@ void SurfaceFlinger::readPersistentProperties() { static_cast<ui::ColorMode>(base::GetIntProperty("persist.sys.sf.color_mode"s, 0)); } -status_t SurfaceFlinger::getSupportedFrameTimestamps( - std::vector<FrameEvent>* outSupported) const { +status_t SurfaceFlinger::getSupportedFrameTimestamps(std::vector<FrameEvent>* outSupported) const { *outSupported = { - FrameEvent::REQUESTED_PRESENT, - FrameEvent::ACQUIRE, - FrameEvent::LATCH, - FrameEvent::FIRST_REFRESH_START, - FrameEvent::LAST_REFRESH_START, - FrameEvent::GPU_COMPOSITION_DONE, - FrameEvent::DEQUEUE_READY, - FrameEvent::RELEASE, + FrameEvent::REQUESTED_PRESENT, + FrameEvent::ACQUIRE, + FrameEvent::LATCH, + FrameEvent::FIRST_REFRESH_START, + FrameEvent::LAST_REFRESH_START, + FrameEvent::GPU_COMPOSITION_DONE, + FrameEvent::DEQUEUE_READY, + FrameEvent::RELEASE, }; if (mHasReliablePresentFences) { @@ -2210,7 +2206,6 @@ status_t SurfaceFlinger::addHdrLayerInfoListener(const sp<IBinder>& displayToken } hdrInfoReporter->addListener(listener); - mAddingHDRLayerInfoListener = true; return OK; } @@ -2271,13 +2266,13 @@ sp<IDisplayEventConnection> SurfaceFlinger::createDisplayEventConnection( const auto cycle = [&] { if (FlagManager::getInstance().deprecate_vsync_sf()) { ALOGW_IF(vsyncSource == gui::ISurfaceComposer::VsyncSource::eVsyncSourceSurfaceFlinger, - "requested unsupported config eVsyncSourceSurfaceFlinger"); + "requested unsupported config eVsyncSourceSurfaceFlinger"); return scheduler::Cycle::Render; } return vsyncSource == gui::ISurfaceComposer::VsyncSource::eVsyncSourceSurfaceFlinger - ? scheduler::Cycle::LastComposite - : scheduler::Cycle::Render; + ? scheduler::Cycle::LastComposite + : scheduler::Cycle::Render; }(); return mScheduler->createDisplayEventConnection(cycle, eventRegistration, layerHandle); } @@ -2807,9 +2802,10 @@ bool SurfaceFlinger::commit(PhysicalDisplayId pacesetterId, // setTransactionFlags which will schedule another SF frame. This was if the tracker // needs to adjust the vsync timeline, it will be done before the next frame. if (FlagManager::getInstance().vrr_config() && mustComposite) { - mScheduler->getVsyncSchedule()->getTracker().onFrameBegin( - pacesetterFrameTarget.expectedPresentTime(), - pacesetterFrameTarget.lastSignaledFrameTime()); + mScheduler->getVsyncSchedule() + ->getTracker() + .onFrameBegin(pacesetterFrameTarget.expectedPresentTime(), + pacesetterFrameTarget.lastSignaledFrameTime()); } if (transactionFlushNeeded()) { setTransactionFlags(eTransactionFlushNeeded); @@ -3058,7 +3054,7 @@ CompositeResultsPerDisplay SurfaceFlinger::composite( // This should be interpreted to mean that there are 2 cached sets. // So there are only 2 non skipped layers -- b and s. // The layers rrc and cc are flattened into layers b and s respectively. - const LayerFE::HwcLayerDebugState &hwcState = layerFE->getLastHwcState(); + const LayerFE::HwcLayerDebugState& hwcState = layerFE->getLastHwcState(); if (hwcState.overrideBufferId != prevOverrideBufferId) { // End the existing run. if (prevOverrideBufferId) { @@ -3070,11 +3066,10 @@ CompositeResultsPerDisplay SurfaceFlinger::composite( } } - compositionSummary.push_back( - layerFE->mSnapshot->classifyCompositionForDebug(hwcState)); + compositionSummary.push_back(layerFE->mSnapshot->classifyCompositionForDebug(hwcState)); if (hwcState.overrideBufferId && !hwcState.wasSkipped) { - compositionSummary.push_back(':'); + compositionSummary.push_back(':'); } prevOverrideBufferId = hwcState.overrideBufferId; @@ -4324,37 +4319,35 @@ void SurfaceFlinger::updateInputFlinger(VsyncId vsyncId, TimePoint frameTime) { mVisibleWindowIds = std::move(visibleWindowIds); } - BackgroundExecutor::getInstance().sendCallbacks({[updateWindowInfo, - windowInfos = std::move(windowInfos), - displayInfos = std::move(displayInfos), - inputWindowCommands = - std::move(mInputWindowCommands), - inputFlinger = mInputFlinger, this, - visibleWindowsChanged, vsyncId, - frameTime]() mutable { - SFTRACE_NAME("BackgroundExecutor::updateInputFlinger"); - if (updateWindowInfo) { - mWindowInfosListenerInvoker - ->windowInfosChanged(gui::WindowInfosUpdate{std::move(windowInfos), - std::move(displayInfos), - ftl::to_underlying(vsyncId), - frameTime.ns()}, - std::move(inputWindowCommands.releaseListeners()), - /* forceImmediateCall= */ visibleWindowsChanged || - !inputWindowCommands.getFocusRequests().empty()); - } else { - // If there are listeners but no changes to input windows, call the listeners - // immediately. - for (const auto& listener : inputWindowCommands.getListeners()) { - if (IInterface::asBinder(listener)->isBinderAlive()) { - listener->onWindowInfosReported(); + BackgroundExecutor::getInstance().sendCallbacks( + {[updateWindowInfo, windowInfos = std::move(windowInfos), + displayInfos = std::move(displayInfos), + inputWindowCommands = std::move(mInputWindowCommands), inputFlinger = mInputFlinger, + this, visibleWindowsChanged, vsyncId, frameTime]() mutable { + SFTRACE_NAME("BackgroundExecutor::updateInputFlinger"); + if (updateWindowInfo) { + mWindowInfosListenerInvoker + ->windowInfosChanged(gui::WindowInfosUpdate{std::move(windowInfos), + std::move(displayInfos), + ftl::to_underlying(vsyncId), + frameTime.ns()}, + std::move(inputWindowCommands.releaseListeners()), + /* forceImmediateCall= */ visibleWindowsChanged || + !inputWindowCommands.getFocusRequests() + .empty()); + } else { + // If there are listeners but no changes to input windows, call the listeners + // immediately. + for (const auto& listener : inputWindowCommands.getListeners()) { + if (IInterface::asBinder(listener)->isBinderAlive()) { + listener->onWindowInfosReported(); + } + } } - } - } - for (const auto& focusRequest : inputWindowCommands.getFocusRequests()) { - inputFlinger->setFocusedWindow(focusRequest); - } - }}); + for (const auto& focusRequest : inputWindowCommands.getFocusRequests()) { + inputFlinger->setFocusedWindow(focusRequest); + } + }}); mInputWindowCommands.clear(); } @@ -5067,8 +5060,8 @@ status_t SurfaceFlinger::setTransactionState( if (resolvedState.state.hasBufferChanges() && resolvedState.state.hasValidBuffer() && resolvedState.state.surface) { sp<Layer> layer = LayerHandle::getLayer(resolvedState.state.surface); - std::string layerName = (layer) ? - layer->getDebugName() : std::to_string(resolvedState.state.layerId); + std::string layerName = + (layer) ? layer->getDebugName() : std::to_string(resolvedState.state.layerId); resolvedState.externalTexture = getExternalTextureFromBufferData(*resolvedState.state.bufferData, layerName.c_str(), transactionId); @@ -5922,8 +5915,7 @@ status_t SurfaceFlinger::doDump(int fd, const DumpArgs& args, bool asProto) { const int pid = ipc->getCallingPid(); const int uid = ipc->getCallingUid(); - if ((uid != AID_SHELL) && - !PermissionCache::checkPermission(sDump, pid, uid)) { + if ((uid != AID_SHELL) && !PermissionCache::checkPermission(sDump, pid, uid)) { StringAppendF(&result, "Permission Denial: can't dump SurfaceFlinger from pid=%d, uid=%d\n", pid, uid); write(fd, result.c_str(), result.size()); @@ -6381,7 +6373,7 @@ void SurfaceFlinger::dumpAll(const DumpArgs& args, const std::string& compositio // figure out if we're stuck somewhere const nsecs_t now = systemTime(); const nsecs_t inTransaction(mDebugInTransaction); - nsecs_t inTransactionDuration = (inTransaction) ? now-inTransaction : 0; + nsecs_t inTransactionDuration = (inTransaction) ? now - inTransaction : 0; /* * Dump library configuration. @@ -6561,7 +6553,7 @@ status_t SurfaceFlinger::CheckTransactCodeCredentials(uint32_t code) { if (!callingThreadHasUnscopedSurfaceFlingerAccess(usePermissionCache)) { IPCThreadState* ipc = IPCThreadState::self(); ALOGE("Permission Denial: can't access SurfaceFlinger pid=%d, uid=%d", - ipc->getCallingPid(), ipc->getCallingUid()); + ipc->getCallingPid(), ipc->getCallingUid()); return PERMISSION_DENIED; } return OK; @@ -6677,11 +6669,12 @@ status_t SurfaceFlinger::onTransact(uint32_t code, const Parcel& data, Parcel* r CHECK_INTERFACE(ISurfaceComposer, data, reply); IPCThreadState* ipc = IPCThreadState::self(); const int uid = ipc->getCallingUid(); - if (CC_UNLIKELY(uid != AID_SYSTEM - && !PermissionCache::checkCallingPermission(sHardwareTest))) { + if (CC_UNLIKELY(uid != AID_SYSTEM && + !PermissionCache::checkCallingPermission(sHardwareTest))) { const int pid = ipc->getCallingPid(); ALOGE("Permission Denial: " - "can't access SurfaceFlinger pid=%d, uid=%d", pid, uid); + "can't access SurfaceFlinger pid=%d, uid=%d", + pid, uid); return PERMISSION_DENIED; } int n; @@ -6752,7 +6745,7 @@ status_t SurfaceFlinger::onTransact(uint32_t code, const Parcel& data, Parcel* r n = data.readInt32(); if (n) { // color matrix is sent as a column-major mat4 matrix - for (size_t i = 0 ; i < 4; i++) { + for (size_t i = 0; i < 4; i++) { for (size_t j = 0; j < 4; j++) { mClientColorMatrix[i][j] = data.readFloat(); } @@ -7272,9 +7265,7 @@ auto SurfaceFlinger::getKernelIdleTimerProperties(PhysicalDisplayId displayId) class WindowDisconnector { public: WindowDisconnector(ANativeWindow* window, int api) : mWindow(window), mApi(api) {} - ~WindowDisconnector() { - native_window_api_disconnect(mWindow, mApi); - } + ~WindowDisconnector() { native_window_api_disconnect(mWindow, mApi); } private: ANativeWindow* mWindow; |