summaryrefslogtreecommitdiff
path: root/src/protocols/types/SurfaceStateQueue.hpp
blob: 8d9db7a5915d1e391fe3d3f993eedc1643475cf8 (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
#pragma once

#include "../../helpers/memory/Memory.hpp"
#include "SurfaceState.hpp"
#include <deque>

class CWLSurfaceResource;

class CSurfaceStateQueue {
  public:
    CSurfaceStateQueue() = default;
    explicit CSurfaceStateQueue(WP<CWLSurfaceResource> surf);

    void              clear();
    WP<SSurfaceState> enqueue(UP<SSurfaceState>&& state);
    void              dropState(const WP<SSurfaceState>& state);
    void              lock(const WP<SSurfaceState>& state, eLockReason reason);
    void              unlock(const WP<SSurfaceState>& state, eLockReason reason);
    void              unlockFirst(eLockReason reason);
    void              tryProcess();

  private:
    std::deque<UP<SSurfaceState>>                    m_queue;
    WP<CWLSurfaceResource>                           m_surface;

    typename std::deque<UP<SSurfaceState>>::iterator find(const WP<SSurfaceState>& state);
};