Loading libs/gui/include/gui/DisplayEventReceiver.h +1 −0 Original line number Diff line number Diff line Loading @@ -65,6 +65,7 @@ public: struct VSync { uint32_t count; nsecs_t expectedVSyncTimestamp; }; struct Hotplug { Loading services/surfaceflinger/RefreshRateOverlay.cpp +5 −1 Original line number Diff line number Diff line Loading @@ -116,9 +116,13 @@ sp<GraphicBuffer> RefreshRateOverlay::SevenSegmentDrawer::drawNumber(int number, sp<GraphicBuffer> buffer = new GraphicBuffer(BUFFER_WIDTH, BUFFER_HEIGHT, HAL_PIXEL_FORMAT_RGBA_8888, 1, GRALLOC_USAGE_SW_WRITE_RARELY, "RefreshRateOverlayBuffer"); GRALLOC_USAGE_SW_WRITE_RARELY | GRALLOC_USAGE_HW_COMPOSER | GRALLOC_USAGE_HW_TEXTURE, "RefreshRateOverlayBuffer"); uint8_t* pixels; buffer->lock(GRALLOC_USAGE_SW_WRITE_RARELY, reinterpret_cast<void**>(&pixels)); // Clear buffer content drawRect(Rect(BUFFER_WIDTH, BUFFER_HEIGHT), half4(0), buffer, pixels); int left = 0; if (hundreds != 0) { drawDigit(hundreds, left, color, buffer, pixels); Loading services/surfaceflinger/RegionSamplingThread.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -130,7 +130,7 @@ private: mVsyncListening = false; } void onDispSyncEvent(nsecs_t /* when */) final { void onDispSyncEvent(nsecs_t /*when*/, nsecs_t /*expectedVSyncTimestamp*/) final { std::unique_lock<decltype(mMutex)> lock(mMutex); if (mPhaseIntervalSetting == Phase::ZERO) { Loading services/surfaceflinger/Scheduler/DispSync.cpp +27 −6 Original line number Diff line number Diff line Loading @@ -200,7 +200,8 @@ public: } } callbackInvocations = gatherCallbackInvocationsLocked(now); callbackInvocations = gatherCallbackInvocationsLocked(now, computeNextRefreshLocked(0, now)); } if (callbackInvocations.size() > 0) { Loading Loading @@ -303,6 +304,11 @@ public: return BAD_VALUE; } nsecs_t computeNextRefresh(int periodOffset, nsecs_t now) const { Mutex::Autolock lock(mMutex); return computeNextRefreshLocked(periodOffset, now); } private: struct EventListener { const char* mName; Loading @@ -315,6 +321,7 @@ private: struct CallbackInvocation { DispSync::Callback* mCallback; nsecs_t mEventTime; nsecs_t mExpectedVSyncTime; }; nsecs_t computeNextEventTimeLocked(nsecs_t now) { Loading @@ -340,7 +347,8 @@ private: return duration < (3 * mPeriod) / 5; } std::vector<CallbackInvocation> gatherCallbackInvocationsLocked(nsecs_t now) { std::vector<CallbackInvocation> gatherCallbackInvocationsLocked(nsecs_t now, nsecs_t expectedVSyncTime) { if (mTraceDetailedInfo) ATRACE_CALL(); ALOGV("[%s] gatherCallbackInvocationsLocked @ %" PRId64, mName, ns2us(now)); Loading @@ -361,6 +369,10 @@ private: CallbackInvocation ci; ci.mCallback = eventListener.mCallback; ci.mEventTime = t; ci.mExpectedVSyncTime = expectedVSyncTime; if (eventListener.mPhase < 0) { ci.mExpectedVSyncTime += mPeriod; } ALOGV("[%s] [%s] Preparing to fire, latency: %" PRId64, mName, eventListener.mName, t - eventListener.mLastEventTime); callbackInvocations.push_back(ci); Loading Loading @@ -426,8 +438,17 @@ private: void fireCallbackInvocations(const std::vector<CallbackInvocation>& callbacks) { if (mTraceDetailedInfo) ATRACE_CALL(); for (size_t i = 0; i < callbacks.size(); i++) { callbacks[i].mCallback->onDispSyncEvent(callbacks[i].mEventTime); callbacks[i].mCallback->onDispSyncEvent(callbacks[i].mEventTime, callbacks[i].mExpectedVSyncTime); } } nsecs_t computeNextRefreshLocked(int periodOffset, nsecs_t now) const { nsecs_t phase = mReferenceTime + mPhase; if (mPeriod == 0) { return 0; } return (((now - phase) / mPeriod) + periodOffset + 1) * mPeriod + phase; } const char* const mName; Loading @@ -444,7 +465,7 @@ private: std::vector<EventListener> mEventListeners; Mutex mMutex; mutable Mutex mMutex; Condition mCond; // Flag to turn on logging in systrace. Loading @@ -458,7 +479,7 @@ class ZeroPhaseTracer : public DispSync::Callback { public: ZeroPhaseTracer() : mParity("ZERO_PHASE_VSYNC", false) {} virtual void onDispSyncEvent(nsecs_t /*when*/) { virtual void onDispSyncEvent(nsecs_t /*when*/, nsecs_t /*expectedVSyncTimestamp*/) { mParity = !mParity; } Loading Loading @@ -845,7 +866,7 @@ nsecs_t DispSync::expectedPresentTime(nsecs_t now) { const uint32_t hwcLatency = 0; // Ask DispSync when the next refresh will be (CLOCK_MONOTONIC). return computeNextRefresh(hwcLatency, now); return mThread->computeNextRefresh(hwcLatency, now); } } // namespace impl Loading services/surfaceflinger/Scheduler/DispSync.h +1 −1 Original line number Diff line number Diff line Loading @@ -36,7 +36,7 @@ public: public: Callback() = default; virtual ~Callback(); virtual void onDispSyncEvent(nsecs_t when) = 0; virtual void onDispSyncEvent(nsecs_t when, nsecs_t expectedVSyncTimestamp) = 0; protected: Callback(Callback const&) = delete; Loading Loading
libs/gui/include/gui/DisplayEventReceiver.h +1 −0 Original line number Diff line number Diff line Loading @@ -65,6 +65,7 @@ public: struct VSync { uint32_t count; nsecs_t expectedVSyncTimestamp; }; struct Hotplug { Loading
services/surfaceflinger/RefreshRateOverlay.cpp +5 −1 Original line number Diff line number Diff line Loading @@ -116,9 +116,13 @@ sp<GraphicBuffer> RefreshRateOverlay::SevenSegmentDrawer::drawNumber(int number, sp<GraphicBuffer> buffer = new GraphicBuffer(BUFFER_WIDTH, BUFFER_HEIGHT, HAL_PIXEL_FORMAT_RGBA_8888, 1, GRALLOC_USAGE_SW_WRITE_RARELY, "RefreshRateOverlayBuffer"); GRALLOC_USAGE_SW_WRITE_RARELY | GRALLOC_USAGE_HW_COMPOSER | GRALLOC_USAGE_HW_TEXTURE, "RefreshRateOverlayBuffer"); uint8_t* pixels; buffer->lock(GRALLOC_USAGE_SW_WRITE_RARELY, reinterpret_cast<void**>(&pixels)); // Clear buffer content drawRect(Rect(BUFFER_WIDTH, BUFFER_HEIGHT), half4(0), buffer, pixels); int left = 0; if (hundreds != 0) { drawDigit(hundreds, left, color, buffer, pixels); Loading
services/surfaceflinger/RegionSamplingThread.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -130,7 +130,7 @@ private: mVsyncListening = false; } void onDispSyncEvent(nsecs_t /* when */) final { void onDispSyncEvent(nsecs_t /*when*/, nsecs_t /*expectedVSyncTimestamp*/) final { std::unique_lock<decltype(mMutex)> lock(mMutex); if (mPhaseIntervalSetting == Phase::ZERO) { Loading
services/surfaceflinger/Scheduler/DispSync.cpp +27 −6 Original line number Diff line number Diff line Loading @@ -200,7 +200,8 @@ public: } } callbackInvocations = gatherCallbackInvocationsLocked(now); callbackInvocations = gatherCallbackInvocationsLocked(now, computeNextRefreshLocked(0, now)); } if (callbackInvocations.size() > 0) { Loading Loading @@ -303,6 +304,11 @@ public: return BAD_VALUE; } nsecs_t computeNextRefresh(int periodOffset, nsecs_t now) const { Mutex::Autolock lock(mMutex); return computeNextRefreshLocked(periodOffset, now); } private: struct EventListener { const char* mName; Loading @@ -315,6 +321,7 @@ private: struct CallbackInvocation { DispSync::Callback* mCallback; nsecs_t mEventTime; nsecs_t mExpectedVSyncTime; }; nsecs_t computeNextEventTimeLocked(nsecs_t now) { Loading @@ -340,7 +347,8 @@ private: return duration < (3 * mPeriod) / 5; } std::vector<CallbackInvocation> gatherCallbackInvocationsLocked(nsecs_t now) { std::vector<CallbackInvocation> gatherCallbackInvocationsLocked(nsecs_t now, nsecs_t expectedVSyncTime) { if (mTraceDetailedInfo) ATRACE_CALL(); ALOGV("[%s] gatherCallbackInvocationsLocked @ %" PRId64, mName, ns2us(now)); Loading @@ -361,6 +369,10 @@ private: CallbackInvocation ci; ci.mCallback = eventListener.mCallback; ci.mEventTime = t; ci.mExpectedVSyncTime = expectedVSyncTime; if (eventListener.mPhase < 0) { ci.mExpectedVSyncTime += mPeriod; } ALOGV("[%s] [%s] Preparing to fire, latency: %" PRId64, mName, eventListener.mName, t - eventListener.mLastEventTime); callbackInvocations.push_back(ci); Loading Loading @@ -426,8 +438,17 @@ private: void fireCallbackInvocations(const std::vector<CallbackInvocation>& callbacks) { if (mTraceDetailedInfo) ATRACE_CALL(); for (size_t i = 0; i < callbacks.size(); i++) { callbacks[i].mCallback->onDispSyncEvent(callbacks[i].mEventTime); callbacks[i].mCallback->onDispSyncEvent(callbacks[i].mEventTime, callbacks[i].mExpectedVSyncTime); } } nsecs_t computeNextRefreshLocked(int periodOffset, nsecs_t now) const { nsecs_t phase = mReferenceTime + mPhase; if (mPeriod == 0) { return 0; } return (((now - phase) / mPeriod) + periodOffset + 1) * mPeriod + phase; } const char* const mName; Loading @@ -444,7 +465,7 @@ private: std::vector<EventListener> mEventListeners; Mutex mMutex; mutable Mutex mMutex; Condition mCond; // Flag to turn on logging in systrace. Loading @@ -458,7 +479,7 @@ class ZeroPhaseTracer : public DispSync::Callback { public: ZeroPhaseTracer() : mParity("ZERO_PHASE_VSYNC", false) {} virtual void onDispSyncEvent(nsecs_t /*when*/) { virtual void onDispSyncEvent(nsecs_t /*when*/, nsecs_t /*expectedVSyncTimestamp*/) { mParity = !mParity; } Loading Loading @@ -845,7 +866,7 @@ nsecs_t DispSync::expectedPresentTime(nsecs_t now) { const uint32_t hwcLatency = 0; // Ask DispSync when the next refresh will be (CLOCK_MONOTONIC). return computeNextRefresh(hwcLatency, now); return mThread->computeNextRefresh(hwcLatency, now); } } // namespace impl Loading
services/surfaceflinger/Scheduler/DispSync.h +1 −1 Original line number Diff line number Diff line Loading @@ -36,7 +36,7 @@ public: public: Callback() = default; virtual ~Callback(); virtual void onDispSyncEvent(nsecs_t when) = 0; virtual void onDispSyncEvent(nsecs_t when, nsecs_t expectedVSyncTimestamp) = 0; protected: Callback(Callback const&) = delete; Loading