~ubuntu-branches/ubuntu/vivid/mir/vivid

« back to all changes in this revision

Viewing changes to src/platform/graphics/android/ipc_operations.cpp

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release
  • Date: 2014-10-10 14:01:26 UTC
  • mto: This revision was merged to the branch mainline in revision 84.
  • Revision ID: package-import@ubuntu.com-20141010140126-n1czko8na1kuz4ll
Tags: upstream-0.8.0+14.10.20141010
Import upstream version 0.8.0+14.10.20141010

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright © 2014 Canonical Ltd.
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify it
 
5
 * under the terms of the GNU Lesser General Public License version 3,
 
6
 * as 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: Kevin DuBois <kevin.dubois@canonical.com>
 
17
 */
 
18
 
 
19
#include "mir/graphics/platform_ipc_package.h"
 
20
#include "mir/graphics/buffer.h"
 
21
#include "mir/graphics/buffer_ipc_message.h"
 
22
#include "mir/graphics/android/android_native_buffer.h"
 
23
#include "ipc_operations.h"
 
24
 
 
25
namespace mg = mir::graphics;
 
26
namespace mga = mir::graphics::android;
 
27
 
 
28
void mga::IpcOperations::pack_buffer(BufferIpcMessage& msg, Buffer const& buffer, BufferIpcMsgType msg_type) const
 
29
{
 
30
    auto native_buffer = buffer.native_buffer_handle();
 
31
 
 
32
    /* TODO: instead of waiting, pack the fence fd in the message to the client */ 
 
33
    native_buffer->ensure_available_for(mga::BufferAccess::write);
 
34
    if (msg_type == mg::BufferIpcMsgType::full_msg)
 
35
    {
 
36
        auto buffer_handle = native_buffer->handle();
 
37
        int offset = 0;
 
38
 
 
39
        for(auto i = 0; i < buffer_handle->numFds; i++)
 
40
        {
 
41
            msg.pack_fd(mir::Fd(IntOwnedFd{buffer_handle->data[offset++]}));
 
42
        }
 
43
        for(auto i = 0; i < buffer_handle->numInts; i++)
 
44
        {
 
45
            msg.pack_data(buffer_handle->data[offset++]);
 
46
        }
 
47
 
 
48
        msg.pack_stride(buffer.stride());
 
49
        msg.pack_size(buffer.size());
 
50
    }
 
51
}
 
52
 
 
53
void mga::IpcOperations::unpack_buffer(BufferIpcMessage&, Buffer const&) const
 
54
{
 
55
}
 
56
 
 
57
std::shared_ptr<mg::PlatformIPCPackage> mga::IpcOperations::connection_ipc_package()
 
58
{
 
59
    return std::make_shared<mg::PlatformIPCPackage>();
 
60
}