Skip to content

Commit 0b7e13d

Browse files
committed
surfaceflinger formatting
no functionality changes here. just some clang-tidy formatting Flag: EXEMPT refactor Test: th Change-Id: I25cd53c40d4fde1edb29f4b8fee28df6f4b66235
1 parent b1b8b4c commit 0b7e13d

File tree

5 files changed

+88
-99
lines changed

5 files changed

+88
-99
lines changed

services/surfaceflinger/DisplayHardware/AidlComposerHal.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,9 +328,7 @@ std::string AidlComposer::dumpDebugInfo() {
328328
std::string str;
329329
// Use other thread to read pipe to prevent
330330
// pipe is full, making HWC be blocked in writing.
331-
std::thread t([&]() {
332-
base::ReadFdToString(pipefds[0], &str);
333-
});
331+
std::thread t([&]() { base::ReadFdToString(pipefds[0], &str); });
334332
const auto status = mAidlComposer->dump(pipefds[1], /*args*/ nullptr, /*numArgs*/ 0);
335333
// Close the write-end of the pipe to make sure that when reading from the
336334
// read-end we will get eof instead of blocking forever

services/surfaceflinger/DisplayHardware/ComposerHal.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,14 +229,13 @@ class Composer {
229229
virtual std::vector<IComposerClient::PerFrameMetadataKey> getPerFrameMetadataKeys(
230230
Display display) = 0;
231231
virtual Error getRenderIntents(Display display, ColorMode colorMode,
232-
std::vector<RenderIntent>* outRenderIntents) = 0;
232+
std::vector<RenderIntent>* outRenderIntents) = 0;
233233
virtual Error getDataspaceSaturationMatrix(Dataspace dataspace, mat4* outMatrix) = 0;
234234

235235
// Composer HAL 2.3
236236
virtual Error getDisplayIdentificationData(Display display, uint8_t* outPort,
237237
std::vector<uint8_t>* outData) = 0;
238-
virtual Error setLayerColorTransform(Display display, Layer layer,
239-
const float* matrix) = 0;
238+
virtual Error setLayerColorTransform(Display display, Layer layer, const float* matrix) = 0;
240239
virtual Error getDisplayedContentSamplingAttributes(Display display, PixelFormat* outFormat,
241240
Dataspace* outDataspace,
242241
uint8_t* outComponentMask) = 0;

services/surfaceflinger/DisplayHardware/HWComposer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ status_t HWComposer::getDeviceCompositionChanges(
560560
if (!hasChangesError(error)) {
561561
RETURN_IF_HWC_ERROR_FOR("presentOrValidate", error, displayId, UNKNOWN_ERROR);
562562
}
563-
if (state == 1) { //Present Succeeded.
563+
if (state == 1) { // Present Succeeded.
564564
std::unordered_map<HWC2::Layer*, sp<Fence>> releaseFences;
565565
error = hwcDisplay->getReleaseFences(&releaseFences);
566566
displayData.releaseFences = std::move(releaseFences);
@@ -824,8 +824,8 @@ mat4 HWComposer::getDataspaceSaturationMatrix(HalDisplayId displayId, ui::Datasp
824824
RETURN_IF_INVALID_DISPLAY(displayId, {});
825825

826826
mat4 matrix;
827-
auto error = mDisplayData[displayId].hwcDisplay->getDataspaceSaturationMatrix(dataspace,
828-
&matrix);
827+
auto error =
828+
mDisplayData[displayId].hwcDisplay->getDataspaceSaturationMatrix(dataspace, &matrix);
829829
RETURN_IF_HWC_ERROR(error, displayId, {});
830830
return matrix;
831831
}

services/surfaceflinger/DisplayHardware/HidlComposerHal.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,15 +1230,16 @@ Error HidlComposer::getDisplayCapabilities(Display display,
12301230
translate<DisplayCapability>(tmpCaps);
12311231
});
12321232
} else {
1233-
mClient_2_3
1234-
->getDisplayCapabilities(display, [&](const auto& tmpError, const auto& tmpCaps) {
1235-
error = static_cast<V2_4::Error>(tmpError);
1236-
if (error != V2_4::Error::NONE) {
1237-
return;
1238-
}
1233+
mClient_2_3->getDisplayCapabilities(display,
1234+
[&](const auto& tmpError, const auto& tmpCaps) {
1235+
error = static_cast<V2_4::Error>(tmpError);
1236+
if (error != V2_4::Error::NONE) {
1237+
return;
1238+
}
12391239

1240-
*outCapabilities = translate<DisplayCapability>(tmpCaps);
1241-
});
1240+
*outCapabilities =
1241+
translate<DisplayCapability>(tmpCaps);
1242+
});
12421243
}
12431244

12441245
return static_cast<Error>(error);

services/surfaceflinger/SurfaceFlinger.cpp

Lines changed: 73 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#pragma clang diagnostic ignored "-Wconversion"
2020
#pragma clang diagnostic ignored "-Wextra"
2121

22-
//#define LOG_NDEBUG 0
22+
// #define LOG_NDEBUG 0
2323
#define ATRACE_TAG ATRACE_TAG_GRAPHICS
2424

2525
#include "SurfaceFlinger.h"
@@ -361,7 +361,7 @@ bool isExpectedPresentWithinTimeout(TimePoint expectedPresentTime,
361361
return std::abs(expectedPresentTime.ns() -
362362
(lastExpectedPresentTimestamp.ns() + timeoutOpt->ns())) < threshold.ns();
363363
}
364-
} // namespace anonymous
364+
} // namespace
365365

