• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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_ADAPTER_OHOS_OSAL_PIXEL_MAP_OHOS_H
17 #define FOUNDATION_ACE_ADAPTER_OHOS_OSAL_PIXEL_MAP_OHOS_H
18 
19 #include "pixel_map.h"
20 
21 #include "base/image/pixel_map.h"
22 
23 namespace OHOS::Ace {
24 
25 class PixelMapOhos : public PixelMap {
DECLARE_ACE_TYPE(PixelMapOhos,PixelMap)26     DECLARE_ACE_TYPE(PixelMapOhos, PixelMap)
27 
28 public:
29     explicit PixelMapOhos(std::shared_ptr<Media::PixelMap> pixmap) : pixmap_(std::move(pixmap)) {}
30     ~PixelMapOhos() override = default;
31     static PixelFormat PixelFormatConverter(Media::PixelFormat pixelFormat);
32     static Media::PixelFormat ConvertToMediaPixelFormat(Ace::PixelFormat pixelFormat);
33     static AlphaType AlphaTypeConverter(Media::AlphaType alphaType);
34     static Media::AlphaType ConvertToMediaAlphaType(Ace::AlphaType alphaType);
35     static AllocatorType AllocatorTypeConverter(Media::AllocatorType allocatorType);
36     static Media::ScaleMode ConvertToMediaScaleMode(Ace::ScaleMode scaleMode);
37     int32_t GetWidth() const override;
38     int32_t GetHeight() const override;
39     bool GetPixelsVec(std::vector<uint8_t>& data) const override;
40     const uint8_t* GetPixels() const override;
41     PixelFormat GetPixelFormat() const override;
42     AlphaType GetAlphaType() const override;
43     int32_t GetRowStride() const override;
44     int32_t GetRowBytes() const override;
45     int32_t GetByteCount() const override;
46     AllocatorType GetAllocatorType() const override;
47     bool IsHdr() const override;
48     void* GetPixelManager() const override;
49     void* GetRawPixelMapPtr() const override;
50     std::string GetId() override;
51     std::string GetModifyId() override;
52     std::shared_ptr<Media::PixelMap> GetPixelMapSharedPtr() override;
53     void* GetWritablePixels() const override;
54     void Scale(float xAxis, float yAxis) override;
55     void Scale(float xAxis, float yAxis, const AceAntiAliasingOption &option) override;
56     void SavePixelMapToFile(const std::string& dst) const override;
57     RefPtr<PixelMap> GetCropPixelMap(const Rect& srcRect) override;
58     bool EncodeTlv(std::vector<uint8_t>& buff) override;
59     uint32_t WritePixels(const WritePixelsOptions& opts) override;
60 
61 private:
62     std::shared_ptr<Media::PixelMap> pixmap_;
63 };
64 
65 } // namespace OHOS::Ace
66 
67 #endif // FOUNDATION_ACE_ADAPTER_OHOS_OSAL_PIXEL_MAP_OHOS_H