blob: 13e054e2496ce4f2bb42773706428408b19b35b4 [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
Ady Abrahamb0dbdaa2020-01-06 16:19:42 -080017// TODO(b/129481165): remove the #pragma below and fix conversion issues
18#pragma clang diagnostic push
19#pragma clang diagnostic ignored "-Wconversion"
20
Robert Carr2047fae2016-11-28 14:09:09 -080021#include "LayerVector.h"
22#include "Layer.h"
23
24namespace android {
Dan Stoza412903f2017-04-27 13:42:17 -070025
chaviwfd462612018-05-31 16:11:27 -070026LayerVector::LayerVector(const StateSet stateSet) : mStateSet(stateSet) {}
Dan Stoza412903f2017-04-27 13:42:17 -070027
chaviwfd462612018-05-31 16:11:27 -070028LayerVector::LayerVector(const LayerVector& rhs, const StateSet stateSet)
29 : SortedVector<sp<Layer>>(rhs), mStateSet(stateSet) {}
Robert Carr2047fae2016-11-28 14:09:09 -080030
Dan Stoza412903f2017-04-27 13:42:17 -070031LayerVector::~LayerVector() = default;
32
chaviwfd462612018-05-31 16:11:27 -070033// This operator override is needed to prevent mStateSet from getting copied over.
34LayerVector& LayerVector::operator=(const LayerVector& rhs) {
35 SortedVector::operator=(rhs);
36 return *this;
37}
38
Robert Carr2047fae2016-11-28 14:09:09 -080039int LayerVector::do_compare(const void* lhs, const void* rhs) const
40{
41 // sort layers per layer-stack, then by z-order and finally by sequence
42 const auto& l = *reinterpret_cast<const sp<Layer>*>(lhs);
43 const auto& r = *reinterpret_cast<const sp<Layer>*>(rhs);
44
Robert Carr6a160312021-05-17 12:08:20 -070045 const auto& lState = l->getDrawingState();
46 const auto& rState = r->getDrawingState();
chaviwfd462612018-05-31 16:11:27 -070047
Ivan Lozano80de6f32017-10-30 11:24:08 -070048 if (l->sequence == r->sequence)
49 return 0;
50
51 return (l->sequence > r->sequence) ? 1 : -1;
Robert Carr2047fae2016-11-28 14:09:09 -080052}
53
Robert Carr2047fae2016-11-28 14:09:09 -080054} // namespace android
Ady Abrahamb0dbdaa2020-01-06 16:19:42 -080055
56// TODO(b/129481165): remove the #pragma below and fix conversion issues
57#pragma clang diagnostic pop // ignored "-Wconversion"