!13973 新增prop产品配置项,添加arsr白名单

Merge pull request !13973 from mikefeng/master
This commit is contained in:
openharmony_ci 2024-08-27 11:26:22 +00:00 committed by Gitee
commit 5781c279ad
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 52 additions and 13 deletions

View File

@ -57,7 +57,10 @@ ohos_shared_library("libcomposer") {
"hdi_backend/src/hdi_screen.cpp",
]
include_dirs = [ "$graphic_2d_root/utils/log" ]
include_dirs = [
"$graphic_2d_root/utils/log",
"$graphic_2d_root/rosen/modules/utils",
]
configs = [ ":composer_config" ]

View File

@ -129,6 +129,8 @@ private:
// DISPLAYENGINE
bool arsrPreEnabled_ = false;
bool arsrPreEnabledForVm_ = false;
std::string vmArsrWhiteList_ = "";
int32_t CreateLayerLocked(uint64_t surfaceId, const LayerInfoPtr &layerInfo);
void DeletePrevLayersLocked();
@ -143,6 +145,8 @@ private:
// DISPLAY ENGINE
bool CheckIfDoArsrPre(const LayerInfoPtr &layerInfo);
bool CheckIfDoArsrPreForVm(const LayerInfoPtr &layerInfo);
bool CheckSupportArsrPreMetadata();
void ClearBufferCache();
std::map<LayerInfoPtr, sptr<SyncFence>> GetLayersReleaseFenceLocked();

View File

@ -18,6 +18,7 @@
#include <unordered_set>
#include "rs_trace.h"
#include "hdi_output.h"
#include "string_utils.h"
#include "metadata_helper.h"
#include "vsync_generator.h"
#include "vsync_sampler.h"
@ -48,6 +49,8 @@ HdiOutput::HdiOutput(uint32_t screenId) : screenId_(screenId)
{
// DISPLAYENGINE ARSR_PRE FLAG
arsrPreEnabled_ = system::GetBoolParameter("const.display.enable_arsr_pre", true);
arsrPreEnabledForVm_ = system::GetBoolParameter("const.display.enable_arsr_pre_for_vm", false);
vmArsrWhiteList_ = system::GetParameter("const.display.vmlayer.whitelist", "unknown");
}
HdiOutput::~HdiOutput()
@ -176,6 +179,15 @@ void HdiOutput::ResetLayerStatusLocked()
}
}
bool HdiOutput::CheckSupportArsrPreMetadata()
{
const auto& validKeys = device_->GetSupportedLayerPerFrameParameterKey();
if (std::find(validKeys.begin(), validKeys.end(), GENERIC_METADATA_KEY_ARSR_PRE_NEEDED) != validKeys.end()) {
return true;
}
return false;
}
int32_t HdiOutput::CreateLayerLocked(uint64_t surfaceId, const LayerInfoPtr &layerInfo)
{
LayerPtr layer = HdiLayer::CreateHdiLayer(screenId_);
@ -194,19 +206,13 @@ int32_t HdiOutput::CreateLayerLocked(uint64_t surfaceId, const LayerInfoPtr &lay
HLOGE("[%{public}s]HdiDevice is nullptr.", __func__);
return GRAPHIC_DISPLAY_SUCCESS;
}
// DISPLAY ENGINE
if (!arsrPreEnabled_) {
return GRAPHIC_DISPLAY_SUCCESS;
}
const auto& validKeys = device_->GetSupportedLayerPerFrameParameterKey();
if (std::find(validKeys.begin(), validKeys.end(), GENERIC_METADATA_KEY_ARSR_PRE_NEEDED) != validKeys.end()) {
if (CheckIfDoArsrPre(layerInfo)) {
const std::vector<int8_t> valueBlob{static_cast<int8_t>(1)};
if (device_->SetLayerPerFrameParameter(screenId_,
layerId, GENERIC_METADATA_KEY_ARSR_PRE_NEEDED, valueBlob) != 0) {
HLOGE("SetLayerPerFrameParameter Fail!");
}
if ((arsrPreEnabledForVm_ && CheckSupportArsrPreMetadata() && CheckIfDoArsrPreForVm(layerInfo)) ||
(arsrPreEnabled_ && CheckSupportArsrPreMetadata() && CheckIfDoArsrPre(layerInfo))) {
const std::vector<int8_t> valueBlob{static_cast<int8_t>(1)};
if (device_->SetLayerPerFrameParameter(screenId_,
layerId, GENERIC_METADATA_KEY_ARSR_PRE_NEEDED, valueBlob) != 0) {
HLOGE("SetLayerPerFrameParameter Fail!");
}
}
@ -483,6 +489,17 @@ bool HdiOutput::CheckIfDoArsrPre(const LayerInfoPtr &layerInfo)
return false;
}
bool HdiOutput::CheckIfDoArsrPreForVm(const LayerInfoPtr &layerInfo)
{
char sep = ';';
std::unordered_set<std::string> vmLayers;
SplitString(vmArsrWhiteList_, vmLayers, sep);
if (vmLayers.count(layerInfo->GetSurface()->GetName()) > 0) {
return true;
}
return false;
}
int32_t HdiOutput::FlushScreen(std::vector<LayerPtr> &compClientLayers)
{
auto fbEntry = GetFramebuffer();

View File

@ -17,6 +17,7 @@
#define STRING_UTILS_H
#include <iostream>
#include <sstream>
#include <hilog/log.h>
@ -38,6 +39,20 @@ void AppendFormat(std::string& out, const char* fmt, Args&& ... args)
}
out += buf;
}
template <class Container>
void SplitString(const std::string& src, Container& dest, const char separator)
{
if (src.empty()) {
return;
}
std::string tmp;
std::stringstream ss(src);
while (std::getline(ss, tmp, separator)) {
dest.insert(tmp);
}
return;
}
}
}
#endif