X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=blobdiff_plain;f=src%2Ftype3_AndroidCloud%2Fanbox-master%2Fsrc%2Fanbox%2Fgraphics%2Fopengles_message_processor.cpp;fp=src%2Ftype3_AndroidCloud%2Fanbox-master%2Fsrc%2Fanbox%2Fgraphics%2Fopengles_message_processor.cpp;h=e54c2054bad70bc899e24307dce85ab42248c3d8;hb=e26c1ec581be598521517829adba8c8dd23a768f;hp=0000000000000000000000000000000000000000;hpb=6699c1aea74eeb0eb400e6299079f0c7576f716f;p=iec.git diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/graphics/opengles_message_processor.cpp b/src/type3_AndroidCloud/anbox-master/src/anbox/graphics/opengles_message_processor.cpp new file mode 100644 index 0000000..e54c205 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/graphics/opengles_message_processor.cpp @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2016 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#include "anbox/graphics/opengles_message_processor.h" +#include "anbox/common/small_vector.h" +#include "anbox/graphics/buffered_io_stream.h" +#include "anbox/graphics/emugl/RenderThread.h" +#include "anbox/logger.h" +#include "anbox/network/connections.h" +#include "anbox/network/delegate_message_processor.h" + +#include +#include +#include + +namespace anbox { +namespace graphics { +std::mutex OpenGlesMessageProcessor::global_lock{}; + +OpenGlesMessageProcessor::OpenGlesMessageProcessor( + const std::shared_ptr &renderer, + const std::shared_ptr &messenger) + : messenger_(messenger), + stream_(std::make_shared(messenger_)) { + // We have to read the client flags first before we can continue + // processing the actual commands + unsigned int client_flags = 0; + auto err = messenger_->receive_msg( + boost::asio::buffer(&client_flags, sizeof(unsigned int))); + if (err) ERROR("%s", err.message()); + + render_thread_.reset(RenderThread::create(renderer, stream_.get(), std::ref(global_lock))); + if (!render_thread_->start()) + BOOST_THROW_EXCEPTION( + std::runtime_error("Failed to start renderer thread")); +} + +OpenGlesMessageProcessor::~OpenGlesMessageProcessor() { + render_thread_->forceStop(); + render_thread_->wait(nullptr); +} + +bool OpenGlesMessageProcessor::process_data( + const std::vector &data) { + auto stream = std::static_pointer_cast(stream_); + Buffer buffer{data.data(), data.data() + data.size()}; + stream->post_data(std::move(buffer)); + return true; +} +} // namespace graphics +} // namespace anbox