This change adds a new CompositionAttributes struct which tracks information about a given composition as it is validated and subsequently presented. Previously CompositionStats were tracked as totals for each display. This change splits the stats according to the CompositionAttributes for each presented composition. This change only affects the reporting behavior of CompositionStatsTracker. The stats logged by DumpState are totaled so as to not be affected. Change-Id: I050cce7f63891971cc807b9c5150d9b5d30f1f0b
66 lines
2.2 KiB
C++
66 lines
2.2 KiB
C++
/*
|
|
* Copyright (C) 2025 The Android Open Source Project
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
#include "CompositionStatsPoller.h"
|
|
|
|
#include <chrono>
|
|
|
|
#include "stats/CompositionStats.h"
|
|
#include "stats/CompositionStatsAtomReporter.h"
|
|
|
|
namespace android::drm_hwcomposer {
|
|
|
|
CompositionStatsPoller::CompositionStatsPoller(
|
|
std::unique_ptr<CompositionStatsAtomReporter> reporter,
|
|
CompositionStatsProvider* provider)
|
|
: tracker_(provider), reporter_(std::move(reporter)) {
|
|
thread_ = std::thread(&CompositionStatsPoller::PollFunc, this);
|
|
}
|
|
|
|
CompositionStatsPoller::~CompositionStatsPoller() {
|
|
{
|
|
std::lock_guard lock(mutex_);
|
|
exit_ = true;
|
|
}
|
|
condition_.notify_one();
|
|
thread_.join();
|
|
}
|
|
|
|
void CompositionStatsPoller::PollFunc() {
|
|
bool thread_exit = false;
|
|
while (!thread_exit) {
|
|
tracker_.ReportStats([this](const CompositionAttributes& attributes,
|
|
const CompositionStats& /*cumulative*/,
|
|
const CompositionStats& delta) {
|
|
if (delta.total_frames == 0) {
|
|
return;
|
|
}
|
|
reporter_->PushAtom(attributes.display_handle, delta.total_frames,
|
|
delta.failed_kms_present, delta.failed_kms_validate);
|
|
});
|
|
|
|
constexpr std::chrono::seconds kPollFrequency = std::chrono::minutes(1);
|
|
std::unique_lock lock(mutex_);
|
|
base::ScopedLockAssertion lock_assertion(mutex_);
|
|
thread_exit = exit_ ||
|
|
condition_.wait_for(lock, kPollFrequency, [this]() -> bool {
|
|
base::ScopedLockAssertion lock_assertion(mutex_);
|
|
return exit_;
|
|
});
|
|
}
|
|
}
|
|
|
|
} // namespace android::drm_hwcomposer
|