diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d49897d..8d00b7b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -109,8 +109,8 @@ set(SOURCES anbox/graphics/emugl/ColorBuffer.cpp anbox/graphics/emugl/DisplayManager.cpp - anbox/graphics/emugl/FbConfig.cpp - anbox/graphics/emugl/FrameBuffer.cpp + anbox/graphics/emugl/RendererConfig.cpp + anbox/graphics/emugl/Renderer.cpp anbox/graphics/emugl/LayerManager.cpp anbox/graphics/emugl/NativeSubWindow_delegate.cpp anbox/graphics/emugl/NativeSubWindow.h diff --git a/src/anbox/graphics/emugl/LayerManager.cpp b/src/anbox/graphics/emugl/LayerManager.cpp index ab2e74c..ac3dd2f 100644 --- a/src/anbox/graphics/emugl/LayerManager.cpp +++ b/src/anbox/graphics/emugl/LayerManager.cpp @@ -76,7 +76,7 @@ void LayerManager::post_layer(const LayerInfo &layer) { if (is_layer_blacklisted(layer.name)) return; - FrameBufferWindow *window = nullptr; + RendererWindow *window = nullptr; for (auto &l : layers_) { if (l.first == layer.name || from_same_package(l.first, layer.name)) { window = l.second.window; @@ -99,7 +99,7 @@ void LayerManager::post_layer(const LayerInfo &layer) { layer.source_crop.right, layer.source_crop.bottom); - window = FrameBuffer::getFB()->createWindow(layer.display_frame.left, + window = Renderer::get()->createWindow(layer.display_frame.left, layer.display_frame.top, width, height); if (!window) { @@ -110,17 +110,17 @@ void LayerManager::post_layer(const LayerInfo &layer) { layers_.insert({ layer.name, Layer{window, true}}); } - FrameBuffer::getFB()->updateWindow(window, + Renderer::get()->updateWindow(window, layer.display_frame.left, layer.display_frame.top, width, height); - FrameBuffer::getFB()->post(window, layer.buffer_handle); + Renderer::get()->post(window, layer.buffer_handle); } void LayerManager::finish_cycle() { for (auto iter = layers_.begin(); iter != layers_.end(); ++iter) { if (!iter->second.updated) { - FrameBuffer::getFB()->destroyWindow(iter->second.window); + Renderer::get()->destroyWindow(iter->second.window); layers_.erase(iter); } } diff --git a/src/anbox/graphics/emugl/LayerManager.h b/src/anbox/graphics/emugl/LayerManager.h index 9e7bf5f..79b104e 100644 --- a/src/anbox/graphics/emugl/LayerManager.h +++ b/src/anbox/graphics/emugl/LayerManager.h @@ -24,7 +24,7 @@ #include #include -#include "FrameBuffer.h" +#include "Renderer.h" struct LayerRect { int left; @@ -53,7 +53,7 @@ private: LayerManager(); struct Layer { - FrameBufferWindow *window; + RendererWindow *window; bool updated; }; diff --git a/src/anbox/graphics/emugl/RenderControl.cpp b/src/anbox/graphics/emugl/RenderControl.cpp index 942e7a4..9e36cc9 100644 --- a/src/anbox/graphics/emugl/RenderControl.cpp +++ b/src/anbox/graphics/emugl/RenderControl.cpp @@ -16,8 +16,8 @@ #include "RenderControl.h" #include "DispatchTables.h" -#include "FbConfig.h" -#include "FrameBuffer.h" +#include "RendererConfig.h" +#include "Renderer.h" #include "RenderThreadInfo.h" #include "ChecksumCalculatorThreadInfo.h" #include "LayerManager.h" @@ -37,7 +37,7 @@ static GLint rcGetRendererVersion() static EGLint rcGetEGLVersion(EGLint* major, EGLint* minor) { - FrameBuffer *fb = FrameBuffer::getFB(); + Renderer *fb = Renderer::get(); if (!fb) { return EGL_FALSE; } @@ -49,7 +49,7 @@ static EGLint rcGetEGLVersion(EGLint* major, EGLint* minor) static EGLint rcQueryEGLString(EGLenum name, void* buffer, EGLint bufferSize) { - FrameBuffer *fb = FrameBuffer::getFB(); + Renderer *fb = Renderer::get(); if (!fb) { return 0; } @@ -123,7 +123,7 @@ static EGLint rcGetNumConfigs(uint32_t* p_numAttribs) { int numConfigs = 0, numAttribs = 0; - FrameBuffer::getFB()->getConfigs()->getPackInfo(&numConfigs, &numAttribs); + Renderer::get()->getConfigs()->getPackInfo(&numConfigs, &numAttribs); if (p_numAttribs) { *p_numAttribs = static_cast(numAttribs); } @@ -133,7 +133,7 @@ static EGLint rcGetNumConfigs(uint32_t* p_numAttribs) static EGLint rcGetConfigs(uint32_t bufSize, GLuint* buffer) { GLuint bufferSize = (GLuint)bufSize; - return FrameBuffer::getFB()->getConfigs()->packConfigs(bufferSize, buffer); + return Renderer::get()->getConfigs()->packConfigs(bufferSize, buffer); } static EGLint rcChooseConfig(EGLint *attribs, @@ -141,7 +141,7 @@ static EGLint rcChooseConfig(EGLint *attribs, uint32_t *configs, uint32_t configs_size) { - FrameBuffer *fb = FrameBuffer::getFB(); + Renderer *fb = Renderer::get(); if (!fb || attribs_size==0) { return 0; } @@ -152,7 +152,7 @@ static EGLint rcChooseConfig(EGLint *attribs, static EGLint rcGetFBParam(EGLint param) { - FrameBuffer *fb = FrameBuffer::getFB(); + Renderer *fb = Renderer::get(); if (!fb) { return 0; } @@ -191,7 +191,7 @@ static EGLint rcGetFBParam(EGLint param) static uint32_t rcCreateContext(uint32_t config, uint32_t share, uint32_t glVersion) { - FrameBuffer *fb = FrameBuffer::getFB(); + Renderer *fb = Renderer::get(); if (!fb) { return 0; } @@ -204,7 +204,7 @@ static uint32_t rcCreateContext(uint32_t config, static void rcDestroyContext(uint32_t context) { - FrameBuffer *fb = FrameBuffer::getFB(); + Renderer *fb = Renderer::get(); if (!fb) { return; } @@ -215,7 +215,7 @@ static void rcDestroyContext(uint32_t context) static uint32_t rcCreateWindowSurface(uint32_t config, uint32_t width, uint32_t height) { - FrameBuffer *fb = FrameBuffer::getFB(); + Renderer *fb = Renderer::get(); if (!fb) { return 0; } @@ -225,7 +225,7 @@ static uint32_t rcCreateWindowSurface(uint32_t config, static void rcDestroyWindowSurface(uint32_t windowSurface) { - FrameBuffer *fb = FrameBuffer::getFB(); + Renderer *fb = Renderer::get(); if (!fb) { return; } @@ -236,7 +236,7 @@ static void rcDestroyWindowSurface(uint32_t windowSurface) static uint32_t rcCreateColorBuffer(uint32_t width, uint32_t height, GLenum internalFormat) { - FrameBuffer *fb = FrameBuffer::getFB(); + Renderer *fb = Renderer::get(); if (!fb) { return 0; } @@ -246,7 +246,7 @@ static uint32_t rcCreateColorBuffer(uint32_t width, static int rcOpenColorBuffer2(uint32_t colorbuffer) { - FrameBuffer *fb = FrameBuffer::getFB(); + Renderer *fb = Renderer::get(); if (!fb) { return -1; } @@ -262,7 +262,7 @@ static void rcOpenColorBuffer(uint32_t colorbuffer) static void rcCloseColorBuffer(uint32_t colorbuffer) { - FrameBuffer *fb = FrameBuffer::getFB(); + Renderer *fb = Renderer::get(); if (!fb) { return; } @@ -271,7 +271,7 @@ static void rcCloseColorBuffer(uint32_t colorbuffer) static int rcFlushWindowColorBuffer(uint32_t windowSurface) { - FrameBuffer *fb = FrameBuffer::getFB(); + Renderer *fb = Renderer::get(); if (!fb) { return -1; } @@ -284,7 +284,7 @@ static int rcFlushWindowColorBuffer(uint32_t windowSurface) static void rcSetWindowColorBuffer(uint32_t windowSurface, uint32_t colorBuffer) { - FrameBuffer *fb = FrameBuffer::getFB(); + Renderer *fb = Renderer::get(); if (!fb) { return; } @@ -294,7 +294,7 @@ static void rcSetWindowColorBuffer(uint32_t windowSurface, static EGLint rcMakeCurrent(uint32_t context, uint32_t drawSurf, uint32_t readSurf) { - FrameBuffer *fb = FrameBuffer::getFB(); + Renderer *fb = Renderer::get(); if (!fb) { return EGL_FALSE; } @@ -306,7 +306,7 @@ static EGLint rcMakeCurrent(uint32_t context, static void rcFBPost(uint32_t colorBuffer) { - FrameBuffer *fb = FrameBuffer::getFB(); + Renderer *fb = Renderer::get(); if (!fb) { return; } @@ -321,7 +321,7 @@ static void rcFBSetSwapInterval(EGLint interval) static void rcBindTexture(uint32_t colorBuffer) { - FrameBuffer *fb = FrameBuffer::getFB(); + Renderer *fb = Renderer::get(); if (!fb) { return; } @@ -331,7 +331,7 @@ static void rcBindTexture(uint32_t colorBuffer) static void rcBindRenderbuffer(uint32_t colorBuffer) { - FrameBuffer *fb = FrameBuffer::getFB(); + Renderer *fb = Renderer::get(); if (!fb) { return; } @@ -351,7 +351,7 @@ static void rcReadColorBuffer(uint32_t colorBuffer, GLint width, GLint height, GLenum format, GLenum type, void* pixels) { - FrameBuffer *fb = FrameBuffer::getFB(); + Renderer *fb = Renderer::get(); if (!fb) { return; } @@ -364,7 +364,7 @@ static int rcUpdateColorBuffer(uint32_t colorBuffer, GLint width, GLint height, GLenum format, GLenum type, void* pixels) { - FrameBuffer *fb = FrameBuffer::getFB(); + Renderer *fb = Renderer::get(); if (!fb) { return -1; } @@ -375,7 +375,7 @@ static int rcUpdateColorBuffer(uint32_t colorBuffer, static uint32_t rcCreateClientImage(uint32_t context, EGLenum target, GLuint buffer) { - FrameBuffer *fb = FrameBuffer::getFB(); + Renderer *fb = Renderer::get(); if (!fb) { return 0; } @@ -385,7 +385,7 @@ static uint32_t rcCreateClientImage(uint32_t context, EGLenum target, GLuint buf static int rcDestroyClientImage(uint32_t image) { - FrameBuffer *fb = FrameBuffer::getFB(); + Renderer *fb = Renderer::get(); if (!fb) { return 0; } diff --git a/src/anbox/graphics/emugl/RenderThread.cpp b/src/anbox/graphics/emugl/RenderThread.cpp index db9c6a9..2185e8c 100644 --- a/src/anbox/graphics/emugl/RenderThread.cpp +++ b/src/anbox/graphics/emugl/RenderThread.cpp @@ -15,7 +15,7 @@ */ #include "RenderThread.h" -#include "FrameBuffer.h" +#include "Renderer.h" #include "ReadBuffer.h" #include "RenderControl.h" #include "RenderThreadInfo.h" @@ -108,14 +108,14 @@ intptr_t RenderThread::main() { // // Release references to the current thread's context/surfaces if any // - FrameBuffer::getFB()->bindContext(0, 0, 0); + Renderer::get()->bindContext(0, 0, 0); if (tInfo.currContext || tInfo.currDrawSurf || tInfo.currReadSurf) { fprintf(stderr, "ERROR: RenderThread exiting with current context/surfaces\n"); } - FrameBuffer::getFB()->drainWindowSurface(); + Renderer::get()->drainWindowSurface(); - FrameBuffer::getFB()->drainRenderContext(); + Renderer::get()->drainRenderContext(); return 0; } diff --git a/src/anbox/graphics/emugl/RenderWindow.cpp b/src/anbox/graphics/emugl/RenderWindow.cpp index 630d966..a734045 100644 --- a/src/anbox/graphics/emugl/RenderWindow.cpp +++ b/src/anbox/graphics/emugl/RenderWindow.cpp @@ -18,7 +18,7 @@ #include "emugl/common/message_channel.h" #include "emugl/common/mutex.h" #include "emugl/common/thread.h" -#include "FrameBuffer.h" +#include "Renderer.h" #include #include @@ -109,13 +109,13 @@ struct RenderWindowMessage { // Returns true on success, or false on failure. bool process() const { const RenderWindowMessage& msg = *this; - FrameBuffer* fb; + Renderer* fb; bool result = false; switch (msg.cmd) { case CMD_INITIALIZE: D("CMD_INITIALIZE\n"); GL_LOG("RenderWindow: CMD_INITIALIZE"); - result = FrameBuffer::initialize(msg.init.nativeDisplay); + result = Renderer::initialize(msg.init.nativeDisplay); break; case CMD_FINALIZE: @@ -123,7 +123,7 @@ struct RenderWindowMessage { // this command may be issued even when frame buffer is not // yet created (e.g. if CMD_INITIALIZE failed), // so make sure we check if it is there before finalizing - if (const auto fb = FrameBuffer::getFB()) { + if (const auto fb = Renderer::get()) { fb->finalize(); } result = true; @@ -278,7 +278,7 @@ bool RenderWindow::getHardwareStrings(const char** vendor, const char** version) { D("Entering\n"); // TODO(digit): Move this to render window thread. - FrameBuffer* fb = FrameBuffer::getFB(); + Renderer* fb = Renderer::get(); if (!fb) { D("No framebuffer!\n"); return false; diff --git a/src/anbox/graphics/emugl/FrameBuffer.cpp b/src/anbox/graphics/emugl/Renderer.cpp similarity index 91% rename from src/anbox/graphics/emugl/FrameBuffer.cpp rename to src/anbox/graphics/emugl/Renderer.cpp index 64b8323..3bce805 100644 --- a/src/anbox/graphics/emugl/FrameBuffer.cpp +++ b/src/anbox/graphics/emugl/Renderer.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "FrameBuffer.h" +#include "Renderer.h" #include "DispatchTables.h" #include "NativeSubWindow.h" @@ -35,7 +35,7 @@ class ScopedBind { public: // Constructor will call bind_locked() on |fb|. // Use isValid() to check for errors. - ScopedBind(FrameBuffer* fb) : mFb(fb) { + ScopedBind(Renderer* fb) : mFb(fb) { if (!mFb->bind_locked()) { mFb = NULL; } @@ -59,14 +59,14 @@ public: } private: - FrameBuffer* mFb; + Renderer* mFb; }; // Implementation of a ColorBuffer::Helper instance that redirects calls // to a FrameBuffer instance. class ColorBufferHelper : public ColorBuffer::Helper { public: - ColorBufferHelper(FrameBuffer* fb) : mFb(fb) {} + ColorBufferHelper(Renderer* fb) : mFb(fb) {} virtual bool setupContext() { return mFb->bind_locked(); @@ -80,13 +80,13 @@ public: return mFb->getTextureDraw(); } private: - FrameBuffer* mFb; + Renderer* mFb; }; } // namespace -FrameBuffer *FrameBuffer::s_theFrameBuffer = NULL; -HandleType FrameBuffer::s_nextHandle = 0; +Renderer *Renderer::s_renderer = NULL; +HandleType Renderer::s_nextHandle = 0; static char* getGLES1ExtensionString(EGLDisplay p_dpy) { @@ -152,7 +152,7 @@ static char* getGLES1ExtensionString(EGLDisplay p_dpy) return extString; } -void FrameBuffer::finalize(){ +void Renderer::finalize(){ m_colorbuffers.clear(); m_windows.clear(); m_contexts.clear(); @@ -162,17 +162,17 @@ void FrameBuffer::finalize(){ s_egl.eglDestroySurface(m_eglDisplay, m_pbufSurface); } -bool FrameBuffer::initialize(EGLNativeDisplayType nativeDisplay) +bool Renderer::initialize(EGLNativeDisplayType nativeDisplay) { GL_LOG("FrameBuffer::initialize"); - if (s_theFrameBuffer != NULL) { + if (s_renderer != NULL) { return true; } // // allocate space for the FrameBuffer object // - FrameBuffer *fb = new FrameBuffer(); + Renderer *fb = new Renderer(); if (!fb) { ERR("Failed to create fb\n"); return false; @@ -355,7 +355,7 @@ bool FrameBuffer::initialize(EGLNativeDisplayType nativeDisplay) // // Initialize set of configs // - fb->m_configs = new FbConfigList(fb->m_eglDisplay); + fb->m_configs = new RendererConfigList(fb->m_eglDisplay); if (fb->m_configs->empty()) { ERR("Failed: Initialize set of configs\n"); bind.release(); @@ -422,12 +422,12 @@ bool FrameBuffer::initialize(EGLNativeDisplayType nativeDisplay) // // Keep the singleton framebuffer pointer // - s_theFrameBuffer = fb; + s_renderer = fb; GL_LOG("basic EGL initialization successful"); return true; } -FrameBuffer::FrameBuffer() : +Renderer::Renderer() : m_configs(NULL), m_eglDisplay(EGL_NO_DISPLAY), m_colorBufferHelper(new ColorBufferHelper(this)), @@ -447,13 +447,13 @@ FrameBuffer::FrameBuffer() : m_fpsStats = getenv("SHOW_FPS_STATS") != NULL; } -FrameBuffer::~FrameBuffer() { +Renderer::~Renderer() { delete m_textureDraw; delete m_configs; delete m_colorBufferHelper; } -struct FrameBufferWindow { +struct RendererWindow { EGLNativeWindowType native_window = 0; EGLSurface surface = EGL_NO_SURFACE; bool needViewportUpdate = false; @@ -461,7 +461,7 @@ struct FrameBufferWindow { int height; }; -FrameBufferWindow* FrameBuffer::createWindow(int x, int y, int width, int height) { +RendererWindow* Renderer::createWindow(int x, int y, int width, int height) { m_lock.lock(); auto native_window = createSubWindow(0, x, y, width, height); @@ -470,7 +470,7 @@ FrameBufferWindow* FrameBuffer::createWindow(int x, int y, int width, int height return nullptr; } - auto window = new FrameBufferWindow; + auto window = new RendererWindow; window->native_window = native_window; window->width = width; window->height = height; @@ -502,7 +502,7 @@ FrameBufferWindow* FrameBuffer::createWindow(int x, int y, int width, int height return window; } -void FrameBuffer::updateWindow(FrameBufferWindow *window, int x, int y, int width, int height) { +void Renderer::updateWindow(RendererWindow *window, int x, int y, int width, int height) { if (!window) return; @@ -512,7 +512,7 @@ void FrameBuffer::updateWindow(FrameBufferWindow *window, int x, int y, int widt window->needViewportUpdate = true; } -void FrameBuffer::destroyWindow(FrameBufferWindow *window) { +void Renderer::destroyWindow(RendererWindow *window) { if (!window) return; @@ -530,7 +530,7 @@ void FrameBuffer::destroyWindow(FrameBufferWindow *window) { m_lock.unlock(); } -HandleType FrameBuffer::genHandle() +HandleType Renderer::genHandle() { HandleType id; do { @@ -542,7 +542,7 @@ HandleType FrameBuffer::genHandle() return id; } -HandleType FrameBuffer::createColorBuffer(int p_width, int p_height, +HandleType Renderer::createColorBuffer(int p_width, int p_height, GLenum p_internalFormat) { emugl::Mutex::AutoLock mutex(m_lock); @@ -563,13 +563,13 @@ HandleType FrameBuffer::createColorBuffer(int p_width, int p_height, return ret; } -HandleType FrameBuffer::createRenderContext(int p_config, HandleType p_share, +HandleType Renderer::createRenderContext(int p_config, HandleType p_share, bool p_isGL2) { emugl::Mutex::AutoLock mutex(m_lock); HandleType ret = 0; - const FbConfig* config = getConfigs()->get(p_config); + const RendererConfig* config = getConfigs()->get(p_config); if (!config) { return ret; } @@ -596,13 +596,13 @@ HandleType FrameBuffer::createRenderContext(int p_config, HandleType p_share, return ret; } -HandleType FrameBuffer::createWindowSurface(int p_config, int p_width, int p_height) +HandleType Renderer::createWindowSurface(int p_config, int p_width, int p_height) { emugl::Mutex::AutoLock mutex(m_lock); HandleType ret = 0; - const FbConfig* config = getConfigs()->get(p_config); + const RendererConfig* config = getConfigs()->get(p_config); if (!config) { return ret; } @@ -619,7 +619,7 @@ HandleType FrameBuffer::createWindowSurface(int p_config, int p_width, int p_hei return ret; } -void FrameBuffer::drainRenderContext() +void Renderer::drainRenderContext() { emugl::Mutex::AutoLock mutex(m_lock); RenderThreadInfo *tinfo = RenderThreadInfo::get(); @@ -632,7 +632,7 @@ void FrameBuffer::drainRenderContext() tinfo->m_contextSet.clear(); } -void FrameBuffer::drainWindowSurface() +void Renderer::drainWindowSurface() { emugl::Mutex::AutoLock mutex(m_lock); RenderThreadInfo *tinfo = RenderThreadInfo::get(); @@ -654,7 +654,7 @@ void FrameBuffer::drainWindowSurface() tinfo->m_windowSet.clear(); } -void FrameBuffer::DestroyRenderContext(HandleType p_context) +void Renderer::DestroyRenderContext(HandleType p_context) { emugl::Mutex::AutoLock mutex(m_lock); m_contexts.erase(p_context); @@ -663,7 +663,7 @@ void FrameBuffer::DestroyRenderContext(HandleType p_context) tinfo->m_contextSet.erase(p_context); } -void FrameBuffer::DestroyWindowSurface(HandleType p_surface) +void Renderer::DestroyWindowSurface(HandleType p_surface) { emugl::Mutex::AutoLock mutex(m_lock); if (m_windows.find(p_surface) != m_windows.end()) { @@ -674,7 +674,7 @@ void FrameBuffer::DestroyWindowSurface(HandleType p_surface) } } -int FrameBuffer::openColorBuffer(HandleType p_colorbuffer) +int Renderer::openColorBuffer(HandleType p_colorbuffer) { emugl::Mutex::AutoLock mutex(m_lock); ColorBufferMap::iterator c(m_colorbuffers.find(p_colorbuffer)); @@ -687,7 +687,7 @@ int FrameBuffer::openColorBuffer(HandleType p_colorbuffer) return 0; } -void FrameBuffer::closeColorBuffer(HandleType p_colorbuffer) +void Renderer::closeColorBuffer(HandleType p_colorbuffer) { emugl::Mutex::AutoLock mutex(m_lock); ColorBufferMap::iterator c(m_colorbuffers.find(p_colorbuffer)); @@ -703,7 +703,7 @@ void FrameBuffer::closeColorBuffer(HandleType p_colorbuffer) } } -bool FrameBuffer::flushWindowSurfaceColorBuffer(HandleType p_surface) +bool Renderer::flushWindowSurfaceColorBuffer(HandleType p_surface) { emugl::Mutex::AutoLock mutex(m_lock); @@ -720,7 +720,7 @@ bool FrameBuffer::flushWindowSurfaceColorBuffer(HandleType p_surface) return true; } -bool FrameBuffer::setWindowSurfaceColorBuffer(HandleType p_surface, +bool Renderer::setWindowSurfaceColorBuffer(HandleType p_surface, HandleType p_colorbuffer) { emugl::Mutex::AutoLock mutex(m_lock); @@ -744,7 +744,7 @@ bool FrameBuffer::setWindowSurfaceColorBuffer(HandleType p_surface, return true; } -void FrameBuffer::readColorBuffer(HandleType p_colorbuffer, +void Renderer::readColorBuffer(HandleType p_colorbuffer, int x, int y, int width, int height, GLenum format, GLenum type, void *pixels) { @@ -759,7 +759,7 @@ void FrameBuffer::readColorBuffer(HandleType p_colorbuffer, (*c).second.cb->readPixels(x, y, width, height, format, type, pixels); } -bool FrameBuffer::updateColorBuffer(HandleType p_colorbuffer, +bool Renderer::updateColorBuffer(HandleType p_colorbuffer, int x, int y, int width, int height, GLenum format, GLenum type, void *pixels) { @@ -776,7 +776,7 @@ bool FrameBuffer::updateColorBuffer(HandleType p_colorbuffer, return true; } -bool FrameBuffer::bindColorBufferToTexture(HandleType p_colorbuffer) +bool Renderer::bindColorBufferToTexture(HandleType p_colorbuffer) { emugl::Mutex::AutoLock mutex(m_lock); @@ -789,7 +789,7 @@ bool FrameBuffer::bindColorBufferToTexture(HandleType p_colorbuffer) return (*c).second.cb->bindToTexture(); } -bool FrameBuffer::bindColorBufferToRenderbuffer(HandleType p_colorbuffer) +bool Renderer::bindColorBufferToRenderbuffer(HandleType p_colorbuffer) { emugl::Mutex::AutoLock mutex(m_lock); @@ -802,7 +802,7 @@ bool FrameBuffer::bindColorBufferToRenderbuffer(HandleType p_colorbuffer) return (*c).second.cb->bindToRenderbuffer(); } -bool FrameBuffer::bindContext(HandleType p_context, +bool Renderer::bindContext(HandleType p_context, HandleType p_drawSurface, HandleType p_readSurface) { @@ -891,7 +891,7 @@ bool FrameBuffer::bindContext(HandleType p_context, return true; } -HandleType FrameBuffer::createClientImage(HandleType context, EGLenum target, GLuint buffer) +HandleType Renderer::createClientImage(HandleType context, EGLenum target, GLuint buffer) { RenderContextPtr ctx(NULL); @@ -913,7 +913,7 @@ HandleType FrameBuffer::createClientImage(HandleType context, EGLenum target, GL return (HandleType)reinterpret_cast(image); } -EGLBoolean FrameBuffer::destroyClientImage(HandleType image) +EGLBoolean Renderer::destroyClientImage(HandleType image) { return s_egl.eglDestroyImageKHR(m_eglDisplay, reinterpret_cast(image)); @@ -922,7 +922,7 @@ EGLBoolean FrameBuffer::destroyClientImage(HandleType image) // // The framebuffer lock should be held when calling this function ! // -bool FrameBuffer::bind_locked() +bool Renderer::bind_locked() { EGLContext prevContext = s_egl.eglGetCurrentContext(); EGLSurface prevReadSurf = s_egl.eglGetCurrentSurface(EGL_READ); @@ -940,7 +940,7 @@ bool FrameBuffer::bind_locked() return true; } -bool FrameBuffer::bindWindow_locked(FrameBufferWindow *window) +bool Renderer::bindWindow_locked(RendererWindow *window) { EGLContext prevContext = s_egl.eglGetCurrentContext(); EGLSurface prevReadSurf = s_egl.eglGetCurrentSurface(EGL_READ); @@ -958,7 +958,7 @@ bool FrameBuffer::bindWindow_locked(FrameBufferWindow *window) return true; } -bool FrameBuffer::unbind_locked() +bool Renderer::unbind_locked() { if (!s_egl.eglMakeCurrent(m_eglDisplay, m_prevDrawSurf, m_prevReadSurf, m_prevContext)) { @@ -971,7 +971,7 @@ bool FrameBuffer::unbind_locked() return true; } -bool FrameBuffer::post(FrameBufferWindow *window, HandleType p_colorbuffer, bool needLock) +bool Renderer::post(RendererWindow *window, HandleType p_colorbuffer, bool needLock) { if (!window) return false; diff --git a/src/anbox/graphics/emugl/FrameBuffer.h b/src/anbox/graphics/emugl/Renderer.h similarity index 93% rename from src/anbox/graphics/emugl/FrameBuffer.h rename to src/anbox/graphics/emugl/Renderer.h index 1a4808d..e41c25b 100644 --- a/src/anbox/graphics/emugl/FrameBuffer.h +++ b/src/anbox/graphics/emugl/Renderer.h @@ -18,7 +18,7 @@ #include "ColorBuffer.h" #include "emugl/common/mutex.h" -#include "FbConfig.h" +#include "RendererConfig.h" #include "RenderContext.h" #include "TextureDraw.h" #include "WindowSurface.h" @@ -51,14 +51,14 @@ typedef std::map ColorBufferMap; // extension is supported. // |eglMajor| and |eglMinor| are the major and minor version numbers of // the underlying EGL implementation. -struct FrameBufferCaps { +struct RendererCaps { bool has_eglimage_texture_2d; bool has_eglimage_renderbuffer; EGLint eglMajor; EGLint eglMinor; }; -struct FrameBufferWindow; +struct RendererWindow; // The FrameBuffer class holds the global state of the emulation library on // top of the underlying EGL/GLES implementation. It should probably be @@ -67,7 +67,7 @@ struct FrameBufferWindow; // There is only one global instance, that can be retrieved with getFB(), // and which must be previously setup by calling initialize(). // -class FrameBuffer { +class Renderer { public: // Initialize the global instance. // |width| and |height| are the dimensions of the emulator GPU display @@ -78,22 +78,22 @@ public: // Returns true on success, false otherwise. static bool initialize(EGLNativeDisplayType nativeDisplay); - FrameBufferWindow* createWindow(int x, int y, int width, int height); - void updateWindow(FrameBufferWindow *window, int x, int y, int width, int height); - void destroyWindow(FrameBufferWindow *window); + RendererWindow* createWindow(int x, int y, int width, int height); + void updateWindow(RendererWindow *window, int x, int y, int width, int height); + void destroyWindow(RendererWindow *window); // Finalize the instance. void finalize(); // Return a pointer to the global instance. initialize() must be called // previously, or this will return NULL. - static FrameBuffer *getFB() { return s_theFrameBuffer; } + static Renderer *get() { return s_renderer; } // Return the capabilities of the underlying display. - const FrameBufferCaps &getCaps() const { return m_caps; } + const RendererCaps &getCaps() const { return m_caps; } // Return the list of configs available from this display. - const FbConfigList* getConfigs() const { return m_configs; } + const RendererConfigList* getConfigs() const { return m_configs; } // Set a callback that will be called each time the emulated GPU content // is updated. This can be relatively slow with host-based GPU emulation, @@ -232,7 +232,7 @@ public: // |needLock| is used to indicate whether the operation requires // acquiring/releasing the FrameBuffer instance's lock. It should be // false only when called internally. - bool post(FrameBufferWindow *window, HandleType p_colorbuffer, bool needLock = true); + bool post(RendererWindow *window, HandleType p_colorbuffer, bool needLock = true); // Return the host EGLDisplay used by this instance. EGLDisplay getDisplay() const { return m_eglDisplay; } @@ -249,19 +249,19 @@ public: bool unbind_locked(); private: - FrameBuffer(); - ~FrameBuffer(); + Renderer(); + ~Renderer(); HandleType genHandle(); - bool bindWindow_locked(FrameBufferWindow *window); + bool bindWindow_locked(RendererWindow *window); private: - static FrameBuffer *s_theFrameBuffer; + static Renderer *s_renderer; static HandleType s_nextHandle; emugl::Mutex m_lock; - FbConfigList* m_configs; + RendererConfigList* m_configs; FBNativeWindowType m_nativeWindow; - FrameBufferCaps m_caps; + RendererCaps m_caps; EGLDisplay m_eglDisplay; RenderContextMap m_contexts; WindowSurfaceMap m_windows; diff --git a/src/anbox/graphics/emugl/FbConfig.cpp b/src/anbox/graphics/emugl/RendererConfig.cpp similarity index 93% rename from src/anbox/graphics/emugl/FbConfig.cpp rename to src/anbox/graphics/emugl/RendererConfig.cpp index a49a984..09f227a 100644 --- a/src/anbox/graphics/emugl/FbConfig.cpp +++ b/src/anbox/graphics/emugl/RendererConfig.cpp @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "FbConfig.h" +#include "RendererConfig.h" #include "OpenGLESDispatch/EGLDispatch.h" @@ -92,11 +92,11 @@ bool isCompatibleHostConfig(EGLConfig config, EGLDisplay display) { } // namespace -FbConfig::~FbConfig() { +RendererConfig::~RendererConfig() { delete [] mAttribValues; } -FbConfig::FbConfig(EGLConfig hostConfig, EGLDisplay hostDisplay) : +RendererConfig::RendererConfig(EGLConfig hostConfig, EGLDisplay hostDisplay) : mEglConfig(hostConfig), mAttribValues(NULL) { mAttribValues = new GLint[kConfigAttributesLen]; for (size_t i = 0; i < kConfigAttributesLen; ++i) { @@ -114,7 +114,7 @@ FbConfig::FbConfig(EGLConfig hostConfig, EGLDisplay hostDisplay) : } } -FbConfigList::FbConfigList(EGLDisplay display) : +RendererConfigList::RendererConfigList(EGLDisplay display) : mCount(0), mConfigs(NULL), mDisplay(display) { if (display == EGL_NO_DISPLAY) { E("%s: Invalid display value %p (EGL_NO_DISPLAY)\n", @@ -130,27 +130,27 @@ FbConfigList::FbConfigList(EGLDisplay display) : EGLConfig* hostConfigs = new EGLConfig[numHostConfigs]; s_egl.eglGetConfigs(display, hostConfigs, numHostConfigs, &numHostConfigs); - mConfigs = new FbConfig*[numHostConfigs]; + mConfigs = new RendererConfig*[numHostConfigs]; for (EGLint i = 0; i < numHostConfigs; ++i) { // Filter out configs that are not compatible with our implementation. if (!isCompatibleHostConfig(hostConfigs[i], display)) { continue; } - mConfigs[mCount] = new FbConfig(hostConfigs[i], display); + mConfigs[mCount] = new RendererConfig(hostConfigs[i], display); mCount++; } delete [] hostConfigs; } -FbConfigList::~FbConfigList() { +RendererConfigList::~RendererConfigList() { for (int n = 0; n < mCount; ++n) { delete mConfigs[n]; } delete [] mConfigs; } -int FbConfigList::chooseConfig(const EGLint* attribs, +int RendererConfigList::chooseConfig(const EGLint* attribs, EGLint* configs, EGLint configsSize) const { EGLint numHostConfigs = 0; @@ -245,7 +245,7 @@ int FbConfigList::chooseConfig(const EGLint* attribs, } -void FbConfigList::getPackInfo(EGLint* numConfigs, +void RendererConfigList::getPackInfo(EGLint* numConfigs, EGLint* numAttributes) const { if (numConfigs) { *numConfigs = mCount; @@ -255,7 +255,7 @@ void FbConfigList::getPackInfo(EGLint* numConfigs, } } -EGLint FbConfigList::packConfigs(GLuint bufferByteSize, GLuint* buffer) const { +EGLint RendererConfigList::packConfigs(GLuint bufferByteSize, GLuint* buffer) const { GLuint numAttribs = static_cast(kConfigAttributesLen); GLuint kGLuintSize = static_cast(sizeof(GLuint)); GLuint neededByteSize = (mCount + 1) * numAttribs * kGLuintSize; diff --git a/src/anbox/graphics/emugl/FbConfig.h b/src/anbox/graphics/emugl/RendererConfig.h similarity index 91% rename from src/anbox/graphics/emugl/FbConfig.h rename to src/anbox/graphics/emugl/RendererConfig.h index 2a653e8..c49ee1a 100644 --- a/src/anbox/graphics/emugl/FbConfig.h +++ b/src/anbox/graphics/emugl/RendererConfig.h @@ -32,10 +32,10 @@ // One doesn't create an FbConfig instance. Instead, create and initialize // an FbConfigList from the host EGLDisplay, and use its size() and get() // methods to access it. -class FbConfig { +class RendererConfig { public: // Destructor - ~FbConfig(); + ~RendererConfig(); // Retrieve host EGLConfig. EGLConfig getEglConfig() const { return mEglConfig; } @@ -57,12 +57,12 @@ public: GLint getConfigId() const { return (GLint)getAttribValue(4); } private: - FbConfig(); - FbConfig(FbConfig& other); + RendererConfig(); + RendererConfig(RendererConfig& other); - explicit FbConfig(EGLConfig hostConfig, EGLDisplay hostDisplay); + explicit RendererConfig(EGLConfig hostConfig, EGLDisplay hostDisplay); - friend class FbConfigList; + friend class RendererConfigList; GLuint getAttribValue(int n) const { return mAttribValues ? mAttribValues[n] : 0U; @@ -91,7 +91,7 @@ private: // // 5) Use getPackInfo() and packConfigs() to retrieve information about // available configs to the guest. -class FbConfigList { +class RendererConfigList { public: // Create a new list of FbConfig instance, by querying all compatible // host configs from |display|. A compatible config is one that supports @@ -99,10 +99,10 @@ public: // // After construction, call empty() to check if there are items. // An empty list means there was an error during construction. - explicit FbConfigList(EGLDisplay display); + explicit RendererConfigList(EGLDisplay display); // Destructor. - ~FbConfigList(); + ~RendererConfigList(); // Return true iff the list is empty. true means there was an error // during construction. @@ -116,7 +116,7 @@ public: // Retrieve the FbConfig instance associated with |guestId|, // which must be an integer between 0 and |size() - 1|. Returns // NULL in case of failure. - const FbConfig* get(int guestId) const { + const RendererConfig* get(int guestId) const { if (guestId >= 0 && guestId < mCount) { return mConfigs[guestId]; } else { @@ -152,11 +152,11 @@ public: EGLint packConfigs(GLuint bufferByteSize, GLuint* buffer) const; private: - FbConfigList(); - FbConfigList(const FbConfigList& other); + RendererConfigList(); + RendererConfigList(const RendererConfigList& other); int mCount; - FbConfig** mConfigs; + RendererConfig** mConfigs; EGLDisplay mDisplay; }; diff --git a/src/anbox/graphics/emugl/WindowSurface.cpp b/src/anbox/graphics/emugl/WindowSurface.cpp index 553b109..caf7609 100644 --- a/src/anbox/graphics/emugl/WindowSurface.cpp +++ b/src/anbox/graphics/emugl/WindowSurface.cpp @@ -16,7 +16,7 @@ #include "WindowSurface.h" #include "ErrorLog.h" -#include "FbConfig.h" +#include "RendererConfig.h" #include "OpenGLESDispatch/EGLDispatch.h"