1 /* 2 * Copyright (c) 2022-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 #include "core/components_ng/image_provider/image_object.h" 17 18 #include "core/components/common/layout/constants.h" 19 20 namespace OHOS::Ace::NG { GetImageSize() const21const SizeF& ImageObject::GetImageSize() const 22 { 23 return imageSize_; 24 } 25 SetImageSize(const SizeF & imageSize)26void ImageObject::SetImageSize(const SizeF& imageSize) 27 { 28 imageSize_ = imageSize; 29 } 30 GetSourceInfo() const31const ImageSourceInfo& ImageObject::GetSourceInfo() const 32 { 33 return src_; 34 } 35 SetImageSourceInfoHdr(bool isHdr)36void ImageObject::SetImageSourceInfoHdr(bool isHdr) 37 { 38 src_.SetImageHdr(isHdr); 39 } 40 GetData() const41RefPtr<ImageData> ImageObject::GetData() const 42 { 43 std::shared_lock lock(dataMutex_); 44 return data_; 45 } 46 SetData(const RefPtr<ImageData> & data)47void ImageObject::SetData(const RefPtr<ImageData>& data) 48 { 49 std::unique_lock lock(dataMutex_); 50 data_ = data; 51 } 52 ClearData()53void ImageObject::ClearData() 54 { 55 std::unique_lock lock(dataMutex_); 56 data_.Reset(); 57 } 58 GetFrameCount() const59int32_t ImageObject::GetFrameCount() const 60 { 61 return frameCount_; 62 } 63 SetFrameCount(int32_t frameCount)64void ImageObject::SetFrameCount(int32_t frameCount) 65 { 66 frameCount_ = frameCount; 67 } 68 SetOrientation(ImageRotateOrientation orientation)69void ImageObject::SetOrientation(ImageRotateOrientation orientation) 70 { 71 orientation_ = orientation; 72 } 73 GetOrientation() const74ImageRotateOrientation ImageObject::GetOrientation() const 75 { 76 return orientation_; 77 } 78 SetUserOrientation(ImageRotateOrientation orientation)79void ImageObject::SetUserOrientation(ImageRotateOrientation orientation) 80 { 81 userOrientation_ = orientation; 82 } 83 GetUserOrientation() const84ImageRotateOrientation ImageObject::GetUserOrientation() const 85 { 86 return userOrientation_; 87 } 88 SetImageFileSize(size_t fileSize)89void ImageObject::SetImageFileSize(size_t fileSize) 90 { 91 fileSize_ = fileSize; 92 } 93 GetImageFileSize() const94size_t ImageObject::GetImageFileSize() const 95 { 96 return fileSize_; 97 } 98 GetImageDataSize() const99size_t ImageObject::GetImageDataSize() const 100 { 101 return imageDataSize_; 102 } 103 } // namespace OHOS::Ace::NG 104