2
* Copyright © 2016 Canonical Ltd.
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU Lesser General Public License version 3 as
6
* 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 Lesser General Public License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17
* Cemil Azizoglu <cemil.azizoglu@canonical.com>
20
#ifndef MIR_CLIENT_RENDER_SURFACE_H
21
#define MIR_CLIENT_RENDER_SURFACE_H
23
#include "mir_connection.h"
24
#include "mir_render_surface.h"
25
#include "mir_toolkit/mir_render_surface.h"
26
#include "mir_toolkit/client_types.h"
27
#include "mir/frontend/surface_id.h"
29
#include <shared_mutex>
41
class RenderSurface : public MirRenderSurface
44
RenderSurface(MirConnection* const connection,
45
std::shared_ptr<void> native_window,
46
std::shared_ptr<ClientPlatform> client_platform,
48
MirConnection* connection() const override;
49
mir::geometry::Size size() const override;
50
void set_size(mir::geometry::Size) override;
51
MirWaitHandle* create_buffer_stream(
52
int width, int height,
53
MirPixelFormat format,
55
mir_buffer_stream_callback callback,
56
void *context) override;
57
mir::frontend::BufferStreamId stream_id() const override;
59
MirWaitHandle* release_buffer_stream(
60
mir_buffer_stream_callback callback,
61
void* context) override;
63
friend void render_surface_buffer_stream_create_callback(BufferStream* stream, void* context);
64
friend void render_surface_buffer_stream_release_callback(MirBufferStream* stream, void* context);
66
struct StreamCreationRequest
68
StreamCreationRequest(
71
mir_buffer_stream_callback cb,
81
mir_buffer_stream_callback callback;
85
struct StreamReleaseRequest
89
mir_buffer_stream_callback cb,
97
mir_buffer_stream_callback callback;
102
MirConnection* const connection_;
103
std::shared_ptr<void> wrapped_native_window;
104
std::shared_ptr<ClientPlatform> platform;
105
ClientBufferStream* stream_;
106
std::shared_ptr<StreamCreationRequest> stream_creation_request;
107
std::shared_ptr<StreamReleaseRequest> stream_release_request;
108
std::shared_timed_mutex guard;
110
std::mutex mutable size_mutex;
111
geometry::Size desired_size;
115
#endif /* MIR_CLIENT_RENDER_SURFACE_H */