blob: e944eb957b639a0881224e5a16a461fa31a237bf [file] [log] [blame]
Ana Krulec61f86db2018-11-19 14:16:35 +01001/*
2 * Copyright 2018 The Android Open Source Project
3 *
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 "LayerHistory.h"
18
19#include <cinttypes>
20#include <cstdint>
21#include <numeric>
22#include <string>
23#include <unordered_map>
24
25#include <utils/Log.h>
26#include <utils/Timers.h>
27#include <utils/Trace.h>
28
29namespace android {
30
31LayerHistory::LayerHistory() {}
32
33LayerHistory::~LayerHistory() = default;
34
35void LayerHistory::insert(const std::string layerName, nsecs_t presentTime) {
36 mElements[mCounter].insert(std::make_pair(layerName, presentTime));
37}
38
39void LayerHistory::incrementCounter() {
40 mCounter++;
41 mCounter = mCounter % ARRAY_SIZE;
42 mElements[mCounter].clear();
43}
44
45const std::unordered_map<std::string, nsecs_t>& LayerHistory::get(size_t index) const {
46 return mElements.at(index);
47}
48
49} // namespace android