~ubuntu-branches/ubuntu/utopic/mir/utopic-proposed

« back to all changes in this revision

Viewing changes to src/client/mesa/client_platform.cpp

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release
  • Date: 2014-03-10 19:28:46 UTC
  • mto: This revision was merged to the branch mainline in revision 63.
  • Revision ID: package-import@ubuntu.com-20140310192846-rq9qm3ec26yrelo2
Tags: upstream-0.1.6+14.04.20140310
ImportĀ upstreamĀ versionĀ 0.1.6+14.04.20140310

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#include "client_platform.h"
21
21
#include "client_buffer_factory.h"
22
22
#include "mesa_native_display_container.h"
23
 
#include "buffer_file_ops.h"
24
23
#include "native_surface.h"
25
24
#include "../mir_connection.h"
26
25
#include "../client_buffer_factory.h"
27
 
#include "../native_client_platform_factory.h"
28
 
 
29
 
#include <sys/mman.h>
30
 
#include <unistd.h>
31
26
 
32
27
namespace mcl=mir::client;
33
28
namespace mclm=mir::client::mesa;
36
31
namespace
37
32
{
38
33
 
39
 
struct RealBufferFileOps : public mclm::BufferFileOps
40
 
{
41
 
    int close(int fd) const
42
 
    {
43
 
        while (::close(fd) == -1)
44
 
        {
45
 
            // Retry on EINTR, return error on anything else
46
 
            if (errno != EINTR)
47
 
                return errno;
48
 
        }
49
 
        return 0;
50
 
    }
51
 
 
52
 
    void* map(int fd, off_t offset, size_t size) const
53
 
    {
54
 
        return mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_SHARED,
55
 
                    fd, offset);
56
 
    }
57
 
 
58
 
    void unmap(void* addr, size_t size) const
59
 
    {
60
 
        munmap(addr, size);
61
 
    }
62
 
};
63
 
 
64
34
struct NativeDisplayDeleter
65
35
{
66
36
    NativeDisplayDeleter(mcl::EGLNativeDisplayContainer& container)
79
49
 
80
50
}
81
51
 
82
 
std::shared_ptr<mcl::ClientPlatform>
83
 
mcl::NativeClientPlatformFactory::create_client_platform(mcl::ClientContext* context)
84
 
{
85
 
    auto buffer_file_ops = std::make_shared<RealBufferFileOps>();
86
 
    return std::make_shared<mclm::ClientPlatform>(
87
 
        context, buffer_file_ops, mcl::EGLNativeDisplayContainer::instance());
88
 
}
89
 
 
90
52
mclm::ClientPlatform::ClientPlatform(
91
53
        ClientContext* const context,
92
54
        std::shared_ptr<BufferFileOps> const& buffer_file_ops,
125
87
    //TODO: this is awkward on both android and gbm...
126
88
    auto native_window = new NativeSurface(*client_surface);
127
89
    auto egl_native_window = new EGLNativeWindowType;
128
 
    *egl_native_window = native_window;
 
90
    *egl_native_window = reinterpret_cast<EGLNativeWindowType>(native_window);
129
91
    NativeWindowDeleter deleter(native_window);
130
92
    return std::shared_ptr<EGLNativeWindowType>(egl_native_window, deleter);
131
93
}