mirror of
https://gitee.com/openharmony/graphic_graphic_2d
synced 2024-11-27 17:21:51 +00:00
进入Adaptive Sync提前送显模式需要关闭vsync校准
Signed-off-by: 陶春龙 <taochunlong@huawei.com>
This commit is contained in:
parent
5791bc5068
commit
68a064891e
@ -63,6 +63,7 @@ public:
|
||||
/* set a temporary period used only for VSyncSampler::GetHardwarePeriod interface */
|
||||
void SetPendingMode(const OutputPtr &output, int64_t period, int64_t timestamp);
|
||||
void SetVsyncSamplerEnabled(const OutputPtr &output, bool enabled);
|
||||
bool GetVsyncSamplerEnabled(const OutputPtr &output);
|
||||
private:
|
||||
HdiBackend() = default;
|
||||
virtual ~HdiBackend() = default;
|
||||
|
@ -97,6 +97,7 @@ public:
|
||||
void ReleaseLayers(sptr<SyncFence>& releaseFence);
|
||||
int32_t GetBufferCacheSize();
|
||||
void SetVsyncSamplerEnabled(bool enabled);
|
||||
bool GetVsyncSamplerEnabled();
|
||||
|
||||
private:
|
||||
HdiDevice *device_ = nullptr;
|
||||
@ -150,7 +151,7 @@ private:
|
||||
|
||||
void ClearBufferCache();
|
||||
std::map<LayerInfoPtr, sptr<SyncFence>> GetLayersReleaseFenceLocked();
|
||||
bool disableVsyncSample_ = false;
|
||||
bool enableVsyncSample_ = true;
|
||||
};
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -257,6 +257,15 @@ void HdiBackend::SetVsyncSamplerEnabled(const OutputPtr &output, bool enabled)
|
||||
output->SetVsyncSamplerEnabled(enabled);
|
||||
}
|
||||
|
||||
bool HdiBackend::GetVsyncSamplerEnabled(const OutputPtr &output)
|
||||
{
|
||||
if (output == nullptr) {
|
||||
HLOGE("output is nullptr.");
|
||||
return false;
|
||||
}
|
||||
output->GetVsyncSamplerEnabled();
|
||||
}
|
||||
|
||||
void HdiBackend::ResetDevice()
|
||||
{
|
||||
if (device_) {
|
||||
|
@ -545,7 +545,7 @@ int32_t HdiOutput::UpdateInfosAfterCommit(sptr<SyncFence> fbFence)
|
||||
int64_t timestamp = thirdFrameAheadPresentFence_->SyncFileReadTimestamp();
|
||||
bool startSample = false;
|
||||
if (timestamp != SyncFence::FENCE_PENDING_TIMESTAMP) {
|
||||
startSample = !disableVsyncSample_ && sampler_->AddPresentFenceTime(timestamp);
|
||||
startSample = enableVsyncSample_ && sampler_->AddPresentFenceTime(timestamp);
|
||||
RecordCompositionTime(timestamp);
|
||||
bool presentTimeUpdated = false;
|
||||
LayerPtr uniRenderLayer = nullptr;
|
||||
@ -580,7 +580,12 @@ int32_t HdiOutput::UpdateInfosAfterCommit(sptr<SyncFence> fbFence)
|
||||
void HdiOutput::SetVsyncSamplerEnabled(bool enabled)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mutex_);
|
||||
disableVsyncSample_ = !enabled;
|
||||
enableVsyncSample_ = enabled;
|
||||
}
|
||||
|
||||
bool HdiOutput::GetVsyncSamplerEnabled()
|
||||
{
|
||||
return enableVsyncSample_;
|
||||
}
|
||||
|
||||
|
||||
@ -714,7 +719,7 @@ int32_t HdiOutput::StartVSyncSampler(bool forceReSample)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mutex_);
|
||||
ScopedBytrace func("HdiOutput::StartVSyncSampler, forceReSample:" + std::to_string(forceReSample));
|
||||
if (disableVsyncSample_) {
|
||||
if (!enableVsyncSample_) {
|
||||
ScopedBytrace func("disabled vsyncSample");
|
||||
return GRAPHIC_DISPLAY_FAILURE;
|
||||
}
|
||||
|
@ -231,19 +231,17 @@ void RSHardwareThread::CommitAndReleaseLayers(OutputPtr output, const std::vecto
|
||||
RS_LOGD("RSHardwareThread::CommitAndReleaseLayers send layer isAdaptive: %{public}u", isAdaptive);
|
||||
if (isAdaptive) {
|
||||
RS_TRACE_NAME("RSHardwareThread::CommitAndReleaseLayers PostTask in Adaptive Mode");
|
||||
if (!isLastAdaptive_) {
|
||||
if (hdiBackend_->GetVsyncSamplerEnabled(output)) {
|
||||
// enter adaptive sync mode must disable vsync sampler
|
||||
isLastAdaptive_ = true;
|
||||
hdiBackend_->SetVsyncSamplerEnabled(output, false);
|
||||
}
|
||||
PostTask(task);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (isLastAdaptive_) {
|
||||
if (!hdiBackend_->GetVsyncSamplerEnabled(output)) {
|
||||
// exit adaptive sync mode must restore vsync sampler
|
||||
hdiBackend_->SetVsyncSamplerEnabled(output, true);
|
||||
isLastAdaptive_ = false;
|
||||
}
|
||||
auto period = CreateVSyncSampler()->GetHardwarePeriod();
|
||||
int64_t pipelineOffset = hgmCore.GetPipelineOffset();
|
||||
|
@ -104,7 +104,6 @@ private:
|
||||
std::map<uint32_t, uint64_t> refreshRateCounts_;
|
||||
sptr<SyncFence> releaseFence_ = SyncFence::InvalidFence();
|
||||
int64_t delayTime_ = 0;
|
||||
bool isLastAdaptive_ = false;
|
||||
|
||||
friend class RSUniRenderThread;
|
||||
friend class RSUifirstManager;
|
||||
|
Loading…
Reference in New Issue
Block a user