• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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_DRAWABLE_DESCRIPTOR_OHOS_H
17 #define FOUNDATION_ACE_ADAPTER_OHOS_OSAL_DRAWABLE_DESCRIPTOR_OHOS_H
18 
19 #include <memory>
20 
21 #include "base/paint.h"
22 #include "core/drawable_descriptor_base.h"
23 
24 #include "base/image/drawable_descriptor.h"
25 
26 namespace OHOS::Ace {
27 
28 class DrawableDescriptorOhos : public DrawableDescriptor {
29     DECLARE_ACE_TYPE(DrawableDescriptorOhos, DrawableDescriptor);
30 
31 public:
32     explicit DrawableDescriptorOhos(Drawable::DrawableDescriptor* drawable);
33     ~DrawableDescriptorOhos();
34 
35     void RegisterRedrawCallback(RedrawCallback&& callback) override;
36 
37     void Draw(RSCanvas& canvas, const NG::ImagePaintConfig& config) override;
38 
39     int32_t GetDrawableSrcType() override;
40 
41 private:
42     Drawable::PaintConfig ConverConfig(const NG::ImagePaintConfig& config);
43 
44     // do not take the object out
45     Drawable::DrawableDescriptor* drawable_;
46     std::shared_ptr<std::mutex> mutex_ = std::make_shared<std::mutex>();
47     std::shared_ptr<bool> isValid_ = std::make_shared<bool>(true);
48 };
49 
50 } // namespace OHOS::Ace
51 
52 #endif // FOUNDATION_ACE_ADAPTER_OHOS_OSAL_DRAWABLE_DESCRIPTOR_OHOS_H
53