Skip to content

Commit 1635578

Browse files
author
Melody Hsu
committed
Track pendingBuffer count in RequestedLayerState
Allows for easier retrieval without added lock contention. RequestedLayerState stores a pointer to the original buffer count from legacy layer. Bug: b/294922229 Test: presubmit Flag: EXEMPT, mechanical refactor Change-Id: Iaab1b2214cc670f6e2d385ba4aba31e635a34030
1 parent 886c2c0 commit 1635578

6 files changed

Lines changed: 8 additions & 4 deletions

File tree

services/surfaceflinger/FrontEnd/LayerCreationArgs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ struct LayerCreationArgs {
6161
ui::LayerStack layerStackToMirror = ui::INVALID_LAYER_STACK;
6262
uint32_t parentId = UNASSIGNED_LAYER_ID;
6363
uint32_t layerIdToMirror = UNASSIGNED_LAYER_ID;
64+
std::atomic<int32_t>* pendingBuffers = 0;
6465
};
6566

6667
} // namespace android::surfaceflinger

services/surfaceflinger/FrontEnd/RequestedLayerState.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ RequestedLayerState::RequestedLayerState(const LayerCreationArgs& args)
5656
ownerUid(args.ownerUid),
5757
ownerPid(args.ownerPid),
5858
parentId(args.parentId),
59-
layerIdToMirror(args.layerIdToMirror) {
59+
layerIdToMirror(args.layerIdToMirror),
60+
pendingBuffers(args.pendingBuffers) {
6061
layerId = static_cast<int32_t>(args.sequence);
6162
changes |= RequestedLayerState::Changes::Created;
6263
metadata.merge(args.metadata);

services/surfaceflinger/FrontEnd/RequestedLayerState.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ struct RequestedLayerState : layer_state_t {
131131
uint64_t barrierFrameNumber = 0;
132132
uint32_t barrierProducerId = 0;
133133
std::string debugName;
134+
std::atomic<int32_t>* pendingBuffers = 0;
134135

135136
// book keeping states
136137
bool handleAlive = true;

services/surfaceflinger/Layer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1347,7 +1347,7 @@ Rect Layer::computeBufferCrop(const State& s) {
13471347
}
13481348

13491349
void Layer::decrementPendingBufferCount() {
1350-
int32_t pendingBuffers = --mPendingBufferTransactions;
1350+
int32_t pendingBuffers = --mPendingBuffers;
13511351
tracePendingBufferCount(pendingBuffers);
13521352
}
13531353

services/surfaceflinger/Layer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ class Layer : public virtual RefBase {
369369

370370
// See mPendingBufferTransactions
371371
void decrementPendingBufferCount();
372-
std::atomic<int32_t>* getPendingBufferCounter() { return &mPendingBufferTransactions; }
372+
std::atomic<int32_t>* getPendingBufferCounter() { return &mPendingBuffers; }
373373
std::string getPendingBufferCounterName() { return mBlastTransactionName; }
374374
void callReleaseBufferCallback(const sp<ITransactionCompletedListener>& listener,
375375
const sp<GraphicBuffer>& buffer, uint64_t framenumber,
@@ -562,7 +562,7 @@ class Layer : public virtual RefBase {
562562
// - If the integer increases, a buffer arrived at the server.
563563
// - If the integer decreases in latchBuffer, that buffer was latched
564564
// - If the integer decreases in setBuffer, a buffer was dropped
565-
std::atomic<int32_t> mPendingBufferTransactions{0};
565+
std::atomic<int32_t> mPendingBuffers{0};
566566

567567
// Contains requested position and matrix updates. This will be applied if the client does
568568
// not specify a destination frame.

services/surfaceflinger/SurfaceFlinger.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5181,6 +5181,7 @@ status_t SurfaceFlinger::createLayer(LayerCreationArgs& args, gui::CreateSurface
51815181
std::string counterName = layer->getPendingBufferCounterName();
51825182
mBufferCountTracker.add(LayerHandle::getLayerId(outResult.handle), counterName,
51835183
pendingBufferCounter);
5184+
args.pendingBuffers = pendingBufferCounter;
51845185
}
51855186
} break;
51865187
default:

0 commit comments

Comments
 (0)