Loading native/android/surface_control.cpp +19 −11 Original line number Diff line number Diff line Loading @@ -141,7 +141,7 @@ void ASurfaceControl_release(ASurfaceControl* aSurfaceControl) { } struct ASurfaceControlStats { int64_t acquireTime; std::variant<int64_t, sp<Fence>> acquireTimeOrFence; sp<Fence> previousReleaseFence; uint64_t frameNumber; }; Loading @@ -153,7 +153,7 @@ void ASurfaceControl_registerSurfaceStatsListener(ASurfaceControl* control, int3 const SurfaceStats& surfaceStats) { ASurfaceControlStats aSurfaceControlStats; aSurfaceControlStats.acquireTime = surfaceStats.acquireTime; aSurfaceControlStats.acquireTimeOrFence = surfaceStats.acquireTimeOrFence; aSurfaceControlStats.previousReleaseFence = surfaceStats.previousReleaseFence; aSurfaceControlStats.frameNumber = surfaceStats.eventStats.frameNumber; Loading @@ -171,7 +171,15 @@ void ASurfaceControl_unregisterSurfaceStatsListener(void* context, } int64_t ASurfaceControlStats_getAcquireTime(ASurfaceControlStats* stats) { return stats->acquireTime; if (const auto* fence = std::get_if<sp<Fence>>(&stats->acquireTimeOrFence)) { // We got a fence instead of the acquire time due to latch unsignaled. // Ideally the client could just get the acquire time dericly from // the fence instead of calling this function which needs to block. (*fence)->waitForever("ASurfaceControlStats_getAcquireTime"); return (*fence)->getSignalTime(); } return std::get<int64_t>(stats->acquireTimeOrFence); } uint64_t ASurfaceControlStats_getFrameNumber(ASurfaceControlStats* stats) { Loading Loading @@ -250,7 +258,7 @@ int64_t ASurfaceTransactionStats_getAcquireTime(ASurfaceTransactionStats* aSurfa aSurfaceControlStats == aSurfaceTransactionStats->aSurfaceControlStats.end(), "ASurfaceControl not found"); return aSurfaceControlStats->second.acquireTime; return ASurfaceControlStats_getAcquireTime(&aSurfaceControlStats->second); } int ASurfaceTransactionStats_getPreviousReleaseFenceFd( Loading Loading @@ -294,9 +302,10 @@ void ASurfaceTransaction_setOnComplete(ASurfaceTransaction* aSurfaceTransaction, auto& aSurfaceControlStats = aSurfaceTransactionStats.aSurfaceControlStats; for (const auto& [surfaceControl, latchTime, acquireTime, presentFence, previousReleaseFence, transformHint, frameEvents] : surfaceControlStats) { for (const auto& [surfaceControl, latchTime, acquireTimeOrFence, presentFence, previousReleaseFence, transformHint, frameEvents] : surfaceControlStats) { ASurfaceControl* aSurfaceControl = reinterpret_cast<ASurfaceControl*>(surfaceControl.get()); aSurfaceControlStats[aSurfaceControl].acquireTime = acquireTime; aSurfaceControlStats[aSurfaceControl].acquireTimeOrFence = acquireTimeOrFence; aSurfaceControlStats[aSurfaceControl].previousReleaseFence = previousReleaseFence; } Loading Loading @@ -643,13 +652,12 @@ void ASurfaceTransaction_setOnCommit(ASurfaceTransaction* aSurfaceTransaction, v aSurfaceTransactionStats.transactionCompleted = false; auto& aSurfaceControlStats = aSurfaceTransactionStats.aSurfaceControlStats; for (const auto& [surfaceControl, latchTime, acquireTime, presentFence, previousReleaseFence, transformHint, frameEvents] : surfaceControlStats) { for (const auto& [surfaceControl, latchTime, acquireTimeOrFence, presentFence, previousReleaseFence, transformHint, frameEvents] : surfaceControlStats) { ASurfaceControl* aSurfaceControl = reinterpret_cast<ASurfaceControl*>(surfaceControl.get()); aSurfaceControlStats[aSurfaceControl].acquireTime = acquireTime; aSurfaceControlStats[aSurfaceControl].acquireTimeOrFence = acquireTimeOrFence; } (*func)(callback_context, &aSurfaceTransactionStats); Loading Loading
native/android/surface_control.cpp +19 −11 Original line number Diff line number Diff line Loading @@ -141,7 +141,7 @@ void ASurfaceControl_release(ASurfaceControl* aSurfaceControl) { } struct ASurfaceControlStats { int64_t acquireTime; std::variant<int64_t, sp<Fence>> acquireTimeOrFence; sp<Fence> previousReleaseFence; uint64_t frameNumber; }; Loading @@ -153,7 +153,7 @@ void ASurfaceControl_registerSurfaceStatsListener(ASurfaceControl* control, int3 const SurfaceStats& surfaceStats) { ASurfaceControlStats aSurfaceControlStats; aSurfaceControlStats.acquireTime = surfaceStats.acquireTime; aSurfaceControlStats.acquireTimeOrFence = surfaceStats.acquireTimeOrFence; aSurfaceControlStats.previousReleaseFence = surfaceStats.previousReleaseFence; aSurfaceControlStats.frameNumber = surfaceStats.eventStats.frameNumber; Loading @@ -171,7 +171,15 @@ void ASurfaceControl_unregisterSurfaceStatsListener(void* context, } int64_t ASurfaceControlStats_getAcquireTime(ASurfaceControlStats* stats) { return stats->acquireTime; if (const auto* fence = std::get_if<sp<Fence>>(&stats->acquireTimeOrFence)) { // We got a fence instead of the acquire time due to latch unsignaled. // Ideally the client could just get the acquire time dericly from // the fence instead of calling this function which needs to block. (*fence)->waitForever("ASurfaceControlStats_getAcquireTime"); return (*fence)->getSignalTime(); } return std::get<int64_t>(stats->acquireTimeOrFence); } uint64_t ASurfaceControlStats_getFrameNumber(ASurfaceControlStats* stats) { Loading Loading @@ -250,7 +258,7 @@ int64_t ASurfaceTransactionStats_getAcquireTime(ASurfaceTransactionStats* aSurfa aSurfaceControlStats == aSurfaceTransactionStats->aSurfaceControlStats.end(), "ASurfaceControl not found"); return aSurfaceControlStats->second.acquireTime; return ASurfaceControlStats_getAcquireTime(&aSurfaceControlStats->second); } int ASurfaceTransactionStats_getPreviousReleaseFenceFd( Loading Loading @@ -294,9 +302,10 @@ void ASurfaceTransaction_setOnComplete(ASurfaceTransaction* aSurfaceTransaction, auto& aSurfaceControlStats = aSurfaceTransactionStats.aSurfaceControlStats; for (const auto& [surfaceControl, latchTime, acquireTime, presentFence, previousReleaseFence, transformHint, frameEvents] : surfaceControlStats) { for (const auto& [surfaceControl, latchTime, acquireTimeOrFence, presentFence, previousReleaseFence, transformHint, frameEvents] : surfaceControlStats) { ASurfaceControl* aSurfaceControl = reinterpret_cast<ASurfaceControl*>(surfaceControl.get()); aSurfaceControlStats[aSurfaceControl].acquireTime = acquireTime; aSurfaceControlStats[aSurfaceControl].acquireTimeOrFence = acquireTimeOrFence; aSurfaceControlStats[aSurfaceControl].previousReleaseFence = previousReleaseFence; } Loading Loading @@ -643,13 +652,12 @@ void ASurfaceTransaction_setOnCommit(ASurfaceTransaction* aSurfaceTransaction, v aSurfaceTransactionStats.transactionCompleted = false; auto& aSurfaceControlStats = aSurfaceTransactionStats.aSurfaceControlStats; for (const auto& [surfaceControl, latchTime, acquireTime, presentFence, previousReleaseFence, transformHint, frameEvents] : surfaceControlStats) { for (const auto& [surfaceControl, latchTime, acquireTimeOrFence, presentFence, previousReleaseFence, transformHint, frameEvents] : surfaceControlStats) { ASurfaceControl* aSurfaceControl = reinterpret_cast<ASurfaceControl*>(surfaceControl.get()); aSurfaceControlStats[aSurfaceControl].acquireTime = acquireTime; aSurfaceControlStats[aSurfaceControl].acquireTimeOrFence = acquireTimeOrFence; } (*func)(callback_context, &aSurfaceTransactionStats); Loading