1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_IMAGE_IMAGE_DFX_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_IMAGE_IMAGE_DFX_H 18 #include <string> 19 #include "base/image/pixel_map.h" 20 namespace OHOS::Ace::NG { 21 struct ImageDfxConfig { 22 int32_t nodeId_ = -1; 23 int64_t accessibilityId_ = -1; 24 std::string imageSrc_; 25 std::string borderRadiusValue_; 26 bool isTrimMemRecycle_ = false; 27 28 // Used in tracing functions, does not include image source information (sensitive data) ToStringWithoutSrcImageDfxConfig29 std::string ToStringWithoutSrc() const 30 { 31 std::string result = std::string("[") 32 .append(std::to_string(nodeId_)) 33 .append("-") 34 .append(std::to_string(accessibilityId_)) 35 .append("]"); 36 return result; 37 } 38 39 // Includes image source, but as the image source may be sensitive, use with caution ToStringWithSrcImageDfxConfig40 std::string ToStringWithSrc() const 41 { 42 std::string result = std::string("[") 43 .append(std::to_string(nodeId_)) 44 .append("-") 45 .append(std::to_string(accessibilityId_)) 46 .append("]-[") 47 .append(imageSrc_) 48 .append("]"); 49 return result; 50 } 51 }; 52 53 struct RenderedImageInfo { 54 // Indicates whether the rendering has been successfully displayed. 55 bool renderSuccess = false; 56 // PixelMap info 57 int32_t width = 0; 58 int32_t height = 0; 59 int32_t rowStride = 0; 60 int32_t rowBytes = 0; 61 int32_t byteCount = 0; 62 bool isHdr = false; 63 AlphaType alphaType = AlphaType::IMAGE_ALPHA_TYPE_UNKNOWN; 64 PixelFormat pixelFormat = PixelFormat::UNKNOWN; 65 AllocatorType allocatorType = AllocatorType::DEFAULT; 66 std::string pixelMapId; 67 std::string srcInfo; 68 ToStringRenderedImageInfo69 std::string ToString() const 70 { 71 if (!renderSuccess) { 72 return "RenderedImageInfo: { RenderStatus: NotRender }"; 73 } 74 std::string result; 75 result.append("RenderedImageInfo: {") 76 .append("RenderStatus: Success") 77 .append(", Width: ") 78 .append(std::to_string(width)) 79 .append(", Height: ") 80 .append(std::to_string(height)) 81 .append(", Row Stride: ") 82 .append(std::to_string(rowStride)) 83 .append(", Row Bytes: ") 84 .append(std::to_string(rowBytes)) 85 .append(", Byte Count: ") 86 .append(std::to_string(byteCount)) 87 .append(", Is HDR: ") 88 .append(isHdr ? "true" : "false") 89 .append(", Alpha Type: ") 90 .append(std::to_string(static_cast<int>(alphaType))) 91 .append(", Pixel Format: ") 92 .append(std::to_string(static_cast<int>(pixelFormat))) 93 .append(", Allocator Type: ") 94 .append(std::to_string(static_cast<int>(allocatorType))) 95 .append(", Pixel Map ID: ") 96 .append(pixelMapId) 97 .append(" }"); 98 return result; 99 } 100 }; 101 } // namespace OHOS::Ace::NG 102 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_IMAGE_IMAGE_DFX_H 103