blob: 7dfa4a035077c4c890c4d4f9e11002c299ec77e0 [file] [log] [blame]
Robert Carr2047fae2016-11-28 14:09:09 -08001/*
2 * Copyright (C) 2016 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#ifndef ANDROID_SURFACE_FLINGER_LAYER_VECTOR_H
18#define ANDROID_SURFACE_FLINGER_LAYER_VECTOR_H
19
20#include <utils/SortedVector.h>
21#include <utils/RefBase.h>
22
23#include <functional>
24
25namespace android {
26class Layer;
27
28/*
29 * Used by the top-level SurfaceFlinger state and individual layers
30 * to track layers they own sorted according to Z-order. Provides traversal
31 * functions for traversing all owned layers, and their descendents.
32 */
33class LayerVector : public SortedVector<sp<Layer>> {
34public:
35 LayerVector() = default;
36 LayerVector(const LayerVector& rhs);
37 // Sorts layer by layer-stack, Z order, and finally creation order (sequence).
38 int do_compare(const void* lhs, const void* rhs) const override;
39
40 void traverseInReverseZOrder(const std::function<void(Layer*)>& consume) const;
41 void traverseInZOrder(const std::function<void(Layer*)>& consume) const;
42};
43}
44
45#endif /* ANDROID_SURFACE_FLINGER_LAYER_VECTOR_H_ */