summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/nvnflinger/surface_flinger.h
blob: a2e66143064f18ee603e6c9e7f1f56417d8b7914 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include <vector>

#include "common/common_types.h"
#include "core/hle/service/kernel_helpers.h"
#include "core/hle/service/nvnflinger/hardware_composer.h"

namespace Core {
class System;
}

namespace Service::Nvidia {
class Module;
}

// TODO: ISurfaceComposer
// TODO: ISurfaceComposerClient

namespace Service::Nvnflinger {

struct Display;
class HosBinderDriverServer;
enum class LayerBlending : u32;
struct Layer;

class SurfaceFlinger {
public:
    explicit SurfaceFlinger(Core::System& system, HosBinderDriverServer& server);
    ~SurfaceFlinger();

    void AddDisplay(u64 display_id);
    void RemoveDisplay(u64 display_id);
    void ComposeDisplay(s32* out_swap_interval, f32* out_compose_speed_scale, u64 display_id);

    void AddLayerToDisplayStack(u64 display_id, s32 consumer_binder_id);
    void RemoveLayerFromDisplayStack(u64 display_id, s32 consumer_binder_id);

    void SetLayerVisibility(s32 consumer_binder_id, bool visible);
    void SetLayerBlending(s32 consumer_binder_id, LayerBlending blending);

private:
    Display* FindDisplay(u64 display_id);
    Layer* FindLayer(s32 consumer_binder_id);

public:
    // TODO: these don't belong here
    void CreateBufferQueue(s32* out_consumer_binder_id, s32* out_producer_binder_id);
    void DestroyBufferQueue(s32 consumer_binder_id, s32 producer_binder_id);

private:
    Core::System& m_system;
    HosBinderDriverServer& m_server;
    KernelHelpers::ServiceContext m_context;

    std::vector<Display> m_displays;
    std::shared_ptr<Nvidia::Module> nvdrv;
    s32 disp_fd;
    HardwareComposer m_composer;
};

} // namespace Service::Nvnflinger