stronger-imageDfx

Signed-off-by: hw_wyx <wuyinxiao@huawei.com>
Change-Id: I9234d9e02d04bd939a173afe292c705403a6739f
This commit is contained in:
hw_wyx 2024-10-29 14:56:22 +08:00
parent 6253e9ef70
commit 3bce0a954b
21 changed files with 404 additions and 302 deletions

View File

@ -70,6 +70,24 @@ AlphaType PixelMapOhos::AlphaTypeConverter(Media::AlphaType alphaType)
}
}
AllocatorType PixelMapOhos::AllocatorTypeConverter(Media::AllocatorType allocatorType)
{
switch (allocatorType) {
case Media::AllocatorType::DEFAULT:
return AllocatorType::DEFAULT;
case Media::AllocatorType::HEAP_ALLOC:
return AllocatorType::HEAP_ALLOC;
case Media::AllocatorType::SHARE_MEM_ALLOC:
return AllocatorType::SHARE_MEM_ALLOC;
case Media::AllocatorType::CUSTOM_ALLOC:
return AllocatorType::CUSTOM_ALLOC;
case Media::AllocatorType::DMA_ALLOC:
return AllocatorType::DMA_ALLOC;
default:
return AllocatorType::DEFAULT;
}
}
RefPtr<PixelMap> PixelMap::Create(std::unique_ptr<Media::PixelMap>&& pixmap)
{
return AceType::MakeRefPtr<PixelMapOhos>(std::move(pixmap));
@ -195,6 +213,18 @@ int32_t PixelMapOhos::GetByteCount() const
return pixmap_->GetByteCount();
}
AllocatorType PixelMapOhos::GetAllocatorType() const
{
CHECK_NULL_RETURN(pixmap_, AllocatorType::DEFAULT);
return AllocatorTypeConverter(pixmap_->GetAllocatorType());
}
bool PixelMapOhos::IsHdr() const
{
CHECK_NULL_RETURN(pixmap_, false);
return pixmap_->IsHdr();
}
void* PixelMapOhos::GetPixelManager() const
{
Media::InitializationOptions opts;

View File

@ -31,6 +31,7 @@ public:
~PixelMapOhos() override = default;
static PixelFormat PixelFormatConverter(Media::PixelFormat pixelFormat);
static AlphaType AlphaTypeConverter(Media::AlphaType alphaType);
static AllocatorType AllocatorTypeConverter(Media::AllocatorType allocatorType);
int32_t GetWidth() const override;
int32_t GetHeight() const override;
bool GetPixelsVec(std::vector<uint8_t>& data) const override;
@ -40,6 +41,8 @@ public:
int32_t GetRowStride() const override;
int32_t GetRowBytes() const override;
int32_t GetByteCount() const override;
AllocatorType GetAllocatorType() const override;
bool IsHdr() const override;
void* GetPixelManager() const override;
void* GetRawPixelMapPtr() const override;
std::string GetId() override;

View File

@ -57,6 +57,15 @@ enum class AlphaType : int32_t {
IMAGE_ALPHA_TYPE_UNPREMUL = 3, // image have alpha component, and all pixels stored without premultiply alpha value.
};
enum class AllocatorType : int32_t {
// keep same with java AllocatorType
DEFAULT = 0,
HEAP_ALLOC = 1,
SHARE_MEM_ALLOC = 2,
CUSTOM_ALLOC = 3, // external
DMA_ALLOC = 4, // SurfaceBuffer
};
enum class ResizableOption {
LEFT,
RIGHT,
@ -163,6 +172,8 @@ public:
virtual int32_t GetRowStride() const = 0;
virtual int32_t GetRowBytes() const = 0;
virtual int32_t GetByteCount() const = 0;
virtual AllocatorType GetAllocatorType() const = 0;
virtual bool IsHdr() const = 0;
virtual void* GetPixelManager() const = 0;
virtual void* GetRawPixelMapPtr() const = 0;
virtual std::string GetId() = 0;

View File

@ -31,13 +31,6 @@
#include "core/image/image_loader.h"
namespace OHOS::Ace::NG {
namespace {
std::string ImageDfxConfigToString(const ImageDfxConfig& imageDfxConfig)
{
return "src = " + imageDfxConfig.imageSrc_ + ", nodeInfo = [" + std::to_string(imageDfxConfig.nodeId_) + "-" +
std::to_string(imageDfxConfig.accessibilityId_) + "]";
}
} // namespace
ImageDecoder::ImageDecoder(const RefPtr<ImageObject>& obj, const SizeF& size, bool forceResize)
: obj_(obj), desiredSize_(size), forceResize_(forceResize)
{
@ -75,15 +68,11 @@ RefPtr<CanvasImage> ImageDecoder::MakePixmapImage(AIImageQuality imageQuality, b
{
CHECK_NULL_RETURN(obj_ && data_, nullptr);
auto imageDfxConfig = obj_->GetImageDfxConfig();
auto nodeId = imageDfxConfig.nodeId_;
long long accessId = imageDfxConfig.accessibilityId_;
auto src = obj_->GetSourceInfo();
auto srcStr = src.GetSrcType() == SrcType::BASE64 ? src.GetKey() : src.ToString();
auto src = imageDfxConfig.imageSrc_;
auto source = ImageSource::Create(static_cast<const uint8_t*>(data_->GetData()), data_->GetSize());
if (!source) {
TAG_LOGE(AceLogTag::ACE_IMAGE,
"ImageSouce Create Fail, id = %{public}d, accessId = %{public}lld, src = %{private}s.", nodeId, accessId,
srcStr.c_str());
TAG_LOGE(AceLogTag::ACE_IMAGE, "ImageSouce Create Fail, %{private}s-%{public}s.", src.c_str(),
imageDfxConfig.ToStringWithoutSrc().c_str());
return nullptr;
}
@ -91,28 +80,23 @@ RefPtr<CanvasImage> ImageDecoder::MakePixmapImage(AIImageQuality imageQuality, b
auto height = std::lround(desiredSize_.Height());
std::pair<int32_t, int32_t> sourceSize = source->GetImageSize();
ACE_SCOPED_TRACE("CreateImagePixelMap %s, sourceSize: [ %d, %d ], targetSize: [ %d, %d ], hdr: [%d], quality: [%d]",
srcStr.c_str(), sourceSize.first, sourceSize.second, static_cast<int32_t>(width), static_cast<int32_t>(height),
src.c_str(), sourceSize.first, sourceSize.second, static_cast<int32_t>(width), static_cast<int32_t>(height),
static_cast<int32_t>(isHdrDecoderNeed), static_cast<int32_t>(imageQuality));
auto pixmap = source->CreatePixelMap({ width, height }, imageQuality, isHdrDecoderNeed);
if (!pixmap) {
TAG_LOGE(AceLogTag::ACE_IMAGE, "PixelMap Create Fail, id = %{public}d-%{public}lld, src = %{private}s.", nodeId,
accessId, srcStr.c_str());
TAG_LOGE(AceLogTag::ACE_IMAGE, "PixelMap Create Fail, src = %{private}s-%{public}s.", src.c_str(),
imageDfxConfig.ToStringWithoutSrc().c_str());
return nullptr;
}
if (SystemProperties::GetDebugPixelMapSaveEnabled()) {
TAG_LOGI(AceLogTag::ACE_IMAGE, "Image Decode success, Info:[%{public}s]-[%{public}d x %{public}d]",
ImageDfxConfigToString(imageDfxConfig).c_str(), pixmap->GetWidth(), pixmap->GetHeight());
pixmap->SavePixelMapToFile(std::to_string(nodeId) + "_" + std::to_string(accessId) + "_decode_");
}
auto image = PixelMapImage::Create(pixmap);
if (SystemProperties::GetDebugEnabled()) {
TAG_LOGD(AceLogTag::ACE_IMAGE,
"decode to pixmap, src=%{private}s, resolutionQuality=%{public}s, desiredSize=%{public}s, pixmap size = "
"%{public}d x %{public}d",
obj_->GetSourceInfo().ToString().c_str(), GetResolutionQuality(imageQuality).c_str(),
desiredSize_.ToString().c_str(), image->GetWidth(), image->GetHeight());
auto image = PixelMapImage::Create(pixmap);
if (SystemProperties::GetDebugPixelMapSaveEnabled()) {
TAG_LOGI(AceLogTag::ACE_IMAGE,
"Image Decode success, Info:%{public}s-%{public}s-%{public}s-%{public}d x %{public}d-%{public}d",
imageDfxConfig.ToStringWithSrc().c_str(), GetResolutionQuality(imageQuality).c_str(),
desiredSize_.ToString().c_str(), image->GetWidth(), image->GetHeight(), isHdrDecoderNeed);
pixmap->SavePixelMapToFile(imageDfxConfig.ToStringWithoutSrc() + "_decode_");
}
return image;

View File

@ -185,6 +185,7 @@ void ImageLoadingContext::OnDataLoading()
}
return;
}
src_.SetImageDfxConfig(GetImageDfxConfig());
ImageProvider::CreateImageObject(src_, WeakClaim(this), syncLoad_);
}
@ -229,8 +230,7 @@ void ImageLoadingContext::DownloadImage()
void ImageLoadingContext::PerformDownload()
{
ACE_SCOPED_TRACE("PerformDownload [%d]-[%lld], src: [%s]", imageDfxConfig_.nodeId_,
static_cast<long long>(imageDfxConfig_.accessibilityId_), src_.GetSrc().c_str());
ACE_SCOPED_TRACE("PerformDownload %s", imageDfxConfig_.ToStringWithSrc().c_str());
DownloadCallback downloadCallback;
downloadCallback.successCallback = [weak = AceType::WeakClaim(this)](
const std::string&& imageData, bool async, int32_t instanceId) {
@ -282,13 +282,7 @@ void ImageLoadingContext::CacheDownloadedImage()
void ImageLoadingContext::DownloadImageSuccess(const std::string& imageData)
{
TAG_LOGI(AceLogTag::ACE_IMAGE,
"Download image successfully, nodeId = %{public}d, accessId = %{public}lld, srcInfo = %{private}s, ImageData "
"length=%{public}zu",
imageDfxConfig_.nodeId_, static_cast<long long>(imageDfxConfig_.accessibilityId_), GetSrc().ToString().c_str(),
imageData.size());
ACE_SCOPED_TRACE("DownloadImageSuccess [%d]-[%lld], [%zu], src: [%s]", imageDfxConfig_.nodeId_,
static_cast<long long>(imageDfxConfig_.accessibilityId_), imageData.size(), src_.GetSrc().c_str());
ACE_SCOPED_TRACE("DownloadImageSuccess %s, [%zu]", imageDfxConfig_.ToStringWithSrc().c_str(), imageData.size());
if (!Positive(imageData.size())) {
FailCallback("The length of imageData from netStack is not positive");
return;
@ -397,10 +391,9 @@ void ImageLoadingContext::FailCallback(const std::string& errorMsg)
{
errorMsg_ = errorMsg;
needErrorCallBack_ = true;
TAG_LOGW(AceLogTag::ACE_IMAGE, "Image LoadFail, src = %{private}s, reason: %{public}s, %{public}s",
src_.ToString().c_str(), errorMsg.c_str(), imageDfxConfig_.ToStringWithoutSrc().c_str());
CHECK_NULL_VOID(measureFinish_);
TAG_LOGW(AceLogTag::ACE_IMAGE, "Image LoadFail, src = %{private}s, reason: %{public}s, [%{public}d]-[%{public}lld]",
src_.ToString().c_str(), errorMsg.c_str(), imageDfxConfig_.nodeId_,
static_cast<long long>(imageDfxConfig_.accessibilityId_));
if (Downloadable()) {
ImageFileCache::GetInstance().EraseCacheFile(GetSourceInfo().GetSrc());
}

View File

@ -60,8 +60,8 @@ bool ImageProvider::PrepareImageData(const RefPtr<ImageObject>& imageObj)
auto container = Container::Current();
if (container && container->IsSubContainer()) {
TAG_LOGW(AceLogTag::ACE_IMAGE, "subContainer's pipeline's dataProviderManager is null, cannot load image "
"source, need to switch pipeline in parentContainer.");
TAG_LOGW(AceLogTag::ACE_IMAGE, "%{private}s-%{public}s. subContainer's pipeline's dataProviderManager is null.",
dfxConfig.imageSrc_.c_str(), dfxConfig.ToStringWithoutSrc().c_str());
auto currentId = SubwindowManager::GetInstance()->GetParentContainerId(Container::CurrentId());
container = Container::GetContainer(currentId);
}
@ -71,10 +71,8 @@ bool ImageProvider::PrepareImageData(const RefPtr<ImageObject>& imageObj)
// if image object has no skData, reload data.
auto imageLoader = ImageLoader::CreateImageLoader(imageObj->GetSourceInfo());
if (!imageLoader) {
TAG_LOGW(AceLogTag::ACE_IMAGE,
"Failed to create loader in prepareImageData. src = %{private}s, nodeId = %{public}d, accessibilityId = "
"%{public}lld.",
dfxConfig.imageSrc_.c_str(), dfxConfig.nodeId_, static_cast<long long>(dfxConfig.accessibilityId_));
TAG_LOGW(AceLogTag::ACE_IMAGE, "Failed to create loader in prepareImageData. %{public}s-[%{private}s]",
dfxConfig.ToStringWithoutSrc().c_str(), dfxConfig.imageSrc_.c_str());
return false;
}
auto newLoadedData = imageLoader->GetImageData(imageObj->GetSourceInfo(), WeakClaim(RawPtr(pipeline)));
@ -164,15 +162,11 @@ void ImageProvider::SuccessCallback(const RefPtr<CanvasImage>& canvasImage, cons
void ImageProvider::CreateImageObjHelper(const ImageSourceInfo& src, bool sync)
{
const ImageDfxConfig& imageDfxConfig = src.GetImageDfxConfig();
auto nodeId = imageDfxConfig.nodeId_;
auto accessId = imageDfxConfig.accessibilityId_;
ACE_SCOPED_TRACE(
"CreateImageObj [%s]-[%d]-[%lld]", src.ToString().c_str(), nodeId, static_cast<long long>(accessId));
ACE_SCOPED_TRACE("CreateImageObj %s", imageDfxConfig.ToStringWithSrc().c_str());
// load image data
auto imageLoader = ImageLoader::CreateImageLoader(src);
if (!imageLoader) {
std::string errorMessage("Failed to create image loader.");
FailCallback(src.GetKey(), src.ToString() + errorMessage, sync);
FailCallback(src.GetKey(), "Failed to create image loader.", sync);
return;
}
auto pipeline = PipelineContext::GetCurrentContext();
@ -185,9 +179,6 @@ void ImageProvider::CreateImageObjHelper(const ImageSourceInfo& src, bool sync)
// build ImageObject
RefPtr<ImageObject> imageObj = ImageProvider::BuildImageObject(src, data);
if (!imageObj) {
TAG_LOGW(AceLogTag::ACE_IMAGE,
"Failed to build image object. src = %{private}s, nodeId = %{public}d-%{public}lld.",
src.ToString().c_str(), nodeId, static_cast<long long>(accessId));
FailCallback(src.GetKey(), "Failed to build image object", sync);
return;
}
@ -270,6 +261,9 @@ void ImageProvider::CreateImageObject(const ImageSourceInfo& src, const WeakPtr<
{
if (!RegisterTask(src.GetKey(), ctxWp)) {
// task is already running, only register callbacks
auto&& dfxConfig = src.GetImageDfxConfig();
TAG_LOGW(AceLogTag::ACE_IMAGE, "Register CreateImageObject fail. src = %{private}s-%{public}s.",
dfxConfig.imageSrc_.c_str(), dfxConfig.ToStringWithoutSrc().c_str());
return;
}
if (sync) {
@ -290,10 +284,8 @@ RefPtr<ImageObject> ImageProvider::BuildImageObject(const ImageSourceInfo& src,
{
auto imageDfxConfig = src.GetImageDfxConfig();
if (!data) {
TAG_LOGW(AceLogTag::ACE_IMAGE,
"data is null when try ParseImageObjectType, src: %{private}s, nodeID = %{public}d-%{public}lld.",
imageDfxConfig.imageSrc_.c_str(), imageDfxConfig.nodeId_,
static_cast<long long>(imageDfxConfig.accessibilityId_));
TAG_LOGW(AceLogTag::ACE_IMAGE, "data is null when try ParseImageObjectType, [%{private}s]-%{public}s.",
imageDfxConfig.imageSrc_.c_str(), imageDfxConfig.ToStringWithoutSrc().c_str());
return nullptr;
}
if (src.IsSvg()) {
@ -306,9 +298,8 @@ RefPtr<ImageObject> ImageProvider::BuildImageObject(const ImageSourceInfo& src,
auto rosenImageData = DynamicCast<DrawingImageData>(data);
if (!rosenImageData) {
TAG_LOGW(AceLogTag::ACE_IMAGE, "rosenImageData null, src: %{private}s, nodeID = %{public}d-%{public}lld.",
imageDfxConfig.imageSrc_.c_str(), imageDfxConfig.nodeId_,
static_cast<long long>(imageDfxConfig.accessibilityId_));
TAG_LOGW(AceLogTag::ACE_IMAGE, "rosenImageData null, [%{private}s]-%{public}s.",
imageDfxConfig.imageSrc_.c_str(), imageDfxConfig.ToStringWithoutSrc().c_str());
return nullptr;
}
rosenImageData->SetDfxConfig(imageDfxConfig.nodeId_, imageDfxConfig.accessibilityId_);
@ -316,9 +307,9 @@ RefPtr<ImageObject> ImageProvider::BuildImageObject(const ImageSourceInfo& src,
if (!size.IsPositive()) {
TAG_LOGW(AceLogTag::ACE_IMAGE,
"Image of src: %{private}s, imageData's size = %{public}d is invalid, and the parsed size is invalid "
"%{private}s, frameCount is %{public}d, nodeId = %{public}d-%{public}lld.",
"%{private}s, frameCount is %{public}d, nodeId = %{public}s.",
src.ToString().c_str(), static_cast<int32_t>(data->GetSize()), size.ToString().c_str(), frameCount,
imageDfxConfig.nodeId_, static_cast<long long>(imageDfxConfig.accessibilityId_));
imageDfxConfig.ToStringWithoutSrc().c_str());
return nullptr;
}
if (frameCount > 1) {
@ -336,9 +327,8 @@ void ImageProvider::MakeCanvasImage(const RefPtr<ImageObject>& obj, const WeakPt
auto&& dfxConfig = obj->GetImageDfxConfig();
// check if same task is already executing
if (!RegisterTask(key, ctxWp)) {
TAG_LOGW(AceLogTag::ACE_IMAGE,
"Register decoderTask fail. src = %{private}s, nodeId = %{public}d, accessibilityId = %{public}lld.",
dfxConfig.imageSrc_.c_str(), dfxConfig.nodeId_, static_cast<long long>(dfxConfig.accessibilityId_));
TAG_LOGW(AceLogTag::ACE_IMAGE, "Register decoderTask fail. src = %{private}s-%{public}s.",
dfxConfig.imageSrc_.c_str(), dfxConfig.ToStringWithoutSrc().c_str());
return;
}
if (imageDecoderOptions.sync) {

View File

@ -16,12 +16,86 @@
#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_IMAGE_IMAGE_DFX_H
#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_IMAGE_IMAGE_DFX_H
#include <string>
#include "base/image/pixel_map.h"
namespace OHOS::Ace::NG {
struct ImageDfxConfig {
int32_t nodeId_ = -1;
int64_t accessibilityId_ = -1;
std::string imageSrc_;
std::string borderRadiusValue_;
// Used in tracing functions, does not include image source information (sensitive data)
std::string ToStringWithoutSrc() const
{
std::string result = std::string("[")
.append(std::to_string(nodeId_))
.append("-")
.append(std::to_string(accessibilityId_))
.append("]");
return result;
}
// Includes image source, but as the image source may be sensitive, use with caution
std::string ToStringWithSrc() const
{
std::string result = std::string("[")
.append(std::to_string(nodeId_))
.append("-")
.append(std::to_string(accessibilityId_))
.append("]-[")
.append(imageSrc_)
.append("]");
return result;
}
};
struct RenderedImageInfo {
// Indicates whether the rendering has been successfully displayed.
bool renderSuccess = false;
// PixelMap info
int32_t width = 0;
int32_t height = 0;
int32_t rowStride = 0;
int32_t rowBytes = 0;
int32_t byteCount = 0;
bool isHdr = false;
AlphaType alphaType = AlphaType::IMAGE_ALPHA_TYPE_UNKNOWN;
PixelFormat pixelFormat = PixelFormat::UNKNOWN;
AllocatorType allocatorType = AllocatorType::DEFAULT;
std::string pixelMapId;
std::string srcInfo;
std::string ToString() const
{
if (!renderSuccess) {
return "RenderedImageInfo: { RenderStatus: NotRender }";
}
std::string result;
result.append("RenderedImageInfo: {")
.append("RenderStatus: Success")
.append(", Width: ")
.append(std::to_string(width))
.append(", Height: ")
.append(std::to_string(height))
.append(", Row Stride: ")
.append(std::to_string(rowStride))
.append(", Row Bytes: ")
.append(std::to_string(rowBytes))
.append(", Byte Count: ")
.append(std::to_string(byteCount))
.append(", Is HDR: ")
.append(isHdr ? "true" : "false")
.append(", Alpha Type: ")
.append(std::to_string(static_cast<int>(alphaType)))
.append(", Pixel Format: ")
.append(std::to_string(static_cast<int>(pixelFormat)))
.append(", Allocator Type: ")
.append(std::to_string(static_cast<int>(allocatorType)))
.append(", Pixel Map ID: ")
.append(pixelMapId)
.append(" }");
return result;
}
};
} // namespace OHOS::Ace::NG
#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_IMAGE_IMAGE_DFX_H

View File

@ -755,9 +755,6 @@ void ImageModelNG::SetAltPixelMap(FrameNode* frameNode, void* pixelMap)
void ImageModelNG::SetImageInterpolation(FrameNode *frameNode, ImageInterpolation interpolation)
{
ACE_UPDATE_NODE_PAINT_PROPERTY(ImageRenderProperty, ImageInterpolation, interpolation, frameNode);
auto pattern = ViewStackProcessor::GetInstance()->GetMainFrameNodePattern<ImagePattern>();
CHECK_NULL_VOID(pattern);
pattern->SetImageInterpolation(interpolation);
}
void ImageModelNG::ResetImageInterpolation(FrameNode *frameNode)

View File

@ -35,10 +35,33 @@ constexpr uint32_t CRITICAL_TIME = 50; // ms. If show time of image is less
constexpr int64_t MICROSEC_TO_MILLISEC = 1000;
constexpr int32_t DEFAULT_ITERATIONS = 1;
constexpr int32_t MEMORY_LEVEL_CRITICAL_STATUS = 2;
std::string ImageDfxConfigToString(const ImageDfxConfig& imageDfxConfig)
std::string GetImageInterpolation(ImageInterpolation interpolation)
{
return "src = " + imageDfxConfig.imageSrc_ + ", nodeInfo = [" + std::to_string(imageDfxConfig.nodeId_) + "-" +
std::to_string(imageDfxConfig.accessibilityId_) + "]";
switch (interpolation) {
case ImageInterpolation::LOW:
return "LOW";
case ImageInterpolation::MEDIUM:
return "MEDIUM";
case ImageInterpolation::HIGH:
return "HIGH";
default:
return "NONE";
}
}
std::string GetDynamicModeString(DynamicRangeMode dynamicMode)
{
switch (dynamicMode) {
case DynamicRangeMode::HIGH:
return "HIGH";
case DynamicRangeMode::CONSTRAINT:
return "CONSTRAINT";
case DynamicRangeMode::STANDARD:
return "STANDARD";
default:
return "STANDARD";
}
}
} // namespace
@ -71,10 +94,10 @@ DataReadyNotifyTask ImagePattern::CreateDataReadyCallback()
auto currentSourceInfo = imageLayoutProperty->GetImageSourceInfo().value_or(ImageSourceInfo(""));
if (currentSourceInfo != sourceInfo) {
TAG_LOGW(AceLogTag::ACE_IMAGE,
"sourceInfo does not match, ignore current callback. nodeId = %{public}d, accessibilityId = "
"%{public}lld. current: %{private}s vs callback's: %{private}s",
pattern->imageDfxConfig_.nodeId_, static_cast<long long>(pattern->imageDfxConfig_.accessibilityId_),
currentSourceInfo.ToString().c_str(), sourceInfo.ToString().c_str());
"sourceInfo does not match, ignore current callback. %{public}s."
"current: %{private}s vs callback's: %{private}s",
pattern->imageDfxConfig_.ToStringWithoutSrc().c_str(), currentSourceInfo.ToString().c_str(),
sourceInfo.ToString().c_str());
return;
}
pattern->OnImageDataReady();
@ -91,10 +114,10 @@ LoadSuccessNotifyTask ImagePattern::CreateLoadSuccessCallback()
auto currentSourceInfo = imageLayoutProperty->GetImageSourceInfo().value_or(ImageSourceInfo(""));
if (currentSourceInfo != sourceInfo) {
TAG_LOGW(AceLogTag::ACE_IMAGE,
"sourceInfo does not match, ignore current callback. nodeId = %{public}d, accessibilityId = "
"%{public}lld. current: %{private}s vs callback's: %{private}s",
pattern->imageDfxConfig_.nodeId_, static_cast<long long>(pattern->imageDfxConfig_.accessibilityId_),
currentSourceInfo.ToString().c_str(), sourceInfo.ToString().c_str());
"sourceInfo does not match, ignore current callback. %{public}s."
"current: %{private}s vs callback's: %{private}s",
pattern->imageDfxConfig_.ToStringWithoutSrc().c_str(), currentSourceInfo.ToString().c_str(),
sourceInfo.ToString().c_str());
return;
}
pattern->OnImageLoadSuccess();
@ -111,10 +134,10 @@ LoadFailNotifyTask ImagePattern::CreateLoadFailCallback()
auto currentSourceInfo = imageLayoutProperty->GetImageSourceInfo().value_or(ImageSourceInfo(""));
if (currentSourceInfo != sourceInfo) {
TAG_LOGW(AceLogTag::ACE_IMAGE,
"sourceInfo does not match, ignore current callback. nodeId = %{public}d, accessibilityId = "
"%{public}lld. current: %{private}s vs callback's: %{private}s",
pattern->imageDfxConfig_.nodeId_, static_cast<long long>(pattern->imageDfxConfig_.accessibilityId_),
currentSourceInfo.ToString().c_str(), sourceInfo.ToString().c_str());
"sourceInfo does not match, ignore current callback. %{public}s."
"current: %{private}s vs callback's: %{private}s",
pattern->imageDfxConfig_.ToStringWithoutSrc().c_str(), currentSourceInfo.ToString().c_str(),
sourceInfo.ToString().c_str());
return;
}
if (!currentSourceInfo.IsFromReset()) {
@ -133,10 +156,10 @@ OnCompleteInDataReadyNotifyTask ImagePattern::CreateCompleteCallBackInDataReady(
auto currentSourceInfo = imageLayoutProperty->GetImageSourceInfo().value_or(ImageSourceInfo(""));
if (currentSourceInfo != sourceInfo) {
TAG_LOGW(AceLogTag::ACE_IMAGE,
"sourceInfo does not match, ignore current callback. nodeId = %{public}d, accessibilityId = "
"%{public}lld. current: %{private}s vs callback's: %{private}s",
pattern->imageDfxConfig_.nodeId_, static_cast<long long>(pattern->imageDfxConfig_.accessibilityId_),
currentSourceInfo.ToString().c_str(), sourceInfo.ToString().c_str());
"sourceInfo does not match, ignore current callback. %{public}s."
"current: %{private}s vs callback's: %{private}s",
pattern->imageDfxConfig_.ToStringWithoutSrc().c_str(), currentSourceInfo.ToString().c_str(),
sourceInfo.ToString().c_str());
return;
}
pattern->OnCompleteInDataReady();
@ -171,15 +194,10 @@ void ImagePattern::TriggerFirstVisibleAreaChange()
RectF visibleRect;
host->GetVisibleRectWithClip(visibleRect, visibleInnerRect, frameRect);
bool visible = GreatNotEqual(visibleInnerRect.Width(), 0.0) && GreatNotEqual(visibleInnerRect.Height(), 0.0);
ACE_SCOPED_TRACE("TriggerFirstVisibleAreaChange visible: [%d], imageInfo: [%d]-[%lld]-[%s]", visible,
imageDfxConfig_.nodeId_, static_cast<long long>(imageDfxConfig_.accessibilityId_),
imageDfxConfig_.imageSrc_.c_str());
ACE_SCOPED_TRACE("TriggerFirstVisibleAreaChange [%d]-%s", visible, imageDfxConfig_.ToStringWithSrc().c_str());
if (SystemProperties::GetDebugEnabled()) {
TAG_LOGD(AceLogTag::ACE_IMAGE,
"TriggerFirstVisibleAreaChange visible:%{public}d, imageInfo: id = %{public}d, accessId = %{public}lld, "
"src = %{public}s",
visible, imageDfxConfig_.nodeId_, static_cast<long long>(imageDfxConfig_.accessibilityId_),
imageDfxConfig_.imageSrc_.c_str());
TAG_LOGD(AceLogTag::ACE_IMAGE, "TriggerFirstVisibleAreaChange [%{public}d]-%{public}s", visible,
imageDfxConfig_.ToStringWithSrc().c_str());
}
OnVisibleAreaChange(visible);
}
@ -379,8 +397,8 @@ void ImagePattern::OnImageLoadSuccess()
image_ = loadingCtx_->MoveCanvasImage();
if (!image_) {
TAG_LOGW(AceLogTag::ACE_IMAGE, "nodeId = %{public}d OnImageLoadSuccess but Canvas image is null.",
imageDfxConfig_.nodeId_);
TAG_LOGW(AceLogTag::ACE_IMAGE, "%{public}s, %{private}s OnImageLoadSuccess but Canvas image is null.",
imageDfxConfig_.ToStringWithoutSrc().c_str(), imageDfxConfig_.imageSrc_.c_str());
return;
}
srcRect_ = loadingCtx_->GetSrcRect();
@ -399,7 +417,7 @@ void ImagePattern::OnImageLoadSuccess()
UpdateSvgSmoothEdgeValue();
}
PrepareAnimation(image_);
if (host->IsDraggable()) {
if (enableDrag_) {
EnableDrag();
}
ClearAltData();
@ -410,10 +428,9 @@ void ImagePattern::OnImageLoadSuccess()
ApplyAIModificationsToImage();
ACE_SCOPED_TRACE("OnImageLoadSuccess [%d]-[%lld], srr: [%s]", imageDfxConfig_.nodeId_,
static_cast<long long>(imageDfxConfig_.accessibilityId_), imageDfxConfig_.imageSrc_.c_str());
ACE_SCOPED_TRACE("OnImageLoadSuccess %s", imageDfxConfig_.ToStringWithSrc().c_str());
if (SystemProperties::GetDebugEnabled()) {
TAG_LOGD(AceLogTag::ACE_IMAGE, "ImageLoadSuccess %{public}s", ImageDfxConfigToString(imageDfxConfig_).c_str());
TAG_LOGI(AceLogTag::ACE_IMAGE, "ImageLoadSuccess %{public}s", imageDfxConfig_.ToStringWithSrc().c_str());
}
host->MarkNeedRenderOnly();
}
@ -542,14 +559,24 @@ RefPtr<NodePaintMethod> ImagePattern::CreateNodePaintMethod()
.imageContentModifier = contentMod_,
.interpolation = interpolationDefault_
};
// Callback function executed after the graphics rendering is complete.
auto drawCompleteCallback = [weakPattern = WeakClaim(this)](const RenderedImageInfo& renderedImageInfo) {
auto pattern = weakPattern.Upgrade();
CHECK_NULL_VOID(pattern);
// Mark the rendering as successful on the instance.
pattern->SetRenderedImageInfo(std::move(renderedImageInfo));
};
if (image_) {
image_->SetDrawCompleteCallback(std::move(drawCompleteCallback));
return MakeRefPtr<ImagePaintMethod>(image_, imagePaintMethodConfig);
}
if (altImage_ && altDstRect_ && altSrcRect_) {
altImage_->SetDrawCompleteCallback(std::move(drawCompleteCallback));
return MakeRefPtr<ImagePaintMethod>(altImage_, imagePaintMethodConfig);
}
CreateObscuredImage();
if (obscuredImage_) {
obscuredImage_->SetDrawCompleteCallback(std::move(drawCompleteCallback));
return MakeRefPtr<ImagePaintMethod>(obscuredImage_, imagePaintMethodConfig);
}
return MakeRefPtr<ImagePaintMethod>(nullptr, imagePaintMethodConfig);
@ -650,7 +677,7 @@ void ImagePattern::LoadImage(
loadingCtx_ = AceType::MakeRefPtr<ImageLoadingContext>(src, std::move(loadNotifier), syncLoad_, imageDfxConfig_);
if (SystemProperties::GetDebugEnabled()) {
TAG_LOGD(AceLogTag::ACE_IMAGE, "load image, %{public}s", ImageDfxConfigToString(imageDfxConfig_).c_str());
TAG_LOGI(AceLogTag::ACE_IMAGE, "load image, %{public}s", imageDfxConfig_.ToStringWithSrc().c_str());
}
if (onProgressCallback_) {
@ -660,6 +687,8 @@ void ImagePattern::LoadImage(
visibleType == VisibleType::GONE) {
loadingCtx_->FinishMearuse();
}
// Before loading new image data, reset the render success status to `false`.
renderedImageInfo_.renderSuccess = false;
loadingCtx_->LoadImageData();
}
@ -737,6 +766,8 @@ void ImagePattern::UpdateGestureAndDragWhenModify()
mouseEvent_ = nullptr;
}
enableDrag_ = host->IsDraggable();
if (host->IsDraggable()) {
EnableDrag();
}
@ -923,10 +954,10 @@ DataReadyNotifyTask ImagePattern::CreateDataReadyCallbackForAlt()
auto currentAltSourceInfo = imageLayoutProperty->GetAlt().value_or(ImageSourceInfo(""));
if (currentAltSourceInfo != sourceInfo) {
TAG_LOGW(AceLogTag::ACE_IMAGE,
"alt image sourceInfo does not match, ignore current callback. nodeId = %{public}d, accessibilityId = "
"%{public}lld. current: %{private}s vs callback's: %{private}s",
pattern->imageDfxConfig_.nodeId_, static_cast<long long>(pattern->imageDfxConfig_.accessibilityId_),
currentAltSourceInfo.ToString().c_str(), sourceInfo.ToString().c_str());
"alt image sourceInfo does not match, ignore current callback. %{public}s. current: %{private}s vs "
"callback's: %{private}s",
pattern->imageDfxConfig_.ToStringWithoutSrc().c_str(), currentAltSourceInfo.ToString().c_str(),
sourceInfo.ToString().c_str());
return;
}
auto host = pattern->GetHost();
@ -957,10 +988,10 @@ LoadSuccessNotifyTask ImagePattern::CreateLoadSuccessCallbackForAlt()
auto currentAltSrc = layoutProps->GetAlt().value_or(ImageSourceInfo(""));
if (currentAltSrc != sourceInfo) {
TAG_LOGW(AceLogTag::ACE_IMAGE,
"alt image sourceInfo does not match, ignore current callback. nodeId = %{public}d, accessibilityId = "
"%{public}lld. current: %{private}s vs callback's: %{private}s",
pattern->imageDfxConfig_.nodeId_, static_cast<long long>(pattern->imageDfxConfig_.accessibilityId_),
currentAltSrc.ToString().c_str(), sourceInfo.ToString().c_str());
"alt image sourceInfo does not match, ignore current callback. %{public}s. current: %{private}s vs "
"callback's: %{private}s",
pattern->imageDfxConfig_.ToStringWithoutSrc().c_str(), currentAltSrc.ToString().c_str(),
sourceInfo.ToString().c_str());
return;
}
pattern->altImage_ = pattern->altLoadingCtx_->MoveCanvasImage();
@ -1014,7 +1045,7 @@ void ImagePattern::OnNotifyMemoryLevel(int32_t level)
// when recycle image component, release the pixelmap resource
void ImagePattern::OnRecycle()
{
TAG_LOGI(AceLogTag::ACE_IMAGE, "OnRecycle. nodeId = %{public}d", imageDfxConfig_.nodeId_);
TAG_LOGI(AceLogTag::ACE_IMAGE, "OnRecycle. %{public}s", imageDfxConfig_.ToStringWithoutSrc().c_str());
loadingCtx_ = nullptr;
image_ = nullptr;
altLoadingCtx_ = nullptr;
@ -1064,8 +1095,8 @@ void ImagePattern::OnWindowHide()
void ImagePattern::OnWindowShow()
{
TAG_LOGW(AceLogTag::ACE_IMAGE, "OnWindowShow. nodeId = %{public}d isImageQualityChange_ = %{public}d",
imageDfxConfig_.nodeId_, isImageQualityChange_);
TAG_LOGW(AceLogTag::ACE_IMAGE, "OnWindowShow. %{public}s, isImageQualityChange_ = %{public}d",
imageDfxConfig_.ToStringWithoutSrc().c_str(), isImageQualityChange_);
isShow_ = true;
LoadImageDataIfNeed();
}
@ -1073,18 +1104,18 @@ void ImagePattern::OnWindowShow()
void ImagePattern::OnVisibleChange(bool visible)
{
if (!visible) {
TAG_LOGW(AceLogTag::ACE_IMAGE, "OnInVisible. nodeId = %{public}d", imageDfxConfig_.nodeId_);
TAG_LOGW(AceLogTag::ACE_IMAGE, "OnInVisible. %{public}s", imageDfxConfig_.ToStringWithoutSrc().c_str());
CloseSelectOverlay();
}
}
void ImagePattern::OnVisibleAreaChange(bool visible, double ratio)
{
ACE_SCOPED_TRACE("OnVisibleAreaChange visible: [%d], imageInfo: [%d]-[%lld]-[%s]", visible, imageDfxConfig_.nodeId_,
static_cast<long long>(imageDfxConfig_.accessibilityId_), imageDfxConfig_.imageSrc_.c_str());
ACE_SCOPED_TRACE(
"OnVisibleAreaChange visible: [%d], imageInfo: %s", visible, imageDfxConfig_.ToStringWithSrc().c_str());
if (SystemProperties::GetDebugEnabled()) {
TAG_LOGD(AceLogTag::ACE_IMAGE, "OnVisibleAreaChange visible:%{public}d, %{public}s", visible,
ImageDfxConfigToString(imageDfxConfig_).c_str());
TAG_LOGI(AceLogTag::ACE_IMAGE, "OnVisibleAreaChange visible:%{public}d, %{public}s", visible,
imageDfxConfig_.ToStringWithoutSrc().c_str());
}
if (!visible) {
CloseSelectOverlay();
@ -1326,9 +1357,7 @@ void ImagePattern::ToJsonValue(std::unique_ptr<JsonValue>& json, const Inspector
json->PutExtAttr("copyOption", COPY_OPTIONS[static_cast<int32_t>(copyOption_)], filter);
json->PutExtAttr("syncLoad", syncLoad_ ? "true" : "false", filter);
auto host = GetHost();
CHECK_NULL_VOID(host);
json->PutExtAttr("draggable", host->IsDraggable() ? "true" : "false", filter);
json->PutExtAttr("draggable", enableDrag_ ? "true" : "false", filter);
json->PutExtAttr("enableAnalyzer", isEnableAnalyzer_ ? "true" : "false", filter);
auto renderProp = GetPaintProperty<ImageRenderProperty>();
CHECK_NULL_VOID(renderProp);
@ -1339,27 +1368,9 @@ void ImagePattern::ToJsonValue(std::unique_ptr<JsonValue>& json, const Inspector
json->PutExtAttr("dynamicRangeMode", GetDynamicModeString(dynamicMode).c_str(), filter);
}
void ImagePattern::UpdateFillColorIfForegroundColor()
{
auto frameNode = GetHost();
CHECK_NULL_VOID(frameNode);
auto renderContext = frameNode->GetRenderContext();
CHECK_NULL_VOID(renderContext);
if (renderContext->HasForegroundColor() || renderContext->HasForegroundColorStrategy()) {
auto imageLayoutProperty = frameNode->GetLayoutProperty<ImageLayoutProperty>();
auto imageSourceInfo = imageLayoutProperty->GetImageSourceInfo().value();
if (imageSourceInfo.IsSvg()) {
imageSourceInfo.SetFillColor(Color::FOREGROUND);
imageLayoutProperty->UpdateImageSourceInfo(imageSourceInfo);
}
auto imageRenderProperty = frameNode->GetPaintProperty<ImageRenderProperty>();
CHECK_NULL_VOID(imageRenderProperty);
imageRenderProperty->UpdateSvgFillColor(Color::FOREGROUND);
}
}
void ImagePattern::DumpLayoutInfo()
{
DumpLog::GetInstance().AddDesc("---- Image Component Layout Dump ----");
auto layoutProp = GetLayoutProperty<ImageLayoutProperty>();
CHECK_NULL_VOID(layoutProp);
@ -1371,11 +1382,20 @@ void ImagePattern::DumpLayoutInfo()
DumpAutoResize(layoutProp);
}
inline void ImagePattern::DumpImageSourceInfo(const RefPtr<OHOS::Ace::NG::ImageLayoutProperty>& layoutProp)
void ImagePattern::DumpImageSourceInfo(const RefPtr<OHOS::Ace::NG::ImageLayoutProperty>& layoutProp)
{
auto src = layoutProp->GetImageSourceInfo().value_or(ImageSourceInfo(""));
DumpLog::GetInstance().AddDesc(std::string("url: ").append(src.ToString()));
DumpLog::GetInstance().AddDesc("SrcCacheKey: " + src.GetKey());
DumpLog::GetInstance().AddDesc(
std::string("SrcType: ").append(std::to_string(static_cast<int32_t>(src.GetSrcType()))));
DumpLog::GetInstance().AddDesc(
std::string("AbilityName: ").append(std::to_string(static_cast<int32_t>(SystemProperties::GetColorMode()))));
DumpLog::GetInstance().AddDesc(std::string("BundleName: ").append(src.GetBundleName()));
DumpLog::GetInstance().AddDesc(std::string("ModuleName: ").append(src.GetModuleName()));
DumpLog::GetInstance().AddDesc(
std::string("ColorMode: ").append(std::to_string(static_cast<int32_t>(SystemProperties::GetColorMode()))));
DumpLog::GetInstance().AddDesc(
std::string("LocalColorMode: ").append(std::to_string(static_cast<int32_t>(src.GetLocalColorMode()))));
}
inline void ImagePattern::DumpAltSourceInfo(const RefPtr<OHOS::Ace::NG::ImageLayoutProperty>& layoutProp)
@ -1412,6 +1432,7 @@ inline void ImagePattern::DumpAutoResize(const RefPtr<OHOS::Ace::NG::ImageLayout
void ImagePattern::DumpRenderInfo()
{
DumpLog::GetInstance().AddDesc("---- Image Component Render Dump ----");
auto renderProp = GetPaintProperty<ImageRenderProperty>();
CHECK_NULL_VOID(renderProp);
@ -1486,6 +1507,8 @@ inline void ImagePattern::DumpResizable(const RefPtr<OHOS::Ace::NG::ImageRenderP
if (renderProp->HasImageResizableSlice() && renderProp->GetImageResizableSliceValue({}).Valid()) {
DumpLog::GetInstance().AddDesc(
std::string("resizable slice: ").append(renderProp->GetImageResizableSliceValue({}).ToString()));
} else {
DumpLog::GetInstance().AddDesc(std::string("resizableSlice: Slice is null"));
}
auto resizableLattice = renderProp->GetImageResizableLatticeValue(nullptr);
@ -1514,29 +1537,34 @@ void ImagePattern::DumpBorderRadiusProperties(const RefPtr<OHOS::Ace::NG::ImageR
}
}
void ImagePattern::DumpInterpolation(const RefPtr<OHOS::Ace::NG::ImageRenderProperty>& renderProp)
{
auto imageInterpolation = renderProp->GetImageInterpolation().value_or(interpolationDefault_);
DumpLog::GetInstance().AddDesc("imageInterpolation:" + GetImageInterpolation(imageInterpolation));
}
void ImagePattern::DumpSvgInfo()
{
DumpLog::GetInstance().AddDesc("---- SVG Related Dump ----");
DumpLog::GetInstance().AddDesc("Your SVG related log description here");
auto imageLayoutProperty = GetLayoutProperty<ImageLayoutProperty>();
CHECK_NULL_VOID(imageLayoutProperty);
auto imageSourceInfo = imageLayoutProperty->GetImageSourceInfo();
CHECK_NULL_VOID(imageSourceInfo);
if (!imageSourceInfo->IsSvg()|| !loadingCtx_) {
if (!imageSourceInfo->IsSvg() || !loadingCtx_) {
return;
}
auto imageObject = loadingCtx_->GetImageObject();
CHECK_NULL_VOID(imageObject);
DumpLog::GetInstance().AddDesc(
std::string("Svg:").append(imageObject->GetDumpInfo()));
DumpLog::GetInstance().AddDesc(std::string("Svg:").append(imageObject->GetDumpInfo()));
}
void ImagePattern::DumpInfo()
void ImagePattern::DumpOtherInfo()
{
DumpLayoutInfo();
DumpRenderInfo();
DumpLog::GetInstance().AddDesc("---- Image Component (Excluding Layout and Drawing) Other Info Dump ----");
DumpLog::GetInstance().AddDesc(renderedImageInfo_.ToString());
syncLoad_ ? DumpLog::GetInstance().AddDesc("syncLoad:true") : DumpLog::GetInstance().AddDesc("syncLoad:false");
DumpLog::GetInstance().AddDesc("imageInterpolation:" + GetImageInterpolation());
if (loadingCtx_) {
auto currentLoadImageState = loadingCtx_->GetCurrentLoadingState();
DumpLog::GetInstance().AddDesc(std::string("currentLoadImageState : ").append(currentLoadImageState));
@ -1546,14 +1574,16 @@ void ImagePattern::DumpInfo()
DumpLog::GetInstance().AddDesc(std::string("imageLoadingContext: null"));
}
auto host = GetHost();
if (host) {
auto enDrage = host->IsDraggable();
enDrage ? DumpLog::GetInstance().AddDesc("draggable:true") : DumpLog::GetInstance().AddDesc("draggable:false");
}
enableDrag_ ? DumpLog::GetInstance().AddDesc("draggable:true") : DumpLog::GetInstance().AddDesc("draggable:false");
DumpLog::GetInstance().AddDesc(std::string("enableAnalyzer: ").append(isEnableAnalyzer_ ? "true" : "false"));
}
void ImagePattern::DumpInfo()
{
DumpLayoutInfo();
DumpRenderInfo();
DumpSvgInfo();
DumpOtherInfo();
}
void ImagePattern::DumpAdvanceInfo()
@ -2337,8 +2367,6 @@ void ImagePattern::DumpInfo(std::unique_ptr<JsonValue>& json)
DumpLayoutInfo(json);
DumpRenderInfo(json);
json->Put("syncLoad", syncLoad_);
json->Put("autoResize", autoResizeDefault_);
json->Put("imageInterpolation", GetImageInterpolation().c_str());
if (loadingCtx_) {
auto currentLoadImageState = loadingCtx_->GetCurrentLoadingState();
json->Put("currentLoadImageState", currentLoadImageState.c_str());
@ -2348,14 +2376,15 @@ void ImagePattern::DumpInfo(std::unique_ptr<JsonValue>& json)
json->Put("imageLoadingContext", "null");
}
auto host = GetHost();
if (host) {
auto enDrage = host->IsDraggable();
json->Put("draggable", enDrage);
}
json->Put("draggable", enableDrag_);
json->Put("enableAnalyzer", isEnableAnalyzer_);
}
void ImagePattern::DumpSimplifyInfo(std::unique_ptr<JsonValue>& json)
{
DumpInfo(json);
}
void ImagePattern::DumpLayoutInfo(std::unique_ptr<JsonValue>& json)
{
auto layoutProp = GetLayoutProperty<ImageLayoutProperty>();
@ -2372,6 +2401,8 @@ void ImagePattern::DumpLayoutInfo(std::unique_ptr<JsonValue>& json)
if (sourceSize.has_value()) {
json->Put("sourceSize", sourceSize.value().ToString().c_str());
}
bool autoResize = layoutProp->GetAutoResize().value_or(autoResizeDefault_);
json->Put("autoResize", autoResize);
}
void ImagePattern::DumpRenderInfo(std::unique_ptr<JsonValue>& json)
@ -2408,6 +2439,8 @@ void ImagePattern::DumpRenderInfo(std::unique_ptr<JsonValue>& json)
if (renderProp && renderProp->HasImageResizableSlice() && renderProp->GetImageResizableSliceValue({}).Valid()) {
json->Put("resizable slice", renderProp->GetImageResizableSliceValue({}).ToString().c_str());
}
auto imageInterpolation = renderProp->GetImageInterpolation().value_or(interpolationDefault_);
json->Put("imageInterpolation", GetImageInterpolation(imageInterpolation).c_str());
}
void ImagePattern::DumpAdvanceInfo(std::unique_ptr<JsonValue>& json)

View File

@ -153,39 +153,6 @@ public:
copyOption_ = value;
}
void SetImageInterpolation(ImageInterpolation value)
{
interpolation_ = value;
}
std::string GetImageInterpolation()
{
switch (interpolation_) {
case ImageInterpolation::LOW:
return "LOW";
case ImageInterpolation::MEDIUM:
return "MEDIUM";
case ImageInterpolation::HIGH:
return "HIGH";
default:
return "NONE";
}
}
std::string GetDynamicModeString(DynamicRangeMode dynamicMode) const
{
switch (dynamicMode) {
case DynamicRangeMode::HIGH:
return "HIGH";
case DynamicRangeMode::CONSTRAINT:
return "CONSTRAINT";
case DynamicRangeMode::STANDARD:
return "STANDARD";
default:
return "STANDARD";
}
}
std::string GetImageFitStr(ImageFit value);
std::string GetImageRepeatStr(ImageRepeat value);
@ -213,9 +180,9 @@ public:
void BeforeCreatePaintWrapper() override;
void DumpInfo() override;
void DumpInfo(std::unique_ptr<JsonValue>& json) override;
void DumpSimplifyInfo(std::unique_ptr<JsonValue>& json) override {}
void DumpSimplifyInfo(std::unique_ptr<JsonValue>& json) override;
void DumpLayoutInfo();
inline void DumpImageSourceInfo(const RefPtr<OHOS::Ace::NG::ImageLayoutProperty>& layoutProp);
void DumpImageSourceInfo(const RefPtr<OHOS::Ace::NG::ImageLayoutProperty>& layoutProp);
inline void DumpAltSourceInfo(const RefPtr<OHOS::Ace::NG::ImageLayoutProperty>& layoutProp);
inline void DumpImageFit(const RefPtr<OHOS::Ace::NG::ImageLayoutProperty>& layoutProp);
inline void DumpFitOriginalSize(const RefPtr<OHOS::Ace::NG::ImageLayoutProperty>& layoutProp);
@ -231,7 +198,9 @@ public:
inline void DumpMatchTextDirection(const RefPtr<OHOS::Ace::NG::ImageRenderProperty>& renderProp);
inline void DumpSmoothEdge(const RefPtr<OHOS::Ace::NG::ImageRenderProperty>& renderProp);
inline void DumpResizable(const RefPtr<OHOS::Ace::NG::ImageRenderProperty>& renderProp);
inline void DumpInterpolation(const RefPtr<OHOS::Ace::NG::ImageRenderProperty>& renderProp);
void DumpBorderRadiusProperties(const RefPtr<OHOS::Ace::NG::ImageRenderProperty>& renderProp);
inline void DumpOtherInfo();
void DumpRenderInfo(std::unique_ptr<JsonValue>& json);
void DumpAdvanceInfo() override;
void DumpAdvanceInfo(std::unique_ptr<JsonValue>& json) override;
@ -398,6 +367,12 @@ public:
{
isComponentSnapshotNode_ = isComponentSnapshotNode;
}
void SetRenderedImageInfo(const RenderedImageInfo& renderedImageInfo)
{
renderedImageInfo_ = renderedImageInfo;
}
protected:
void RegisterWindowStateChangedCallback();
void UnregisterWindowStateChangedCallback();
@ -465,7 +440,6 @@ private:
void TriggerFirstVisibleAreaChange();
void UpdateFillColorIfForegroundColor();
void UpdateDragEvent(const RefPtr<OHOS::Ace::DragEvent>& event);
void ToJsonValue(std::unique_ptr<JsonValue>& json, const InspectorFilter& filter) const override;
@ -525,6 +499,7 @@ private:
CopyOptions copyOption_ = CopyOptions::None;
ImageInterpolation interpolation_ = ImageInterpolation::LOW;
bool needLoadAlt_ = true;
RenderedImageInfo renderedImageInfo_;
RefPtr<ImageLoadingContext> loadingCtx_;
RefPtr<CanvasImage> image_;
@ -547,6 +522,7 @@ private:
std::shared_ptr<ImageAnalyzerManager> imageAnalyzerManager_;
ImageDfxConfig imageDfxConfig_;
ImageDfxConfig altImageDfxConfig_;
bool enableDrag_ = false;
std::function<bool(const KeyEvent& event)> keyEventCallback_ = nullptr;
bool syncLoad_ = false;

View File

@ -291,17 +291,32 @@ bool PixelMapImage::CheckIfNeedForStretching(
return false;
}
void PixelMapImage::NotifyDrawCompletion(const std::string& srcInfo, const RefPtr<PixelMap>& pixmap)
{
FireDrawCompleteCallback(RenderedImageInfo{
.renderSuccess = true,
.width = pixmap->GetWidth(),
.height = pixmap->GetHeight(),
.rowStride = pixmap->GetRowStride(),
.rowBytes = pixmap->GetRowBytes(),
.byteCount = pixmap->GetByteCount(),
.isHdr = pixmap->IsHdr(),
.alphaType = pixmap->GetAlphaType(),
.pixelFormat = pixmap->GetPixelFormat(),
.allocatorType = pixmap->GetAllocatorType(),
.pixelMapId = pixmap->GetId(),
.srcInfo = srcInfo
});
}
void PixelMapImage::DrawToRSCanvas(
RSCanvas& canvas, const RSRect& srcRect, const RSRect& dstRect, const BorderRadiusArray& radiusXY)
{
auto pixmap = GetPixelMap();
auto dfxConfig = GetImageDfxConfig();
const auto& src = dfxConfig.imageSrc_;
const auto& nodeId = dfxConfig.nodeId_;
long long accessId = dfxConfig.accessibilityId_;
if (!pixmap || !pixmap->GetPixelMapSharedPtr()) {
TAG_LOGE(
AceLogTag::ACE_IMAGE, "pixmap null, %{public}s-[%{public}d-%{public}lld]", src.c_str(), nodeId, accessId);
TAG_LOGE(AceLogTag::ACE_IMAGE, "pixmap null, %{private}s-%{public}s", dfxConfig.imageSrc_.c_str(),
dfxConfig.ToStringWithoutSrc().c_str());
return;
}
#ifdef ENABLE_ROSEN_BACKEND
@ -309,8 +324,8 @@ void PixelMapImage::DrawToRSCanvas(
return;
}
const auto& config = GetPaintConfig();
ACE_SCOPED_TRACE("DrawToRSCanvas [%d]-[%lld]-[%d x %d], src:[%s], [%s]", nodeId, accessId, pixmap->GetWidth(),
pixmap->GetHeight(), src.c_str(), dfxConfig.borderRadiusValue_.c_str());
ACE_SCOPED_TRACE("DrawToRSCanvas %s-[%d x %d]-[%s]", dfxConfig.ToStringWithSrc().c_str(), pixmap->GetWidth(),
pixmap->GetHeight(), dfxConfig.borderRadiusValue_.c_str());
RSBrush brush;
RSSamplingOptions options;
ImagePainterUtils::AddFilter(brush, options, config);
@ -333,13 +348,12 @@ void PixelMapImage::DrawToRSCanvas(
1.0, 0, 0, 0, static_cast<int32_t>(config.dynamicMode) };
recordingCanvas.AttachBrush(brush);
if (SystemProperties::GetDebugPixelMapSaveEnabled()) {
TAG_LOGI(AceLogTag::ACE_IMAGE,
"pixmap, src:%{public}s, [%{public}d-%{public}lld]-[%{public}d * "
"%{public}d]-[%{public}s][%{public}s]",
src.c_str(), nodeId, accessId, pixmap->GetWidth(), pixmap->GetHeight(),
TAG_LOGI(AceLogTag::ACE_IMAGE, "pixmap, %{public}s-[%{public}d * %{public}d]-[%{public}s][%{public}s]",
dfxConfig.ToStringWithSrc().c_str(), pixmap->GetWidth(), pixmap->GetHeight(),
dfxConfig.borderRadiusValue_.c_str(), GetDynamicModeString(config.dynamicMode).c_str());
pixmap->SavePixelMapToFile(std::to_string(nodeId) + "_" + std::to_string(accessId) + "_ToRS_");
pixmap->SavePixelMapToFile(dfxConfig.ToStringWithoutSrc() + "_ToRS_");
}
NotifyDrawCompletion(dfxConfig.ToStringWithSrc(), pixmap);
recordingCanvas.DrawPixelMapWithParm(pixmap->GetPixelMapSharedPtr(), rsImageInfo, options);
recordingCanvas.DetachBrush();
#endif

View File

@ -43,6 +43,7 @@ public:
RefPtr<CanvasImage> Clone() override;
void NotifyDrawCompletion(const std::string& srcInfo, const RefPtr<PixelMap>& pixmap);
void DrawToRSCanvas(
RSCanvas& canvas, const RSRect& srcRect, const RSRect& dstRect, const BorderRadiusArray& radiusXY) override;
void DrawRect(RSCanvas& canvas, const RSRect& srcRect, const RSRect& dstRect) override;

View File

@ -141,12 +141,26 @@ public:
imageDfxConfig_ = imageDfxConfig;
}
void SetDrawCompleteCallback(std::function<void(const RenderedImageInfo&)>&& drawCompleteCallback)
{
drawCompleteCallback_ = std::move(drawCompleteCallback);
}
void FireDrawCompleteCallback(const RenderedImageInfo& renderedImageInfo)
{
if (drawCompleteCallback_) {
drawCompleteCallback_(renderedImageInfo);
}
}
protected:
bool isDrawAnimate_ = false;
private:
std::unique_ptr<ImagePaintConfig> paintConfig_;
ImageDfxConfig imageDfxConfig_;
// Callback function executed after the graphics rendering is complete.
std::function<void(const RenderedImageInfo&)> drawCompleteCallback_ = nullptr;
ACE_DISALLOW_COPY_AND_MOVE(CanvasImage);
};

View File

@ -97,7 +97,6 @@ std::string ImageLoader::RemovePathHead(const std::string& uri)
RefPtr<ImageLoader> ImageLoader::CreateImageLoader(const ImageSourceInfo& imageSourceInfo)
{
SrcType srcType = imageSourceInfo.GetSrcType();
auto imageDfx = imageSourceInfo.GetImageDfxConfig();
switch (srcType) {
case SrcType::INTERNAL:
case SrcType::FILE: {
@ -244,26 +243,23 @@ std::shared_ptr<RSData> FileImageLoader::LoadImageData(
const ImageSourceInfo& imageSourceInfo, const WeakPtr<PipelineBase>& /* context */)
#endif
{
ACE_SCOPED_TRACE("LoadImageData %s", imageSourceInfo.ToString().c_str());
const auto& src = imageSourceInfo.GetSrc();
std::string filePath = RemovePathHead(src);
auto imageDfxConfig = imageSourceInfo.GetImageDfxConfig();
ACE_SCOPED_TRACE("LoadImageData %s", imageDfxConfig.ToStringWithSrc().c_str());
if (imageSourceInfo.GetSrcType() == SrcType::INTERNAL) {
// the internal source uri format is like "internal://app/imagename.png", the absolute path of which is like
// "/data/data/{bundleName}/files/imagename.png"
auto bundleName = AceApplicationInfo::GetInstance().GetPackageName();
if (bundleName.empty()) {
TAG_LOGW(AceLogTag::ACE_IMAGE,
"bundleName is empty, LoadImageData for internal source fail! Src = %{private}s, NodeId = "
"%{public}d-%{public}lld.",
imageDfxConfig.imageSrc_.c_str(), imageDfxConfig.nodeId_,
static_cast<long long>(imageDfxConfig.accessibilityId_));
"bundleName is empty, LoadImageData for internal source fail! %{private}s-%{public}s.",
imageDfxConfig.imageSrc_.c_str(), imageDfxConfig.ToStringWithoutSrc().c_str());
return nullptr;
}
if (!StringUtils::StartWith(filePath, "app/")) { // "app/" is infix of internal path
TAG_LOGW(AceLogTag::ACE_IMAGE,
"internal path format is wrong. path is %{private}s, NodeId = %{public}d-%{public}lld.", src.c_str(),
imageDfxConfig.nodeId_, static_cast<long long>(imageDfxConfig.accessibilityId_));
TAG_LOGW(AceLogTag::ACE_IMAGE, "internal path format is wrong. path is %{private}s-%{public}s.",
src.c_str(), imageDfxConfig.ToStringWithoutSrc().c_str());
return nullptr;
}
filePath = std::string("/data/data/") // head of absolute path
@ -274,8 +270,7 @@ std::shared_ptr<RSData> FileImageLoader::LoadImageData(
filePath = FileUriHelper::GetRealPath(src);
}
if (filePath.length() > PATH_MAX) {
TAG_LOGW(AceLogTag::ACE_IMAGE, "src path is too long. NodeId = %{public}d-%{public}lld.",
imageDfxConfig.nodeId_, static_cast<long long>(imageDfxConfig.accessibilityId_));
TAG_LOGW(AceLogTag::ACE_IMAGE, "path is too long. %{public}s.", imageDfxConfig.ToStringWithoutSrc().c_str());
return nullptr;
}
char realPath[PATH_MAX] = { 0x00 };
@ -284,9 +279,8 @@ std::shared_ptr<RSData> FileImageLoader::LoadImageData(
if (!result) {
TAG_LOGW(AceLogTag::ACE_IMAGE,
"read data failed, filePath: %{private}s, realPath: %{private}s, src: %{private}s, fail reason: "
"%{private}s. NodeId = %{public}d-%{public}lld.",
filePath.c_str(), src.c_str(), realPath, strerror(errno), imageDfxConfig.nodeId_,
static_cast<long long>(imageDfxConfig.accessibilityId_));
"%{private}s.%{public}s.",
filePath.c_str(), src.c_str(), realPath, strerror(errno), imageDfxConfig.ToStringWithoutSrc().c_str());
}
#ifndef USE_ROSEN_DRAWING
#ifdef PREVIEW
@ -357,8 +351,7 @@ std::shared_ptr<RSData> AssetImageLoader::LoadImageData(
const auto& src = imageSourceInfo.GetSrc();
auto imageDfxConfig = imageSourceInfo.GetImageDfxConfig();
if (src.empty()) {
TAG_LOGW(AceLogTag::ACE_IMAGE, "image src is empty. NodeId = %{public}d-%{public}lld.", imageDfxConfig.nodeId_,
static_cast<long long>(imageDfxConfig.accessibilityId_));
TAG_LOGW(AceLogTag::ACE_IMAGE, "image src is empty. %{public}s.", imageDfxConfig.ToStringWithoutSrc().c_str());
return nullptr;
}
@ -370,20 +363,18 @@ std::shared_ptr<RSData> AssetImageLoader::LoadImageData(
}
auto pipelineContext = context.Upgrade();
if (!pipelineContext) {
TAG_LOGW(AceLogTag::ACE_IMAGE, "invalid pipeline context. NodeId = %{public}d-%{public}lld.",
imageDfxConfig.nodeId_, static_cast<long long>(imageDfxConfig.accessibilityId_));
TAG_LOGW(
AceLogTag::ACE_IMAGE, "invalid pipeline context. %{public}s.", imageDfxConfig.ToStringWithoutSrc().c_str());
return nullptr;
}
auto assetManager = pipelineContext->GetAssetManager();
if (!assetManager) {
TAG_LOGW(AceLogTag::ACE_IMAGE, "No asset manager! NodeId = %{public}d-%{public}lld.", imageDfxConfig.nodeId_,
static_cast<long long>(imageDfxConfig.accessibilityId_));
TAG_LOGW(AceLogTag::ACE_IMAGE, "No asset manager! %{public}s.", imageDfxConfig.ToStringWithoutSrc().c_str());
return nullptr;
}
auto assetData = assetManager->GetAsset(assetSrc);
if (!assetData) {
TAG_LOGW(AceLogTag::ACE_IMAGE, "No asset data! NodeId = %{public}d-%{public}lld.", imageDfxConfig.nodeId_,
static_cast<long long>(imageDfxConfig.accessibilityId_));
TAG_LOGW(AceLogTag::ACE_IMAGE, "No asset data! %{public}s.", imageDfxConfig.ToStringWithoutSrc().c_str());
return nullptr;
}
const uint8_t* data = assetData->GetData();
@ -439,8 +430,8 @@ std::shared_ptr<RSData> NetworkImageLoader::LoadImageData(
auto pipelineContext = context.Upgrade();
auto imageDfxConfig = imageSourceInfo.GetImageDfxConfig();
if (!pipelineContext || pipelineContext->IsJsCard()) {
TAG_LOGW(AceLogTag::ACE_IMAGE, "network image in JS card is forbidden. NodeId = %{public}d-%{public}lld",
imageDfxConfig.nodeId_, static_cast<long long>(imageDfxConfig.accessibilityId_));
TAG_LOGW(AceLogTag::ACE_IMAGE, "network image in JS card is forbidden. %{public}s",
imageDfxConfig.ToStringWithoutSrc().c_str());
return nullptr;
}
// 1. find in cache file path.
@ -451,9 +442,8 @@ std::shared_ptr<RSData> NetworkImageLoader::LoadImageData(
// 2. if not found. download it.
if (SystemProperties::GetDebugEnabled()) {
TAG_LOGD(AceLogTag::ACE_IMAGE,
"Download network image by loader, uri=%{private}s, nodeId = %{public}d-%{public}lld", uri.c_str(),
imageDfxConfig.nodeId_, static_cast<long long>(imageDfxConfig.accessibilityId_));
TAG_LOGD(AceLogTag::ACE_IMAGE, "Download network image by loader, uri=%{private}s, %{public}s", uri.c_str(),
imageDfxConfig.ToStringWithoutSrc().c_str());
}
#ifndef OHOS_PLATFORM
@ -489,8 +479,7 @@ std::shared_ptr<RSData> InternalImageLoader::LoadImageData(
InternalResource::GetInstance().GetResource(imageSourceInfo.GetResourceId(), imageSize);
if (internalData == nullptr) {
auto imageDfxConfig = imageSourceInfo.GetImageDfxConfig();
TAG_LOGW(AceLogTag::ACE_IMAGE, "Resource is invalid, nodeId = %{public}d-%{public}lld",
imageDfxConfig.nodeId_, static_cast<long long>(imageDfxConfig.accessibilityId_));
TAG_LOGW(AceLogTag::ACE_IMAGE, "Resource is invalid, %{public}s", imageDfxConfig.ToStringWithoutSrc().c_str());
return nullptr;
}
auto drawingData = std::make_shared<RSData>();
@ -509,9 +498,8 @@ std::shared_ptr<RSData> Base64ImageLoader::LoadImageData(
std::string_view base64Code = GetBase64ImageCode(imageSourceInfo.GetSrc());
auto imageDfxConfig = imageSourceInfo.GetImageDfxConfig();
if (base64Code.size() == 0) {
TAG_LOGW(AceLogTag::ACE_IMAGE, "base64Code = %{private}s is empty. NodeId = %{public}d-%{public}lld.",
imageDfxConfig.imageSrc_.c_str(), imageDfxConfig.nodeId_,
static_cast<long long>(imageDfxConfig.accessibilityId_));
TAG_LOGW(AceLogTag::ACE_IMAGE, "base64Code = %{private}s is empty. %{public}s.",
imageDfxConfig.imageSrc_.c_str(), imageDfxConfig.ToStringWithoutSrc().c_str());
return nullptr;
}
@ -519,10 +507,9 @@ std::shared_ptr<RSData> Base64ImageLoader::LoadImageData(
SkBase64::Error error = SkBase64::Decode(base64Code.data(), base64Code.size(), nullptr, &outputLen);
if (error != SkBase64::Error::kNoError) {
TAG_LOGW(AceLogTag::ACE_IMAGE,
"error base64 image code = %{public}d! Base64Size = %{public}d, outputLen = %{public}d, nodeId = "
"%{public}d-%{public}lld",
"error base64 image code = %{public}d! Base64Size = %{public}d, outputLen = %{public}d, %{public}s",
static_cast<int32_t>(base64Code.size()), static_cast<int32_t>(error), static_cast<int32_t>(outputLen),
imageDfxConfig.nodeId_, static_cast<long long>(imageDfxConfig.accessibilityId_));
imageDfxConfig.ToStringWithoutSrc().c_str());
return nullptr;
}
@ -533,16 +520,14 @@ std::shared_ptr<RSData> Base64ImageLoader::LoadImageData(
error = SkBase64::Decode(base64Code.data(), base64Code.size(), output, &outputLen);
if (error != SkBase64::Error::kNoError) {
TAG_LOGW(AceLogTag::ACE_IMAGE,
"error base64 image code = %{public}d! Base64Size = %{public}d, outputLen = %{public}d, nodeId = "
"%{public}d-%{public}lld",
"error base64 image code = %{public}d! Base64Size = %{public}d, outputLen = %{public}d, %{public}s",
static_cast<int32_t>(base64Code.size()), static_cast<int32_t>(error), static_cast<int32_t>(outputLen),
imageDfxConfig.nodeId_, static_cast<long long>(imageDfxConfig.accessibilityId_));
imageDfxConfig.ToStringWithoutSrc().c_str());
return nullptr;
}
if (SystemProperties::GetDebugEnabled()) {
TAG_LOGD(AceLogTag::ACE_IMAGE, "base64 size=%{public}d, src=%{private}s. NodeId = %{public}d-%{public}lld.",
(int)base64Code.size(), imageSourceInfo.ToString().c_str(), imageDfxConfig.nodeId_,
static_cast<long long>(imageDfxConfig.accessibilityId_));
TAG_LOGD(AceLogTag::ACE_IMAGE, "base64 size=%{public}d, src=%{private}s. %{public}s.", (int)base64Code.size(),
imageSourceInfo.ToString().c_str(), imageDfxConfig.ToStringWithoutSrc().c_str());
}
return resData;
}
@ -728,39 +713,35 @@ RefPtr<NG::ImageData> DecodedDataProviderImageLoader::LoadDecodedImageData(
auto pipeline = pipelineWk.Upgrade();
auto imageDfxConfig = src.GetImageDfxConfig();
if (!pipeline) {
TAG_LOGW(AceLogTag::ACE_IMAGE, "Pipeline is empty in decodeData. NodeId = %{public}d-%{public}lld.",
imageDfxConfig.nodeId_, static_cast<long long>(imageDfxConfig.accessibilityId_));
TAG_LOGW(AceLogTag::ACE_IMAGE, "Pipeline is empty in decodeData. %{public}s.",
imageDfxConfig.ToStringWithoutSrc().c_str());
return nullptr;
}
auto dataProvider = pipeline->GetDataProviderManager();
if (!dataProvider) {
TAG_LOGW(AceLogTag::ACE_IMAGE, "dataProvider is empty in pipeline. NodeId = %{public}d-%{public}lld.",
imageDfxConfig.nodeId_, static_cast<long long>(imageDfxConfig.accessibilityId_));
TAG_LOGW(AceLogTag::ACE_IMAGE, "dataProvider is empty in pipeline. %{public}s.",
imageDfxConfig.ToStringWithoutSrc().c_str());
return nullptr;
}
void* pixmapMediaUniquePtr = dataProvider->GetDataProviderThumbnailResFromUri(src.GetSrc());
auto pixmap = PixelMap::CreatePixelMapFromDataAbility(pixmapMediaUniquePtr);
if (!pixmap) {
TAG_LOGW(AceLogTag::ACE_IMAGE, "DecodeData is Empty. NodeId = %{public}d-%{public}lld.", imageDfxConfig.nodeId_,
static_cast<long long>(imageDfxConfig.accessibilityId_));
TAG_LOGW(AceLogTag::ACE_IMAGE, "DecodeData is Empty. %{public}s.", imageDfxConfig.ToStringWithoutSrc().c_str());
return nullptr;
}
TAG_LOGI(AceLogTag::ACE_IMAGE,
"src=%{private}s, pixmap from Media width*height=%{public}d*%{public}d, ByteCount=%{public}d. NodeId = "
"%{public}d-%{public}lld.",
src.ToString().c_str(), pixmap->GetWidth(), pixmap->GetHeight(), pixmap->GetByteCount(), imageDfxConfig.nodeId_,
static_cast<long long>(imageDfxConfig.accessibilityId_));
"src=%{private}s, pixmap from Media width*height=%{public}d*%{public}d, ByteCount=%{public}d. %{public}s",
src.ToString().c_str(), pixmap->GetWidth(), pixmap->GetHeight(), pixmap->GetByteCount(),
imageDfxConfig.ToStringWithoutSrc().c_str());
if (SystemProperties::GetDebugPixelMapSaveEnabled()) {
pixmap->SavePixelMapToFile("_fromMedia_");
}
auto cache = pipeline->GetImageCache();
if (SystemProperties::GetDebugEnabled()) {
TAG_LOGD(AceLogTag::ACE_IMAGE,
"DecodedDataProvider src=%{private}s,Key=%{private}s. NodeId = %{public}d-%{public}lld.",
src.ToString().c_str(), src.GetKey().c_str(), imageDfxConfig.nodeId_,
static_cast<long long>(imageDfxConfig.accessibilityId_));
TAG_LOGD(AceLogTag::ACE_IMAGE, "DecodedDataProvider src=%{private}s,Key=%{private}s. %{public}s.",
src.ToString().c_str(), src.GetKey().c_str(), imageDfxConfig.ToStringWithoutSrc().c_str());
}
if (cache) {
cache->CacheImageData(src.GetKey(), MakeRefPtr<NG::PixmapData>(pixmap));
@ -788,16 +769,13 @@ RefPtr<NG::ImageData> PixelMapImageLoader::LoadDecodedImageData(
#else
auto imageDfxConfig = imageSourceInfo.GetImageDfxConfig();
if (!imageSourceInfo.GetPixmap()) {
TAG_LOGW(AceLogTag::ACE_IMAGE,
"no pixel map in imageSourceInfo, imageSourceInfo: %{private}s. NodeId = %{public}d-%{public}lld.",
imageSourceInfo.ToString().c_str(), imageDfxConfig.nodeId_,
static_cast<long long>(imageDfxConfig.accessibilityId_));
TAG_LOGW(AceLogTag::ACE_IMAGE, "no pixel map in imageSourceInfo, imageSourceInfo: %{private}s. %{public}s.",
imageSourceInfo.ToString().c_str(), imageDfxConfig.ToStringWithoutSrc().c_str());
return nullptr;
}
if (SystemProperties::GetDebugEnabled()) {
TAG_LOGD(AceLogTag::ACE_IMAGE, "src is pixmap %{private}s, nodeId = %{public}d-%{public}lld.",
imageSourceInfo.ToString().c_str(), imageDfxConfig.nodeId_,
static_cast<long long>(imageDfxConfig.accessibilityId_));
TAG_LOGD(AceLogTag::ACE_IMAGE, "src is pixmap %{private}s, %{public}s.", imageSourceInfo.ToString().c_str(),
imageDfxConfig.ToStringWithoutSrc().c_str());
}
return MakeRefPtr<NG::PixmapData>(imageSourceInfo.GetPixmap());
#endif
@ -815,8 +793,8 @@ std::shared_ptr<RSData> SharedMemoryImageLoader::LoadImageData(
auto imageDfxConfig = src.GetImageDfxConfig();
auto pipeline = pipelineWk.Upgrade();
if (!pipeline) {
TAG_LOGW(AceLogTag::ACE_IMAGE, "Pipeline is empty in sharedImageLoader. NodeId = %{public}d-%{public}lld.",
imageDfxConfig.nodeId_, static_cast<long long>(imageDfxConfig.accessibilityId_));
TAG_LOGW(AceLogTag::ACE_IMAGE, "Pipeline is empty in sharedImageLoader. %{public}s.",
imageDfxConfig.ToStringWithoutSrc().c_str());
return nullptr;
}
auto manager = pipeline->GetOrCreateSharedImageManager();
@ -829,10 +807,8 @@ std::shared_ptr<RSData> SharedMemoryImageLoader::LoadImageData(
std::unique_lock<std::mutex> lock(mtx_);
auto status = cv_.wait_for(lock, TIMEOUT_DURATION);
if (status == std::cv_status::timeout) {
TAG_LOGW(AceLogTag::ACE_IMAGE,
"load SharedMemoryImage timeout! %{private}s, nodeId = %{public}d-%{public}lld.",
imageDfxConfig.imageSrc_.c_str(), imageDfxConfig.nodeId_,
static_cast<long long>(imageDfxConfig.accessibilityId_));
TAG_LOGW(AceLogTag::ACE_IMAGE, "load SharedMemoryImage timeout! %{private}s, %{public}s.",
imageDfxConfig.imageSrc_.c_str(), imageDfxConfig.ToStringWithoutSrc().c_str());
return nullptr;
}
}
@ -881,40 +857,33 @@ RefPtr<NG::ImageData> AstcImageLoader::LoadDecodedImageData(
auto pipeline = pipelineWK.Upgrade();
if (!pipeline) {
TAG_LOGW(AceLogTag::ACE_IMAGE,
"Pipeline is empty in sharedImageLoader. Src = %{private}s, nodeId = %{public}d-%{public}lld.",
imageDfxConfig.imageSrc_.c_str(), imageDfxConfig.nodeId_,
static_cast<long long>(imageDfxConfig.accessibilityId_));
"Pipeline is empty in sharedImageLoader. Src = %{private}s-%{public}s.",
imageDfxConfig.imageSrc_.c_str(), imageDfxConfig.ToStringWithoutSrc().c_str());
return nullptr;
}
auto dataProvider = pipeline->GetDataProviderManager();
if (!dataProvider) {
TAG_LOGW(AceLogTag::ACE_IMAGE,
"DataProvider is empty in AstcLoading. Src = %{private}s, NodeId = %{public}d-%{public}lld.",
imageDfxConfig.imageSrc_.c_str(), imageDfxConfig.nodeId_,
static_cast<long long>(imageDfxConfig.accessibilityId_));
"DataProvider is empty in AstcLoading. Src = %{private}s, %{public}s.",
imageDfxConfig.imageSrc_.c_str(), imageDfxConfig.ToStringWithoutSrc().c_str());
return nullptr;
}
void* pixmapMediaUniquePtr = dataProvider->GetDataProviderThumbnailResFromUri(src.GetSrc());
auto pixmap = PixelMap::CreatePixelMapFromDataAbility(pixmapMediaUniquePtr);
if (!pixmap) {
TAG_LOGW(AceLogTag::ACE_IMAGE,
"Pixelmap is Empty. Src = %{private}s, nodeId = %{public}d-%{public}lld.",
imageDfxConfig.imageSrc_.c_str(), imageDfxConfig.nodeId_,
static_cast<long long>(imageDfxConfig.accessibilityId_));
TAG_LOGW(AceLogTag::ACE_IMAGE, "Pixelmap is Empty. Src = %{private}s, %{public}s.",
imageDfxConfig.imageSrc_.c_str(), imageDfxConfig.ToStringWithoutSrc().c_str());
return nullptr;
}
if (SystemProperties::GetDebugEnabled()) {
TAG_LOGD(AceLogTag::ACE_IMAGE,
"src=%{private}s,astc pixmap from Media width*height=%{public}d*%{public}d, ByteCount=%{public}d nodeId = "
"%{public}d-%{public}lld.",
src.ToString().c_str(), pixmap->GetWidth(), pixmap->GetHeight(), pixmap->GetByteCount(),
imageDfxConfig.nodeId_, static_cast<long long>(imageDfxConfig.accessibilityId_));
"src=%{public}s, astc pixmap from Media width*height=%{public}d*%{public}d, ByteCount=%{public}d.",
imageDfxConfig.ToStringWithSrc().c_str(), pixmap->GetWidth(), pixmap->GetHeight(), pixmap->GetByteCount());
}
if (SystemProperties::GetDebugPixelMapSaveEnabled()) {
pixmap->SavePixelMapToFile(std::to_string(imageDfxConfig.nodeId_) + "_" +
std::to_string(imageDfxConfig.accessibilityId_) + "_ASTC_LOADER_");
pixmap->SavePixelMapToFile(imageDfxConfig.ToStringWithoutSrc() + "_ASTC_LOADER_");
}
auto cache = pipeline->GetImageCache();

View File

@ -41,6 +41,8 @@ public:
MOCK_METHOD(void, SavePixelMapToFile, (const std::string& dst), (const override));
MOCK_METHOD(RefPtr<PixelMap>, GetCropPixelMap, (const Rect& srcRect), (override));
MOCK_METHOD(bool, EncodeTlv, (std::vector<uint8_t>& buff), (override));
MOCK_METHOD(AllocatorType, GetAllocatorType, (), (const override));
MOCK_METHOD(bool, IsHdr, (), (const override));
};
} // namespace OHOS::Ace
#endif // FOUNDATION_ACE_TEST_MOCK_BASE_MOCK_PIXEL_MAP_H

View File

@ -276,6 +276,11 @@ bool ImageSourceInfo::SupportObjCache() const
return false;
}
const std::string& ImageSourceInfo::GetBundleName() const
{
return bundleName_;
}
const std::string& ImageSourceInfo::GetModuleName() const
{
return moduleName_;

View File

@ -508,7 +508,6 @@ HWTEST_F(ImagePatternTestNg, UpdateFillColorIfForegroundColor001, TestSize.Level
imageLayoutProperty->UpdateImageSourceInfo(value1);
auto imageRenderProperty = imagePattern->GetPaintProperty<ImageRenderProperty>();
ASSERT_NE(imageRenderProperty, nullptr);
imagePattern->UpdateFillColorIfForegroundColor();
Color value(10);
renderContext->UpdateForegroundColor(value);
@ -516,7 +515,6 @@ HWTEST_F(ImagePatternTestNg, UpdateFillColorIfForegroundColor001, TestSize.Level
value3.isSvg_ = true;
imageLayoutProperty->UpdateImageSourceInfo(value3);
renderContext->ResetForegroundColorStrategy();
imagePattern->UpdateFillColorIfForegroundColor();
auto imageSourceInfo = imageLayoutProperty->GetImageSourceInfo().value();
EXPECT_EQ(imageSourceInfo.fillColor_.value_or(Color::TRANSPARENT), Color::FOREGROUND);
}

View File

@ -1597,7 +1597,6 @@ void ImageModelNGTest001_MixedProperties01(ImageModelNG &image)
ImageModelNG::SetImageInterpolation(frameNode, ImageInterpolation::HIGH);
EXPECT_EQ(imageRenderProperty->GetImageInterpolation().value(), ImageInterpolation::HIGH);
EXPECT_EQ(imagePattern->GetImageInterpolation(), string("HIGH"));
auto imageInterpolation = ImageModelNG::GetInterpolation(frameNode);
EXPECT_EQ(imageInterpolation, ImageInterpolation::HIGH);

View File

@ -1364,7 +1364,6 @@ HWTEST_F(ImageTestThreeNg, ImagePatternUpdateFillColorIfForegroundColor, TestSiz
ASSERT_NE(imagePattern, nullptr);
auto renderContext = frameNode->GetRenderContext();
renderContext->UpdateForegroundColor(Color::BLACK);
imagePattern->UpdateFillColorIfForegroundColor();
EXPECT_TRUE(renderContext->HasForegroundColor());
}

View File

@ -159,6 +159,14 @@ public:
{
return static_cast<AlphaType>(0);
}
AllocatorType GetAllocatorType() const override
{
return static_cast<AllocatorType>(0);
}
bool IsHdr() const override
{
return false;
}
int32_t GetRowStride() const override
{
return 0;

View File

@ -83,6 +83,8 @@ public:
MOCK_METHOD(void, SavePixelMapToFile, (const std::string& dst), (const, override));
MOCK_METHOD(RefPtr<PixelMap>, GetCropPixelMap, (const Rect& srcRect), (override));
MOCK_METHOD(bool, EncodeTlv, (std::vector<uint8_t> & buff), (override));
MOCK_METHOD(AllocatorType, GetAllocatorType, (), (const override));
MOCK_METHOD(bool, IsHdr, (), (const override));
};
class WebDelegateDummy : public WebDelegate {