blob: cb319a58be867e960859ef35774a546b3c9df855 [file] [log] [blame]
Brian Lindahlf5fdff82024-11-01 09:28:47 -06001/*
2 * Copyright 2024 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#pragma once
18
19#include <vector>
20
21#include <android/gui/ActivePicture.h>
Brian Lindahlf1cfbf62024-12-06 08:07:16 -070022#include <android/gui/IActivePictureListener.h>
Brian Lindahlf5fdff82024-11-01 09:28:47 -060023
24namespace android {
25
26class Layer;
27class LayerFE;
28struct CompositionResult;
29
30// Keeps track of active pictures - layers that are undergoing picture processing.
Brian Lindahle8334902024-12-06 08:25:05 -070031class ActivePictureTracker {
Brian Lindahlf5fdff82024-11-01 09:28:47 -060032public:
Brian Lindahlf1cfbf62024-12-06 08:07:16 -070033 typedef std::vector<sp<gui::IActivePictureListener>> Listeners;
34
Brian Lindahlf5fdff82024-11-01 09:28:47 -060035 // Called for each visible layer when SurfaceFlinger finishes composing.
36 void onLayerComposed(const Layer& layer, const LayerFE& layerFE,
37 const CompositionResult& result);
38
39 // Update internals and return whether the set of active pictures have changed.
Brian Lindahlf1cfbf62024-12-06 08:07:16 -070040 void updateAndNotifyListeners(const Listeners& activePictureListenersToAdd,
41 const Listeners& activePictureListenersToRemove);
Brian Lindahlf5fdff82024-11-01 09:28:47 -060042
43 // The current set of active pictures.
44 const std::vector<gui::ActivePicture>& getActivePictures() const;
45
46private:
Brian Lindahlf1cfbf62024-12-06 08:07:16 -070047 Listeners updateListeners(const Listeners& listenersToAdd, const Listeners& listenersToRemove);
48 bool updateAndHasChanged();
49
Brian Lindahlf5fdff82024-11-01 09:28:47 -060050 std::vector<gui::ActivePicture> mOldActivePictures;
51 std::vector<gui::ActivePicture> mNewActivePictures;
Brian Lindahlf1cfbf62024-12-06 08:07:16 -070052 Listeners mListeners;
Brian Lindahlf5fdff82024-11-01 09:28:47 -060053};
54
55} // namespace android