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,const std::smatch & matcheLine,DataIndex alpha)115 TableRowId DynamicFrame::AppendDynamicFrame(DataIndex nameId, const std::smatch &matcheLine, DataIndex alpha)
116
117 {
118 if (matcheLine.size() < DYNAMICFRAME_MATCH_LAST) {
119 return INVALID_INT32;
120 }
121 uint8_t matcheIndex = 1;
122 names_.emplace_back(nameId);
123 ids_.emplace_back(Size());
124 xs_.emplace_back(base::StrToInt<uint32_t>(matcheLine[++matcheIndex].str()).value());
125 ys_.emplace_back(base::StrToInt<uint32_t>(matcheLine[++matcheIndex].str()).value());
126 widths_.emplace_back(base::StrToInt<uint32_t>(matcheLine[++matcheIndex].str()).value());
127 heights_.emplace_back(base::StrToInt<uint32_t>(matcheLine[++matcheIndex].str()).value());
128 alphas_.emplace_back(alpha);
129 endTimes_.emplace_back(INVALID_TIME);
130 return ids_.size() - 1;
131 }
UpdateNameIndex(TableRowId index,DataIndex nameId)132 void DynamicFrame::UpdateNameIndex(TableRowId index, DataIndex nameId)
133 {
134 if (index <= Size()) {
135 names_[index] = nameId;
136 }
137 }
UpdateEndTime(TableRowId index,InternalTime endTime)138 void DynamicFrame::UpdateEndTime(TableRowId index, InternalTime endTime)
139 {
140 if (index <= Size()) {
141 endTimes_[index] = endTime;
142 }
143 }
Size() const144 size_t DynamicFrame::Size() const
145 {
146 return ids_.size();
147 }
IdsData() const148 const std::deque<uint64_t> &DynamicFrame::IdsData() const
149 {
150 return ids_;
151 }
Xs() const152 const std::deque<uint32_t> &DynamicFrame::Xs() const
153 {
154 return xs_;
155 }
Ys() const156 const std::deque<uint32_t> &DynamicFrame::Ys() const
157 {
158 return ys_;
159 }
Widths() const160 const std::deque<uint32_t> &DynamicFrame::Widths() const
161 {
162 return widths_;
163 }
Heights() const164 const std::deque<uint32_t> &DynamicFrame::Heights() const
165 {
166 return heights_;
167 }
Alphas() const168 const std::deque<DataIndex> &DynamicFrame::Alphas() const
169 {
170 return alphas_;
171 }
Names() const172 const std::deque<DataIndex> &DynamicFrame::Names() const
173 {
174 return names_;
175 }
EndTimes() const176 const std::deque<InternalTime> &DynamicFrame::EndTimes() const
177 {
178 return endTimes_;
179 }
Clear()180 void DynamicFrame::Clear()
181 {
182 xs_.clear();
183 ys_.clear();
184 widths_.clear();
185 heights_.clear();
186 alphas_.clear();
187 names_.clear();
188 endTimes_.clear();
189 ids_.clear();
190 }
191 } // namespace TraceStdtype
192 } // namespace SysTuning
193