aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/protocols/MesaDRM.hpp
blob: 46811d68500581e3687ca290ef254514bc602641 (plain)
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
#pragma once

#include <memory>
#include <vector>
#include <cstdint>
#include "WaylandProtocol.hpp"
#include "wayland-drm.hpp"
#include "types/Buffer.hpp"
#include "types/DMABuffer.hpp"

class CMesaDRMBufferResource {
  public:
    CMesaDRMBufferResource(uint32_t id, wl_client* client, Aquamarine::SDMABUFAttrs attrs);
    ~CMesaDRMBufferResource();

    bool good();

  private:
    SP<CDMABuffer> buffer;

    struct {
        CHyprSignalListener bufferResourceDestroy;
    } listeners;

    friend class CMesaDRMResource;
};

class CMesaDRMResource {
  public:
    CMesaDRMResource(SP<CWlDrm> resource_);

    bool good();

  private:
    SP<CWlDrm> resource;
};

class CMesaDRMProtocol : public IWaylandProtocol {
  public:
    CMesaDRMProtocol(const wl_interface* iface, const int& ver, const std::string& name);

    virtual void bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id);

  private:
    void destroyResource(CMesaDRMResource* resource);
    void destroyResource(CMesaDRMBufferResource* resource);

    //
    std::vector<SP<CMesaDRMResource>>       m_vManagers;
    std::vector<SP<CMesaDRMBufferResource>> m_vBuffers;

    std::string                             nodeName = "";

    friend class CMesaDRMResource;
    friend class CMesaDRMBufferResource;
};

namespace PROTO {
    inline UP<CMesaDRMProtocol> mesaDRM;
};