• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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>
22 #include <android/gui/IActivePictureListener.h>
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.
31 class ActivePictureTracker {
32 public:
33     typedef std::vector<sp<gui::IActivePictureListener>> Listeners;
34 
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.
40     void updateAndNotifyListeners(const Listeners& activePictureListenersToAdd,
41                                   const Listeners& activePictureListenersToRemove);
42 
43     // The current set of active pictures.
44     const std::vector<gui::ActivePicture>& getActivePictures() const;
45 
46 private:
47     Listeners updateListeners(const Listeners& listenersToAdd, const Listeners& listenersToRemove);
48     bool updateAndHasChanged();
49 
50     std::vector<gui::ActivePicture> mOldActivePictures;
51     std::vector<gui::ActivePicture> mNewActivePictures;
52     Listeners mListeners;
53 };
54 
55 } // namespace android
56