Brian Lindahl | f5fdff8 | 2024-11-01 09:28:47 -0600 | [diff] [blame] | 1 | /* |
| 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 Lindahl | f1cfbf6 | 2024-12-06 08:07:16 -0700 | [diff] [blame] | 22 | #include <android/gui/IActivePictureListener.h> |
Brian Lindahl | f5fdff8 | 2024-11-01 09:28:47 -0600 | [diff] [blame] | 23 | |
| 24 | namespace android { |
| 25 | |
| 26 | class Layer; |
| 27 | class LayerFE; |
| 28 | struct CompositionResult; |
| 29 | |
| 30 | // Keeps track of active pictures - layers that are undergoing picture processing. |
Brian Lindahl | e833490 | 2024-12-06 08:25:05 -0700 | [diff] [blame] | 31 | class ActivePictureTracker { |
Brian Lindahl | f5fdff8 | 2024-11-01 09:28:47 -0600 | [diff] [blame] | 32 | public: |
Brian Lindahl | f1cfbf6 | 2024-12-06 08:07:16 -0700 | [diff] [blame] | 33 | typedef std::vector<sp<gui::IActivePictureListener>> Listeners; |
| 34 | |
Brian Lindahl | f5fdff8 | 2024-11-01 09:28:47 -0600 | [diff] [blame] | 35 | // 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 Lindahl | f1cfbf6 | 2024-12-06 08:07:16 -0700 | [diff] [blame] | 40 | void updateAndNotifyListeners(const Listeners& activePictureListenersToAdd, |
| 41 | const Listeners& activePictureListenersToRemove); |
Brian Lindahl | f5fdff8 | 2024-11-01 09:28:47 -0600 | [diff] [blame] | 42 | |
| 43 | // The current set of active pictures. |
| 44 | const std::vector<gui::ActivePicture>& getActivePictures() const; |
| 45 | |
| 46 | private: |
Brian Lindahl | f1cfbf6 | 2024-12-06 08:07:16 -0700 | [diff] [blame] | 47 | Listeners updateListeners(const Listeners& listenersToAdd, const Listeners& listenersToRemove); |
| 48 | bool updateAndHasChanged(); |
| 49 | |
Brian Lindahl | f5fdff8 | 2024-11-01 09:28:47 -0600 | [diff] [blame] | 50 | std::vector<gui::ActivePicture> mOldActivePictures; |
| 51 | std::vector<gui::ActivePicture> mNewActivePictures; |
Brian Lindahl | f1cfbf6 | 2024-12-06 08:07:16 -0700 | [diff] [blame] | 52 | Listeners mListeners; |
Brian Lindahl | f5fdff8 | 2024-11-01 09:28:47 -0600 | [diff] [blame] | 53 | }; |
| 54 | |
| 55 | } // namespace android |