From f20a4e498316df0f29f4db0d390739776c904df9 Mon Sep 17 00:00:00 2001 From: w00675913 Date: Sat, 21 Jun 2025 17:14:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9B=9B=E5=91=A8=E6=B0=B4?= =?UTF-8?q?=E5=8D=B0=E8=B7=B3=E9=97=AA=E5=92=8C=E6=A6=82=E7=8E=87=E9=BB=91?= =?UTF-8?q?=E7=BA=BF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: w00675913 --- .../movingphoto_layout_algorithm.cpp | 12 ++++++----- .../movingphoto/movingphoto_pattern.cpp | 21 +++++++------------ .../movingphoto/movingphoto_test_ng.cpp | 1 - 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/component_ext/movingphoto/movingphoto_layout_algorithm.cpp b/component_ext/movingphoto/movingphoto_layout_algorithm.cpp index 63e01bf3668..46fb8ec6d66 100644 --- a/component_ext/movingphoto/movingphoto_layout_algorithm.cpp +++ b/component_ext/movingphoto/movingphoto_layout_algorithm.cpp @@ -19,6 +19,7 @@ namespace OHOS::Ace::NG { namespace { constexpr int32_t ROUND_XMAGE_MODE_VALUE = 10; +constexpr int32_t ROUND_XMAGE_PIXEL_GAP = 2; } void MovingPhotoLayoutAlgorithm::Layout(LayoutWrapper* layoutWrapper) @@ -122,8 +123,8 @@ void MovingPhotoLayoutAlgorithm::MeasureInRoundXmageMode(LayoutWrapper* layoutWr auto columnSize = contentSize; SizeF xmageOffsetRatio = pattern->CalculateXmageOffsetRatio(contentSize); SizeF imageSize = layoutProperty->GetImageSize().value(); - columnSize.SetHeight(imageSize.Height() * xmageOffsetRatio.Height() + 1); - columnSize.SetWidth(imageSize.Width() * xmageOffsetRatio.Width() + 1); + columnSize.SetHeight(imageSize.Height() * xmageOffsetRatio.Height() + ROUND_XMAGE_PIXEL_GAP); + columnSize.SetWidth(imageSize.Width() * xmageOffsetRatio.Width() + ROUND_XMAGE_PIXEL_GAP); layoutConstraintForColumn.UpdateSelfMarginSizeWithCheck(OptionalSizeF(columnSize)); layoutConstraintForColumn.UpdateMaxSizeWithCheck(columnSize); layoutConstraintForColumn.UpdateMinSizeWithCheck(columnSize); @@ -161,8 +162,8 @@ void MovingPhotoLayoutAlgorithm::ChildMeasureInXmage(RefPtr child if (columnChild->GetHostTag() == V2::COLUMN_ETS_TAG) { auto layoutConstraintForVideo = layoutConstraint; auto videoSize = contentSize; - videoSize.SetHeight(imageSize.Height() * xmageRatio.Height()); - videoSize.SetWidth(imageSize.Width() * xmageRatio.Width()); + videoSize.SetHeight(imageSize.Height() * xmageRatio.Height() + ROUND_XMAGE_PIXEL_GAP); + videoSize.SetWidth(imageSize.Width() * xmageRatio.Width() + ROUND_XMAGE_PIXEL_GAP); layoutConstraintForVideo.UpdateSelfMarginSizeWithCheck(OptionalSizeF(videoSize)); layoutConstraintForVideo.UpdateMaxSizeWithCheck(videoSize); layoutConstraintForVideo.UpdateMinSizeWithCheck(videoSize); @@ -195,7 +196,8 @@ SizeF MovingPhotoLayoutAlgorithm::GetRoundXmageLayoutOffset(LayoutWrapper* layou } SizeF xmageOffset = layoutProperty->GetXmageOffset().value(); SizeF xmageOffsetRatio = pattern->CalculateXmageOffsetRatio(contentSize); - ret = SizeF(xmageOffset.Width() * xmageOffsetRatio.Width(), xmageOffset.Height() * xmageOffsetRatio.Height()); + ret = SizeF(xmageOffset.Width() * xmageOffsetRatio.Width() - 1, + xmageOffset.Height() * xmageOffsetRatio.Height() - 1); } return ret; } diff --git a/component_ext/movingphoto/movingphoto_pattern.cpp b/component_ext/movingphoto/movingphoto_pattern.cpp index b2877f26e3d..0a711d88e93 100644 --- a/component_ext/movingphoto/movingphoto_pattern.cpp +++ b/component_ext/movingphoto/movingphoto_pattern.cpp @@ -36,7 +36,7 @@ constexpr int32_t ROUND_XMAGE_MODE_VALUE = 10; constexpr int64_t PERIOD_START = 0; constexpr int32_t PREPARE_RETURN = 0; constexpr int64_t VIDEO_PLAYTIME_START_POSITION = 0; -constexpr int32_t IMAGE_LOADING_COMPLETE = 0; +constexpr int32_t IMAGE_DECODE_COMPLETE = 1; constexpr int32_t DURATION_FLAG = -1; const std::string THUMBNAIL_MEDIUM_JOINT = "?&oper=thumbnail&width=-1&height=-1&path="; const std::string COVER_POSITION = "cover_positon"; @@ -54,6 +54,7 @@ constexpr int32_t ANALYZER_DELAY_TIME = 100; constexpr int32_t ANALYZER_CAPTURE_DELAY_TIME = 1000; constexpr int32_t AVERAGE_VALUE = 2; constexpr int32_t US_CONVERT = 1000; +constexpr int32_t ROUND_XMAGE_PIXEL_GAP = 2; } MovingPhotoPattern::MovingPhotoPattern(const RefPtr& controller) : instanceId_(Container::CurrentId()), controller_(controller) @@ -429,7 +430,7 @@ void MovingPhotoPattern::HandleImageCompleteEvent(const LoadImageSuccessEvent& i { auto loadingStatus = info.GetLoadingStatus(); TAG_LOGI(AceLogTag::ACE_MOVING_PHOTO, "HandleImageCompleteEvent start:%{public}d.", loadingStatus); - if (loadingStatus == IMAGE_LOADING_COMPLETE) { + if (loadingStatus == IMAGE_DECODE_COMPLETE) { FireMediaPlayerImageComplete(); } } @@ -822,7 +823,6 @@ void MovingPhotoPattern::SetRenderContextBoundsInRoundXmage( CHECK_NULL_VOID(host); auto pattern = DynamicCast(host->GetPattern()); CHECK_NULL_VOID(pattern); - float ratio = 0; SizeF xmageOffset = SizeF(0, 0); SizeF imageSize = SizeF(0, 0); SizeF xmageOffsetRatio = SizeF(0, 0); @@ -831,23 +831,18 @@ void MovingPhotoPattern::SetRenderContextBoundsInRoundXmage( } if (layoutProperty->HasImageSize()) { imageSize = layoutProperty->GetImageSize().value(); - ratio = CalculateRatio(movingPhotoNodeSize); xmageOffsetRatio = pattern->CalculateXmageOffsetRatio(movingPhotoNodeSize); } if (columnRenderContext_) { - columnRenderContext_->SetBounds( - (movingPhotoNodeSize.Width() - videoFrameSize.Width()) / HALF, - (movingPhotoNodeSize.Height() - videoFrameSize.Height()) / HALF, imageSize.Width() * ratio, - imageSize.Height() * ratio); + columnRenderContext_->SetBounds(0, 0, imageSize.Width() * xmageOffsetRatio.Width() + ROUND_XMAGE_PIXEL_GAP, + imageSize.Height() * xmageOffsetRatio.Height() + ROUND_XMAGE_PIXEL_GAP); } if (renderContextForMediaPlayer_) { - renderContextForMediaPlayer_->SetBounds( - (movingPhotoNodeSize.Width() - videoFrameSize.Width()) / HALF, - (movingPhotoNodeSize.Height() - videoFrameSize.Height()) / HALF, imageSize.Width() * ratio, - imageSize.Height() * ratio); + renderContextForMediaPlayer_->SetBounds(0, 0, + imageSize.Width() * xmageOffsetRatio.Width() + ROUND_XMAGE_PIXEL_GAP, + imageSize.Height() * xmageOffsetRatio.Height() + ROUND_XMAGE_PIXEL_GAP); } } - SizeF MovingPhotoPattern::CalculateFitContain(const SizeF& rawSize, const SizeF& layoutSize) { if (NearZero(rawSize.Height()) || NearZero(rawSize.Width()) || NearZero(layoutSize.Height())) { diff --git a/test/unittest/core/pattern/movingphoto/movingphoto_test_ng.cpp b/test/unittest/core/pattern/movingphoto/movingphoto_test_ng.cpp index b78bcd81aba..2a73354d830 100644 --- a/test/unittest/core/pattern/movingphoto/movingphoto_test_ng.cpp +++ b/test/unittest/core/pattern/movingphoto/movingphoto_test_ng.cpp @@ -1044,7 +1044,6 @@ HWTEST_F(MovingphotoTestNg, ShouldUpdateImageAnalyzer001, TestSize.Level1) ASSERT_NE(movingphotoPattern, nullptr); auto movingPhotoLayoutProperty = frameNode->GetLayoutProperty(); ASSERT_NE(movingPhotoLayoutProperty, nullptr); - EXPECT_FALSE(movingphotoPattern->ShouldUpdateImageAnalyzer()); } -- Gitee