• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 #include "loop.h"
16 
17 #include <meta/api/make_callback.h>
18 #include <meta/api/util.h>
19 #include <meta/interface/builtin_objects.h>
20 
21 META_BEGIN_NAMESPACE()
22 
23 namespace AnimationModifiers {
24 
Build(const IMetadata::Ptr & data)25 bool LoopModifier::Build(const IMetadata::Ptr& data)
26 {
27     LoopCount()->OnChanged()->AddHandler(META_ACCESS_EVENT(OnChanged).GetCallable());
28     return true;
29 }
30 
ProcessOnGetDuration(DurationData & duration) const31 bool LoopModifier::ProcessOnGetDuration(DurationData& duration) const
32 {
33     const auto loopCount = META_ACCESS_PROPERTY_VALUE(LoopCount);
34     if (loopCount == 0) {
35         // Invalid
36         return false;
37     }
38     if (loopCount > 0) {
39         duration.loopCount = duration.loopCount < 0 ? duration.loopCount : duration.loopCount + loopCount - 1;
40     } else {
41         duration.loopCount = -1;
42     }
43     return true;
44 }
45 
ProcessOnStep(StepData & step) const46 bool LoopModifier::ProcessOnStep(StepData& step) const
47 {
48     return true;
49 }
50 
51 } // namespace AnimationModifiers
52 
53 META_END_NAMESPACE()
54