Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2020 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 | #undef LOG_TAG |
Marin Shalamanov | 1bc43ee | 2020-11-20 16:56:52 +0100 | [diff] [blame] | 18 | #define LOG_TAG "LayerHistory" |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 19 | #define ATRACE_TAG ATRACE_TAG_GRAPHICS |
| 20 | |
| 21 | #include "LayerHistory.h" |
| 22 | |
Dominik Laskowski | 983f2b5 | 2020-06-25 16:54:06 -0700 | [diff] [blame] | 23 | #include <android-base/stringprintf.h> |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 24 | #include <cutils/properties.h> |
| 25 | #include <utils/Log.h> |
| 26 | #include <utils/Timers.h> |
| 27 | #include <utils/Trace.h> |
| 28 | |
| 29 | #include <algorithm> |
| 30 | #include <cmath> |
| 31 | #include <string> |
| 32 | #include <utility> |
| 33 | |
| 34 | #include "../Layer.h" |
Marin Shalamanov | 1bc43ee | 2020-11-20 16:56:52 +0100 | [diff] [blame] | 35 | #include "LayerInfo.h" |
Dominik Laskowski | 983f2b5 | 2020-06-25 16:54:06 -0700 | [diff] [blame] | 36 | #include "SchedulerUtils.h" |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 37 | |
Marin Shalamanov | 1bc43ee | 2020-11-20 16:56:52 +0100 | [diff] [blame] | 38 | namespace android::scheduler { |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 39 | |
| 40 | namespace { |
| 41 | |
Ady Abraham | bdda8f0 | 2021-04-01 16:06:11 -0700 | [diff] [blame] | 42 | bool isLayerActive(const LayerInfo& info, nsecs_t threshold) { |
Ady Abraham | 89089c9 | 2020-04-15 18:24:41 -0700 | [diff] [blame] | 43 | // Layers with an explicit vote are always kept active |
Ady Abraham | bdda8f0 | 2021-04-01 16:06:11 -0700 | [diff] [blame] | 44 | if (info.getSetFrameRateVote().rate.isValid()) { |
Ady Abraham | 89089c9 | 2020-04-15 18:24:41 -0700 | [diff] [blame] | 45 | return true; |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 46 | } |
Ady Abraham | 89089c9 | 2020-04-15 18:24:41 -0700 | [diff] [blame] | 47 | |
Ady Abraham | bdda8f0 | 2021-04-01 16:06:11 -0700 | [diff] [blame] | 48 | return info.isVisible() && info.getLastUpdatedTime() >= threshold; |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | bool traceEnabled() { |
| 52 | return property_get_bool("debug.sf.layer_history_trace", false); |
| 53 | } |
| 54 | |
| 55 | bool useFrameRatePriority() { |
| 56 | char value[PROPERTY_VALUE_MAX]; |
| 57 | property_get("debug.sf.use_frame_rate_priority", value, "1"); |
| 58 | return atoi(value); |
| 59 | } |
| 60 | |
Ady Abraham | bdda8f0 | 2021-04-01 16:06:11 -0700 | [diff] [blame] | 61 | void trace(const LayerInfo& info, LayerHistory::LayerVoteType type, int fps) { |
Ady Abraham | 0ccd79b | 2020-06-10 10:11:17 -0700 | [diff] [blame] | 62 | const auto traceType = [&](LayerHistory::LayerVoteType checkedType, int value) { |
| 63 | ATRACE_INT(info.getTraceTag(checkedType), type == checkedType ? value : 0); |
Ady Abraham | a6b676e | 2020-05-27 14:29:09 -0700 | [diff] [blame] | 64 | }; |
| 65 | |
Ady Abraham | 0ccd79b | 2020-06-10 10:11:17 -0700 | [diff] [blame] | 66 | traceType(LayerHistory::LayerVoteType::NoVote, 1); |
| 67 | traceType(LayerHistory::LayerVoteType::Heuristic, fps); |
| 68 | traceType(LayerHistory::LayerVoteType::ExplicitDefault, fps); |
| 69 | traceType(LayerHistory::LayerVoteType::ExplicitExactOrMultiple, fps); |
Ady Abraham | dd5bfa9 | 2021-01-07 17:56:08 -0800 | [diff] [blame] | 70 | traceType(LayerHistory::LayerVoteType::ExplicitExact, fps); |
Ady Abraham | 0ccd79b | 2020-06-10 10:11:17 -0700 | [diff] [blame] | 71 | traceType(LayerHistory::LayerVoteType::Min, 1); |
| 72 | traceType(LayerHistory::LayerVoteType::Max, 1); |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 73 | |
Ady Abraham | bdda8f0 | 2021-04-01 16:06:11 -0700 | [diff] [blame] | 74 | ALOGD("%s: %s @ %d Hz", __FUNCTION__, info.getName().c_str(), fps); |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 75 | } |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 76 | } // namespace |
| 77 | |
Ady Abraham | 3efa394 | 2021-06-24 19:01:25 -0700 | [diff] [blame] | 78 | LayerHistory::LayerHistory() |
Ady Abraham | b1b9d41 | 2020-06-01 19:53:52 -0700 | [diff] [blame] | 79 | : mTraceEnabled(traceEnabled()), mUseFrameRatePriority(useFrameRatePriority()) { |
Marin Shalamanov | 1bc43ee | 2020-11-20 16:56:52 +0100 | [diff] [blame] | 80 | LayerInfo::setTraceEnabled(mTraceEnabled); |
Ady Abraham | b1b9d41 | 2020-06-01 19:53:52 -0700 | [diff] [blame] | 81 | } |
| 82 | |
Marin Shalamanov | 1bc43ee | 2020-11-20 16:56:52 +0100 | [diff] [blame] | 83 | LayerHistory::~LayerHistory() = default; |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 84 | |
Marin Shalamanov | 4ad8b30 | 2020-12-11 15:50:08 +0100 | [diff] [blame] | 85 | void LayerHistory::registerLayer(Layer* layer, LayerVoteType type) { |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 86 | std::lock_guard lock(mLock); |
Nathaniel Nifong | 1303d91 | 2021-10-06 09:41:24 -0400 | [diff] [blame^] | 87 | LOG_ALWAYS_FATAL_IF(findLayer(layer->getSequence()).first != |
| 88 | LayerHistory::layerStatus::NotFound, |
| 89 | "%s already registered", layer->getName().c_str()); |
Ady Abraham | be09aad | 2021-05-03 18:59:38 -0700 | [diff] [blame] | 90 | auto info = std::make_unique<LayerInfo>(layer->getName(), layer->getOwnerUid(), type); |
Nathaniel Nifong | 1303d91 | 2021-10-06 09:41:24 -0400 | [diff] [blame^] | 91 | |
| 92 | // The layer can be placed on either map, it is assumed that partitionLayers() will be called |
| 93 | // to correct them. |
| 94 | mInactiveLayerInfos.insert({layer->getSequence(), std::make_pair(layer, std::move(info))}); |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 95 | } |
| 96 | |
Ady Abraham | bdda8f0 | 2021-04-01 16:06:11 -0700 | [diff] [blame] | 97 | void LayerHistory::deregisterLayer(Layer* layer) { |
| 98 | std::lock_guard lock(mLock); |
Nathaniel Nifong | 1303d91 | 2021-10-06 09:41:24 -0400 | [diff] [blame^] | 99 | if (!mActiveLayerInfos.erase(layer->getSequence())) { |
| 100 | if (!mInactiveLayerInfos.erase(layer->getSequence())) { |
| 101 | LOG_ALWAYS_FATAL("%s: unknown layer %p", __FUNCTION__, layer); |
| 102 | } |
Ady Abraham | bdda8f0 | 2021-04-01 16:06:11 -0700 | [diff] [blame] | 103 | } |
Ady Abraham | bdda8f0 | 2021-04-01 16:06:11 -0700 | [diff] [blame] | 104 | } |
| 105 | |
Marin Shalamanov | 1bc43ee | 2020-11-20 16:56:52 +0100 | [diff] [blame] | 106 | void LayerHistory::record(Layer* layer, nsecs_t presentTime, nsecs_t now, |
| 107 | LayerUpdateType updateType) { |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 108 | std::lock_guard lock(mLock); |
Nathaniel Nifong | 1303d91 | 2021-10-06 09:41:24 -0400 | [diff] [blame^] | 109 | auto id = layer->getSequence(); |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 110 | |
Nathaniel Nifong | 1303d91 | 2021-10-06 09:41:24 -0400 | [diff] [blame^] | 111 | auto [found, layerPair] = findLayer(id); |
| 112 | if (found == LayerHistory::layerStatus::NotFound) { |
Ady Abraham | be09aad | 2021-05-03 18:59:38 -0700 | [diff] [blame] | 113 | // Offscreen layer |
| 114 | ALOGV("LayerHistory::record: %s not registered", layer->getName().c_str()); |
| 115 | return; |
| 116 | } |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 117 | |
Nathaniel Nifong | 1303d91 | 2021-10-06 09:41:24 -0400 | [diff] [blame^] | 118 | const auto& info = layerPair->second; |
Ady Abraham | bdda8f0 | 2021-04-01 16:06:11 -0700 | [diff] [blame] | 119 | const auto layerProps = LayerInfo::LayerProps{ |
| 120 | .visible = layer->isVisible(), |
| 121 | .bounds = layer->getBounds(), |
| 122 | .transform = layer->getTransform(), |
| 123 | .setFrameRateVote = layer->getFrameRateForLayerTree(), |
| 124 | .frameRateSelectionPriority = layer->getFrameRateSelectionPriority(), |
| 125 | }; |
| 126 | |
| 127 | info->setLastPresentTime(presentTime, now, updateType, mModeChangePending, layerProps); |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 128 | |
| 129 | // Activate layer if inactive. |
Nathaniel Nifong | 1303d91 | 2021-10-06 09:41:24 -0400 | [diff] [blame^] | 130 | if (found == LayerHistory::layerStatus::LayerInInactiveMap) { |
| 131 | mActiveLayerInfos.insert( |
| 132 | {id, std::make_pair(layerPair->first, std::move(layerPair->second))}); |
| 133 | mInactiveLayerInfos.erase(id); |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 134 | } |
| 135 | } |
| 136 | |
Ady Abraham | 3efa394 | 2021-06-24 19:01:25 -0700 | [diff] [blame] | 137 | LayerHistory::Summary LayerHistory::summarize(const RefreshRateConfigs& refreshRateConfigs, |
| 138 | nsecs_t now) { |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 139 | LayerHistory::Summary summary; |
| 140 | |
| 141 | std::lock_guard lock(mLock); |
| 142 | |
| 143 | partitionLayers(now); |
| 144 | |
Nathaniel Nifong | 1303d91 | 2021-10-06 09:41:24 -0400 | [diff] [blame^] | 145 | for (const auto& [key, value] : mActiveLayerInfos) { |
| 146 | auto& info = value.second; |
Ady Abraham | bdda8f0 | 2021-04-01 16:06:11 -0700 | [diff] [blame] | 147 | const auto frameRateSelectionPriority = info->getFrameRateSelectionPriority(); |
Ady Abraham | aae5ed5 | 2020-06-26 09:32:43 -0700 | [diff] [blame] | 148 | const auto layerFocused = Layer::isLayerFocusedBasedOnPriority(frameRateSelectionPriority); |
Ady Abraham | bdda8f0 | 2021-04-01 16:06:11 -0700 | [diff] [blame] | 149 | ALOGV("%s has priority: %d %s focused", info->getName().c_str(), frameRateSelectionPriority, |
| 150 | layerFocused ? "" : "not"); |
Ana Krulec | 3803b8d | 2020-02-03 16:35:46 -0800 | [diff] [blame] | 151 | |
Ady Abraham | 3efa394 | 2021-06-24 19:01:25 -0700 | [diff] [blame] | 152 | const auto vote = info->getRefreshRateVote(refreshRateConfigs, now); |
Ady Abraham | 89089c9 | 2020-04-15 18:24:41 -0700 | [diff] [blame] | 153 | // Skip NoVote layer as those don't have any requirements |
Marin Shalamanov | 4608442 | 2020-10-13 12:33:42 +0200 | [diff] [blame] | 154 | if (vote.type == LayerHistory::LayerVoteType::NoVote) { |
Ady Abraham | 89089c9 | 2020-04-15 18:24:41 -0700 | [diff] [blame] | 155 | continue; |
| 156 | } |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 157 | |
Ady Abraham | 89089c9 | 2020-04-15 18:24:41 -0700 | [diff] [blame] | 158 | // Compute the layer's position on the screen |
Ady Abraham | bdda8f0 | 2021-04-01 16:06:11 -0700 | [diff] [blame] | 159 | const Rect bounds = Rect(info->getBounds()); |
| 160 | const ui::Transform transform = info->getTransform(); |
Ady Abraham | 89089c9 | 2020-04-15 18:24:41 -0700 | [diff] [blame] | 161 | constexpr bool roundOutwards = true; |
| 162 | Rect transformed = transform.transform(bounds, roundOutwards); |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 163 | |
Ady Abraham | 89089c9 | 2020-04-15 18:24:41 -0700 | [diff] [blame] | 164 | const float layerArea = transformed.getWidth() * transformed.getHeight(); |
| 165 | float weight = mDisplayArea ? layerArea / mDisplayArea : 0.0f; |
Ady Abraham | bdda8f0 | 2021-04-01 16:06:11 -0700 | [diff] [blame] | 166 | summary.push_back({info->getName(), info->getOwnerUid(), vote.type, vote.fps, |
Ady Abraham | 62a0be2 | 2020-12-08 16:54:10 -0800 | [diff] [blame] | 167 | vote.seamlessness, weight, layerFocused}); |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 168 | |
Ady Abraham | 89089c9 | 2020-04-15 18:24:41 -0700 | [diff] [blame] | 169 | if (CC_UNLIKELY(mTraceEnabled)) { |
Ady Abraham | bdda8f0 | 2021-04-01 16:06:11 -0700 | [diff] [blame] | 170 | trace(*info, vote.type, vote.fps.getIntValue()); |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 171 | } |
| 172 | } |
| 173 | |
| 174 | return summary; |
| 175 | } |
| 176 | |
Marin Shalamanov | 1bc43ee | 2020-11-20 16:56:52 +0100 | [diff] [blame] | 177 | void LayerHistory::partitionLayers(nsecs_t now) { |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 178 | const nsecs_t threshold = getActiveLayerThreshold(now); |
| 179 | |
Nathaniel Nifong | 1303d91 | 2021-10-06 09:41:24 -0400 | [diff] [blame^] | 180 | // iterate over inactive map |
| 181 | LayerInfos::iterator it = mInactiveLayerInfos.begin(); |
| 182 | while (it != mInactiveLayerInfos.end()) { |
| 183 | auto& [layerUnsafe, info] = it->second; |
Ady Abraham | bdda8f0 | 2021-04-01 16:06:11 -0700 | [diff] [blame] | 184 | if (isLayerActive(*info, threshold)) { |
Nathaniel Nifong | 1303d91 | 2021-10-06 09:41:24 -0400 | [diff] [blame^] | 185 | // move this to the active map |
| 186 | |
| 187 | mActiveLayerInfos.insert({it->first, std::move(it->second)}); |
| 188 | it = mInactiveLayerInfos.erase(it); |
| 189 | } else { |
| 190 | if (CC_UNLIKELY(mTraceEnabled)) { |
| 191 | trace(*info, LayerHistory::LayerVoteType::NoVote, 0); |
| 192 | } |
| 193 | info->onLayerInactive(now); |
| 194 | it++; |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | // iterate over active map |
| 199 | it = mActiveLayerInfos.begin(); |
| 200 | while (it != mActiveLayerInfos.end()) { |
| 201 | auto& [layerUnsafe, info] = it->second; |
| 202 | if (isLayerActive(*info, threshold)) { |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 203 | // Set layer vote if set |
Ady Abraham | bdda8f0 | 2021-04-01 16:06:11 -0700 | [diff] [blame] | 204 | const auto frameRate = info->getSetFrameRateVote(); |
Ady Abraham | 71c437d | 2020-01-31 15:56:57 -0800 | [diff] [blame] | 205 | const auto voteType = [&]() { |
| 206 | switch (frameRate.type) { |
| 207 | case Layer::FrameRateCompatibility::Default: |
| 208 | return LayerVoteType::ExplicitDefault; |
| 209 | case Layer::FrameRateCompatibility::ExactOrMultiple: |
| 210 | return LayerVoteType::ExplicitExactOrMultiple; |
| 211 | case Layer::FrameRateCompatibility::NoVote: |
| 212 | return LayerVoteType::NoVote; |
Ady Abraham | dd5bfa9 | 2021-01-07 17:56:08 -0800 | [diff] [blame] | 213 | case Layer::FrameRateCompatibility::Exact: |
| 214 | return LayerVoteType::ExplicitExact; |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 215 | } |
Ady Abraham | 71c437d | 2020-01-31 15:56:57 -0800 | [diff] [blame] | 216 | }(); |
Ady Abraham | 5dde597 | 2020-05-13 10:50:54 -0700 | [diff] [blame] | 217 | |
Marin Shalamanov | e8a663d | 2020-11-24 17:48:00 +0100 | [diff] [blame] | 218 | if (frameRate.rate.isValid() || voteType == LayerVoteType::NoVote) { |
Ady Abraham | bdda8f0 | 2021-04-01 16:06:11 -0700 | [diff] [blame] | 219 | const auto type = info->isVisible() ? voteType : LayerVoteType::NoVote; |
Marin Shalamanov | 53fc11d | 2020-11-20 14:00:13 +0100 | [diff] [blame] | 220 | info->setLayerVote({type, frameRate.rate, frameRate.seamlessness}); |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 221 | } else { |
| 222 | info->resetLayerVote(); |
| 223 | } |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 224 | |
Nathaniel Nifong | 1303d91 | 2021-10-06 09:41:24 -0400 | [diff] [blame^] | 225 | it++; |
| 226 | } else { |
| 227 | if (CC_UNLIKELY(mTraceEnabled)) { |
| 228 | trace(*info, LayerHistory::LayerVoteType::NoVote, 0); |
| 229 | } |
| 230 | info->onLayerInactive(now); |
| 231 | // move this to the inactive map |
| 232 | mInactiveLayerInfos.insert({it->first, std::move(it->second)}); |
| 233 | it = mActiveLayerInfos.erase(it); |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 234 | } |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 235 | } |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 236 | } |
| 237 | |
Marin Shalamanov | 1bc43ee | 2020-11-20 16:56:52 +0100 | [diff] [blame] | 238 | void LayerHistory::clear() { |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 239 | std::lock_guard lock(mLock); |
Nathaniel Nifong | 1303d91 | 2021-10-06 09:41:24 -0400 | [diff] [blame^] | 240 | for (const auto& [key, value] : mActiveLayerInfos) { |
| 241 | value.second->clearHistory(systemTime()); |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 242 | } |
Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 243 | } |
Ady Abraham | 0ccd79b | 2020-06-10 10:11:17 -0700 | [diff] [blame] | 244 | |
Marin Shalamanov | 1bc43ee | 2020-11-20 16:56:52 +0100 | [diff] [blame] | 245 | std::string LayerHistory::dump() const { |
Dominik Laskowski | 983f2b5 | 2020-06-25 16:54:06 -0700 | [diff] [blame] | 246 | std::lock_guard lock(mLock); |
Nathaniel Nifong | 1303d91 | 2021-10-06 09:41:24 -0400 | [diff] [blame^] | 247 | return base::StringPrintf("LayerHistory{size=%zu, active=%zu}", |
| 248 | mActiveLayerInfos.size() + mInactiveLayerInfos.size(), |
| 249 | mActiveLayerInfos.size()); |
| 250 | } |
| 251 | |
| 252 | float LayerHistory::getLayerFramerate(nsecs_t now, int32_t id) const { |
| 253 | std::lock_guard lock(mLock); |
| 254 | auto [found, layerPair] = findLayer(id); |
| 255 | if (found != LayerHistory::layerStatus::NotFound) { |
| 256 | return layerPair->second->getFps(now).getValue(); |
| 257 | } |
| 258 | return 0.f; |
| 259 | } |
| 260 | |
| 261 | std::pair<LayerHistory::layerStatus, LayerHistory::LayerPair*> LayerHistory::findLayer(int32_t id) { |
| 262 | // the layer could be in either the active or inactive map, try both |
| 263 | auto it = mActiveLayerInfos.find(id); |
| 264 | if (it != mActiveLayerInfos.end()) { |
| 265 | return std::make_pair(LayerHistory::layerStatus::LayerInActiveMap, &(it->second)); |
| 266 | } |
| 267 | it = mInactiveLayerInfos.find(id); |
| 268 | if (it != mInactiveLayerInfos.end()) { |
| 269 | return std::make_pair(LayerHistory::layerStatus::LayerInInactiveMap, &(it->second)); |
| 270 | } |
| 271 | return std::make_pair(LayerHistory::layerStatus::NotFound, nullptr); |
| 272 | } |
| 273 | |
| 274 | std::pair<LayerHistory::layerStatus, const LayerHistory::LayerPair*> LayerHistory::findLayer( |
| 275 | int32_t id) const { |
| 276 | // the layer could be in either the active or inactive map, try both |
| 277 | auto it = mActiveLayerInfos.find(id); |
| 278 | if (it != mActiveLayerInfos.end()) { |
| 279 | return std::make_pair(LayerHistory::layerStatus::LayerInActiveMap, &(it->second)); |
| 280 | } |
| 281 | it = mInactiveLayerInfos.find(id); |
| 282 | if (it != mInactiveLayerInfos.end()) { |
| 283 | return std::make_pair(LayerHistory::layerStatus::LayerInInactiveMap, &(it->second)); |
| 284 | } |
| 285 | return std::make_pair(LayerHistory::layerStatus::NotFound, nullptr); |
Dominik Laskowski | 983f2b5 | 2020-06-25 16:54:06 -0700 | [diff] [blame] | 286 | } |
| 287 | |
Marin Shalamanov | 1bc43ee | 2020-11-20 16:56:52 +0100 | [diff] [blame] | 288 | } // namespace android::scheduler |