Correct emugl includes and move to std::{mutex,shared_ptr} where possible

This commit is contained in:
Simon Fels 2017-05-14 20:52:12 +02:00
commit 4fde30b7b6
27 changed files with 160 additions and 147 deletions

View file

@ -13,17 +13,16 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#include "ColorBuffer.h"
#include "DispatchTables.h"
#include "RenderThreadInfo.h"
#include "TextureDraw.h"
#include "TextureResize.h"
#include "OpenGLESDispatch/EGLDispatch.h"
#include "anbox/graphics/emugl/ColorBuffer.h"
#include "anbox/graphics/emugl/DispatchTables.h"
#include "anbox/graphics/emugl/RenderThreadInfo.h"
#include "anbox/graphics/emugl/TextureDraw.h"
#include "anbox/graphics/emugl/TextureResize.h"
#include "anbox/logger.h" #include "anbox/logger.h"
#include "external/android-emugl/host/include/OpenGLESDispatch/EGLDispatch.h"
#include <stdio.h> #include <stdio.h>
namespace { namespace {
@ -251,7 +250,7 @@ void ColorBuffer::subUpdate(int x, int y, int width, int height,
bool ColorBuffer::blitFromCurrentReadBuffer() { bool ColorBuffer::blitFromCurrentReadBuffer() {
RenderThreadInfo* tInfo = RenderThreadInfo::get(); RenderThreadInfo* tInfo = RenderThreadInfo::get();
if (!tInfo->currContext.Ptr()) { if (!tInfo->currContext) {
// no Current context // no Current context
return false; return false;
} }
@ -312,7 +311,7 @@ bool ColorBuffer::bindToTexture() {
return false; return false;
} }
RenderThreadInfo* tInfo = RenderThreadInfo::get(); RenderThreadInfo* tInfo = RenderThreadInfo::get();
if (!tInfo->currContext.Ptr()) { if (!tInfo->currContext) {
return false; return false;
} }
if (tInfo->currContext->isGL2()) { if (tInfo->currContext->isGL2()) {
@ -328,7 +327,7 @@ bool ColorBuffer::bindToRenderbuffer() {
return false; return false;
} }
RenderThreadInfo* tInfo = RenderThreadInfo::get(); RenderThreadInfo* tInfo = RenderThreadInfo::get();
if (!tInfo->currContext.Ptr()) { if (!tInfo->currContext) {
return false; return false;
} }
if (tInfo->currContext->isGL2()) { if (tInfo->currContext->isGL2()) {

View file

@ -19,7 +19,6 @@
#include <EGL/egl.h> #include <EGL/egl.h>
#include <EGL/eglext.h> #include <EGL/eglext.h>
#include <GLES/gl.h> #include <GLES/gl.h>
#include "emugl/common/smart_ptr.h"
#include <memory> #include <memory>
@ -135,6 +134,6 @@ class ColorBuffer {
TextureResize* m_resizer; TextureResize* m_resizer;
}; };
typedef emugl::SmartPtr<ColorBuffer> ColorBufferPtr; typedef std::shared_ptr<ColorBuffer> ColorBufferPtr;
#endif #endif

View file

@ -13,13 +13,14 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#include "ReadBuffer.h"
#include "anbox/graphics/emugl/ReadBuffer.h"
#include "anbox/logger.h"
#include <assert.h> #include <assert.h>
#include <limits.h> #include <limits.h>
#include <string.h> #include <string.h>
#include "anbox/logger.h"
ReadBuffer::ReadBuffer(size_t bufsize) { ReadBuffer::ReadBuffer(size_t bufsize) {
m_size = bufsize; m_size = bufsize;
m_buf = static_cast<unsigned char*>(malloc(m_size * sizeof(unsigned char))); m_buf = static_cast<unsigned char*>(malloc(m_size * sizeof(unsigned char)));

View file

@ -16,7 +16,7 @@
#ifndef _READ_BUFFER_H #ifndef _READ_BUFFER_H
#define _READ_BUFFER_H #define _READ_BUFFER_H
#include "IOStream.h" #include "external/android-emugl/host/include/libOpenglRender/IOStream.h"
class ReadBuffer { class ReadBuffer {
public: public:
@ -34,4 +34,5 @@ class ReadBuffer {
size_t m_size; size_t m_size;
size_t m_validData; size_t m_validData;
}; };
#endif #endif

View file

@ -14,15 +14,14 @@
* limitations under the License. * limitations under the License.
*/ */
#include "RenderApi.h" #include "anbox/graphics/emugl/RenderApi.h"
#include "anbox/graphics/emugl/DispatchTables.h"
#include "DispatchTables.h" #include "external/android-emugl/host/include/OpenGLESDispatch/EGLDispatch.h"
#include "external/android-emugl/host/include/OpenGLESDispatch/GLESv1Dispatch.h"
#include "external/android-emugl/host/include/OpenGLESDispatch/GLESv2Dispatch.h"
#include "OpenGLESDispatch/EGLDispatch.h" #include "external/android-emugl/shared/emugl/common/crash_reporter.h"
#include "OpenGLESDispatch/GLESv1Dispatch.h"
#include "OpenGLESDispatch/GLESv2Dispatch.h"
#include "emugl/common/crash_reporter.h"
#include <string.h> #include <string.h>

View file

@ -21,7 +21,7 @@
#include <boost/filesystem/path.hpp> #include <boost/filesystem/path.hpp>
#include "emugl/common/logging.h" #include "external/android-emugl/shared/emugl/common/logging.h"
typedef struct { typedef struct {
logger_t coarse; logger_t coarse;

View file

@ -13,7 +13,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#include "RenderContext.h"
#include "anbox/graphics/emugl/RenderContext.h"
#include "OpenGLESDispatch/EGLDispatch.h" #include "OpenGLESDispatch/EGLDispatch.h"

View file

@ -13,14 +13,16 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef _LIBRENDER_RENDER_CONTEXT_H #ifndef _LIBRENDER_RENDER_CONTEXT_H
#define _LIBRENDER_RENDER_CONTEXT_H #define _LIBRENDER_RENDER_CONTEXT_H
#include "GLDecoderContextData.h" #include "external/android-emugl/shared/OpenglCodecCommon/GLDecoderContextData.h"
#include "emugl/common/smart_ptr.h"
#include <EGL/egl.h> #include <EGL/egl.h>
#include <memory>
// A class used to model a guest EGLContext. This simply wraps a host // A class used to model a guest EGLContext. This simply wraps a host
// EGLContext, associated with an GLDecoderContextData instance that is // EGLContext, associated with an GLDecoderContextData instance that is
// used to store copies of guest-side arrays. // used to store copies of guest-side arrays.
@ -60,6 +62,6 @@ class RenderContext {
GLDecoderContextData mContextData; GLDecoderContextData mContextData;
}; };
typedef emugl::SmartPtr<RenderContext> RenderContextPtr; typedef std::shared_ptr<RenderContext> RenderContextPtr;
#endif // _LIBRENDER_RENDER_CONTEXT_H #endif // _LIBRENDER_RENDER_CONTEXT_H

View file

@ -13,20 +13,20 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#include "RenderControl.h"
#include "ChecksumCalculatorThreadInfo.h"
#include "DispatchTables.h"
#include "DisplayManager.h"
#include "RenderThreadInfo.h"
#include "Renderer.h"
#include "RendererConfig.h"
#include "OpenGLESDispatch/EGLDispatch.h"
#include "anbox/graphics/emugl/RenderControl.h"
#include "anbox/graphics/emugl/DispatchTables.h"
#include "anbox/graphics/emugl/DisplayManager.h"
#include "anbox/graphics/emugl/RenderThreadInfo.h"
#include "anbox/graphics/emugl/Renderer.h"
#include "anbox/graphics/emugl/RendererConfig.h"
#include "anbox/graphics/layer_composer.h" #include "anbox/graphics/layer_composer.h"
#include "anbox/logger.h" #include "anbox/logger.h"
#include "external/android-emugl/shared/OpenglCodecCommon/ChecksumCalculatorThreadInfo.h"
#include "external/android-emugl/host/include/OpenGLESDispatch/EGLDispatch.h"
#include <map> #include <map>
#include <string> #include <string>

View file

@ -13,9 +13,11 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef _RENDER_CONTROL_H #ifndef _RENDER_CONTROL_H
#define _RENDER_CONTROL_H #define _RENDER_CONTROL_H
// Generated with emugl at build time
#include "renderControl_dec.h" #include "renderControl_dec.h"
#include <memory> #include <memory>

View file

@ -13,32 +13,31 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#include "RenderThread.h"
#include "ReadBuffer.h"
#include "RenderControl.h"
#include "RenderThreadInfo.h"
#include "Renderer.h"
#include "TimeUtils.h"
#include "../../../shared/OpenglCodecCommon/ChecksumCalculatorThreadInfo.h"
#include "OpenGLESDispatch/EGLDispatch.h"
#include "OpenGLESDispatch/GLESv1Dispatch.h"
#include "OpenGLESDispatch/GLESv2Dispatch.h"
#include "anbox/graphics/emugl/RenderThread.h"
#include "anbox/graphics/emugl/ReadBuffer.h"
#include "anbox/graphics/emugl/RenderControl.h"
#include "anbox/graphics/emugl/RenderThreadInfo.h"
#include "anbox/graphics/emugl/Renderer.h"
#include "anbox/graphics/emugl/TimeUtils.h"
#include "anbox/logger.h" #include "anbox/logger.h"
#include "external/android-emugl/shared/OpenglCodecCommon/ChecksumCalculatorThreadInfo.h"
#include "external/android-emugl/host/include/OpenGLESDispatch/EGLDispatch.h"
#include "external/android-emugl/host/include/OpenGLESDispatch/GLESv1Dispatch.h"
#include "external/android-emugl/host/include/OpenGLESDispatch/GLESv2Dispatch.h"
#define STREAM_BUFFER_SIZE 4 * 1024 * 1024 #define STREAM_BUFFER_SIZE 4 * 1024 * 1024
RenderThread::RenderThread(const std::shared_ptr<Renderer> &renderer, IOStream *stream, emugl::Mutex *lock) RenderThread::RenderThread(const std::shared_ptr<Renderer> &renderer, IOStream *stream, std::mutex &m)
: emugl::Thread(), renderer_(renderer), m_lock(lock), m_stream(stream) {} : emugl::Thread(), renderer_(renderer), m_lock(m), m_stream(stream) {}
RenderThread::~RenderThread() { RenderThread::~RenderThread() {
forceStop(); forceStop();
} }
RenderThread *RenderThread::create(const std::shared_ptr<Renderer> &renderer, IOStream *stream, emugl::Mutex *lock) { RenderThread *RenderThread::create(const std::shared_ptr<Renderer> &renderer, IOStream *stream, std::mutex &m) {
return new RenderThread(renderer, stream, lock); return new RenderThread(renderer, stream, m);
} }
void RenderThread::forceStop() { m_stream->forceStop(); } void RenderThread::forceStop() { m_stream->forceStop(); }
@ -62,7 +61,8 @@ intptr_t RenderThread::main() {
do { do {
progress = false; progress = false;
m_lock->lock(); std::unique_lock<std::mutex> l(m_lock);
size_t last = size_t last =
threadInfo.m_glDec.decode(readBuf.buf(), readBuf.validData(), m_stream); threadInfo.m_glDec.decode(readBuf.buf(), readBuf.validData(), m_stream);
if (last > 0) { if (last > 0) {
@ -83,8 +83,6 @@ intptr_t RenderThread::main() {
progress = true; progress = true;
} }
m_lock->unlock();
} while (progress); } while (progress);
} }

View file

@ -13,15 +13,16 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef _LIB_OPENGL_RENDER_RENDER_THREAD_H #ifndef _LIB_OPENGL_RENDER_RENDER_THREAD_H
#define _LIB_OPENGL_RENDER_RENDER_THREAD_H #define _LIB_OPENGL_RENDER_RENDER_THREAD_H
#include "IOStream.h" #include "external/android-emugl/host/include/libOpenglRender/IOStream.h"
#include "emugl/common/mutex.h"
#include "emugl/common/thread.h" #include "emugl/common/thread.h"
#include <memory> #include <memory>
#include <mutex>
class Renderer; class Renderer;
@ -36,7 +37,7 @@ class RenderThread : public emugl::Thread {
// decoding operations between all threads. // decoding operations between all threads.
// TODO(digit): Why is this needed here? Shouldn't this be handled // TODO(digit): Why is this needed here? Shouldn't this be handled
// by the decoders themselves or at a lower-level? // by the decoders themselves or at a lower-level?
static RenderThread* create(const std::shared_ptr<Renderer>& renderer, IOStream* stream, emugl::Mutex* mutex); static RenderThread* create(const std::shared_ptr<Renderer>& renderer, IOStream* stream, std::mutex &m);
// Destructor. // Destructor.
virtual ~RenderThread(); virtual ~RenderThread();
@ -51,12 +52,12 @@ class RenderThread : public emugl::Thread {
private: private:
RenderThread(); // No default constructor RenderThread(); // No default constructor
RenderThread(const std::shared_ptr<Renderer>& renderer, IOStream* stream, emugl::Mutex* mutex); RenderThread(const std::shared_ptr<Renderer>& renderer, IOStream* stream, std::mutex &m);
virtual intptr_t main(); virtual intptr_t main();
std::shared_ptr<Renderer> renderer_; std::shared_ptr<Renderer> renderer_;
emugl::Mutex* m_lock; std::mutex &m_lock;
IOStream* m_stream; IOStream* m_stream;
}; };

View file

@ -14,10 +14,10 @@
* limitations under the License. * limitations under the License.
*/ */
#include "RenderThreadInfo.h" #include "anbox/graphics/emugl/RenderThreadInfo.h"
#include "emugl/common/lazy_instance.h" #include "external/android-emugl/shared/emugl/common/lazy_instance.h"
#include "emugl/common/thread_store.h" #include "external/android-emugl/shared/emugl/common/thread_store.h"
namespace { namespace {
class ThreadInfoStore : public ::emugl::ThreadStore { class ThreadInfoStore : public ::emugl::ThreadStore {

View file

@ -13,13 +13,17 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef _LIB_OPENGL_RENDER_THREAD_INFO_H #ifndef _LIB_OPENGL_RENDER_THREAD_INFO_H
#define _LIB_OPENGL_RENDER_THREAD_INFO_H #define _LIB_OPENGL_RENDER_THREAD_INFO_H
#include "GLESv1Decoder.h" #include "anbox/graphics/emugl/RenderContext.h"
#include "GLESv2Decoder.h" #include "anbox/graphics/emugl/WindowSurface.h"
#include "RenderContext.h"
#include "WindowSurface.h" #include "external/android-emugl/host/libs/GLESv1_dec/GLESv1Decoder.h"
#include "external/android-emugl/host/libs/GLESv2_dec/GLESv2Decoder.h"
// Generated with emugl at build time
#include "renderControl_dec.h" #include "renderControl_dec.h"
#include <set> #include <set>

View file

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
#include "Renderable.h" #include "anbox/graphics/emugl/Renderable.h"
Renderable::Renderable(const std::string &name, const std::uint32_t &buffer, Renderable::Renderable(const std::string &name, const std::uint32_t &buffer,
const anbox::graphics::Rect &screen_position, const anbox::graphics::Rect &screen_position,

View file

@ -14,19 +14,18 @@
* limitations under the License. * limitations under the License.
*/ */
#include "Renderer.h" #include "anbox/graphics/emugl/Renderer.h"
#include "anbox/graphics/emugl/DispatchTables.h"
#include "DispatchTables.h" #include "anbox/graphics/emugl/RenderThreadInfo.h"
#include "RenderThreadInfo.h" #include "anbox/graphics/emugl/TimeUtils.h"
#include "TimeUtils.h"
#include "gles2_dec.h"
#include "OpenGLESDispatch/EGLDispatch.h"
#include "anbox/graphics/gl_extensions.h" #include "anbox/graphics/gl_extensions.h"
#include "anbox/logger.h" #include "anbox/logger.h"
#include "external/android-emugl/host/include/OpenGLESDispatch/EGLDispatch.h"
// Generated with emugl at build time
#include "gles2_dec.h"
#include <stdio.h> #include <stdio.h>
#include <glm/glm.hpp> #include <glm/glm.hpp>
@ -361,13 +360,14 @@ HandleType Renderer::genHandle() {
HandleType Renderer::createColorBuffer(int p_width, int p_height, HandleType Renderer::createColorBuffer(int p_width, int p_height,
GLenum p_internalFormat) { GLenum p_internalFormat) {
emugl::Mutex::AutoLock mutex(m_lock); std::unique_lock<std::mutex> l(m_lock);
HandleType ret = 0; HandleType ret = 0;
ColorBufferPtr cb(ColorBuffer::create( ColorBufferPtr cb(ColorBuffer::create(
getDisplay(), p_width, p_height, p_internalFormat, getDisplay(), p_width, p_height, p_internalFormat,
getCaps().has_eglimage_texture_2d, m_colorBufferHelper)); getCaps().has_eglimage_texture_2d, m_colorBufferHelper));
if (cb.Ptr() != NULL) { if (cb) {
ret = genHandle(); ret = genHandle();
m_colorbuffers[ret].cb = cb; m_colorbuffers[ret].cb = cb;
m_colorbuffers[ret].refcount = 1; m_colorbuffers[ret].refcount = 1;
@ -377,7 +377,8 @@ HandleType Renderer::createColorBuffer(int p_width, int p_height,
HandleType Renderer::createRenderContext(int p_config, HandleType p_share, HandleType Renderer::createRenderContext(int p_config, HandleType p_share,
bool p_isGL2) { bool p_isGL2) {
emugl::Mutex::AutoLock mutex(m_lock); std::unique_lock<std::mutex> l(m_lock);
HandleType ret = 0; HandleType ret = 0;
const RendererConfig *config = getConfigs()->get(p_config); const RendererConfig *config = getConfigs()->get(p_config);
@ -394,11 +395,11 @@ HandleType Renderer::createRenderContext(int p_config, HandleType p_share,
share = (*s).second; share = (*s).second;
} }
EGLContext sharedContext = EGLContext sharedContext =
share.Ptr() ? share->getEGLContext() : EGL_NO_CONTEXT; share ? share->getEGLContext() : EGL_NO_CONTEXT;
RenderContextPtr rctx(RenderContext::create( RenderContextPtr rctx(RenderContext::create(
m_eglDisplay, config->getEglConfig(), sharedContext, p_isGL2)); m_eglDisplay, config->getEglConfig(), sharedContext, p_isGL2));
if (rctx.Ptr() != NULL) { if (rctx) {
ret = genHandle(); ret = genHandle();
m_contexts[ret] = rctx; m_contexts[ret] = rctx;
RenderThreadInfo *tinfo = RenderThreadInfo::get(); RenderThreadInfo *tinfo = RenderThreadInfo::get();
@ -409,7 +410,7 @@ HandleType Renderer::createRenderContext(int p_config, HandleType p_share,
HandleType Renderer::createWindowSurface(int p_config, int p_width, HandleType Renderer::createWindowSurface(int p_config, int p_width,
int p_height) { int p_height) {
emugl::Mutex::AutoLock mutex(m_lock); std::unique_lock<std::mutex> l(m_lock);
HandleType ret = 0; HandleType ret = 0;
@ -420,7 +421,7 @@ HandleType Renderer::createWindowSurface(int p_config, int p_width,
WindowSurfacePtr win(WindowSurface::create( WindowSurfacePtr win(WindowSurface::create(
getDisplay(), config->getEglConfig(), p_width, p_height)); getDisplay(), config->getEglConfig(), p_width, p_height));
if (win.Ptr() != NULL) { if (win) {
ret = genHandle(); ret = genHandle();
m_windows[ret] = std::pair<WindowSurfacePtr, HandleType>(win, 0); m_windows[ret] = std::pair<WindowSurfacePtr, HandleType>(win, 0);
RenderThreadInfo *tinfo = RenderThreadInfo::get(); RenderThreadInfo *tinfo = RenderThreadInfo::get();
@ -431,7 +432,8 @@ HandleType Renderer::createWindowSurface(int p_config, int p_width,
} }
void Renderer::drainRenderContext() { void Renderer::drainRenderContext() {
emugl::Mutex::AutoLock mutex(m_lock); std::unique_lock<std::mutex> l(m_lock);
RenderThreadInfo *tinfo = RenderThreadInfo::get(); RenderThreadInfo *tinfo = RenderThreadInfo::get();
if (tinfo->m_contextSet.empty()) return; if (tinfo->m_contextSet.empty()) return;
for (std::set<HandleType>::iterator it = tinfo->m_contextSet.begin(); for (std::set<HandleType>::iterator it = tinfo->m_contextSet.begin();
@ -443,7 +445,8 @@ void Renderer::drainRenderContext() {
} }
void Renderer::drainWindowSurface() { void Renderer::drainWindowSurface() {
emugl::Mutex::AutoLock mutex(m_lock); std::unique_lock<std::mutex> l(m_lock);
RenderThreadInfo *tinfo = RenderThreadInfo::get(); RenderThreadInfo *tinfo = RenderThreadInfo::get();
if (tinfo->m_windowSet.empty()) return; if (tinfo->m_windowSet.empty()) return;
for (std::set<HandleType>::iterator it = tinfo->m_windowSet.begin(); for (std::set<HandleType>::iterator it = tinfo->m_windowSet.begin();
@ -466,7 +469,8 @@ void Renderer::drainWindowSurface() {
} }
void Renderer::DestroyRenderContext(HandleType p_context) { void Renderer::DestroyRenderContext(HandleType p_context) {
emugl::Mutex::AutoLock mutex(m_lock); std::unique_lock<std::mutex> l(m_lock);
m_contexts.erase(p_context); m_contexts.erase(p_context);
RenderThreadInfo *tinfo = RenderThreadInfo::get(); RenderThreadInfo *tinfo = RenderThreadInfo::get();
if (tinfo->m_contextSet.empty()) return; if (tinfo->m_contextSet.empty()) return;
@ -474,7 +478,8 @@ void Renderer::DestroyRenderContext(HandleType p_context) {
} }
void Renderer::DestroyWindowSurface(HandleType p_surface) { void Renderer::DestroyWindowSurface(HandleType p_surface) {
emugl::Mutex::AutoLock mutex(m_lock); std::unique_lock<std::mutex> l(m_lock);
if (m_windows.find(p_surface) != m_windows.end()) { if (m_windows.find(p_surface) != m_windows.end()) {
m_windows.erase(p_surface); m_windows.erase(p_surface);
RenderThreadInfo *tinfo = RenderThreadInfo::get(); RenderThreadInfo *tinfo = RenderThreadInfo::get();
@ -484,7 +489,8 @@ void Renderer::DestroyWindowSurface(HandleType p_surface) {
} }
int Renderer::openColorBuffer(HandleType p_colorbuffer) { int Renderer::openColorBuffer(HandleType p_colorbuffer) {
emugl::Mutex::AutoLock mutex(m_lock); std::unique_lock<std::mutex> l(m_lock);
ColorBufferMap::iterator c(m_colorbuffers.find(p_colorbuffer)); ColorBufferMap::iterator c(m_colorbuffers.find(p_colorbuffer));
if (c == m_colorbuffers.end()) { if (c == m_colorbuffers.end()) {
// bad colorbuffer handle // bad colorbuffer handle
@ -496,7 +502,8 @@ int Renderer::openColorBuffer(HandleType p_colorbuffer) {
} }
void Renderer::closeColorBuffer(HandleType p_colorbuffer) { void Renderer::closeColorBuffer(HandleType p_colorbuffer) {
emugl::Mutex::AutoLock mutex(m_lock); std::unique_lock<std::mutex> l(m_lock);
ColorBufferMap::iterator c(m_colorbuffers.find(p_colorbuffer)); ColorBufferMap::iterator c(m_colorbuffers.find(p_colorbuffer));
if (c == m_colorbuffers.end()) { if (c == m_colorbuffers.end()) {
// This is harmless: it is normal for guest system to issue // This is harmless: it is normal for guest system to issue
@ -511,7 +518,7 @@ void Renderer::closeColorBuffer(HandleType p_colorbuffer) {
} }
bool Renderer::flushWindowSurfaceColorBuffer(HandleType p_surface) { bool Renderer::flushWindowSurfaceColorBuffer(HandleType p_surface) {
emugl::Mutex::AutoLock mutex(m_lock); std::unique_lock<std::mutex> l(m_lock);
WindowSurfaceMap::iterator w(m_windows.find(p_surface)); WindowSurfaceMap::iterator w(m_windows.find(p_surface));
if (w == m_windows.end()) { if (w == m_windows.end()) {
@ -521,7 +528,10 @@ bool Renderer::flushWindowSurfaceColorBuffer(HandleType p_surface) {
return false; return false;
} }
WindowSurface *surface = (*w).second.first.Ptr(); auto surface = (*w).second.first;
if (!surface)
return false;
surface->flushColorBuffer(); surface->flushColorBuffer();
return true; return true;
@ -529,7 +539,7 @@ bool Renderer::flushWindowSurfaceColorBuffer(HandleType p_surface) {
bool Renderer::setWindowSurfaceColorBuffer(HandleType p_surface, bool Renderer::setWindowSurfaceColorBuffer(HandleType p_surface,
HandleType p_colorbuffer) { HandleType p_colorbuffer) {
emugl::Mutex::AutoLock mutex(m_lock); std::unique_lock<std::mutex> l(m_lock);
WindowSurfaceMap::iterator w(m_windows.find(p_surface)); WindowSurfaceMap::iterator w(m_windows.find(p_surface));
if (w == m_windows.end()) { if (w == m_windows.end()) {
@ -553,7 +563,7 @@ bool Renderer::setWindowSurfaceColorBuffer(HandleType p_surface,
void Renderer::readColorBuffer(HandleType p_colorbuffer, int x, int y, void Renderer::readColorBuffer(HandleType p_colorbuffer, int x, int y,
int width, int height, GLenum format, int width, int height, GLenum format,
GLenum type, void *pixels) { GLenum type, void *pixels) {
emugl::Mutex::AutoLock mutex(m_lock); std::unique_lock<std::mutex> l(m_lock);
ColorBufferMap::iterator c(m_colorbuffers.find(p_colorbuffer)); ColorBufferMap::iterator c(m_colorbuffers.find(p_colorbuffer));
if (c == m_colorbuffers.end()) { if (c == m_colorbuffers.end()) {
@ -567,7 +577,7 @@ void Renderer::readColorBuffer(HandleType p_colorbuffer, int x, int y,
bool Renderer::updateColorBuffer(HandleType p_colorbuffer, int x, int y, bool Renderer::updateColorBuffer(HandleType p_colorbuffer, int x, int y,
int width, int height, GLenum format, int width, int height, GLenum format,
GLenum type, void *pixels) { GLenum type, void *pixels) {
emugl::Mutex::AutoLock mutex(m_lock); std::unique_lock<std::mutex> l(m_lock);
ColorBufferMap::iterator c(m_colorbuffers.find(p_colorbuffer)); ColorBufferMap::iterator c(m_colorbuffers.find(p_colorbuffer));
if (c == m_colorbuffers.end()) { if (c == m_colorbuffers.end()) {
@ -581,7 +591,7 @@ bool Renderer::updateColorBuffer(HandleType p_colorbuffer, int x, int y,
} }
bool Renderer::bindColorBufferToTexture(HandleType p_colorbuffer) { bool Renderer::bindColorBufferToTexture(HandleType p_colorbuffer) {
emugl::Mutex::AutoLock mutex(m_lock); std::unique_lock<std::mutex> l(m_lock);
ColorBufferMap::iterator c(m_colorbuffers.find(p_colorbuffer)); ColorBufferMap::iterator c(m_colorbuffers.find(p_colorbuffer));
if (c == m_colorbuffers.end()) { if (c == m_colorbuffers.end()) {
@ -593,7 +603,7 @@ bool Renderer::bindColorBufferToTexture(HandleType p_colorbuffer) {
} }
bool Renderer::bindColorBufferToRenderbuffer(HandleType p_colorbuffer) { bool Renderer::bindColorBufferToRenderbuffer(HandleType p_colorbuffer) {
emugl::Mutex::AutoLock mutex(m_lock); std::unique_lock<std::mutex> l(m_lock);
ColorBufferMap::iterator c(m_colorbuffers.find(p_colorbuffer)); ColorBufferMap::iterator c(m_colorbuffers.find(p_colorbuffer));
if (c == m_colorbuffers.end()) { if (c == m_colorbuffers.end()) {
@ -606,7 +616,7 @@ bool Renderer::bindColorBufferToRenderbuffer(HandleType p_colorbuffer) {
bool Renderer::bindContext(HandleType p_context, HandleType p_drawSurface, bool Renderer::bindContext(HandleType p_context, HandleType p_drawSurface,
HandleType p_readSurface) { HandleType p_readSurface) {
emugl::Mutex::AutoLock mutex(m_lock); std::unique_lock<std::mutex> l(m_lock);
WindowSurfacePtr draw(NULL), read(NULL); WindowSurfacePtr draw(NULL), read(NULL);
RenderContextPtr ctx(NULL); RenderContextPtr ctx(NULL);
@ -654,7 +664,7 @@ bool Renderer::bindContext(HandleType p_context, HandleType p_drawSurface,
// //
RenderThreadInfo *tinfo = RenderThreadInfo::get(); RenderThreadInfo *tinfo = RenderThreadInfo::get();
WindowSurfacePtr bindDraw, bindRead; WindowSurfacePtr bindDraw, bindRead;
if (draw.Ptr() == NULL && read.Ptr() == NULL) { if (!draw && !read) {
// Unbind the current read and draw surfaces from the context // Unbind the current read and draw surfaces from the context
bindDraw = tinfo->currDrawSurf; bindDraw = tinfo->currDrawSurf;
bindRead = tinfo->currReadSurf; bindRead = tinfo->currReadSurf;
@ -663,8 +673,8 @@ bool Renderer::bindContext(HandleType p_context, HandleType p_drawSurface,
bindRead = read; bindRead = read;
} }
if (bindDraw.Ptr() != NULL && bindRead.Ptr() != NULL) { if (bindDraw && bindRead) {
if (bindDraw.Ptr() != bindRead.Ptr()) { if (bindDraw != bindRead) {
bindDraw->bind(ctx, WindowSurface::BIND_DRAW); bindDraw->bind(ctx, WindowSurface::BIND_DRAW);
bindRead->bind(ctx, WindowSurface::BIND_READ); bindRead->bind(ctx, WindowSurface::BIND_READ);
} else { } else {

View file

@ -16,14 +16,12 @@
#ifndef _LIBRENDER_FRAMEBUFFER_H #ifndef _LIBRENDER_FRAMEBUFFER_H
#define _LIBRENDER_FRAMEBUFFER_H #define _LIBRENDER_FRAMEBUFFER_H
#include "ColorBuffer.h" #include "anbox/graphics/emugl/ColorBuffer.h"
#include "RenderContext.h" #include "anbox/graphics/emugl/RenderContext.h"
#include "RendererConfig.h" #include "anbox/graphics/emugl/RendererConfig.h"
#include "TextureDraw.h" #include "anbox/graphics/emugl/TextureDraw.h"
#include "WindowSurface.h" #include "anbox/graphics/emugl/WindowSurface.h"
#include "emugl/common/mutex.h" #include "anbox/graphics/emugl/Renderable.h"
#include "Renderable.h"
#include "anbox/graphics/primitives.h" #include "anbox/graphics/primitives.h"
#include "anbox/graphics/program_family.h" #include "anbox/graphics/program_family.h"
@ -32,6 +30,7 @@
#include <EGL/egl.h> #include <EGL/egl.h>
#include <map> #include <map>
#include <mutex>
#include <stdint.h> #include <stdint.h>
@ -257,7 +256,7 @@ class Renderer : public anbox::graphics::Renderer {
private: private:
static Renderer* s_renderer; static Renderer* s_renderer;
static HandleType s_nextHandle; static HandleType s_nextHandle;
emugl::Mutex m_lock; std::mutex m_lock;
RendererConfigList* m_configs; RendererConfigList* m_configs;
RendererCaps m_caps; RendererCaps m_caps;
EGLDisplay m_eglDisplay; EGLDisplay m_eglDisplay;

View file

@ -12,15 +12,14 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "RendererConfig.h" #include "anbox/graphics/emugl/RendererConfig.h"
#include "anbox/logger.h"
#include "OpenGLESDispatch/EGLDispatch.h" #include "external/android-emugl/host/include/OpenGLESDispatch/EGLDispatch.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "anbox/logger.h"
namespace { namespace {
const GLuint kConfigAttributes[] = { const GLuint kConfigAttributes[] = {
EGL_DEPTH_SIZE, // must be first - see getDepthSize() EGL_DEPTH_SIZE, // must be first - see getDepthSize()

View file

@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "TextureDraw.h" #include "anbox/graphics/emugl/TextureDraw.h"
#include "anbox/graphics/emugl/DispatchTables.h"
#include "DispatchTables.h" #include "anbox/logger.h"
#include <math.h> #include <math.h>
#include <string.h> #include <string.h>
@ -22,8 +22,6 @@
#include <stdio.h> #include <stdio.h>
#include "anbox/logger.h"
// M_PI isn't defined in C++ (when strict ISO compliance is enabled) // M_PI isn't defined in C++ (when strict ISO compliance is enabled)
#ifndef M_PI #ifndef M_PI
#define M_PI 3.14159265358979323846264338327 #define M_PI 3.14159265358979323846264338327

View file

@ -13,17 +13,16 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#include "TextureResize.h"
#include "DispatchTables.h" #include "anbox/graphics/emugl/TextureResize.h"
#include "anbox/graphics/emugl/DispatchTables.h"
#include "anbox/logger.h"
#include <stdio.h> #include <stdio.h>
#include <sstream> #include <sstream>
#include <string> #include <string>
#include <utility> #include <utility>
#include "anbox/logger.h"
#define MAX_FACTOR_POWER 4 #define MAX_FACTOR_POWER 4
static const char kCommonShaderSource[] = static const char kCommonShaderSource[] =

View file

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef _LIBRENDER_TEXTURERESIZE_H #ifndef _LIBRENDER_TEXTURERESIZE_H
#define _LIBRENDER_TEXTURERESIZE_H #define _LIBRENDER_TEXTURERESIZE_H

View file

@ -13,7 +13,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#include "TimeUtils.h"
#include "anbox/graphics/emugl/TimeUtils.h"
#include <stdlib.h> #include <stdlib.h>
#include <sys/time.h> #include <sys/time.h>

View file

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef _TIME_UTILS_H #ifndef _TIME_UTILS_H
#define _TIME_UTILS_H #define _TIME_UTILS_H

View file

@ -13,17 +13,18 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#include "WindowSurface.h"
#include "RendererConfig.h"
#include "OpenGLESDispatch/EGLDispatch.h" #include "anbox/graphics/emugl/WindowSurface.h"
#include "anbox/graphics/emugl/RendererConfig.h"
#include "anbox/logger.h"
#include "external/android-emugl/host/include/OpenGLESDispatch/EGLDispatch.h"
#include <GLES/glext.h> #include <GLES/glext.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "anbox/logger.h"
WindowSurface::WindowSurface(EGLDisplay display, EGLConfig config) WindowSurface::WindowSurface(EGLDisplay display, EGLConfig config)
: mSurface(NULL), : mSurface(NULL),
@ -84,7 +85,7 @@ void WindowSurface::bind(RenderContextPtr p_ctx, BindType p_bindType) {
} }
bool WindowSurface::flushColorBuffer() { bool WindowSurface::flushColorBuffer() {
if (!mAttachedColorBuffer.Ptr()) { if (!mAttachedColorBuffer) {
return true; return true;
} }
if (!mWidth || !mHeight) { if (!mWidth || !mHeight) {
@ -98,7 +99,7 @@ bool WindowSurface::flushColorBuffer() {
return false; return false;
} }
if (!mDrawContext.Ptr()) { if (!mDrawContext) {
ERROR("Draw context is NULL"); ERROR("Draw context is NULL");
return false; return false;
} }

View file

@ -16,10 +16,8 @@
#ifndef _LIBRENDER_WINDOW_SURFACE_H #ifndef _LIBRENDER_WINDOW_SURFACE_H
#define _LIBRENDER_WINDOW_SURFACE_H #define _LIBRENDER_WINDOW_SURFACE_H
#include "ColorBuffer.h" #include "anbox/graphics/emugl/ColorBuffer.h"
#include "RenderContext.h" #include "anbox/graphics/emugl/RenderContext.h"
#include "emugl/common/smart_ptr.h"
#include <EGL/egl.h> #include <EGL/egl.h>
#include <GLES/gl.h> #include <GLES/gl.h>
@ -94,6 +92,6 @@ class WindowSurface {
EGLDisplay mDisplay; EGLDisplay mDisplay;
}; };
typedef emugl::SmartPtr<WindowSurface> WindowSurfacePtr; typedef std::shared_ptr<WindowSurface> WindowSurfacePtr;
#endif // _LIBRENDER_WINDOW_SURFACE_H #endif // _LIBRENDER_WINDOW_SURFACE_H

View file

@ -29,7 +29,7 @@
namespace anbox { namespace anbox {
namespace graphics { namespace graphics {
emugl::Mutex OpenGlesMessageProcessor::global_lock{}; std::mutex OpenGlesMessageProcessor::global_lock{};
OpenGlesMessageProcessor::OpenGlesMessageProcessor( OpenGlesMessageProcessor::OpenGlesMessageProcessor(
const std::shared_ptr<Renderer> &renderer, const std::shared_ptr<Renderer> &renderer,
@ -43,7 +43,7 @@ OpenGlesMessageProcessor::OpenGlesMessageProcessor(
boost::asio::buffer(&client_flags, sizeof(unsigned int))); boost::asio::buffer(&client_flags, sizeof(unsigned int)));
if (err) ERROR("%s", err.message()); if (err) ERROR("%s", err.message());
render_thread_.reset(RenderThread::create(renderer, stream_.get(), &global_lock)); render_thread_.reset(RenderThread::create(renderer, stream_.get(), std::ref(global_lock)));
if (!render_thread_->start()) if (!render_thread_->start())
BOOST_THROW_EXCEPTION( BOOST_THROW_EXCEPTION(
std::runtime_error("Failed to start renderer thread")); std::runtime_error("Failed to start renderer thread"));

View file

@ -18,16 +18,15 @@
#ifndef ANBOX_GRAPHICS_OPENGLES_MESSAGE_PROCESSOR_H_ #ifndef ANBOX_GRAPHICS_OPENGLES_MESSAGE_PROCESSOR_H_
#define ANBOX_GRAPHICS_OPENGLES_MESSAGE_PROCESSOR_H_ #define ANBOX_GRAPHICS_OPENGLES_MESSAGE_PROCESSOR_H_
#include <memory>
#include <boost/asio.hpp>
#include "anbox/network/message_processor.h" #include "anbox/network/message_processor.h"
#include "anbox/network/socket_connection.h" #include "anbox/network/socket_connection.h"
#include "anbox/network/socket_messenger.h" #include "anbox/network/socket_messenger.h"
#include "anbox/runtime.h" #include "anbox/runtime.h"
#include "external/android-emugl/shared/emugl/common/mutex.h" #include <boost/asio.hpp>
#include <memory>
#include <mutex>
class IOStream; class IOStream;
class RenderThread; class RenderThread;
@ -45,7 +44,7 @@ class OpenGlesMessageProcessor : public network::MessageProcessor {
bool process_data(const std::vector<std::uint8_t> &data) override; bool process_data(const std::vector<std::uint8_t> &data) override;
private: private:
static emugl::Mutex global_lock; static std::mutex global_lock;
std::shared_ptr<network::SocketMessenger> messenger_; std::shared_ptr<network::SocketMessenger> messenger_;
std::shared_ptr<IOStream> stream_; std::shared_ptr<IOStream> stream_;