mirror of
https://gitee.com/openharmony/graphic_graphic_2d
synced 2024-11-23 15:11:51 +00:00
!1810 统一渲染时,截图和主屏绘制流程保持一致
Merge pull request !1810 from xxfeng_hw/yu_dev
This commit is contained in:
commit
2a2f3dbcd4
@ -983,7 +983,7 @@ void RSBaseRenderUtil::SetPropertiesForCanvas(RSPaintFilterCanvas& canvas, const
|
||||
}
|
||||
}
|
||||
if (SkColorGetA(params.backgroundColor) != SK_AlphaTRANSPARENT) {
|
||||
canvas.clear(params.backgroundColor);
|
||||
canvas.drawColor(params.backgroundColor);
|
||||
}
|
||||
canvas.concat(params.matrix);
|
||||
}
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "pipeline/rs_uni_render_util.h"
|
||||
#include "platform/common/rs_log.h"
|
||||
#include "platform/drawing/rs_surface.h"
|
||||
#include "property/rs_transition_properties.h"
|
||||
#include "render/rs_skia_filter.h"
|
||||
#include "screen_manager/rs_screen_manager.h"
|
||||
#include "screen_manager/rs_screen_mode_info.h"
|
||||
@ -251,8 +252,9 @@ void RSSurfaceCaptureTask::RSSurfaceCaptureVisitor::CaptureSurfaceInDisplayWithU
|
||||
canvas_->clipRect(contextClipRect);
|
||||
}
|
||||
|
||||
const auto& property = node.GetRenderProperties();
|
||||
SkMatrix translateMatrix;
|
||||
auto geoPtr = std::static_pointer_cast<RSObjAbsGeometry>(node.GetRenderProperties().GetBoundsGeometry());
|
||||
auto geoPtr = std::static_pointer_cast<RSObjAbsGeometry>(property.GetBoundsGeometry());
|
||||
translateMatrix.setTranslate(
|
||||
std::ceil(geoPtr->GetMatrix().getTranslateX()),
|
||||
std::ceil(geoPtr->GetMatrix().getTranslateY()));
|
||||
@ -261,8 +263,15 @@ void RSSurfaceCaptureTask::RSSurfaceCaptureVisitor::CaptureSurfaceInDisplayWithU
|
||||
auto params = RSBaseRenderUtil::CreateBufferDrawParam(node, true); // use node's local coordinate.
|
||||
|
||||
const auto saveCnt = canvas_->save();
|
||||
if (node.GetConsumer() == nullptr) {
|
||||
canvas_->concat(params.matrix);
|
||||
auto transitionProperties = node.GetAnimationManager().GetTransitionProperties();
|
||||
RSPropertiesPainter::DrawTransitionProperties(transitionProperties, property, *canvas_);
|
||||
boundsRect_ = SkRect::MakeWH(property.GetBoundsWidth(), property.GetBoundsHeight());
|
||||
frameGravity_ = property.GetFrameGravity();
|
||||
canvas_->clipRect(boundsRect_);
|
||||
auto backgroundColor = static_cast<SkColor>(property.GetBackgroundColor().AsArgbInt());
|
||||
if (SkColorGetA(backgroundColor) != SK_AlphaTRANSPARENT) {
|
||||
canvas_->drawColor(backgroundColor);
|
||||
}
|
||||
ProcessBaseRenderNode(node);
|
||||
canvas_->restoreToCount(saveCnt);
|
||||
@ -305,6 +314,14 @@ void RSSurfaceCaptureTask::RSSurfaceCaptureVisitor::ProcessRootRenderNode(RSRoot
|
||||
}
|
||||
|
||||
canvas_->save();
|
||||
const auto& property = node.GetRenderProperties();
|
||||
const float frameWidth = property.GetFrameWidth();
|
||||
const float frameHeight = property.GetFrameHeight();
|
||||
SkMatrix gravityMatrix;
|
||||
(void)RSPropertiesPainter::GetGravityMatrix(frameGravity_,
|
||||
RectF {0.0f, 0.0f, boundsRect_.width(), boundsRect_.height()},
|
||||
frameWidth, frameHeight, gravityMatrix);
|
||||
canvas_->concat(gravityMatrix);
|
||||
ProcessCanvasRenderNode(node);
|
||||
canvas_->restore();
|
||||
}
|
||||
|
@ -81,6 +81,9 @@ private:
|
||||
float scaleY_ = 1.0f;
|
||||
bool isUniRender_ = false;
|
||||
|
||||
SkRect boundsRect_;
|
||||
Gravity frameGravity_ = Gravity::DEFAULT;
|
||||
|
||||
std::shared_ptr<RSRenderEngine> renderEngine_;
|
||||
};
|
||||
|
||||
|
@ -371,7 +371,7 @@ void RSUniRenderVisitor::ProcessSurfaceRenderNode(RSSurfaceRenderNode& node)
|
||||
RS_LOGE("RSUniRenderVisitor::ProcessSurfaceRenderNode node:%" PRIu64 ", get geoPtr failed", node.GetId());
|
||||
return;
|
||||
}
|
||||
RS_TRACE_BEGIN("RSUniRender::Process:" + node.GetName());
|
||||
RS_TRACE_NAME("RSUniRender::Process:" + node.GetName());
|
||||
canvas_->save();
|
||||
canvas_->SaveAlpha();
|
||||
|
||||
@ -383,34 +383,35 @@ void RSUniRenderVisitor::ProcessSurfaceRenderNode(RSSurfaceRenderNode& node)
|
||||
canvas_->clipRect(contextClipRect);
|
||||
}
|
||||
|
||||
canvas_->concat(geoPtr->GetMatrix());
|
||||
SkRect boundsRect = SkRect::MakeWH(property.GetBoundsWidth(), property.GetBoundsHeight());
|
||||
clipRect_ = boundsRect;
|
||||
frameGravity_ = property.GetFrameGravity();
|
||||
canvas_->clipRect(clipRect_);
|
||||
SkMatrix translateMatrix;
|
||||
translateMatrix.setTranslate(
|
||||
std::ceil(geoPtr->GetMatrix().getTranslateX()),
|
||||
std::ceil(geoPtr->GetMatrix().getTranslateY()));
|
||||
canvas_->concat(translateMatrix);
|
||||
|
||||
auto params = RSBaseRenderUtil::CreateBufferDrawParam(node, true); // use node's local coordinate.
|
||||
|
||||
const auto saveCnt = canvas_->save();
|
||||
canvas_->concat(params.matrix);
|
||||
auto transitionProperties = node.GetAnimationManager().GetTransitionProperties();
|
||||
RSPropertiesPainter::DrawTransitionProperties(transitionProperties, property, *canvas_);
|
||||
boundsRect_ = SkRect::MakeWH(property.GetBoundsWidth(), property.GetBoundsHeight());
|
||||
frameGravity_ = property.GetFrameGravity();
|
||||
canvas_->clipRect(boundsRect_);
|
||||
auto backgroundColor = static_cast<SkColor>(property.GetBackgroundColor().AsArgbInt());
|
||||
if (SkColorGetA(backgroundColor) != SK_AlphaTRANSPARENT) {
|
||||
canvas_->drawColor(backgroundColor);
|
||||
}
|
||||
ProcessBaseRenderNode(node);
|
||||
canvas_->restoreToCount(saveCnt);
|
||||
|
||||
if (node.GetConsumer() != nullptr) {
|
||||
RS_TRACE_BEGIN("UniRender::Process:" + node.GetName());
|
||||
if (node.GetBuffer() == nullptr) {
|
||||
RS_LOGD("RSUniRenderVisitor::ProcessSurfaceRenderNode:%" PRIu64 " buffer is not available", node.GetId());
|
||||
} else {
|
||||
if (node.GetBuffer() != nullptr) {
|
||||
node.NotifyRTBufferAvailable();
|
||||
auto params = RSBaseRenderUtil::CreateBufferDrawParam(node, true); // in node's local coordinate.
|
||||
renderEngine_->DrawSurfaceNodeWithParams(*canvas_, node, params);
|
||||
}
|
||||
RS_TRACE_END();
|
||||
}
|
||||
|
||||
canvas_->RestoreAlpha();
|
||||
canvas_->restore();
|
||||
RS_TRACE_END();
|
||||
}
|
||||
|
||||
void RSUniRenderVisitor::ProcessRootRenderNode(RSRootRenderNode& node)
|
||||
@ -428,15 +429,14 @@ void RSUniRenderVisitor::ProcessRootRenderNode(RSRootRenderNode& node)
|
||||
return;
|
||||
}
|
||||
|
||||
canvas_->save();
|
||||
const float frameWidth = property.GetFrameWidth();
|
||||
const float frameHeight = property.GetFrameHeight();
|
||||
SkMatrix gravityMatrix;
|
||||
(void)RSPropertiesPainter::GetGravityMatrix(frameGravity_,
|
||||
RectF {0.0f, 0.0f, clipRect_.width(), clipRect_.height()},
|
||||
RectF {0.0f, 0.0f, boundsRect_.width(), boundsRect_.height()},
|
||||
frameWidth, frameHeight, gravityMatrix);
|
||||
canvas_->concat(gravityMatrix);
|
||||
|
||||
canvas_->save();
|
||||
ProcessCanvasRenderNode(node);
|
||||
canvas_->restore();
|
||||
}
|
||||
|
@ -53,8 +53,8 @@ private:
|
||||
bool dirtyFlag_ { false };
|
||||
std::unique_ptr<RSPaintFilterCanvas> canvas_;
|
||||
std::map<NodeId, std::shared_ptr<RSSurfaceRenderNode>> dirtySurfaceNodeMap_;
|
||||
SkRect clipRect_;
|
||||
Gravity frameGravity_;
|
||||
SkRect boundsRect_;
|
||||
Gravity frameGravity_ = Gravity::DEFAULT;
|
||||
|
||||
int32_t offsetX_ { 0 };
|
||||
int32_t offsetY_ { 0 };
|
||||
|
Loading…
Reference in New Issue
Block a user