• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved.
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 "animation_stdtype.h"
16 
17 namespace SysTuning {
18 namespace TraceStdtype {
AppendAnimation(InternalTime inputTime,InternalTime startPoint,DataIndex nameIndex)19 TableRowId Animation::AppendAnimation(InternalTime inputTime, InternalTime startPoint, DataIndex nameIndex)
20 {
21     inputTimes_.emplace_back(inputTime);
22     startPoints_.emplace_back(startPoint);
23     endPoins_.emplace_back(INVALID_TIME);
24     frameInfos_.emplace_back(INVALID_UINT64);
25     names_.emplace_back(nameIndex);
26     ids_.emplace_back(Size());
27     return ids_.size() - 1;
28 }
UpdateStartPoint(TableRowId index,InternalTime startPoint)29 void Animation::UpdateStartPoint(TableRowId index, InternalTime startPoint)
30 {
31     if (index <= Size()) {
32         startPoints_[index] = startPoint;
33     }
34 }
UpdateEndPoint(TableRowId index,InternalTime endPoint)35 void Animation::UpdateEndPoint(TableRowId index, InternalTime endPoint)
36 {
37     if (index <= Size()) {
38         endPoins_[index] = endPoint;
39     }
40 }
UpdateFrameInfo(TableRowId index,InternalTime frameInfo)41 void Animation::UpdateFrameInfo(TableRowId index, InternalTime frameInfo)
42 {
43     if (index <= Size()) {
44         frameInfos_[index] = frameInfo;
45     }
46 }
Size() const47 size_t Animation::Size() const
48 {
49     return ids_.size();
50 }
InputTimes() const51 const std::deque<InternalTime> &Animation::InputTimes() const
52 {
53     return inputTimes_;
54 }
StartPoints() const55 const std::deque<InternalTime> &Animation::StartPoints() const
56 {
57     return startPoints_;
58 }
EndPoints() const59 const std::deque<InternalTime> &Animation::EndPoints() const
60 {
61     return endPoins_;
62 }
FrameInfos() const63 const std::deque<DataIndex> &Animation::FrameInfos() const
64 {
65     return frameInfos_;
66 }
Names() const67 const std::deque<DataIndex> &Animation::Names() const
68 {
69     return names_;
70 }
IdsData() const71 const std::deque<uint64_t> &Animation::IdsData() const
72 {
73     return ids_;
74 }
Clear()75 void Animation::Clear()
76 {
77     inputTimes_.clear();
78     startPoints_.clear();
79     endPoins_.clear();
80     frameInfos_.clear();
81     ids_.clear();
82 }
83 
PhysicalWidth() const84 uint32_t DeviceInfo::PhysicalWidth() const
85 {
86     return physicalWidth_;
87 }
PhysicalHeight() const88 uint32_t DeviceInfo::PhysicalHeight() const
89 {
90     return physicalHeight_;
91 }
PhysicalFrameRate() const92 uint32_t DeviceInfo::PhysicalFrameRate() const
93 {
94     return physicalFrameRate_;
95 }
UpdateWidthAndHeight(const std::smatch & matcheLine)96 void DeviceInfo::UpdateWidthAndHeight(const std::smatch &matcheLine)
97 {
98     if (matcheLine.size() > DEVICEINFO_MATCH_LAST) {
99         uint8_t matcheIndex = 0;
100         physicalWidth_ = base::StrToInt<uint32_t>(matcheLine[++matcheIndex].str()).value();
101         physicalHeight_ = base::StrToInt<uint32_t>(matcheLine[++matcheIndex].str()).value();
102     }
103 }
UpdateFrameRate(uint32_t frameRate)104 void DeviceInfo::UpdateFrameRate(uint32_t frameRate)
105 {
106     physicalFrameRate_ = frameRate;
107 }
Clear()108 void DeviceInfo::Clear()
109 {
110     physicalWidth_ = INVALID_UINT32;
111     physicalHeight_ = INVALID_UINT32;
112     physicalFrameRate_ = INVALID_UINT32;
113 }
114 
AppendDynamicFrame(DataIndex nameId)115 TableRowId DynamicFrame::AppendDynamicFrame(DataIndex nameId)
116 {
117     names_.emplace_back(nameId);
118     ids_.emplace_back(Size());
119     xs_.emplace_back(INVALID_UINT32);
120     ys_.emplace_back(INVALID_UINT32);
121     widths_.emplace_back(INVALID_UINT32);
122     heights_.emplace_back(INVALID_UINT32);
123     alphas_.emplace_back(INVALID_UINT64);
124     endTimes_.emplace_back(INVALID_TIME);
125     return ids_.size() - 1;
126 }
UpdateNameIndex(TableRowId index,DataIndex nameId)127 void DynamicFrame::UpdateNameIndex(TableRowId index, DataIndex nameId)
128 {
129     if (index <= Size()) {
130         names_[index] = nameId;
131     }
132 }
UpdatePosition(TableRowId index,const std::smatch & matcheLine,DataIndex alpha)133 void DynamicFrame::UpdatePosition(TableRowId index, const std::smatch &matcheLine, DataIndex alpha)
134 {
135     if (index <= Size() && matcheLine.size() > DYNAMICFRAME_MATCH_LAST) {
136         uint8_t matcheIndex = 0;
137         xs_[index] = base::StrToInt<uint32_t>(matcheLine[++matcheIndex].str()).value();
138         ys_[index] = base::StrToInt<uint32_t>(matcheLine[++matcheIndex].str()).value();
139         widths_[index] = base::StrToInt<uint32_t>(matcheLine[++matcheIndex].str()).value();
140         heights_[index] = base::StrToInt<uint32_t>(matcheLine[++matcheIndex].str()).value();
141         alphas_[index] = alpha;
142     }
143 }
UpdateEndTime(TableRowId index,InternalTime endTime)144 void DynamicFrame::UpdateEndTime(TableRowId index, InternalTime endTime)
145 {
146     if (index <= Size()) {
147         endTimes_[index] = endTime;
148     }
149 }
Size() const150 size_t DynamicFrame::Size() const
151 {
152     return ids_.size();
153 }
IdsData() const154 const std::deque<uint64_t> &DynamicFrame::IdsData() const
155 {
156     return ids_;
157 }
Xs() const158 const std::deque<uint32_t> &DynamicFrame::Xs() const
159 {
160     return xs_;
161 }
Ys() const162 const std::deque<uint32_t> &DynamicFrame::Ys() const
163 {
164     return ys_;
165 }
Widths() const166 const std::deque<uint32_t> &DynamicFrame::Widths() const
167 {
168     return widths_;
169 }
Heights() const170 const std::deque<uint32_t> &DynamicFrame::Heights() const
171 {
172     return heights_;
173 }
Alphas() const174 const std::deque<DataIndex> &DynamicFrame::Alphas() const
175 {
176     return alphas_;
177 }
Names() const178 const std::deque<DataIndex> &DynamicFrame::Names() const
179 {
180     return names_;
181 }
EndTimes() const182 const std::deque<InternalTime> &DynamicFrame::EndTimes() const
183 {
184     return endTimes_;
185 }
Clear()186 void DynamicFrame::Clear()
187 {
188     xs_.clear();
189     ys_.clear();
190     widths_.clear();
191     heights_.clear();
192     alphas_.clear();
193     names_.clear();
194     endTimes_.clear();
195     ids_.clear();
196 }
197 } // namespace TraceStdtype
198 } // namespace SysTuning
199