~kdub/mir/real-nested-platform

« back to all changes in this revision

Viewing changes to src/client/render_surface.h

  • Committer: Kevin DuBois
  • Date: 2016-11-23 12:59:00 UTC
  • mfrom: (3665.5.163 development-branch)
  • Revision ID: kevin.dubois@canonical.com-20161123125900-4gzspvl0y7q47rsj
merge in base, fix many conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright © 2016 Canonical Ltd.
 
3
 *
 
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.
 
7
 *
 
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.
 
12
 *
 
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/>.
 
15
 *
 
16
 * Authored by:
 
17
 *   Cemil Azizoglu <cemil.azizoglu@canonical.com>
 
18
 */
 
19
 
 
20
#ifndef MIR_CLIENT_RENDER_SURFACE_H
 
21
#define MIR_CLIENT_RENDER_SURFACE_H
 
22
 
 
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"
 
28
 
 
29
#include <shared_mutex>
 
30
#include <memory>
 
31
 
 
32
namespace mir
 
33
{
 
34
namespace client
 
35
{
 
36
class ClientPlatform;
 
37
namespace rpc
 
38
{
 
39
class DisplayServer;
 
40
}
 
41
class RenderSurface : public MirRenderSurface
 
42
{
 
43
public:
 
44
    RenderSurface(MirConnection* const connection,
 
45
                  std::shared_ptr<void> native_window,
 
46
                  std::shared_ptr<ClientPlatform> client_platform,
 
47
                  geometry::Size size);
 
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,
 
54
        MirBufferUsage usage,
 
55
        mir_buffer_stream_callback callback,
 
56
        void *context) override;
 
57
    mir::frontend::BufferStreamId stream_id() const override;
 
58
 
 
59
    MirWaitHandle* release_buffer_stream(
 
60
        mir_buffer_stream_callback callback,
 
61
        void* context) override;
 
62
 
 
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);
 
65
 
 
66
    struct StreamCreationRequest
 
67
    {
 
68
        StreamCreationRequest(
 
69
                RenderSurface* rs,
 
70
                MirBufferUsage usage,
 
71
                mir_buffer_stream_callback cb,
 
72
                void* context) :
 
73
                    rs(rs),
 
74
                    usage(usage),
 
75
                    callback(cb),
 
76
                    context(context)
 
77
        {
 
78
        }
 
79
        RenderSurface* rs;
 
80
        MirBufferUsage usage;
 
81
        mir_buffer_stream_callback callback;
 
82
        void* context;
 
83
    };
 
84
 
 
85
    struct StreamReleaseRequest
 
86
    {
 
87
        StreamReleaseRequest(
 
88
                RenderSurface* rs,
 
89
                mir_buffer_stream_callback cb,
 
90
                void* context) :
 
91
                    rs(rs),
 
92
                    callback(cb),
 
93
                    context(context)
 
94
        {
 
95
        }
 
96
        RenderSurface* rs;
 
97
        mir_buffer_stream_callback callback;
 
98
        void* context;
 
99
    };
 
100
 
 
101
private:
 
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;
 
109
 
 
110
    std::mutex mutable size_mutex;
 
111
    geometry::Size desired_size;
 
112
};
 
113
}
 
114
}
 
115
#endif /* MIR_CLIENT_RENDER_SURFACE_H */