2
* Copyright © 2014 Canonical Ltd.
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.
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/>.
16
* Authored by: Kevin DuBois <kevin.dubois@canonical.com>
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"
25
namespace mg = mir::graphics;
26
namespace mga = mir::graphics::android;
28
void mga::IpcOperations::pack_buffer(BufferIpcMessage& msg, Buffer const& buffer, BufferIpcMsgType msg_type) const
30
auto native_buffer = buffer.native_buffer_handle();
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)
36
auto buffer_handle = native_buffer->handle();
39
for(auto i = 0; i < buffer_handle->numFds; i++)
41
msg.pack_fd(mir::Fd(IntOwnedFd{buffer_handle->data[offset++]}));
43
for(auto i = 0; i < buffer_handle->numInts; i++)
45
msg.pack_data(buffer_handle->data[offset++]);
48
msg.pack_stride(buffer.stride());
49
msg.pack_size(buffer.size());
53
void mga::IpcOperations::unpack_buffer(BufferIpcMessage&, Buffer const&) const
57
std::shared_ptr<mg::PlatformIPCPackage> mga::IpcOperations::connection_ipc_package()
59
return std::make_shared<mg::PlatformIPCPackage>();