mirror of
https://gitee.com/openharmony/graphic_graphic_2d
synced 2024-11-27 17:21:51 +00:00
draw dirty_rects_dfx when capture
Signed-off-by: hsc <husichao1@huawei.com>
This commit is contained in:
parent
b449b9aada
commit
fccd175242
@ -55,68 +55,59 @@ static const std::map<DirtyRegionType, std::string> DIRTY_REGION_TYPE_MAP {
|
||||
{ DirtyRegionType::SUBTREE_SKIP_OUT_OF_PARENT_RECT, "SUBTREE_SKIP_OUT_OF_PARENT_RECT" },
|
||||
};
|
||||
|
||||
void RSDirtyRectsDfx::OnDraw(std::shared_ptr<RSPaintFilterCanvas> canvas)
|
||||
void RSDirtyRectsDfx::OnDraw(RSPaintFilterCanvas& canvas)
|
||||
{
|
||||
auto& renderThreadParams = RSUniRenderThread::Instance().GetRSRenderThreadParams();
|
||||
if (UNLIKELY(!renderThreadParams)) {
|
||||
RS_LOGE("RSDirtyRectsDfx::OnDraw render thread params is nullptr!");
|
||||
return;
|
||||
}
|
||||
if (!canvas) {
|
||||
RS_LOGE("RSDirtyRectsDfx::OnDraw canvas is nullptr!");
|
||||
return;
|
||||
}
|
||||
canvas_ = canvas;
|
||||
|
||||
// the following code makes DirtyRegion visible, enable this method by turning on the dirtyregiondebug property
|
||||
if (renderThreadParams->isPartialRenderEnabled_) {
|
||||
if (renderThreadParams->isDirtyRegionDfxEnabled_) {
|
||||
DrawAllSurfaceDirtyRegionForDFX();
|
||||
DrawAllSurfaceDirtyRegionForDFX(canvas);
|
||||
}
|
||||
if (renderThreadParams->isTargetDirtyRegionDfxEnabled_) {
|
||||
DrawTargetSurfaceDirtyRegionForDFX();
|
||||
DrawTargetSurfaceDirtyRegionForDFX(canvas);
|
||||
}
|
||||
if (renderThreadParams->isDisplayDirtyDfxEnabled_) {
|
||||
DrawDirtyRegionForDFX(targetDrawable_.GetSyncDirtyManager()->GetMergedDirtyRegions());
|
||||
DrawDirtyRegionForDFX(canvas, targetDrawable_.GetSyncDirtyManager()->GetMergedDirtyRegions());
|
||||
}
|
||||
}
|
||||
|
||||
if (renderThreadParams->isOpaqueRegionDfxEnabled_) {
|
||||
DrawAllSurfaceOpaqueRegionForDFX();
|
||||
DrawAllSurfaceOpaqueRegionForDFX(canvas);
|
||||
}
|
||||
if (renderThreadParams->isVisibleRegionDfxEnabled_) {
|
||||
DrawTargetSurfaceVisibleRegionForDFX();
|
||||
DrawTargetSurfaceVisibleRegionForDFX(canvas);
|
||||
}
|
||||
|
||||
if (RSRealtimeRefreshRateManager::Instance().GetShowRefreshRateEnabled()) {
|
||||
DrawCurrentRefreshRate();
|
||||
DrawCurrentRefreshRate(canvas);
|
||||
}
|
||||
|
||||
if (RSSystemProperties::GetHwcRegionDfxEnabled()) {
|
||||
DrawHwcRegionForDFX();
|
||||
DrawHwcRegionForDFX(canvas);
|
||||
}
|
||||
|
||||
DrawableV2::RSRenderNodeDrawable::DrawDfxForCacheInfo(*canvas_);
|
||||
DrawableV2::RSRenderNodeDrawable::DrawDfxForCacheInfo(canvas);
|
||||
}
|
||||
|
||||
void RSDirtyRectsDfx::OnDrawVirtual(std::shared_ptr<RSPaintFilterCanvas> canvas)
|
||||
void RSDirtyRectsDfx::OnDrawVirtual(RSPaintFilterCanvas& canvas)
|
||||
{
|
||||
if (!canvas) {
|
||||
RS_LOGE("RSDirtyRectsDfx::OnDraw canvas is nullptr!");
|
||||
return;
|
||||
}
|
||||
auto& renderThreadParams = RSUniRenderThread::Instance().GetRSRenderThreadParams();
|
||||
if (UNLIKELY(!renderThreadParams)) {
|
||||
RS_LOGE("RSDirtyRectsDfx::OnDraw render thread params is nullptr!");
|
||||
return;
|
||||
}
|
||||
|
||||
canvas_ = canvas;
|
||||
if (renderThreadParams->isVirtualDirtyDfxEnabled_) {
|
||||
DrawDirtyRegionInVirtual();
|
||||
DrawDirtyRegionInVirtual(canvas);
|
||||
}
|
||||
}
|
||||
|
||||
void RSDirtyRectsDfx::DrawHwcRegionForDFX() const
|
||||
void RSDirtyRectsDfx::DrawHwcRegionForDFX(RSPaintFilterCanvas& canvas) const
|
||||
{
|
||||
auto& hardwareDrawables =
|
||||
RSUniRenderThread::Instance().GetRSRenderThreadParams()->GetHardwareEnabledTypeDrawables();
|
||||
@ -131,16 +122,16 @@ void RSDirtyRectsDfx::DrawHwcRegionForDFX() const
|
||||
auto surfaceParams = static_cast<RSSurfaceRenderParams*>(drawable->GetRenderParams().get());
|
||||
std::string extraInfo = surfaceParams->GetName() + " UpdateCnt: " + std::to_string(updateCnt);
|
||||
if (surfaceParams->GetHardwareEnabled()) {
|
||||
RSUniRenderUtil::DrawRectForDfx(*canvas_, surfaceParams->GetDstRect(), Drawing::Color::COLOR_BLUE,
|
||||
RSUniRenderUtil::DrawRectForDfx(canvas, surfaceParams->GetDstRect(), Drawing::Color::COLOR_BLUE,
|
||||
HWC_DFX_FILL_ALPHA, extraInfo);
|
||||
} else {
|
||||
RSUniRenderUtil::DrawRectForDfx(*canvas_, surfaceParams->GetDstRect(), Drawing::Color::COLOR_RED,
|
||||
RSUniRenderUtil::DrawRectForDfx(canvas, surfaceParams->GetDstRect(), Drawing::Color::COLOR_RED,
|
||||
HWC_DFX_FILL_ALPHA, extraInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RSDirtyRectsDfx::DrawDirtyRegionInVirtual() const
|
||||
void RSDirtyRectsDfx::DrawDirtyRegionInVirtual(RSPaintFilterCanvas& canvas) const
|
||||
{
|
||||
for (const auto& subRect : virtualDirtyRects_) {
|
||||
RectI tmpRect;
|
||||
@ -158,25 +149,26 @@ void RSDirtyRectsDfx::DrawDirtyRegionInVirtual() const
|
||||
static_cast<int32_t>(screenInfo_.GetRotatedHeight()) - subRect.GetTop() - subRect.GetHeight(),
|
||||
subRect.GetWidth(), subRect.GetHeight());
|
||||
#endif
|
||||
DrawDirtyRectForDFX(tmpRect, Drawing::Color::COLOR_BLUE, RSPaintStyle::STROKE, DFXFillAlpha);
|
||||
DrawDirtyRectForDFX(canvas, tmpRect, Drawing::Color::COLOR_BLUE, RSPaintStyle::STROKE);
|
||||
}
|
||||
}
|
||||
|
||||
bool RSDirtyRectsDfx::RefreshRateRotationProcess(ScreenRotation rotation, uint64_t screenId)
|
||||
bool RSDirtyRectsDfx::RefreshRateRotationProcess(RSPaintFilterCanvas& canvas,
|
||||
ScreenRotation rotation, uint64_t screenId)
|
||||
{
|
||||
if (rotation != ScreenRotation::ROTATION_0) {
|
||||
auto screenManager = CreateOrGetScreenManager();
|
||||
auto mainScreenInfo = screenManager->QueryScreenInfo(screenId);
|
||||
if (rotation == ScreenRotation::ROTATION_90) {
|
||||
canvas_->Rotate(-90, 0, 0); // 90 degree for text draw
|
||||
canvas_->Translate(-(static_cast<float>(mainScreenInfo.height)), 0);
|
||||
canvas.Rotate(-90, 0, 0); // 90 degree for text draw
|
||||
canvas.Translate(-(static_cast<float>(mainScreenInfo.height)), 0);
|
||||
} else if (rotation == ScreenRotation::ROTATION_180) {
|
||||
// 180 degree for text draw
|
||||
canvas_->Rotate(-180, static_cast<float>(mainScreenInfo.width) / 2, // 2 half of screen width
|
||||
canvas.Rotate(-180, static_cast<float>(mainScreenInfo.width) / 2, // 2 half of screen width
|
||||
static_cast<float>(mainScreenInfo.height) / 2); // 2 half of screen height
|
||||
} else if (rotation == ScreenRotation::ROTATION_270) {
|
||||
canvas_->Rotate(-270, 0, 0); // 270 degree for text draw
|
||||
canvas_->Translate(0, -(static_cast<float>(mainScreenInfo.width)));
|
||||
canvas.Rotate(-270, 0, 0); // 270 degree for text draw
|
||||
canvas.Translate(0, -(static_cast<float>(mainScreenInfo.width)));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@ -184,7 +176,7 @@ bool RSDirtyRectsDfx::RefreshRateRotationProcess(ScreenRotation rotation, uint64
|
||||
return true;
|
||||
}
|
||||
|
||||
void RSDirtyRectsDfx::DrawCurrentRefreshRate()
|
||||
void RSDirtyRectsDfx::DrawCurrentRefreshRate(RSPaintFilterCanvas& canvas)
|
||||
{
|
||||
RS_TRACE_FUNC();
|
||||
if (UNLIKELY(!displayParams_)) {
|
||||
@ -214,8 +206,8 @@ void RSDirtyRectsDfx::DrawCurrentRefreshRate()
|
||||
Drawing::Brush brush;
|
||||
brush.SetColor(currentRefreshRate <= 60 ? SK_ColorRED : SK_ColorGREEN); // low refresh rate 60
|
||||
brush.SetAntiAlias(true);
|
||||
RSAutoCanvasRestore acr(canvas_);
|
||||
canvas_->AttachBrush(brush);
|
||||
RSAutoCanvasRestore acr(&canvas);
|
||||
canvas.AttachBrush(brush);
|
||||
auto rotation = displayParams_->GetScreenRotation();
|
||||
// fold device with one logic screen
|
||||
bool isOneLogicScreenDevice = FOLD_SCREEN_TYPE[0] != DUAL_DISPLAY &&
|
||||
@ -231,18 +223,18 @@ void RSDirtyRectsDfx::DrawCurrentRefreshRate()
|
||||
(rotation == ScreenRotation::ROTATION_0 ? ScreenRotation::ROTATION_270
|
||||
: static_cast<ScreenRotation>(static_cast<int>(rotation) - 1));
|
||||
}
|
||||
auto saveCount = canvas_->Save();
|
||||
if (!RefreshRateRotationProcess(rotation, screenId)) {
|
||||
auto saveCount = canvas.Save();
|
||||
if (!RefreshRateRotationProcess(canvas, rotation, screenId)) {
|
||||
return;
|
||||
}
|
||||
// 100.f:Scalar x of drawing TextBlob; 200.f:Scalar y of drawing TextBlob
|
||||
canvas_->DrawTextBlob(textBlob.get(), 100.f, 200.f);
|
||||
canvas_->RestoreToCount(saveCount);
|
||||
canvas_->DetachBrush();
|
||||
canvas.DrawTextBlob(textBlob.get(), 100.f, 200.f);
|
||||
canvas.RestoreToCount(saveCount);
|
||||
canvas.DetachBrush();
|
||||
}
|
||||
|
||||
void RSDirtyRectsDfx::DrawDirtyRectForDFX(
|
||||
RectI dirtyRect, const Drawing::Color color, const RSPaintStyle fillType, float alpha, int edgeWidth) const
|
||||
void RSDirtyRectsDfx::DrawDirtyRectForDFX(RSPaintFilterCanvas& canvas,
|
||||
RectI dirtyRect, const Drawing::Color color, const RSPaintStyle fillType, int edgeWidth) const
|
||||
{
|
||||
if (dirtyRect.width_ <= 0 || dirtyRect.height_ <= 0) {
|
||||
ROSEN_LOGD("DrawDirtyRectForDFX dirty rect is invalid.");
|
||||
@ -251,11 +243,11 @@ void RSDirtyRectsDfx::DrawDirtyRectForDFX(
|
||||
ROSEN_LOGD("DrawDirtyRectForDFX current dirtyRect = %{public}s", dirtyRect.ToString().c_str());
|
||||
auto rect = Drawing::Rect(
|
||||
dirtyRect.left_, dirtyRect.top_, dirtyRect.left_ + dirtyRect.width_, dirtyRect.top_ + dirtyRect.height_);
|
||||
RSAutoCanvasRestore acr(canvas_);
|
||||
RSAutoCanvasRestore acr(&canvas);
|
||||
Drawing::Matrix invertMatrix;
|
||||
if (displayParams_ && displayParams_->GetMatrix().Invert(invertMatrix)) {
|
||||
// Modifying the drawing origin does not affect the actual drawing content
|
||||
canvas_->ConcatMatrix(displayParams_->GetMatrix());
|
||||
canvas.ConcatMatrix(displayParams_->GetMatrix());
|
||||
invertMatrix.MapRect(rect, rect);
|
||||
dirtyRect.SetAll(rect.GetLeft(), rect.GetTop(), rect.GetWidth(), rect.GetHeight());
|
||||
}
|
||||
@ -271,32 +263,32 @@ void RSDirtyRectsDfx::DrawDirtyRectForDFX(
|
||||
if (fillType == RSPaintStyle::STROKE) {
|
||||
rectPen.SetColor(color);
|
||||
rectPen.SetAntiAlias(true);
|
||||
rectPen.SetAlphaF(alpha);
|
||||
rectPen.SetAlphaF(DFXFillAlpha);
|
||||
rectPen.SetWidth(edgeWidth);
|
||||
rectPen.SetJoinStyle(Drawing::Pen::JoinStyle::ROUND_JOIN);
|
||||
canvas_->AttachPen(rectPen);
|
||||
canvas.AttachPen(rectPen);
|
||||
} else {
|
||||
rectBrush.SetColor(color);
|
||||
rectBrush.SetAntiAlias(true);
|
||||
rectBrush.SetAlphaF(alpha);
|
||||
canvas_->AttachBrush(rectBrush);
|
||||
rectBrush.SetAlphaF(DFXFillAlpha);
|
||||
canvas.AttachBrush(rectBrush);
|
||||
}
|
||||
canvas_->DrawRect(rect);
|
||||
canvas_->DetachPen();
|
||||
canvas_->DetachBrush();
|
||||
canvas_->AttachBrush(Drawing::Brush());
|
||||
canvas_->DrawTextBlob(textBlob.get(), dirtyRect.left_ + defaultTextOffsetX, dirtyRect.top_ + defaultTextOffsetY);
|
||||
canvas_->DetachBrush();
|
||||
canvas.DrawRect(rect);
|
||||
canvas.DetachPen();
|
||||
canvas.DetachBrush();
|
||||
canvas.AttachBrush(Drawing::Brush());
|
||||
canvas.DrawTextBlob(textBlob.get(), dirtyRect.left_ + defaultTextOffsetX, dirtyRect.top_ + defaultTextOffsetY);
|
||||
canvas.DetachBrush();
|
||||
}
|
||||
|
||||
void RSDirtyRectsDfx::DrawDirtyRegionForDFX(const std::vector<RectI>& dirtyRects) const
|
||||
void RSDirtyRectsDfx::DrawDirtyRegionForDFX(RSPaintFilterCanvas& canvas, const std::vector<RectI>& dirtyRects) const
|
||||
{
|
||||
for (const auto& subRect : dirtyRects) {
|
||||
DrawDirtyRectForDFX(subRect, Drawing::Color::COLOR_BLUE, RSPaintStyle::STROKE, DFXFillAlpha);
|
||||
DrawDirtyRectForDFX(canvas, subRect, Drawing::Color::COLOR_BLUE, RSPaintStyle::STROKE);
|
||||
}
|
||||
}
|
||||
|
||||
void RSDirtyRectsDfx::DrawAndTraceSingleDirtyRegionTypeForDFX(
|
||||
void RSDirtyRectsDfx::DrawAndTraceSingleDirtyRegionTypeForDFX(RSPaintFilterCanvas& canvas,
|
||||
DrawableV2::RSSurfaceRenderNodeDrawable& surfaceDrawable, DirtyRegionType dirtyType, bool isDrawn) const
|
||||
{
|
||||
auto dirtyManager = surfaceDrawable.GetSyncDirtyManager();
|
||||
@ -316,7 +308,7 @@ void RSDirtyRectsDfx::DrawAndTraceSingleDirtyRegionTypeForDFX(
|
||||
subInfo += (" " + info.first + "node amount: " + std::to_string(dirtyInfo.size()));
|
||||
for (const auto& [nid, rect] : dirtyInfo) {
|
||||
if (isDrawn) {
|
||||
DrawDirtyRectForDFX(rect, info.second, RSPaintStyle::STROKE, DFXFillAlpha);
|
||||
DrawDirtyRectForDFX(canvas, rect, info.second, RSPaintStyle::STROKE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -328,7 +320,7 @@ void RSDirtyRectsDfx::DrawAndTraceSingleDirtyRegionTypeForDFX(
|
||||
surfaceDrawable.GetName().c_str(), surfaceDrawable.GetId(), matchType->second.c_str(), subInfo.c_str());
|
||||
}
|
||||
|
||||
bool RSDirtyRectsDfx::DrawDetailedTypesOfDirtyRegionForDFX(
|
||||
bool RSDirtyRectsDfx::DrawDetailedTypesOfDirtyRegionForDFX(RSPaintFilterCanvas& canvas,
|
||||
DrawableV2::RSSurfaceRenderNodeDrawable& surfaceDrawable) const
|
||||
{
|
||||
auto dirtyRegionDebugType = RSUniRenderThread::Instance().GetRSRenderThreadParams()->dirtyRegionDebugType_;
|
||||
@ -338,7 +330,7 @@ bool RSDirtyRectsDfx::DrawDetailedTypesOfDirtyRegionForDFX(
|
||||
if (dirtyRegionDebugType == DirtyRegionDebugType::CUR_DIRTY_DETAIL_ONLY_TRACE) {
|
||||
auto i = DirtyRegionType::UPDATE_DIRTY_REGION;
|
||||
for (; i < DirtyRegionType::TYPE_AMOUNT; i = static_cast<DirtyRegionType>(i + 1)) {
|
||||
DrawAndTraceSingleDirtyRegionTypeForDFX(surfaceDrawable, i, false);
|
||||
DrawAndTraceSingleDirtyRegionTypeForDFX(canvas, surfaceDrawable, i, false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -356,34 +348,35 @@ bool RSDirtyRectsDfx::DrawDetailedTypesOfDirtyRegionForDFX(
|
||||
};
|
||||
auto matchType = DIRTY_REGION_DEBUG_TYPE_MAP.find(dirtyRegionDebugType);
|
||||
if (matchType != DIRTY_REGION_DEBUG_TYPE_MAP.end()) {
|
||||
DrawAndTraceSingleDirtyRegionTypeForDFX(surfaceDrawable, matchType->second);
|
||||
DrawAndTraceSingleDirtyRegionTypeForDFX(canvas, surfaceDrawable, matchType->second);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void RSDirtyRectsDfx::DrawSurfaceOpaqueRegionForDFX(RSSurfaceRenderParams& surfaceParams) const
|
||||
void RSDirtyRectsDfx::DrawSurfaceOpaqueRegionForDFX(RSPaintFilterCanvas& canvas,
|
||||
RSSurfaceRenderParams& surfaceParams) const
|
||||
{
|
||||
const auto& opaqueRegionRects = surfaceParams.GetOpaqueRegion().GetRegionRects();
|
||||
for (const auto& subRect : opaqueRegionRects) {
|
||||
DrawDirtyRectForDFX(subRect.ToRectI(), Drawing::Color::COLOR_GREEN, RSPaintStyle::FILL, DFXFillAlpha, 0);
|
||||
DrawDirtyRectForDFX(canvas, subRect.ToRectI(), Drawing::Color::COLOR_GREEN, RSPaintStyle::FILL, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void RSDirtyRectsDfx::DrawAllSurfaceDirtyRegionForDFX() const
|
||||
void RSDirtyRectsDfx::DrawAllSurfaceDirtyRegionForDFX(RSPaintFilterCanvas& canvas) const
|
||||
{
|
||||
const auto& visibleDirtyRects = dirtyRegion_.GetRegionRects();
|
||||
std::vector<RectI> rects;
|
||||
for (auto& rect : visibleDirtyRects) {
|
||||
rects.emplace_back(rect.left_, rect.top_, rect.right_ - rect.left_, rect.bottom_ - rect.top_);
|
||||
}
|
||||
DrawDirtyRegionForDFX(rects);
|
||||
DrawDirtyRegionForDFX(canvas, rects);
|
||||
|
||||
// draw display dirtyregion with red color
|
||||
RectI dirtySurfaceRect = targetDrawable_.GetSyncDirtyManager()->GetDirtyRegion();
|
||||
DrawDirtyRectForDFX(dirtySurfaceRect, Drawing::Color::COLOR_RED, RSPaintStyle::STROKE, DFXFillAlpha);
|
||||
DrawDirtyRectForDFX(canvas, dirtySurfaceRect, Drawing::Color::COLOR_RED, RSPaintStyle::STROKE);
|
||||
}
|
||||
|
||||
void RSDirtyRectsDfx::DrawAllSurfaceOpaqueRegionForDFX() const
|
||||
void RSDirtyRectsDfx::DrawAllSurfaceOpaqueRegionForDFX(RSPaintFilterCanvas& canvas) const
|
||||
{
|
||||
if (!displayParams_) {
|
||||
RS_LOGE("RSDirtyRectsDfx::DrawAllSurfaceOpaqueRegionForDFX displayParams is null ptr.");
|
||||
@ -393,12 +386,12 @@ void RSDirtyRectsDfx::DrawAllSurfaceOpaqueRegionForDFX() const
|
||||
for (auto it = curAllSurfacesDrawables.rbegin(); it != curAllSurfacesDrawables.rend(); ++it) {
|
||||
auto surfaceParams = static_cast<RSSurfaceRenderParams*>((*it)->GetRenderParams().get());
|
||||
if (surfaceParams && surfaceParams->IsMainWindowType()) {
|
||||
DrawSurfaceOpaqueRegionForDFX(*surfaceParams);
|
||||
DrawSurfaceOpaqueRegionForDFX(canvas, *surfaceParams);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RSDirtyRectsDfx::DrawTargetSurfaceDirtyRegionForDFX() const
|
||||
void RSDirtyRectsDfx::DrawTargetSurfaceDirtyRegionForDFX(RSPaintFilterCanvas& canvas) const
|
||||
{
|
||||
if (UNLIKELY(!displayParams_)) {
|
||||
return;
|
||||
@ -414,7 +407,7 @@ void RSDirtyRectsDfx::DrawTargetSurfaceDirtyRegionForDFX() const
|
||||
continue;
|
||||
}
|
||||
if (CheckIfSurfaceTargetedForDFX(surfaceDrawable->GetName())) {
|
||||
if (DrawDetailedTypesOfDirtyRegionForDFX(*surfaceDrawable)) {
|
||||
if (DrawDetailedTypesOfDirtyRegionForDFX(canvas, *surfaceDrawable)) {
|
||||
continue;
|
||||
}
|
||||
auto dirtyManager = targetDrawable_.GetSyncDirtyManager();
|
||||
@ -430,12 +423,12 @@ void RSDirtyRectsDfx::DrawTargetSurfaceDirtyRegionForDFX() const
|
||||
auto intersectRegion = displayDirtyRegion.IntersectRect(visibleRect);
|
||||
rects.emplace_back(intersectRegion);
|
||||
}
|
||||
DrawDirtyRegionForDFX(rects);
|
||||
DrawDirtyRegionForDFX(canvas, rects);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RSDirtyRectsDfx::DrawTargetSurfaceVisibleRegionForDFX() const
|
||||
void RSDirtyRectsDfx::DrawTargetSurfaceVisibleRegionForDFX(RSPaintFilterCanvas& canvas) const
|
||||
{
|
||||
if (!displayParams_) {
|
||||
RS_LOGE("RSDirtyRectsDfx: displayParams is null ptr.");
|
||||
@ -453,7 +446,7 @@ void RSDirtyRectsDfx::DrawTargetSurfaceVisibleRegionForDFX() const
|
||||
for (auto& rect : visibleRects) {
|
||||
rects.emplace_back(rect.left_, rect.top_, rect.right_ - rect.left_, rect.bottom_ - rect.top_);
|
||||
}
|
||||
DrawDirtyRegionForDFX(rects);
|
||||
DrawDirtyRegionForDFX(canvas, rects);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,8 +41,8 @@ public:
|
||||
~RSDirtyRectsDfx() = default;
|
||||
|
||||
enum class RSPaintStyle { FILL, STROKE };
|
||||
void OnDraw(std::shared_ptr<RSPaintFilterCanvas> canvas);
|
||||
void OnDrawVirtual(std::shared_ptr<RSPaintFilterCanvas> canvas);
|
||||
void OnDraw(RSPaintFilterCanvas& canvas);
|
||||
void OnDrawVirtual(RSPaintFilterCanvas& canvas);
|
||||
void SetDirtyRegion(Occlusion::Region& dirtyRegion)
|
||||
{
|
||||
dirtyRegion_ = dirtyRegion;
|
||||
@ -59,25 +59,25 @@ private:
|
||||
std::vector<RectI> virtualDirtyRects_;
|
||||
ScreenInfo screenInfo_;
|
||||
const DrawableV2::RSDisplayRenderNodeDrawable& targetDrawable_;
|
||||
std::shared_ptr<RSPaintFilterCanvas> canvas_;
|
||||
const std::unique_ptr<RSRenderParams>& displayParams_;
|
||||
|
||||
bool RefreshRateRotationProcess(ScreenRotation rotation, uint64_t screenId);
|
||||
void DrawCurrentRefreshRate();
|
||||
void DrawDirtyRectForDFX(RectI dirtyRect, const Drawing::Color color, const RSPaintStyle fillType,
|
||||
float alpha, int edgeWidth = 6) const;
|
||||
bool DrawDetailedTypesOfDirtyRegionForDFX(DrawableV2::RSSurfaceRenderNodeDrawable& surfaceDrawable) const;
|
||||
void DrawSurfaceOpaqueRegionForDFX(RSSurfaceRenderParams& surfaceParams) const;
|
||||
void DrawHwcRegionForDFX() const;
|
||||
bool RefreshRateRotationProcess(RSPaintFilterCanvas& canvas, ScreenRotation rotation, uint64_t screenId);
|
||||
void DrawCurrentRefreshRate(RSPaintFilterCanvas& canvas);
|
||||
void DrawDirtyRectForDFX(RSPaintFilterCanvas& canvas, RectI dirtyRect,
|
||||
const Drawing::Color color, const RSPaintStyle fillType, int edgeWidth = 6) const;
|
||||
bool DrawDetailedTypesOfDirtyRegionForDFX(RSPaintFilterCanvas& canvas,
|
||||
DrawableV2::RSSurfaceRenderNodeDrawable& surfaceDrawable) const;
|
||||
void DrawSurfaceOpaqueRegionForDFX(RSPaintFilterCanvas& canvas, RSSurfaceRenderParams& surfaceParams) const;
|
||||
void DrawHwcRegionForDFX(RSPaintFilterCanvas& canvas) const;
|
||||
|
||||
void DrawDirtyRegionForDFX(const std::vector<RectI>& dirtyRects) const;
|
||||
void DrawAllSurfaceDirtyRegionForDFX() const;
|
||||
void DrawAllSurfaceOpaqueRegionForDFX() const;
|
||||
void DrawTargetSurfaceDirtyRegionForDFX() const;
|
||||
void DrawTargetSurfaceVisibleRegionForDFX() const;
|
||||
void DrawAndTraceSingleDirtyRegionTypeForDFX(
|
||||
void DrawDirtyRegionForDFX(RSPaintFilterCanvas& canvas, const std::vector<RectI>& dirtyRects) const;
|
||||
void DrawAllSurfaceDirtyRegionForDFX(RSPaintFilterCanvas& canvas) const;
|
||||
void DrawAllSurfaceOpaqueRegionForDFX(RSPaintFilterCanvas& canvas) const;
|
||||
void DrawTargetSurfaceDirtyRegionForDFX(RSPaintFilterCanvas& canvas) const;
|
||||
void DrawTargetSurfaceVisibleRegionForDFX(RSPaintFilterCanvas& canvas) const;
|
||||
void DrawAndTraceSingleDirtyRegionTypeForDFX(RSPaintFilterCanvas& canvas,
|
||||
DrawableV2::RSSurfaceRenderNodeDrawable& surfaceDrawable, DirtyRegionType dirtyType, bool isDrawn = true) const;
|
||||
void DrawDirtyRegionInVirtual() const;
|
||||
void DrawDirtyRegionInVirtual(RSPaintFilterCanvas& canvas) const;
|
||||
|
||||
// dfx check if surface name is in dfx target list
|
||||
inline bool CheckIfSurfaceTargetedForDFX(std::string nodeName) const
|
||||
|
@ -671,7 +671,9 @@ void RSDisplayRenderNodeDrawable::OnDraw(Drawing::Canvas& canvas)
|
||||
}
|
||||
rsDirtyRectsDfx.SetVirtualDirtyRects(damageRegionRects, screenInfo);
|
||||
DrawExpandScreen(*expandProcessor);
|
||||
rsDirtyRectsDfx.OnDrawVirtual(curCanvas_);
|
||||
if (curCanvas_) {
|
||||
rsDirtyRectsDfx.OnDrawVirtual(*curCanvas_);
|
||||
}
|
||||
uniParam->SetOpDropped(isOpDropped);
|
||||
}
|
||||
processor->PostProcess();
|
||||
@ -814,7 +816,7 @@ void RSDisplayRenderNodeDrawable::OnDraw(Drawing::Canvas& canvas)
|
||||
DrawWatermarkIfNeed(*params, *curCanvas_);
|
||||
SwitchColorFilter(*curCanvas_, hdrBrightnessRatio);
|
||||
}
|
||||
rsDirtyRectsDfx.OnDraw(curCanvas_);
|
||||
rsDirtyRectsDfx.OnDraw(*curCanvas_);
|
||||
if ((RSSystemProperties::IsFoldScreenFlag() || RSSystemProperties::IsTabletType())
|
||||
&& !params->IsRotationChanged()) {
|
||||
offscreenSurface_ = nullptr;
|
||||
@ -1036,7 +1038,7 @@ void RSDisplayRenderNodeDrawable::DrawMirror(RSDisplayRenderParams& params,
|
||||
RSUniRenderThread::ResetCaptureParam();
|
||||
// Restore the initial state of the canvas to avoid state accumulation
|
||||
curCanvas_->RestoreToCount(0);
|
||||
rsDirtyRectsDfx.OnDrawVirtual(curCanvas_);
|
||||
rsDirtyRectsDfx.OnDrawVirtual(*curCanvas_);
|
||||
RSUniRenderThread::Instance().SetBlackList({});
|
||||
RSUniRenderThread::Instance().SetWhiteList({});
|
||||
uniParam.SetSecExemption(false);
|
||||
@ -1079,7 +1081,7 @@ void RSDisplayRenderNodeDrawable::DrawMirrorCopy(
|
||||
uniParam.SetOpDropped(isOpDropped);
|
||||
// Restore the initial state of the canvas to avoid state accumulation
|
||||
curCanvas_->RestoreToCount(0);
|
||||
rsDirtyRectsDfx.OnDrawVirtual(curCanvas_);
|
||||
rsDirtyRectsDfx.OnDrawVirtual(*curCanvas_);
|
||||
}
|
||||
|
||||
void RSDisplayRenderNodeDrawable::DrawExpandScreen(RSUniRenderVirtualProcessor& processor)
|
||||
@ -1144,7 +1146,7 @@ void RSDisplayRenderNodeDrawable::WiredScreenProjection(
|
||||
*mirroredDrawable->GetRSSurfaceHandlerOnDraw(), drawParams);
|
||||
}
|
||||
curCanvas_->Restore();
|
||||
rsDirtyRectsDfx.OnDrawVirtual(curCanvas_);
|
||||
rsDirtyRectsDfx.OnDrawVirtual(*curCanvas_);
|
||||
renderFrame->Flush();
|
||||
processor->ProcessDisplaySurfaceForRenderThread(*this);
|
||||
processor->PostProcess();
|
||||
@ -1308,6 +1310,8 @@ void RSDisplayRenderNodeDrawable::OnCapture(Drawing::Canvas& canvas)
|
||||
|
||||
RSRenderNodeDrawable::OnCapture(canvas);
|
||||
DrawWatermarkIfNeed(*params, *rscanvas);
|
||||
RSDirtyRectsDfx rsDirtyRectsDfx(*this);
|
||||
rsDirtyRectsDfx.OnDraw(*rscanvas);
|
||||
} else {
|
||||
DrawHardwareEnabledNodes(canvas, *params);
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ HWTEST_F(RSDirtyRectsDFXTest, OnDraw, TestSize.Level1)
|
||||
std::shared_ptr<RSPaintFilterCanvas> canvas = nullptr;
|
||||
rsDirtyRectsDfx_->OnDraw(canvas);
|
||||
ASSERT_NE(canvas_, nullptr);
|
||||
rsDirtyRectsDfx_->OnDraw(canvas_);
|
||||
rsDirtyRectsDfx_->OnDraw(*canvas_);
|
||||
|
||||
auto& renderThreadParams = RSUniRenderThread::Instance().GetRSRenderThreadParams();
|
||||
ASSERT_TRUE(renderThreadParams);
|
||||
@ -104,12 +104,12 @@ HWTEST_F(RSDirtyRectsDFXTest, OnDraw, TestSize.Level1)
|
||||
renderThreadParams->isOpaqueRegionDfxEnabled_ = true;
|
||||
renderThreadParams->isVisibleRegionDfxEnabled_ = true;
|
||||
RSRealtimeRefreshRateManager::Instance().enableState_ = true;
|
||||
rsDirtyRectsDfx_->OnDraw(canvas_);
|
||||
rsDirtyRectsDfx_->OnDraw(*canvas_);
|
||||
|
||||
renderThreadParams->isDirtyRegionDfxEnabled_ = true;
|
||||
renderThreadParams->isTargetDirtyRegionDfxEnabled_ = true;
|
||||
renderThreadParams->isDisplayDirtyDfxEnabled_ = true;
|
||||
rsDirtyRectsDfx_->OnDraw(canvas_);
|
||||
rsDirtyRectsDfx_->OnDraw(*canvas_);
|
||||
renderThreadParams->isPartialRenderEnabled_ = false;
|
||||
renderThreadParams->isOpaqueRegionDfxEnabled_ = false;
|
||||
renderThreadParams->isVisibleRegionDfxEnabled_ = false;
|
||||
@ -129,13 +129,13 @@ HWTEST_F(RSDirtyRectsDFXTest, OnDrawVirtual, TestSize.Level1)
|
||||
{
|
||||
ASSERT_NE(rsDirtyRectsDfx_, nullptr);
|
||||
std::shared_ptr<RSPaintFilterCanvas> canvas = nullptr;
|
||||
rsDirtyRectsDfx_->OnDraw(canvas);
|
||||
rsDirtyRectsDfx_->OnDraw(*canvas);
|
||||
ASSERT_NE(canvas_, nullptr);
|
||||
rsDirtyRectsDfx_->OnDrawVirtual(canvas_);
|
||||
rsDirtyRectsDfx_->OnDrawVirtual(*canvas_);
|
||||
ASSERT_FALSE(RSUniRenderThread::Instance().GetRSRenderThreadParams()->isVirtualDirtyDfxEnabled_);
|
||||
|
||||
RSUniRenderThread::Instance().GetRSRenderThreadParams()->isVirtualDirtyDfxEnabled_ = true;
|
||||
rsDirtyRectsDfx_->OnDrawVirtual(canvas_);
|
||||
rsDirtyRectsDfx_->OnDrawVirtual(*canvas_);
|
||||
RSUniRenderThread::Instance().GetRSRenderThreadParams()->isVirtualDirtyDfxEnabled_ = false;
|
||||
}
|
||||
|
||||
@ -148,8 +148,7 @@ HWTEST_F(RSDirtyRectsDFXTest, OnDrawVirtual, TestSize.Level1)
|
||||
HWTEST_F(RSDirtyRectsDFXTest, DrawDirtyRegionInVirtual, TestSize.Level1)
|
||||
{
|
||||
ASSERT_NE(rsDirtyRectsDfx_, nullptr);
|
||||
rsDirtyRectsDfx_->DrawDirtyRegionInVirtual();
|
||||
ASSERT_EQ(rsDirtyRectsDfx_->canvas_, nullptr);
|
||||
rsDirtyRectsDfx_->DrawDirtyRegionInVirtual(*canvas_);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -162,10 +161,9 @@ HWTEST_F(RSDirtyRectsDFXTest, DrawCurrentRefreshRate, TestSize.Level1)
|
||||
{
|
||||
ASSERT_NE(rsDirtyRectsDfx_, nullptr);
|
||||
auto drawingCanvas = std::make_unique<Drawing::Canvas>();
|
||||
rsDirtyRectsDfx_->canvas_ = std::make_shared<RSPaintFilterCanvas>(drawingCanvas.get());
|
||||
rsDirtyRectsDfx_->DrawCurrentRefreshRate();
|
||||
ASSERT_TRUE(rsDirtyRectsDfx_->canvas_);
|
||||
rsDirtyRectsDfx_->canvas_ = nullptr;
|
||||
auto canvas = std::make_shared<RSPaintFilterCanvas>(drawingCanvas.get());
|
||||
rsDirtyRectsDfx_->DrawCurrentRefreshRate(*canvas);
|
||||
ASSERT_TRUE(canvas);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -182,13 +180,13 @@ HWTEST_F(RSDirtyRectsDFXTest, DrawDirtyRegionForDFX, TestSize.Level1)
|
||||
for (auto& rect : visibleDirtyRects) {
|
||||
rects.emplace_back(rect.left_, rect.top_, rect.right_ - rect.left_, rect.bottom_ - rect.top_);
|
||||
}
|
||||
rsDirtyRectsDfx_->DrawDirtyRegionForDFX(rects);
|
||||
rsDirtyRectsDfx_->DrawDirtyRegionForDFX(*canvas_, rects);
|
||||
|
||||
auto& targetDrawable = rsDirtyRectsDfx_->targetDrawable_;
|
||||
auto dirtyManager = targetDrawable.GetSyncDirtyManager();
|
||||
ASSERT_NE(dirtyManager, nullptr);
|
||||
rects = dirtyManager->GetMergedDirtyRegions();
|
||||
rsDirtyRectsDfx_->DrawDirtyRegionForDFX(rects);
|
||||
rsDirtyRectsDfx_->DrawDirtyRegionForDFX(*canvas_, rects);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -200,7 +198,7 @@ HWTEST_F(RSDirtyRectsDFXTest, DrawDirtyRegionForDFX, TestSize.Level1)
|
||||
HWTEST_F(RSDirtyRectsDFXTest, DrawAllSurfaceOpaqueRegionForDFX, TestSize.Level1)
|
||||
{
|
||||
ASSERT_NE(rsDirtyRectsDfx_, nullptr);
|
||||
rsDirtyRectsDfx_->DrawAllSurfaceOpaqueRegionForDFX();
|
||||
rsDirtyRectsDfx_->DrawAllSurfaceOpaqueRegionForDFX(*canvas_);
|
||||
auto& targetDrawable = rsDirtyRectsDfx_->targetDrawable_;
|
||||
ASSERT_NE(targetDrawable.GetRenderParams(), nullptr);
|
||||
}
|
||||
@ -214,7 +212,7 @@ HWTEST_F(RSDirtyRectsDFXTest, DrawAllSurfaceOpaqueRegionForDFX, TestSize.Level1)
|
||||
HWTEST_F(RSDirtyRectsDFXTest, DrawTargetSurfaceDirtyRegionForDFX, TestSize.Level1)
|
||||
{
|
||||
ASSERT_NE(rsDirtyRectsDfx_, nullptr);
|
||||
rsDirtyRectsDfx_->DrawTargetSurfaceDirtyRegionForDFX();
|
||||
rsDirtyRectsDfx_->DrawTargetSurfaceDirtyRegionForDFX(*canvas);
|
||||
ASSERT_NE(rsDirtyRectsDfx_->targetDrawable_.GetRenderParams(), nullptr);
|
||||
}
|
||||
|
||||
@ -227,7 +225,7 @@ HWTEST_F(RSDirtyRectsDFXTest, DrawTargetSurfaceDirtyRegionForDFX, TestSize.Level
|
||||
HWTEST_F(RSDirtyRectsDFXTest, DrawTargetSurfaceVisibleRegionForDFX, TestSize.Level1)
|
||||
{
|
||||
ASSERT_NE(rsDirtyRectsDfx_, nullptr);
|
||||
rsDirtyRectsDfx_->DrawTargetSurfaceVisibleRegionForDFX();
|
||||
rsDirtyRectsDfx_->DrawTargetSurfaceVisibleRegionForDFX(*canvas);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -241,27 +239,25 @@ HWTEST_F(RSDirtyRectsDFXTest, RefreshRateRotationProcess, TestSize.Level1)
|
||||
ASSERT_NE(rsDirtyRectsDfx_, nullptr);
|
||||
ScreenRotation rotation = ScreenRotation::ROTATION_0;
|
||||
uint64_t screenId = 0;
|
||||
bool res = rsDirtyRectsDfx_->RefreshRateRotationProcess(rotation, screenId);
|
||||
bool res = rsDirtyRectsDfx_->RefreshRateRotationProcess(*canvas_, rotation, screenId);
|
||||
ASSERT_TRUE(res);
|
||||
ASSERT_FALSE(rsDirtyRectsDfx_->canvas_);
|
||||
|
||||
rotation = ScreenRotation::ROTATION_90;
|
||||
auto drawingCanvas = std::make_unique<Drawing::Canvas>();
|
||||
rsDirtyRectsDfx_->canvas_ = std::make_shared<RSPaintFilterCanvas>(drawingCanvas.get());
|
||||
ASSERT_TRUE(rsDirtyRectsDfx_->canvas_);
|
||||
res = rsDirtyRectsDfx_->RefreshRateRotationProcess(rotation, screenId);
|
||||
canvas_ = std::make_shared<RSPaintFilterCanvas>(drawingCanvas.get());
|
||||
res = rsDirtyRectsDfx_->RefreshRateRotationProcess(*canvas_, rotation, screenId);
|
||||
ASSERT_TRUE(res);
|
||||
|
||||
rotation = ScreenRotation::ROTATION_180;
|
||||
res = rsDirtyRectsDfx_->RefreshRateRotationProcess(rotation, screenId);
|
||||
res = rsDirtyRectsDfx_->RefreshRateRotationProcess(*canvas_, rotation, screenId);
|
||||
ASSERT_TRUE(res);
|
||||
|
||||
rotation = ScreenRotation::ROTATION_270;
|
||||
res = rsDirtyRectsDfx_->RefreshRateRotationProcess(rotation, screenId);
|
||||
res = rsDirtyRectsDfx_->RefreshRateRotationProcess(*canvas_, rotation, screenId);
|
||||
ASSERT_TRUE(res);
|
||||
|
||||
rotation = ScreenRotation::INVALID_SCREEN_ROTATION;
|
||||
res = rsDirtyRectsDfx_->RefreshRateRotationProcess(rotation, screenId);
|
||||
res = rsDirtyRectsDfx_->RefreshRateRotationProcess(*canvas_, rotation, screenId);
|
||||
ASSERT_FALSE(res);
|
||||
}
|
||||
|
||||
@ -280,16 +276,16 @@ HWTEST_F(RSDirtyRectsDFXTest, DrawDirtyRectForDFX, TestSize.Level1)
|
||||
float alpha = 1.f;
|
||||
int edgeWidth = 1;
|
||||
auto drawingCanvas = std::make_unique<Drawing::Canvas>();
|
||||
rsDirtyRectsDfx_->canvas_ = std::make_shared<RSPaintFilterCanvas>(drawingCanvas.get());
|
||||
rsDirtyRectsDfx_->DrawDirtyRectForDFX(dirtyRect, color, fillType, alpha, edgeWidth);
|
||||
canvas_ = std::make_shared<RSPaintFilterCanvas>(drawingCanvas.get());
|
||||
rsDirtyRectsDfx_->DrawDirtyRectForDFX(*canvas_, dirtyRect, color, fillType, alpha, edgeWidth);
|
||||
ASSERT_TRUE(rsDirtyRectsDfx_->displayParams_);
|
||||
|
||||
fillType = RSDirtyRectsDfx::RSPaintStyle::FILL;
|
||||
rsDirtyRectsDfx_->DrawDirtyRectForDFX(dirtyRect, color, fillType, alpha, edgeWidth);
|
||||
rsDirtyRectsDfx_->DrawDirtyRectForDFX(*canvas_, dirtyRect, color, fillType, alpha, edgeWidth);
|
||||
dirtyRect.height_ = 0;
|
||||
rsDirtyRectsDfx_->DrawDirtyRectForDFX(dirtyRect, color, fillType, alpha, edgeWidth);
|
||||
rsDirtyRectsDfx_->DrawDirtyRectForDFX(*canvas_, dirtyRect, color, fillType, alpha, edgeWidth);
|
||||
dirtyRect.width_ = 0;
|
||||
rsDirtyRectsDfx_->DrawDirtyRectForDFX(dirtyRect, color, fillType, alpha, edgeWidth);
|
||||
rsDirtyRectsDfx_->DrawDirtyRectForDFX(*canvas_, dirtyRect, color, fillType, alpha, edgeWidth);
|
||||
ASSERT_TRUE(rsDirtyRectsDfx_->canvas_);
|
||||
}
|
||||
|
||||
@ -313,13 +309,13 @@ HWTEST_F(RSDirtyRectsDFXTest, DrawDetailedTypesOfDirtyRegionForDFX, TestSize.Lev
|
||||
}
|
||||
surfaceDrawable->syncDirtyManager_ = std::make_shared<RSDirtyRegionManager>();
|
||||
auto drawingCanvas = std::make_unique<Drawing::Canvas>();
|
||||
rsDirtyRectsDfx_->canvas_ = std::make_shared<RSPaintFilterCanvas>(drawingCanvas.get());
|
||||
bool res = rsDirtyRectsDfx_->DrawDetailedTypesOfDirtyRegionForDFX(*surfaceDrawable);
|
||||
canvas_ = std::make_shared<RSPaintFilterCanvas>(drawingCanvas.get());
|
||||
bool res = rsDirtyRectsDfx_->DrawDetailedTypesOfDirtyRegionForDFX(*canvas_, *surfaceDrawable);
|
||||
ASSERT_FALSE(res);
|
||||
|
||||
RSUniRenderThread::Instance().GetRSRenderThreadParams()->dirtyRegionDebugType_ =
|
||||
DirtyRegionDebugType::SUBTREE_SKIP_RECT;
|
||||
res = rsDirtyRectsDfx_->DrawDetailedTypesOfDirtyRegionForDFX(*surfaceDrawable);
|
||||
res = rsDirtyRectsDfx_->DrawDetailedTypesOfDirtyRegionForDFX(*canvas_, *surfaceDrawable);
|
||||
ASSERT_TRUE(res);
|
||||
RSUniRenderThread::Instance().GetRSRenderThreadParams()->dirtyRegionDebugType_ = DirtyRegionDebugType::DISABLED;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user