mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2025-02-03 16:56:51 +00:00
!26856 【bug】新增imageDump日志
Merge pull request !26856 from 吴寅潇/addImageLog0130
This commit is contained in:
commit
dcf6eb8400
@ -53,6 +53,7 @@ void* DataAbilityHelperStandard::QueryThumbnailResFromDataAbility(const std::str
|
||||
#ifdef MEDIA_LIBRARY_EXISTS
|
||||
ACE_FUNCTION_TRACE();
|
||||
Uri fileUri(uri);
|
||||
LOGI("QueryThumbnailResFromDataAbility GetThumbnail uri=%{public}s", uri.c_str());
|
||||
return mgr_.GetThumbnail(fileUri).release();
|
||||
#else
|
||||
return nullptr;
|
||||
|
@ -234,10 +234,13 @@ void PixelMapOhos::SavePixelMapToFile(const std::string& dst) const
|
||||
int32_t w = pixmap_->GetWidth();
|
||||
int32_t h = pixmap_->GetHeight();
|
||||
int32_t totalSize = pixmap_->GetByteCount();
|
||||
auto rowStride = pixmap_->GetRowStride();
|
||||
uint64_t nowTime = static_cast<uint64_t>(
|
||||
std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch())
|
||||
.count());
|
||||
std::string filename = std::to_string(nowTime) + "_w" + std::to_string(w) + "_h" + std::to_string(h) + dst + ".dat";
|
||||
std::string filename = std::to_string(nowTime) + "_w" + std::to_string(w) + "_h" + std::to_string(h) +
|
||||
"_rowStride" + std::to_string(rowStride) + "_byteCount" + std::to_string(totalSize) + dst +
|
||||
".dat";
|
||||
auto path = ImageFileCache::GetInstance().ConstructCacheFilePath(filename);
|
||||
std::ofstream outFile(path, std::fstream::out);
|
||||
if (!outFile.is_open()) {
|
||||
|
@ -16,8 +16,6 @@
|
||||
#include "core/image/image_source_info.h"
|
||||
#define NAPI_VERSION 8
|
||||
|
||||
#include "core/components_ng/pattern/image/image_pattern.h"
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
|
||||
@ -36,6 +34,7 @@
|
||||
#include "core/components_ng/event/event_hub.h"
|
||||
#include "core/components_ng/pattern/image/image_layout_property.h"
|
||||
#include "core/components_ng/pattern/image/image_paint_method.h"
|
||||
#include "core/components_ng/pattern/image/image_pattern.h"
|
||||
#include "core/components_ng/property/measure_property.h"
|
||||
#include "core/pipeline_ng/pipeline_context.h"
|
||||
#include "frameworks/bridge/common/utils/engine_helper.h"
|
||||
@ -204,7 +203,7 @@ void ImagePattern::OnImageLoadSuccess()
|
||||
eventHub->FireCompleteEvent(event);
|
||||
}
|
||||
|
||||
SetImagePaintConfig(image_, srcRect_, dstRect_, loadingCtx_->GetSourceInfo().IsSvg(), loadingCtx_->GetFrameCount());
|
||||
SetImagePaintConfig(image_, srcRect_, dstRect_, loadingCtx_->GetSourceInfo(), loadingCtx_->GetFrameCount());
|
||||
PrepareAnimation(image_);
|
||||
if (host->IsDraggable()) {
|
||||
EnableDrag();
|
||||
@ -251,9 +250,8 @@ void ImagePattern::OnImageLoadFail(const std::string& errorMsg)
|
||||
imageEventHub->FireErrorEvent(event);
|
||||
}
|
||||
|
||||
void ImagePattern::SetImagePaintConfig(
|
||||
const RefPtr<CanvasImage>& canvasImage, const RectF& srcRect,
|
||||
const RectF& dstRect, bool isSvg, int32_t frameCount)
|
||||
void ImagePattern::SetImagePaintConfig(const RefPtr<CanvasImage>& canvasImage, const RectF& srcRect,
|
||||
const RectF& dstRect, const ImageSourceInfo& sourceInfo, int32_t frameCount)
|
||||
{
|
||||
auto layoutProps = GetLayoutProperty<ImageLayoutProperty>();
|
||||
CHECK_NULL_VOID(layoutProps);
|
||||
@ -263,8 +261,9 @@ void ImagePattern::SetImagePaintConfig(
|
||||
.dstRect_ = dstRect,
|
||||
};
|
||||
config.imageFit_ = layoutProps->GetImageFit().value_or(ImageFit::COVER);
|
||||
config.isSvg_ = isSvg;
|
||||
config.isSvg_ = sourceInfo.IsSvg();
|
||||
config.frameCount_ = frameCount;
|
||||
config.sourceInfo_ = sourceInfo;
|
||||
auto host = GetHost();
|
||||
if (!host) {
|
||||
canvasImage->SetPaintConfig(config);
|
||||
@ -308,9 +307,8 @@ bool ImagePattern::OnDirtyLayoutWrapperSwap(const RefPtr<LayoutWrapper>& dirty,
|
||||
auto renderProp = GetPaintProperty<ImageRenderProperty>();
|
||||
if (renderProp && renderProp->HasImageResizableSlice() && image_) {
|
||||
loadingCtx_->ResizableCalcDstSize();
|
||||
SetImagePaintConfig(
|
||||
image_, loadingCtx_->GetSrcRect(), loadingCtx_->GetDstRect(),
|
||||
loadingCtx_->GetSrc().IsSvg(), loadingCtx_->GetFrameCount());
|
||||
SetImagePaintConfig(image_, loadingCtx_->GetSrcRect(), loadingCtx_->GetDstRect(), loadingCtx_->GetSrc(),
|
||||
loadingCtx_->GetFrameCount());
|
||||
}
|
||||
}
|
||||
|
||||
@ -318,9 +316,8 @@ bool ImagePattern::OnDirtyLayoutWrapperSwap(const RefPtr<LayoutWrapper>& dirty,
|
||||
auto renderProp = GetPaintProperty<ImageRenderProperty>();
|
||||
if (renderProp && renderProp->HasImageResizableSlice() && altImage_) {
|
||||
altLoadingCtx_->ResizableCalcDstSize();
|
||||
SetImagePaintConfig(
|
||||
altImage_, altLoadingCtx_->GetSrcRect(), altLoadingCtx_->GetDstRect(),
|
||||
altLoadingCtx_->GetSrc().IsSvg(), altLoadingCtx_->GetFrameCount());
|
||||
SetImagePaintConfig(altImage_, altLoadingCtx_->GetSrcRect(), altLoadingCtx_->GetDstRect(),
|
||||
altLoadingCtx_->GetSrc(), altLoadingCtx_->GetFrameCount());
|
||||
}
|
||||
}
|
||||
|
||||
@ -344,7 +341,7 @@ void ImagePattern::CreateObscuredImage()
|
||||
if (reasons.size() && layoutConstraint->selfIdealSize.IsValid()) {
|
||||
if (!obscuredImage_) {
|
||||
obscuredImage_ = MakeRefPtr<ObscuredImage>();
|
||||
SetImagePaintConfig(obscuredImage_, srcRect_, dstRect_, sourceInfo.IsSvg());
|
||||
SetImagePaintConfig(obscuredImage_, srcRect_, dstRect_, sourceInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -522,7 +519,7 @@ LoadSuccessNotifyTask ImagePattern::CreateLoadSuccessCallbackForAlt()
|
||||
pattern->altSrcRect_ = std::make_unique<RectF>(pattern->altLoadingCtx_->GetSrcRect());
|
||||
pattern->altDstRect_ = std::make_unique<RectF>(pattern->altLoadingCtx_->GetDstRect());
|
||||
pattern->SetImagePaintConfig(pattern->altImage_, *pattern->altSrcRect_, *pattern->altDstRect_,
|
||||
pattern->altLoadingCtx_->GetSourceInfo().IsSvg(), pattern->altLoadingCtx_->GetFrameCount());
|
||||
pattern->altLoadingCtx_->GetSourceInfo(), pattern->altLoadingCtx_->GetFrameCount());
|
||||
|
||||
pattern->PrepareAnimation(pattern->altImage_);
|
||||
|
||||
@ -653,7 +650,7 @@ void ImagePattern::EnableDrag()
|
||||
{
|
||||
auto host = GetHost();
|
||||
CHECK_NULL_VOID(host);
|
||||
auto dragStart = [weak = WeakClaim(this)](const RefPtr<OHOS::Ace::DragEvent>& event, const std::string &
|
||||
auto dragStart = [weak = WeakClaim(this)](const RefPtr<OHOS::Ace::DragEvent>& event, const std::string&
|
||||
/* extraParams */) -> DragDropInfo {
|
||||
DragDropInfo info;
|
||||
auto imagePattern = weak.Upgrade();
|
||||
@ -934,7 +931,7 @@ void ImagePattern::OnConfigurationUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
void ImagePattern::SetImageAnalyzerConfig(const ImageAnalyzerConfig &config)
|
||||
void ImagePattern::SetImageAnalyzerConfig(const ImageAnalyzerConfig& config)
|
||||
{
|
||||
if (!isEnableAnalyzer_) {
|
||||
return;
|
||||
@ -1003,8 +1000,7 @@ void ImagePattern::UpdateAnalyzerOverlay()
|
||||
napi_value pixelmapNapiVal = ConvertPixmapNapi(pixelMap);
|
||||
auto frameNode = GetHost();
|
||||
auto overlayNode = frameNode->GetOverlayNode();
|
||||
ImageAnalyzerMgr::GetInstance().UpdateImage(
|
||||
&overlayData_, pixelmapNapiVal, &analyzerConfig_, &analyzerUIConfig_);
|
||||
ImageAnalyzerMgr::GetInstance().UpdateImage(&overlayData_, pixelmapNapiVal, &analyzerConfig_, &analyzerUIConfig_);
|
||||
overlayNode->MarkDirtyNode(PROPERTY_UPDATE_MEASURE);
|
||||
}
|
||||
|
||||
@ -1042,9 +1038,10 @@ bool ImagePattern::IsSupportImageAnalyzerFeature()
|
||||
CHECK_NULL_RETURN(imageRenderProperty, false);
|
||||
ImageRepeat repeat = imageRenderProperty->GetImageRepeat().value_or(ImageRepeat::NO_REPEAT);
|
||||
|
||||
return isEnabled && !hasObscured && isEnableAnalyzer_ && ImageAnalyzerMgr::GetInstance().IsImageAnalyzerSupported()
|
||||
&& image_ && !loadingCtx_->GetSourceInfo().IsSvg() && repeat == ImageRepeat::NO_REPEAT
|
||||
&& loadingCtx_->GetFrameCount() == 1;
|
||||
return isEnabled && !hasObscured && isEnableAnalyzer_ &&
|
||||
ImageAnalyzerMgr::GetInstance().IsImageAnalyzerSupported() && image_ &&
|
||||
!loadingCtx_->GetSourceInfo().IsSvg() && repeat == ImageRepeat::NO_REPEAT &&
|
||||
loadingCtx_->GetFrameCount() == 1;
|
||||
}
|
||||
|
||||
void ImagePattern::UpdateAnalyzerUIConfig(const RefPtr<GeometryNode>& geometryNode)
|
||||
|
@ -178,9 +178,8 @@ private:
|
||||
void OnImageDataReady();
|
||||
void OnImageLoadFail(const std::string& errorMsg);
|
||||
void OnImageLoadSuccess();
|
||||
void SetImagePaintConfig(
|
||||
const RefPtr<CanvasImage>& canvasImage, const RectF& srcRect,
|
||||
const RectF& dstRect, bool isSvg, int32_t frameCount = 1);
|
||||
void SetImagePaintConfig(const RefPtr<CanvasImage>& canvasImage, const RectF& srcRect, const RectF& dstRect,
|
||||
const ImageSourceInfo& sourceInfo, int32_t frameCount = 1);
|
||||
void UpdateInternalResource(ImageSourceInfo& sourceInfo);
|
||||
|
||||
void PrepareAnimation(const RefPtr<CanvasImage>& image);
|
||||
|
@ -259,8 +259,8 @@ void PixelMapImage::DrawToRSCanvas(
|
||||
1.0, 0, 0, 0 };
|
||||
recordingCanvas.AttachBrush(brush);
|
||||
if (SystemProperties::GetDebugPixelMapSaveEnabled()) {
|
||||
TAG_LOGI(AceLogTag::ACE_IMAGE, "pixmap, width=%{public}d * height=%{public}d", pixmap->GetWidth(),
|
||||
pixmap->GetHeight());
|
||||
TAG_LOGI(AceLogTag::ACE_IMAGE, "pixmap, sourceInfo:%{public}s ,width=%{public}d * height=%{public}d",
|
||||
config.sourceInfo_.ToString().c_str(), pixmap->GetWidth(), pixmap->GetHeight());
|
||||
pixmap->SavePixelMapToFile("_ToRS_");
|
||||
}
|
||||
recordingCanvas.DrawPixelMapWithParm(pixmap->GetPixelMapSharedPtr(), rsImageInfo, options);
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "base/utils/noncopyable.h"
|
||||
#include "core/components/common/properties/decoration.h"
|
||||
#include "core/components_ng/render/drawing_forward.h"
|
||||
#include "core/image/image_source_info.h"
|
||||
|
||||
namespace OHOS::Ace::NG {
|
||||
using BorderRadiusArray = std::array<PointF, 4>;
|
||||
@ -44,6 +45,7 @@ struct ImagePaintConfig {
|
||||
int32_t frameCount_ = 1;
|
||||
std::vector<ObscuredReasons> obscuredReasons_;
|
||||
ImageResizableSlice resizableSlice_;
|
||||
ImageSourceInfo sourceInfo_;
|
||||
};
|
||||
|
||||
// CanvasImage is interface for drawing image.
|
||||
|
@ -418,13 +418,14 @@ HWTEST_F(ImageTestNg, SetImagePaintConfig002, TestSize.Level1)
|
||||
/**
|
||||
* @tc.steps: step3. start set ImagePaintConfig and Verify it will be set correctly.
|
||||
*/
|
||||
imagePattern->SetImagePaintConfig(canvasImage, RectF(), RectF(), true);
|
||||
imagePattern->SetImagePaintConfig(
|
||||
canvasImage, RectF(), RectF(), ImageSourceInfo(IMAGE_SRC_URL, IMAGE_SOURCEINFO_WIDTH, IMAGE_SOURCEINFO_HEIGHT));
|
||||
ASSERT_NE(canvasImage->paintConfig_, nullptr);
|
||||
auto paintConfig = canvasImage->GetPaintConfig();
|
||||
EXPECT_EQ(paintConfig.srcRect_, RectF());
|
||||
EXPECT_EQ(paintConfig.dstRect_, RectF());
|
||||
EXPECT_EQ(paintConfig.imageFit_, ImageFit::COVER);
|
||||
EXPECT_TRUE(paintConfig.isSvg_);
|
||||
EXPECT_TRUE(paintConfig.sourceInfo_.IsSvg());
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user