366366
// ---------------------------------------------------------------------------
367367

@@ -393,16 +393,15 @@ ui::PixelFormat SurfaceFlinger::wideColorGamutCompositionPixelFormat = ui::Pixel
393393
LatchUnsignaledConfig SurfaceFlinger::enableLatchUnsignaledConfig;
394394

395395
std::string decodeDisplayColorSetting(DisplayColorSetting displayColorSetting) {
396-
switch(displayColorSetting) {
396+
switch (displayColorSetting) {
397397
case DisplayColorSetting::kManaged:
398398
return std::string("Managed");
399399
case DisplayColorSetting::kUnmanaged:
400400
return std::string("Unmanaged");
401401
case DisplayColorSetting::kEnhanced:
402402
return std::string("Enhanced");
403403
default:
404-
return std::string("Unknown ") +
405-
std::to_string(static_cast<int>(displayColorSetting));
404+
return std::string("Unknown ") + std::to_string(static_cast<int>(displayColorSetting));
406405
}
407406
}
408407

@@ -594,15 +593,14 @@ sp<IBinder> SurfaceFlinger::createVirtualDisplay(
594593
class DisplayToken : public BBinder {
595594
sp<SurfaceFlinger> flinger;
596595
virtual ~DisplayToken() {
597-
// no more references, this display must be terminated
598-
Mutex::Autolock _l(flinger->mStateLock);
599-
flinger->mCurrentState.displays.removeItem(wp<IBinder>::fromExisting(this));
600-
flinger->setTransactionFlags(eDisplayTransactionNeeded);
601-
}
602-
public:
603-
explicit DisplayToken(const sp<SurfaceFlinger>& flinger)
604-
: flinger(flinger) {
596+
// no more references, this display must be terminated
597+
Mutex::Autolock _l(flinger->mStateLock);
598+
flinger->mCurrentState.displays.removeItem(wp<IBinder>::fromExisting(this));
599+
flinger->setTransactionFlags(eDisplayTransactionNeeded);
605600
}
601+
602+
public:
603+
explicit DisplayToken(const sp<SurfaceFlinger>& flinger) : flinger(flinger) {}
606604
};
607605

608606
sp<BBinder> token = sp<DisplayToken>::make(sp<SurfaceFlinger>::fromExisting(this));
@@ -761,7 +759,7 @@ void SurfaceFlinger::bootFinished() {
761759

762760
const nsecs_t now = systemTime();
763761
const nsecs_t duration = now - mBootTime;
764-
ALOGI("Boot is finished (%ld ms)", long(ns2ms(duration)) );
762+
ALOGI("Boot is finished (%ld ms)", long(ns2ms(duration)));
765763

766764
mFrameTracer->initialize();
767765
mFrameTimeline->onBootFinished();
@@ -780,8 +778,7 @@ void SurfaceFlinger::bootFinished() {
780778
property_set("service.bootanim.exit", "1");
781779

782780
const int LOGTAG_SF_STOP_BOOTANIM = 60110;
783-
LOG_EVENT_LONG(LOGTAG_SF_STOP_BOOTANIM,
784-
ns2ms(systemTime(SYSTEM_TIME_MONOTONIC)));
781+
LOG_EVENT_LONG(LOGTAG_SF_STOP_BOOTANIM, ns2ms(systemTime(SYSTEM_TIME_MONOTONIC)));
785782

786783
sp<IBinder> input(defaultServiceManager()->waitForService(String16("inputflinger")));
787784

@@ -901,8 +898,8 @@ renderengine::RenderEngine::BlurAlgorithm chooseBlurAlgorithm(bool supportsBlur)
901898

902899
void SurfaceFlinger::init() FTL_FAKE_GUARD(kMainThreadContext) {
903900
SFTRACE_CALL();
904-
ALOGI( "SurfaceFlinger's main thread ready to run. "
905-
"Initializing graphics H/W...");
901+
ALOGI("SurfaceFlinger's main thread ready to run. "
902+
"Initializing graphics H/W...");
906903
addTransactionReadyFilters();
907904
Mutex::Autolock lock(mStateLock);
908905

@@ -1125,17 +1122,16 @@ void SurfaceFlinger::readPersistentProperties() {
11251122
static_cast<ui::ColorMode>(base::GetIntProperty("persist.sys.sf.color_mode"s, 0));
11261123
}
11271124

1128-
status_t SurfaceFlinger::getSupportedFrameTimestamps(
1129-
std::vector<FrameEvent>* outSupported) const {
1125+
status_t SurfaceFlinger::getSupportedFrameTimestamps(std::vector<FrameEvent>* outSupported) const {
11301126
*outSupported = {
1131-
FrameEvent::REQUESTED_PRESENT,
1132-
FrameEvent::ACQUIRE,
1133-
FrameEvent::LATCH,
1134-
FrameEvent::FIRST_REFRESH_START,
1135-
FrameEvent::LAST_REFRESH_START,
1136-
FrameEvent::GPU_COMPOSITION_DONE,
1137-
FrameEvent::DEQUEUE_READY,
1138-
FrameEvent::RELEASE,
1127+
FrameEvent::REQUESTED_PRESENT,
1128+
FrameEvent::ACQUIRE,
1129+
FrameEvent::LATCH,
1130+
FrameEvent::FIRST_REFRESH_START,
1131+
FrameEvent::LAST_REFRESH_START,
1132+
FrameEvent::GPU_COMPOSITION_DONE,
1133+
FrameEvent::DEQUEUE_READY,
1134+
FrameEvent::RELEASE,
11391135
};
11401136

11411137
if (mHasReliablePresentFences) {
@@ -2210,7 +2206,6 @@ status_t SurfaceFlinger::addHdrLayerInfoListener(const sp<IBinder>& displayToken
22102206
}
22112207
hdrInfoReporter->addListener(listener);
22122208

2213-
22142209
mAddingHDRLayerInfoListener = true;
22152210
return OK;
22162211
}
@@ -2271,13 +2266,13 @@ sp<IDisplayEventConnection> SurfaceFlinger::createDisplayEventConnection(
22712266
const auto cycle = [&] {
22722267
if (FlagManager::getInstance().deprecate_vsync_sf()) {
22732268
ALOGW_IF(vsyncSource == gui::ISurfaceComposer::VsyncSource::eVsyncSourceSurfaceFlinger,
2274-
"requested unsupported config eVsyncSourceSurfaceFlinger");
2269+
"requested unsupported config eVsyncSourceSurfaceFlinger");
22752270
return scheduler::Cycle::Render;
22762271
}
22772272

22782273
return vsyncSource == gui::ISurfaceComposer::VsyncSource::eVsyncSourceSurfaceFlinger
2279-
? scheduler::Cycle::LastComposite
2280-
: scheduler::Cycle::Render;
2274+
? scheduler::Cycle::LastComposite
2275+
: scheduler::Cycle::Render;
22812276
}();
22822277
return mScheduler->createDisplayEventConnection(cycle, eventRegistration, layerHandle);
22832278
}
@@ -2807,9 +2802,10 @@ bool SurfaceFlinger::commit(PhysicalDisplayId pacesetterId,
28072802
// setTransactionFlags which will schedule another SF frame. This was if the tracker
28082803
// needs to adjust the vsync timeline, it will be done before the next frame.
28092804
if (FlagManager::getInstance().vrr_config() && mustComposite) {
2810-
mScheduler->getVsyncSchedule()->getTracker().onFrameBegin(
2811-
pacesetterFrameTarget.expectedPresentTime(),
2812-
pacesetterFrameTarget.lastSignaledFrameTime());
2805+
mScheduler->getVsyncSchedule()
2806+
->getTracker()
2807+
.onFrameBegin(pacesetterFrameTarget.expectedPresentTime(),
2808+
pacesetterFrameTarget.lastSignaledFrameTime());
28132809
}
28142810
if (transactionFlushNeeded()) {
28152811
setTransactionFlags(eTransactionFlushNeeded);
@@ -3058,7 +3054,7 @@ CompositeResultsPerDisplay SurfaceFlinger::composite(
30583054
// This should be interpreted to mean that there are 2 cached sets.
30593055
// So there are only 2 non skipped layers -- b and s.
30603056
// The layers rrc and cc are flattened into layers b and s respectively.
3061-
const LayerFE::HwcLayerDebugState &hwcState = layerFE->getLastHwcState();
3057+
const LayerFE::HwcLayerDebugState& hwcState = layerFE->getLastHwcState();
30623058
if (hwcState.overrideBufferId != prevOverrideBufferId) {
30633059
// End the existing run.
30643060
if (prevOverrideBufferId) {
@@ -3070,11 +3066,10 @@ CompositeResultsPerDisplay SurfaceFlinger::composite(
30703066
}
30713067
}
30723068

3073-
compositionSummary.push_back(
3074-
layerFE->mSnapshot->classifyCompositionForDebug(hwcState));
3069+
compositionSummary.push_back(layerFE->mSnapshot->classifyCompositionForDebug(hwcState));
30753070

30763071
if (hwcState.overrideBufferId && !hwcState.wasSkipped) {
3077-
compositionSummary.push_back(':');
3072+
compositionSummary.push_back(':');
30783073
}
30793074
prevOverrideBufferId = hwcState.overrideBufferId;
30803075

@@ -4324,37 +4319,35 @@ void SurfaceFlinger::updateInputFlinger(VsyncId vsyncId, TimePoint frameTime) {
43244319
mVisibleWindowIds = std::move(visibleWindowIds);
43254320
}
43264321

4327-
BackgroundExecutor::getInstance().sendCallbacks({[updateWindowInfo,
4328-
windowInfos = std::move(windowInfos),
4329-
displayInfos = std::move(displayInfos),
4330-
inputWindowCommands =
4331-
std::move(mInputWindowCommands),
4332-
inputFlinger = mInputFlinger, this,
4333-
visibleWindowsChanged, vsyncId,
4334-
frameTime]() mutable {
4335-
SFTRACE_NAME("BackgroundExecutor::updateInputFlinger");
4336-
if (updateWindowInfo) {
4337-
mWindowInfosListenerInvoker
4338-
->windowInfosChanged(gui::WindowInfosUpdate{std::move(windowInfos),
4339-
std::move(displayInfos),
4340-
ftl::to_underlying(vsyncId),
4341-
frameTime.ns()},
4342-
std::move(inputWindowCommands.releaseListeners()),
4343-
/* forceImmediateCall= */ visibleWindowsChanged ||
4344-
!inputWindowCommands.getFocusRequests().empty());
4345-
} else {
4346-
// If there are listeners but no changes to input windows, call the listeners
4347-
// immediately.
4348-
for (const auto& listener : inputWindowCommands.getListeners()) {
4349-
if (IInterface::asBinder(listener)->isBinderAlive()) {
4350-
listener->onWindowInfosReported();
4322+
BackgroundExecutor::getInstance().sendCallbacks(
4323+
{[updateWindowInfo, windowInfos = std::move(windowInfos),
4324+
displayInfos = std::move(displayInfos),
4325+
inputWindowCommands = std::move(mInputWindowCommands), inputFlinger = mInputFlinger,
4326+
this, visibleWindowsChanged, vsyncId, frameTime]() mutable {
4327+
SFTRACE_NAME("BackgroundExecutor::updateInputFlinger");
4328+
if (updateWindowInfo) {
4329+
mWindowInfosListenerInvoker
4330+
->windowInfosChanged(gui::WindowInfosUpdate{std::move(windowInfos),
4331+
std::move(displayInfos),
4332+
ftl::to_underlying(vsyncId),
4333+
frameTime.ns()},
4334+
std::move(inputWindowCommands.releaseListeners()),
4335+
/* forceImmediateCall= */ visibleWindowsChanged ||
4336+
!inputWindowCommands.getFocusRequests()
4337+
.empty());
4338+
} else {
4339+
// If there are listeners but no changes to input windows, call the listeners
4340+
// immediately.
4341+
for (const auto& listener : inputWindowCommands.getListeners()) {
4342+
if (IInterface::asBinder(listener)->isBinderAlive()) {
4343+
listener->onWindowInfosReported();
4344+
}
4345+
}
43514346
}
4352-
}
4353-
}
4354-
for (const auto& focusRequest : inputWindowCommands.getFocusRequests()) {
4355-
inputFlinger->setFocusedWindow(focusRequest);
4356-
}
4357-
}});
4347+
for (const auto& focusRequest : inputWindowCommands.getFocusRequests()) {
4348+
inputFlinger->setFocusedWindow(focusRequest);
4349+
}
4350+
}});
43584351

43594352
mInputWindowCommands.clear();
43604353
}
@@ -5067,8 +5060,8 @@ status_t SurfaceFlinger::setTransactionState(
50675060
if (resolvedState.state.hasBufferChanges() && resolvedState.state.hasValidBuffer() &&
50685061
resolvedState.state.surface) {
50695062
sp<Layer> layer = LayerHandle::getLayer(resolvedState.state.surface);
5070-
std::string layerName = (layer) ?
5071-
layer->getDebugName() : std::to_string(resolvedState.state.layerId);
5063+
std::string layerName =
5064+
(layer) ? layer->getDebugName() : std::to_string(resolvedState.state.layerId);
50725065
resolvedState.externalTexture =
50735066
getExternalTextureFromBufferData(*resolvedState.state.bufferData,
50745067
layerName.c_str(), transactionId);
@@ -5922,8 +5915,7 @@ status_t SurfaceFlinger::doDump(int fd, const DumpArgs& args, bool asProto) {
59225915
const int pid = ipc->getCallingPid();
59235916
const int uid = ipc->getCallingUid();
59245917

5925-
if ((uid != AID_SHELL) &&
5926-
!PermissionCache::checkPermission(sDump, pid, uid)) {
5918+
if ((uid != AID_SHELL) && !PermissionCache::checkPermission(sDump, pid, uid)) {
59275919
StringAppendF(&result, "Permission Denial: can't dump SurfaceFlinger from pid=%d, uid=%d\n",
59285920
pid, uid);
59295921
write(fd, result.c_str(), result.size());
@@ -6381,7 +6373,7 @@ void SurfaceFlinger::dumpAll(const DumpArgs& args, const std::string& compositio
63816373
// figure out if we're stuck somewhere
63826374
const nsecs_t now = systemTime();
63836375
const nsecs_t inTransaction(mDebugInTransaction);
6384-
nsecs_t inTransactionDuration = (inTransaction) ? now-inTransaction : 0;
6376+
nsecs_t inTransactionDuration = (inTransaction) ? now - inTransaction : 0;
63856377

63866378
/*
63876379
* Dump library configuration.
@@ -6561,7 +6553,7 @@ status_t SurfaceFlinger::CheckTransactCodeCredentials(uint32_t code) {
65616553
if (!callingThreadHasUnscopedSurfaceFlingerAccess(usePermissionCache)) {
65626554
IPCThreadState* ipc = IPCThreadState::self();
65636555
ALOGE("Permission Denial: can't access SurfaceFlinger pid=%d, uid=%d",
6564-
ipc->getCallingPid(), ipc->getCallingUid());
6556+
ipc->getCallingPid(), ipc->getCallingUid());
65656557
return PERMISSION_DENIED;
65666558
}
65676559
return OK;
@@ -6677,11 +6669,12 @@ status_t SurfaceFlinger::onTransact(uint32_t code, const Parcel& data, Parcel* r
66776669
CHECK_INTERFACE(ISurfaceComposer, data, reply);
66786670
IPCThreadState* ipc = IPCThreadState::self();
66796671
const int uid = ipc->getCallingUid();
6680-
if (CC_UNLIKELY(uid != AID_SYSTEM
6681-
&& !PermissionCache::checkCallingPermission(sHardwareTest))) {
6672+
if (CC_UNLIKELY(uid != AID_SYSTEM &&
6673+
!PermissionCache::checkCallingPermission(sHardwareTest))) {
66826674
const int pid = ipc->getCallingPid();
66836675
ALOGE("Permission Denial: "
6684-
"can't access SurfaceFlinger pid=%d, uid=%d", pid, uid);
6676+
"can't access SurfaceFlinger pid=%d, uid=%d",
6677+
pid, uid);
66856678
return PERMISSION_DENIED;
66866679
}
66876680
int n;
@@ -6752,7 +6745,7 @@ status_t SurfaceFlinger::onTransact(uint32_t code, const Parcel& data, Parcel* r
67526745
n = data.readInt32();
67536746
if (n) {
67546747
// color matrix is sent as a column-major mat4 matrix
6755-
for (size_t i = 0 ; i < 4; i++) {
6748+
for (size_t i = 0; i < 4; i++) {
67566749
for (size_t j = 0; j < 4; j++) {
67576750
mClientColorMatrix[i][j] = data.readFloat();
67586751
}
@@ -7272,9 +7265,7 @@ auto SurfaceFlinger::getKernelIdleTimerProperties(PhysicalDisplayId displayId)
72727265
class WindowDisconnector {
72737266
public:
72747267
WindowDisconnector(ANativeWindow* window, int api) : mWindow(window), mApi(api) {}
7275-
~WindowDisconnector() {
7276-
native_window_api_disconnect(mWindow, mApi);
7277-
}
7268+
~WindowDisconnector() { native_window_api_disconnect(mWindow, mApi); }
72787269

72797270
private:
72807271
ANativeWindow* mWindow;

0 commit comments

Comments
 (0)