• 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 
16 #include "loop.h"
17 
18 #include <algorithm>
19 #include <limits>
20 
21 #include <meta/api/make_callback.h>
22 #include <meta/api/util.h>
23 #include <meta/interface/builtin_objects.h>
24 
25 META_BEGIN_NAMESPACE()
26 
27 namespace AnimationModifiers {
28 
Build(const IMetadata::Ptr & data)29 bool Loop::Build(const IMetadata::Ptr& data)
30 {
31     LoopCount()->OnChanged()->AddHandler(META_ACCESS_EVENT(OnChanged).GetCallable());
32     return true;
33 }
34 
ProcessOnGetDuration(DurationData & duration) const35 bool Loop::ProcessOnGetDuration(DurationData& duration) const
36 {
37     const auto loopCount = META_ACCESS_PROPERTY_VALUE(LoopCount);
38     if (loopCount == 0) {
39         // Invalid
40         return false;
41     }
42     if (loopCount > 0) {
43         duration.loopCount = duration.loopCount < 0 ? duration.loopCount : duration.loopCount + loopCount - 1;
44     } else {
45         duration.loopCount = -1;
46     }
47     return true;
48 }
49 
ProcessOnStep(StepData & step) const50 bool Loop::ProcessOnStep(StepData& step) const
51 {
52     return true;
53 }
54 
55 } // namespace AnimationModifiers
56 
57 META_END_NAMESPACE()
58