~mir-team/mir/in-process-egl+input-conglomeration

« back to all changes in this revision

Viewing changes to src/server/graphics/gbm/gbm_platform.cpp

Merged trunk and fixed issues

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
#include "gbm_buffer_allocator.h"
22
22
#include "gbm_display.h"
 
23
#include "internal_client.h"
 
24
#include "internal_native_display.h"
23
25
#include "linux_virtual_terminal.h"
24
26
#include "mir/graphics/platform_ipc_package.h"
25
 
#include "mir/graphics/egl/mesa_native_display.h"
26
27
 
27
28
#include <xf86drm.h>
28
29
 
31
32
 
32
33
namespace mg = mir::graphics;
33
34
namespace mgg = mg::gbm;
34
 
namespace mgeglm = mg::egl::mesa;
35
35
namespace mc = mir::compositor;
36
 
 
37
36
namespace
38
37
{
39
38
 
76
75
 
77
76
}
78
77
 
 
78
std::shared_ptr<mgg::InternalNativeDisplay> mgg::GBMPlatform::internal_native_display;
 
79
bool mgg::GBMPlatform::internal_display_clients_present;
79
80
mgg::GBMPlatform::GBMPlatform(std::shared_ptr<DisplayReport> const& listener,
80
81
                              std::shared_ptr<VirtualTerminal> const& vt)
81
82
    : listener{listener},
82
 
      vt{vt},
83
 
      native_display{0}
 
83
      vt{vt}
84
84
{
85
85
    drm.setup();
86
86
    gbm.setup(drm);
87
 
}
 
87
    internal_display_clients_present = false;
 
88
}
 
89
 
 
90
mgg::GBMPlatform::~GBMPlatform()
 
91
{
 
92
    internal_native_display.reset();
 
93
    internal_display_clients_present = false;
 
94
}
 
95
 
88
96
 
89
97
std::shared_ptr<mc::GraphicBufferAllocator> mgg::GBMPlatform::create_buffer_allocator(
90
98
        const std::shared_ptr<mg::BufferInitializer>& buffer_initializer)
110
118
    drm.auth_magic(magic);
111
119
}
112
120
 
113
 
EGLNativeDisplayType mgg::GBMPlatform::shell_egl_display()
 
121
std::shared_ptr<mg::InternalClient> mgg::GBMPlatform::create_internal_client(
 
122
    std::shared_ptr<frontend::Surface> const& surface)
114
123
{
115
 
    if (native_display)
116
 
        return reinterpret_cast<EGLNativeDisplayType>(native_display.get());
117
 
    native_display = mgeglm::create_native_display(this->shared_from_this());
118
 
    
119
 
    return reinterpret_cast<EGLNativeDisplayType>(native_display.get());
 
124
    if (!internal_native_display)
 
125
        internal_native_display = std::make_shared<mgg::InternalNativeDisplay>(get_ipc_package()); 
 
126
    internal_display_clients_present = true;
 
127
    return std::make_shared<mgg::InternalClient>(internal_native_display, surface);
120
128
}
121
129
 
122
130
std::shared_ptr<mg::Platform> mg::create_platform(std::shared_ptr<DisplayReport> const& report)
125
133
    auto vt = std::make_shared<mgg::LinuxVirtualTerminal>(real_fops, report);
126
134
    return std::make_shared<mgg::GBMPlatform>(report, vt);
127
135
}
 
136
 
 
137
extern "C"
 
138
{
 
139
int mir_server_internal_display_is_valid(MirMesaEGLNativeDisplay* display)
 
140
{
 
141
    return ((mgg::GBMPlatform::internal_display_clients_present) &&
 
142
            (display == mgg::GBMPlatform::internal_native_display.get()));
 
143
}
 
144
 
 
145
/* TODO: this function is a bit fragile because libmirserver and libmirclient both have very different
 
146
 *       implementations and both have symbols for it.
 
147
 *       bug filed: lp:1177902
 
148
 */
 
149
int mir_egl_mesa_display_is_valid(MirMesaEGLNativeDisplay* display)
 
150
{
 
151
    return mir_server_internal_display_is_valid(display);
 
152
}
 
153
}