1 /*
2  * Copyright (c) 2023-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_IMAGE_PROVIDER_ADAPTER_ROSEN_DRAWING_IMAGE_DATA_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_IMAGE_PROVIDER_ADAPTER_ROSEN_DRAWING_IMAGE_DATA_H
18 
19 #include "core/components/common/layout/constants.h"
20 #include "core/components_ng/image_provider/image_data.h"
21 #include "core/components_ng/image_provider/svg_dom_base.h"
22 #include "core/components_ng/render/drawing.h"
23 #include "core/image/image_source_info.h"
24 
25 namespace OHOS::Ace::NG {
26 struct ImageCodec {
27     SizeF imageSize = { -1, -1 };
28     int32_t frameCount = 1;
29     ImageRotateOrientation orientation = ImageRotateOrientation::UP;
30 };
31 
32 class DrawingImageData : public ImageData {
33     DECLARE_ACE_TYPE(DrawingImageData, ImageData);
34 
35 public:
36     DrawingImageData(const void* data, size_t length);
DrawingImageData(std::shared_ptr<RSData> rsData)37     explicit DrawingImageData(std::shared_ptr<RSData> rsData) : rsData_(std::move(rsData)) {}
38     size_t GetSize() const override;
39     const void* GetData() const override;
40     std::shared_ptr<RSData> GetRSData() const;
41     ImageCodec Parse() const;
42     RefPtr<SvgDomBase> MakeSvgDom(const ImageSourceInfo& src);
43     std::string ToString() const override;
44 
45 private:
46     std::shared_ptr<RSData> rsData_;
47 };
48 } // namespace OHOS::Ace::NG
49 
50 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_IMAGE_PROVIDER_ADAPTER_ROSEN_DRAWING_IMAGE_DATA_H