• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2023 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_RENDER_ADAPTER_PIXELMAP_IMAGE_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_RENDER_ADAPTER_PIXELMAP_IMAGE_H
18 
19 #include <utility>
20 
21 #include "base/utils/noncopyable.h"
22 #include "core/components_ng/render/canvas_image.h"
23 
24 namespace OHOS::Ace::NG {
25 
26 class PixelMapImage : public virtual CanvasImage {
27     DECLARE_ACE_TYPE(PixelMapImage, CanvasImage)
28 public:
29     PixelMapImage() = default;
PixelMapImage(RefPtr<PixelMap> pixelMap)30     explicit PixelMapImage(RefPtr<PixelMap> pixelMap) : pixelMap_(std::move(pixelMap)) {}
31 
32     ~PixelMapImage() override = default;
33 
34     int32_t GetWidth() const override;
35     int32_t GetHeight() const override;
36 
GetPixelMap()37     RefPtr<PixelMap> GetPixelMap() const override
38     {
39         return pixelMap_;
40     }
41 
42     void Cache(const std::string& key) override;
43 
44     RefPtr<CanvasImage> Clone() override;
45 
46     void DrawToRSCanvas(
47         RSCanvas& canvas, const RSRect& srcRect, const RSRect& dstRect, const BorderRadiusArray& radiusXY) override;
48     void DrawRect(RSCanvas& canvas, const RSRect& dstRect);
49 
50     static RefPtr<CanvasImage> QueryFromCache(const std::string& key);
51 
52 private:
53     RefPtr<PixelMap> pixelMap_;
54 
55     ACE_DISALLOW_COPY_AND_MOVE(PixelMapImage);
56 };
57 } // namespace OHOS::Ace::NG
58 
59 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_RENDER_ADAPTER_PIXELMAP_IMAGE_H
60