!645 视频场景下,视频随窗口一起动效退出

Merge pull request !645 from lastking/master
This commit is contained in:
openharmony_ci 2022-03-10 01:52:24 +00:00 committed by Gitee
commit 8c302641ff
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 60 additions and 21 deletions

View File

@ -15,9 +15,11 @@
#include "pipeline/rs_hardware_processor.h"
#include "common/rs_vector3.h"
#include "common/rs_vector4.h"
#include "display_type.h"
#include "pipeline/rs_main_thread.h"
#include "pipeline/rs_surface_render_node.h"
#include "platform/common/rs_log.h"
namespace OHOS {
@ -231,25 +233,24 @@ void RSHardwareProcessor::CalculateInfoWithVideo(ComposeInfo& info, RSSurfaceRen
void RSHardwareProcessor::CalculateInfoWithAnimation(
const std::unique_ptr<RSTransitionProperties>& transitionProperties, ComposeInfo& info, RSSurfaceRenderNode& node)
{
if (!transitionProperties) {
return;
}
AnimationInfo animationInfo;
RsRenderServiceUtil::ExtractAnimationInfo(transitionProperties, node, animationInfo);
auto geoPtr = std::static_pointer_cast<RSObjAbsGeometry>(node.GetRenderProperties().GetBoundsGeometry());
if (geoPtr == nullptr) {
ROSEN_LOGE("RsDebug RSHardwareProcessor::ProcessSurface geoPtr == nullptr");
return;
}
float paddingX = (1 - transitionProperties->GetScale().x_) * geoPtr->GetAbsRect().width_ / 2;
float paddingY = (1 - transitionProperties->GetScale().y_) * geoPtr->GetAbsRect().height_ / 2;
float paddingX = (1 - animationInfo.scale.x_) * geoPtr->GetAbsRect().width_ / 2;
float paddingY = (1 - animationInfo.scale.y_) * geoPtr->GetAbsRect().height_ / 2;
info.dstRect = {
.x = info.dstRect.x + transitionProperties->GetTranslate().x_ + paddingX,
.y = info.dstRect.y + transitionProperties->GetTranslate().y_ + paddingY,
.w = info.dstRect.w * transitionProperties->GetScale().x_,
.h = info.dstRect.h * transitionProperties->GetScale().y_,
.x = info.dstRect.x + animationInfo.translate.x_ + paddingX,
.y = info.dstRect.y + animationInfo.translate.y_ + paddingY,
.w = info.dstRect.w * animationInfo.scale.x_,
.h = info.dstRect.h * animationInfo.scale.y_,
};
info.alpha = {
.enGlobalAlpha = true,
.gAlpha = node.GetAlpha() * node.GetRenderProperties().GetAlpha() * transitionProperties->GetAlpha() * 255,
.gAlpha = node.GetAlpha() * node.GetRenderProperties().GetAlpha() * animationInfo.alpha * 255,
};
}

View File

@ -542,26 +542,56 @@ bool RsRenderServiceUtil::IsNeedClient(RSSurfaceRenderNode* node)
}
}
void RsRenderServiceUtil::DealAnimation(SkCanvas& canvas, RSSurfaceRenderNode& node, BufferDrawParam& params)
void RsRenderServiceUtil::ExtractAnimationInfo(const std::unique_ptr<RSTransitionProperties>& transitionProperties,
RSSurfaceRenderNode& node, AnimationInfo& info)
{
auto transitionProperties = node.GetAnimationManager().GetTransitionProperties();
if (transitionProperties == nullptr) {
ROSEN_LOGD("RsRenderServiceUtil::dealAnimation: node's transitionProperties is nullptr.");
auto existedParent = node.GetParent().lock();
if (!existedParent) {
ROSEN_LOGI("RsDebug RsRenderServiceUtil::ExtractAnimationInfo this node[%s] have no parent",
node.GetName().c_str());
return;
}
if (existedParent->IsInstanceOf<RSSurfaceRenderNode>()) {
auto parentTransitionProperties = std::static_pointer_cast<RSSurfaceRenderNode>(existedParent)->
GetAnimationManager().GetTransitionProperties();
if (!parentTransitionProperties) {
ROSEN_LOGI("RsDebug RSHardwareProcessor::CalculateInfoWithAnimation this node[%s] parent have no effect",
node.GetName().c_str());
return;
}
info.scale = parentTransitionProperties->GetScale();
info.translate = parentTransitionProperties->GetTranslate();
info.alpha = parentTransitionProperties->GetAlpha();
info.rotateMatrix = parentTransitionProperties->GetRotate();
} else {
if (!transitionProperties) {
ROSEN_LOGI("RsDebug RSHardwareProcessor::CalculateInfoWithAnimation this node have no effect",
node.GetName().c_str());
return;
}
info.scale = transitionProperties->GetScale();
info.translate = transitionProperties->GetTranslate();
info.alpha = transitionProperties->GetAlpha();
info.rotateMatrix = transitionProperties->GetRotate();
}
}
void RsRenderServiceUtil::DealAnimation(SkCanvas& canvas, RSSurfaceRenderNode& node, BufferDrawParam& params)
{
AnimationInfo animationInfo;
auto transitionProperties = node.GetAnimationManager().GetTransitionProperties();
ExtractAnimationInfo(transitionProperties, node, animationInfo);
const RSProperties& property = node.GetRenderProperties();
params.paint.setAlphaf(params.paint.getAlphaf() * transitionProperties->GetAlpha());
auto translate = transitionProperties->GetTranslate();
canvas.translate(translate.x_, translate.y_);
params.paint.setAlphaf(params.paint.getAlphaf() * animationInfo.alpha);
canvas.translate(animationInfo.translate.x_, animationInfo.translate.y_);
// scale and rotate about the center of node, currently scaleZ is not used
auto center = property.GetBoundsSize() * 0.5f;
auto scale = transitionProperties->GetScale();
canvas.translate(center.x_, center.y_);
canvas.scale(scale.x_, scale.y_);
canvas.concat(transitionProperties->GetRotate());
canvas.scale(animationInfo.scale.x_, animationInfo.scale.y_);
canvas.concat(animationInfo.rotateMatrix);
canvas.translate(-center.x_, -center.y_);
auto filter = std::static_pointer_cast<RSSkiaFilter>(property.GetBackgroundFilter());
if (filter != nullptr) {

View File

@ -40,6 +40,13 @@ struct BufferDrawParam {
ColorGamut targetColorGamut = ColorGamut::COLOR_GAMUT_SRGB;
};
struct AnimationInfo {
Vector3f scale = { 1.0f, 1.0f, 1.0f };
Vector3f translate = { 0.0f, 0.0f, 0.0f };
float alpha = 1.0f;
SkMatrix44 rotateMatrix = SkMatrix44::I();
};
struct ComposeInfo {
IRect srcRect;
IRect dstRect;
@ -61,7 +68,8 @@ public:
static void DrawBuffer(SkCanvas& canvas, BufferDrawParam& bufferDrawParam, CanvasPostProcess process = nullptr);
static BufferDrawParam CreateBufferDrawParam(RSSurfaceRenderNode& node);
static void DealAnimation(SkCanvas& canvas, RSSurfaceRenderNode& node, BufferDrawParam& params);
static void ExtractAnimationInfo(const std::unique_ptr<RSTransitionProperties>& transitionProperties,
RSSurfaceRenderNode& node, AnimationInfo& info);
private:
static bool IsNeedClient(RSSurfaceRenderNode* node);
static bool CreateBitmap(sptr<OHOS::SurfaceBuffer> buffer, SkBitmap& bitmap);