• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 /*
3  * Copyright (c) 2022 Huawei Device Co., Ltd.
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "modifier/rs_modifier.h"
18 
19 #include "modifier/rs_modifier_manager.h"
20 #include "modifier/rs_modifier_manager_map.h"
21 #include "platform/common/rs_log.h"
22 
23 namespace OHOS {
24 namespace Rosen {
AttachProperty(const std::shared_ptr<RSPropertyBase> & property)25 void RSModifier::AttachProperty(const std::shared_ptr<RSPropertyBase>& property)
26 {
27     if (property != nullptr && property_ != nullptr) {
28         property->target_ = property_->target_;
29         property->SetIsCustom(true);
30         property->AttachModifier(shared_from_this());
31         property->MarkModifierDirty();
32     }
33 }
34 
SetDirty(const bool isDirty,const std::shared_ptr<RSModifierManager> & modifierManager)35 void RSModifier::SetDirty(const bool isDirty, const std::shared_ptr<RSModifierManager>& modifierManager)
36 {
37     if (!isDirty) {
38         isDirty_ = isDirty;
39         return;
40     }
41 
42     if (isDirty_) {
43         return;
44     }
45     isDirty_ = isDirty;
46 
47     if (modifierManager == nullptr) {
48         ROSEN_LOGE("multi-instance, Modifier manager is null while mark modifier dirty Id: %{public}" PRIu64 "!",
49             GetPropertyId());
50         return;
51     }
52 
53     modifierManager->AddModifier(shared_from_this());
54 }
55 
ResetRSNodeExtendModifierDirty()56 void RSModifier::ResetRSNodeExtendModifierDirty()
57 {
58     if (property_ == nullptr) {
59         return;
60     }
61 
62     auto target = property_->target_.lock();
63     if (target == nullptr) {
64         return;
65     }
66 
67     target->ResetExtendModifierDirty();
68 }
69 } // namespace Rosen
70 } // namespace OHOS
71