mirror of
https://gitee.com/openharmony/graphic_graphic_2d
synced 2024-11-23 07:02:25 +00:00
!17104 add wired screen ondraw
Merge pull request !17104 from shiguoquan/wired_ondraw
This commit is contained in:
commit
980cc56d22
@ -578,6 +578,7 @@ void RSDisplayRenderNodeDrawable::OnDraw(Drawing::Canvas& canvas)
|
||||
// set for cache and draw cross node in extended screen model
|
||||
uniParam->SetIsMirrorScreen(params->IsMirrorScreen());
|
||||
uniParam->SetIsFirstVisitCrossNodeDisplay(params->IsFirstVisitCrossNodeDisplay());
|
||||
uniParam->SetCompositeType(params->GetCompositeType());
|
||||
// check rotation for point light
|
||||
constexpr int ROTATION_NUM = 4;
|
||||
auto screenRotation = GetRenderParams()->GetScreenRotation();
|
||||
@ -1183,7 +1184,12 @@ void RSDisplayRenderNodeDrawable::WiredScreenProjection(
|
||||
std::vector<RectI> damageRegionRects =
|
||||
CalculateVirtualDirtyForWiredScreen(renderFrame, params, curCanvas_->GetTotalMatrix());
|
||||
rsDirtyRectsDfx.SetVirtualDirtyRects(damageRegionRects, params.GetScreenInfo());
|
||||
DrawWiredMirrorCopy(*mirroredDrawable);
|
||||
// HDR does not support wired screen
|
||||
if (params.GetHDRPresent() && RSSystemParameters::GetWiredScreenOndrawEnabled()) {
|
||||
DrawWiredMirrorOnDraw(*mirroredDrawable, params);
|
||||
} else {
|
||||
DrawWiredMirrorCopy(*mirroredDrawable);
|
||||
}
|
||||
RSUniRenderThread::SetCaptureParam(CaptureParam(false, false, true, 1.0f, 1.0f));
|
||||
mirroredDrawable->DrawHardCursorNodesMissedInCacheImage(*curCanvas_);
|
||||
RSUniRenderThread::ResetCaptureParam();
|
||||
@ -1220,6 +1226,33 @@ void RSDisplayRenderNodeDrawable::DrawWiredMirrorCopy(RSDisplayRenderNodeDrawabl
|
||||
}
|
||||
}
|
||||
|
||||
void RSDisplayRenderNodeDrawable::DrawWiredMirrorOnDraw(
|
||||
RSDisplayRenderNodeDrawable& mirroredDrawable, RSDisplayRenderParams& params)
|
||||
{
|
||||
auto& uniParam = RSUniRenderThread::Instance().GetRSRenderThreadParams();
|
||||
if (uniParam == nullptr) {
|
||||
return;
|
||||
}
|
||||
curCanvas_->SetCapture(true);
|
||||
curCanvas_->SetDisableFilterCache(true);
|
||||
curCanvas_->SetHighContrast(RSUniRenderThread::Instance().IsHighContrastTextModeOn());
|
||||
bool isOpDropped = uniParam->IsOpDropped();
|
||||
uniParam->SetOpDropped(false);
|
||||
if (const auto& mirrorParams = static_cast<RSDisplayRenderParams*>(mirroredDrawable.GetRenderParams().get())) {
|
||||
auto screenInfo = mirrorParams->GetScreenInfo();
|
||||
uniParam->SetScreenInfo(screenInfo);
|
||||
Drawing::Rect rect(0, 0, screenInfo.width, screenInfo.height);
|
||||
curCanvas_->ClipRect(rect, Drawing::ClipOp::INTERSECT, false);
|
||||
curCanvas_->ConcatMatrix(mirrorParams->GetMatrix());
|
||||
RSRenderParams::SetParentSurfaceMatrix(curCanvas_->GetTotalMatrix());
|
||||
mirroredDrawable.RSRenderNodeDrawable::OnDraw(*curCanvas_);
|
||||
DrawCurtainScreen();
|
||||
DrawWatermarkIfNeed(*mirrorParams, *curCanvas_);
|
||||
SwitchColorFilter(*curCanvas_, 1.f); // 1.f: wired screen not use hdr, use default value 1.f
|
||||
}
|
||||
uniParam->SetOpDropped(isOpDropped);
|
||||
}
|
||||
|
||||
std::vector<RectI> RSDisplayRenderNodeDrawable::CalculateVirtualDirtyForWiredScreen(
|
||||
std::unique_ptr<RSRenderFrame>& renderFrame, RSDisplayRenderParams& params, Drawing::Matrix canvasMatrix)
|
||||
{
|
||||
|
@ -141,6 +141,7 @@ private:
|
||||
void WiredScreenProjection(RSDisplayRenderParams& params, std::shared_ptr<RSProcessor> processor);
|
||||
void ScaleAndRotateMirrorForWiredScreen(RSDisplayRenderNodeDrawable& mirroredDrawable);
|
||||
void DrawWiredMirrorCopy(RSDisplayRenderNodeDrawable& mirroredDrawable);
|
||||
void DrawWiredMirrorOnDraw(RSDisplayRenderNodeDrawable& mirroredDrawable, RSDisplayRenderParams& params);
|
||||
std::vector<RectI> CalculateVirtualDirtyForWiredScreen(
|
||||
std::unique_ptr<RSRenderFrame>& renderFrame, RSDisplayRenderParams& params, Drawing::Matrix canvasMatrix);
|
||||
void DrawWatermarkIfNeed(RSDisplayRenderParams& params, RSPaintFilterCanvas& canvas) const;
|
||||
|
@ -251,6 +251,13 @@ bool RSSurfaceRenderNodeDrawable::PrepareOffscreenRender()
|
||||
}
|
||||
int offscreenWidth = curCanvas_->GetSurface()->Width();
|
||||
int offscreenHeight = curCanvas_->GetSurface()->Height();
|
||||
auto& uniParam = RSUniRenderThread::Instance().GetRSRenderThreadParams();
|
||||
if (uniParam && uniParam->IsMirrorScreen() &&
|
||||
uniParam->GetCompositeType() == RSDisplayRenderNode::CompositeType::UNI_RENDER_COMPOSITE) {
|
||||
auto screenInfo = uniParam->GetScreenInfo();
|
||||
offscreenWidth = screenInfo.width;
|
||||
offscreenHeight = screenInfo.height;
|
||||
}
|
||||
if (offscreenWidth <= 0 || offscreenHeight <= 0) {
|
||||
RS_LOGE("RSSurfaceRenderNodeDrawable::PrepareOffscreenRender, offscreenWidth or offscreenHeight is invalid");
|
||||
return false;
|
||||
@ -385,7 +392,8 @@ void RSSurfaceRenderNodeDrawable::OnDraw(Drawing::Canvas& canvas)
|
||||
nodeCacheType_ = NodeStrategyType::CACHE_NONE;
|
||||
}
|
||||
bool isUiFirstNode = rscanvas->GetIsParallelCanvas();
|
||||
if (!isUiFirstNode && surfaceParams->GetOccludedByFilterCache()) {
|
||||
bool disableFilterCache = rscanvas->GetDisableFilterCache();
|
||||
if (!disableFilterCache && !isUiFirstNode && surfaceParams->GetOccludedByFilterCache()) {
|
||||
SetDrawSkipType(DrawSkipType::FILTERCACHE_OCCLUSION_SKIP);
|
||||
RS_TRACE_NAME_FMT("RSSurfaceRenderNodeDrawable::OnDraw filterCache occlusion skip [%s] %sAlpha: %f, "
|
||||
"NodeId:%" PRIu64 "", name_.c_str(), surfaceParams->GetAbsDrawRect().ToString().c_str(),
|
||||
|
@ -208,5 +208,13 @@ bool RSSystemParameters::IsNeedScRGBForP3(const GraphicColorGamut& currentGamut)
|
||||
static bool isSupportScRGBForP3_ = system::GetBoolParameter("persist.sys.graphic.scrgb.enabled", false);
|
||||
return isSupportScRGBForP3_ && (currentGamut != GraphicColorGamut::GRAPHIC_COLOR_GAMUT_SRGB);
|
||||
}
|
||||
|
||||
bool RSSystemParameters::GetWiredScreenOndrawEnabled()
|
||||
{
|
||||
static CachedHandle g_Handle = CachedParameterCreate("rosen.wiredScreenOndraw.enabled", "1");
|
||||
int changed = 0;
|
||||
const char *enable = CachedParameterGetChanged(g_Handle, &changed);
|
||||
return ConvertToInt(enable, 0) != 0;
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -76,6 +76,7 @@ public:
|
||||
static bool GetTcacheEnabled();
|
||||
static bool GetDumpCanvasDrawingNodeEnabled();
|
||||
static bool IsNeedScRGBForP3(const GraphicColorGamut& currentGamut);
|
||||
static bool GetWiredScreenOndrawEnabled();
|
||||
};
|
||||
|
||||
} // namespace Rosen
|
||||
|
@ -19,9 +19,11 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include "common/rs_occlusion_region.h"
|
||||
#include "pipeline/rs_display_render_node.h"
|
||||
#include "pipeline/rs_surface_render_node.h"
|
||||
#include "platform/ohos/rs_jank_stats.h"
|
||||
#include "property/rs_properties.h"
|
||||
#include "screen_manager/rs_screen_info.h"
|
||||
|
||||
namespace OHOS::Rosen {
|
||||
struct CaptureParam {
|
||||
@ -414,6 +416,25 @@ public:
|
||||
return isDrawingCacheDfxEnabled_;
|
||||
}
|
||||
|
||||
const ScreenInfo& GetScreenInfo() const
|
||||
{
|
||||
return screenInfo_;
|
||||
}
|
||||
|
||||
void SetScreenInfo(const ScreenInfo& info)
|
||||
{
|
||||
screenInfo_ = info;
|
||||
}
|
||||
|
||||
RSDisplayRenderNode::CompositeType GetCompositeType() const
|
||||
{
|
||||
return compositeType_;
|
||||
}
|
||||
|
||||
void SetCompositeType(RSDisplayRenderNode::CompositeType type)
|
||||
{
|
||||
compositeType_ = type;
|
||||
}
|
||||
private:
|
||||
// Used by hardware thred
|
||||
uint64_t timestamp_ = 0;
|
||||
@ -467,12 +488,14 @@ private:
|
||||
bool isUniRenderAndOnVsync_ = false;
|
||||
std::weak_ptr<RSContext> context_;
|
||||
bool isCurtainScreenOn_ = false;
|
||||
RSDisplayRenderNode::CompositeType compositeType_ = RSDisplayRenderNode::CompositeType::HARDWARE_COMPOSITE;
|
||||
|
||||
Drawing::Region clipRegion_;
|
||||
bool isImplicitAnimationEnd_ = false;
|
||||
bool discardJankFrames_ = false;
|
||||
|
||||
bool isSecurityExemption_ = false;
|
||||
ScreenInfo screenInfo_ = {};
|
||||
|
||||
friend class RSMainThread;
|
||||
friend class RSUniRenderVisitor;
|
||||
|
@ -1431,4 +1431,15 @@ HWTEST_F(RSDisplayRenderNodeDrawableTest, EnablescRGBForP3AndUiFirstTest, TestSi
|
||||
auto result = displayDrawable_->EnablescRGBForP3AndUiFirst(currentGamut);
|
||||
EXPECT_FALSE(result);
|
||||
}
|
||||
|
||||
HWTEST_F(RSDisplayRenderNodeDrawableTest, DrawWiredMirrorOnDraw, TestSize.Level2)
|
||||
{
|
||||
ASSERT_NE(displayDrawable_, nullptr);
|
||||
ASSERT_NE(mirroredDisplayDrawable_, nullptr);
|
||||
auto params = static_cast<RSDisplayRenderParams*>(displayDrawable_->GetRenderParams().get());
|
||||
RSRenderThreadParamsManager::Instance().renderThreadParams_ = nullptr;
|
||||
displayDrawable_->DrawWiredMirrorOnDraw(*mirroredDisplayDrawable_, *params);
|
||||
RSRenderThreadParamsManager::Instance().renderThreadParams_ = std::make_unique<RSRenderThreadParams>();
|
||||
displayDrawable_->DrawWiredMirrorOnDraw(*mirroredDisplayDrawable_, *params);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user