2
* Copyright © 2017 Canonical Ltd.
4
* This program is free software: you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License version 3,
6
* as published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Authored by: Kevin DuBois <kevin.dubois@canonical.com>
19
#ifndef MIR_GRAPHICS_NESTED_HOST_BUFFER_H_
20
#define MIR_GRAPHICS_NESTED_HOST_BUFFER_H_
22
#include "mir/graphics/buffer_properties.h"
23
#include "mir_toolkit/mir_buffer.h"
24
#include "mir_toolkit/extensions/gbm_buffer.h"
25
#include "mir_toolkit/extensions/android_buffer.h"
26
#include "native_buffer.h"
29
#include <condition_variable>
37
class HostBuffer : public NativeBuffer
40
HostBuffer(MirConnection* mir_connection, BufferProperties const& properties);
41
HostBuffer(MirConnection* mir_connection, geometry::Size size, MirPixelFormat format);
42
HostBuffer(MirConnection* mir_connection,
43
MirExtensionGbmBufferV1 const* ext,
44
geometry::Size size, unsigned int native_pf, unsigned int native_flags);
45
HostBuffer(MirConnection* mir_connection,
46
MirExtensionAndroidBufferV1 const* ext,
47
geometry::Size size, unsigned int native_pf, unsigned int native_flags);
50
void sync(MirBufferAccess access, std::chrono::nanoseconds ns) override;
51
MirBuffer* client_handle() const override;
52
std::unique_ptr<GraphicsRegion> get_graphics_region() override;
53
geometry::Size size() const override;
54
MirPixelFormat format() const override;
55
std::tuple<EGLenum, EGLClientBuffer, EGLint*> egl_image_creation_hints() const override;
56
static void buffer_available(MirBuffer* buffer, void* context);
57
void available(MirBuffer* buffer) override;
58
void on_ownership_notification(std::function<void()> const& fn) override;
59
MirBufferPackage* package() const override;
60
void set_fence(mir::Fd fd) override;
61
mir::Fd fence() const override;
64
MirExtensionFencedBuffersV1 const* fence_extensions = nullptr;
65
std::function<void()> f;
66
MirBuffer* handle = nullptr;
68
std::condition_variable cv;
73
#endif /* MIR_GRAPHICS_NESTED_HOST_BUFFER_H_ */