summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/nvnflinger/display.h
blob: 8a1956fe0ac06ba4f75cab1dc1a990fde3ae18b8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include <list>

#include "core/hle/service/nvnflinger/buffer_item_consumer.h"
#include "core/hle/service/nvnflinger/hwc_layer.h"

namespace Service::Nvnflinger {

struct Layer {
    explicit Layer(std::shared_ptr<android::BufferItemConsumer> buffer_item_consumer_,
                   s32 consumer_id_)
        : buffer_item_consumer(std::move(buffer_item_consumer_)), consumer_id(consumer_id_),
          blending(LayerBlending::None), visible(true) {}
    ~Layer() {
        buffer_item_consumer->Abandon();
    }

    std::shared_ptr<android::BufferItemConsumer> buffer_item_consumer;
    s32 consumer_id;
    LayerBlending blending;
    bool visible;
};

struct LayerStack {
    std::list<Layer> layers;
};

struct Display {
    explicit Display(u64 id_) {
        id = id_;
    }

    Layer* FindLayer(s32 consumer_id) {
        for (auto& layer : stack.layers) {
            if (layer.consumer_id == consumer_id) {
                return &layer;
            }
        }

        return nullptr;
    }

    u64 id;
    LayerStack stack;
};

} // namespace Service::Nvnflinger