diff --git a/android/jni/com/mapswithme/opengl/androidoglcontext.cpp b/android/jni/com/mapswithme/opengl/androidoglcontext.cpp index cb41ec0bbf..58cd2a1f9f 100644 --- a/android/jni/com/mapswithme/opengl/androidoglcontext.cpp +++ b/android/jni/com/mapswithme/opengl/androidoglcontext.cpp @@ -1,18 +1,8 @@ #include "androidoglcontext.hpp" #include "android_gl_utils.hpp" - #include "base/assert.hpp" #include "base/logging.hpp" -#ifdef GL_GLEXT_PROTOTYPES - #undef GL_GLEXT_PROTOTYPES - #include - #define GL_GLEXT_PROTOTYPES -#else - #include -#endif - - namespace android { @@ -25,11 +15,10 @@ static EGLint * getContextAttributesList() return contextAttrList; } -AndroidOGLContext::AndroidOGLContext(EGLDisplay display, EGLSurface surface, EGLConfig config, AndroidOGLContext * contextToShareWith, bool csaaUsed) +AndroidOGLContext::AndroidOGLContext(EGLDisplay display, EGLSurface surface, EGLConfig config, AndroidOGLContext * contextToShareWith) : m_nativeContext(EGL_NO_CONTEXT) , m_surface(surface) , m_display(display) - , m_csaaUsed(csaaUsed) { ASSERT(m_surface != EGL_NO_SURFACE, ()); ASSERT(m_display != EGL_NO_DISPLAY, ()); @@ -56,17 +45,6 @@ void AndroidOGLContext::makeCurrent() ASSERT(m_surface != EGL_NO_SURFACE, ()); if (eglMakeCurrent(m_display, m_surface, m_surface, m_nativeContext) == EGL_FALSE) CHECK_EGL_CALL(); - - if (m_csaaUsed) - { - PFNGLCOVERAGEMASKNVPROC glCoverageMaskNVFn = (PFNGLCOVERAGEMASKNVPROC)eglGetProcAddress("glCoverageMaskNV"); - ASSERT(glCoverageMaskNVFn != nullptr, ()); - glCoverageMaskNVFn(GL_TRUE); - - PFNGLCOVERAGEOPERATIONNVPROC glCoverageOperationNVFn = (PFNGLCOVERAGEOPERATIONNVPROC)eglGetProcAddress("glCoverageOperationNV"); - ASSERT(glCoverageOperationNVFn != nullptr, ()); - glCoverageOperationNVFn(GL_COVERAGE_EDGE_FRAGMENTS_NV); - } } void AndroidOGLContext::clearCurrent() @@ -90,11 +68,6 @@ void AndroidOGLContext::present() CHECK_EGL_CALL(); } -int AndroidOGLContext::additionClearFlags() -{ - return m_csaaUsed ? GL_COVERAGE_BUFFER_BIT_NV : 0; -} - void AndroidOGLContext::setSurface(EGLSurface surface) { m_surface = surface; diff --git a/android/jni/com/mapswithme/opengl/androidoglcontext.hpp b/android/jni/com/mapswithme/opengl/androidoglcontext.hpp index 0781e4a9e6..98a4da3a80 100644 --- a/android/jni/com/mapswithme/opengl/androidoglcontext.hpp +++ b/android/jni/com/mapswithme/opengl/androidoglcontext.hpp @@ -11,13 +11,12 @@ namespace android class AndroidOGLContext : public dp::OGLContext { public: - AndroidOGLContext(EGLDisplay display, EGLSurface surface, EGLConfig config, AndroidOGLContext * contextToShareWith, bool csaaUsed); + AndroidOGLContext(EGLDisplay display, EGLSurface surface, EGLConfig config, AndroidOGLContext * contextToShareWith); ~AndroidOGLContext(); void makeCurrent() override; void present() override; void setDefaultFramebuffer() override; - int additionClearFlags() override; void setRenderingEnabled(bool enabled) override; void setSurface(EGLSurface surface); @@ -34,8 +33,6 @@ private: EGLSurface m_surface; EGLDisplay m_display; // @} - - bool m_csaaUsed; //CSAA = Coverage Sample Anti Aliasing }; } // namespace android diff --git a/android/jni/com/mapswithme/opengl/androidoglcontextfactory.cpp b/android/jni/com/mapswithme/opengl/androidoglcontextfactory.cpp index 78302d2ab2..d46394feb8 100644 --- a/android/jni/com/mapswithme/opengl/androidoglcontextfactory.cpp +++ b/android/jni/com/mapswithme/opengl/androidoglcontextfactory.cpp @@ -7,55 +7,15 @@ #include "std/algorithm.hpp" #include -#include #include #include namespace android { -static EGLint * getMultisampleAttributesList() -{ - static EGLint attr_list[] = - { - EGL_RED_SIZE, 5, - EGL_GREEN_SIZE, 6, - EGL_BLUE_SIZE, 5, - EGL_STENCIL_SIZE, 0, - EGL_DEPTH_SIZE, 16, - EGL_SAMPLE_BUFFERS, 1, - EGL_SAMPLES, 2, - EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, - EGL_SURFACE_TYPE, EGL_PBUFFER_BIT | EGL_WINDOW_BIT, - EGL_NONE - }; - return attr_list; -} - -/// nVidia Tegra2 doen't support EGL_SAMPLE_BUFFERS, but provide they own extension NV_coverage_sample -/// Also https://gfxbench.com/result.jsp says, that this extension supported on many Samsung, Asus, LG, Sony and other devices -static EGLint * getNVCoverageAttributesList() -{ - static EGLint attr_list[] = - { - EGL_RED_SIZE, 5, - EGL_GREEN_SIZE, 6, - EGL_BLUE_SIZE, 5, - EGL_STENCIL_SIZE, 0, - EGL_DEPTH_SIZE, 16, - EGL_COVERAGE_BUFFERS_NV, 1, - EGL_COVERAGE_SAMPLES_NV, 2, - EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, - EGL_SURFACE_TYPE, EGL_PBUFFER_BIT | EGL_WINDOW_BIT, - EGL_NONE - }; - return attr_list; -} - static EGLint * getConfigAttributesList() { - static EGLint attr_list[] = - { + static EGLint attr_list[] = { EGL_RED_SIZE, 5, EGL_GREEN_SIZE, 6, EGL_BLUE_SIZE, 5, @@ -79,7 +39,6 @@ AndroidOGLContextFactory::AndroidOGLContextFactory(JNIEnv * env, jobject jsurfac , m_surfaceWidth(0) , m_surfaceHeight(0) , m_windowSurfaceValid(false) - , m_useCSAA(false) { m_display = eglGetDisplay(EGL_DEFAULT_DISPLAY); if (m_display == EGL_NO_DISPLAY) @@ -227,7 +186,7 @@ dp::OGLContext * AndroidOGLContextFactory::getDrawContext() ASSERT(IsValid(), ()); ASSERT(m_windowSurface != EGL_NO_SURFACE, ()); if (m_drawContext == nullptr) - m_drawContext = new AndroidOGLContext(m_display, m_windowSurface, m_config, m_uploadContext, m_useCSAA); + m_drawContext = new AndroidOGLContext(m_display, m_windowSurface, m_config, m_uploadContext); return m_drawContext; } @@ -236,7 +195,7 @@ dp::OGLContext * AndroidOGLContextFactory::getResourcesUploadContext() ASSERT(IsValid(), ()); ASSERT(m_pixelbufferSurface != EGL_NO_SURFACE, ()); if (m_uploadContext == nullptr) - m_uploadContext = new AndroidOGLContext(m_display, m_pixelbufferSurface, m_config, m_drawContext, false /* don't use CSAA for upload context*/); + m_uploadContext = new AndroidOGLContext(m_display, m_pixelbufferSurface, m_config, m_drawContext); return m_uploadContext; } @@ -250,75 +209,17 @@ bool AndroidOGLContextFactory::isUploadContextCreated() const return m_uploadContext != nullptr; } -namespace -{ - -int GetConfigCount(EGLDisplay display, EGLint * attribs) -{ - int count = 0; - VERIFY(eglChooseConfig(display, attribs, nullptr, 0, &count) == EGL_TRUE, ()); - LOG(LINFO, ("Matched Config count = ", count)); - return count; -} - -EGLint GetConfigValue(EGLDisplay display, EGLConfig config, EGLint attr) -{ - EGLint v = 0; - VERIFY(eglGetConfigAttrib(display, config, attr, &v) == EGL_TRUE, ()); - return v; -} - -/// It's a usefull code in debug -//void PrintConfig(EGLDisplay display, EGLConfig config) -//{ -// LOG(LINFO, ("==================")); -// LOG(LINFO, ("Alpha = ", GetConfigValue(display, config, EGL_ALPHA_SIZE))); -// LOG(LINFO, ("Red = ", GetConfigValue(display, config, EGL_RED_SIZE))); -// LOG(LINFO, ("Blue = ", GetConfigValue(display, config, EGL_BLUE_SIZE))); -// LOG(LINFO, ("Green = ", GetConfigValue(display, config, EGL_GREEN_SIZE))); -// LOG(LINFO, ("Depth = ", GetConfigValue(display, config, EGL_DEPTH_SIZE))); -// LOG(LINFO, ("Sample buffer = ", GetConfigValue(display, config, EGL_SAMPLE_BUFFERS))); -// LOG(LINFO, ("Samples = ", GetConfigValue(display, config, EGL_SAMPLES))); -// LOG(LINFO, ("NV Coverage buffers = ", GetConfigValue(display, config, 0x30E0))); -// LOG(LINFO, ("NV Sample = ", GetConfigValue(display, config, 0x30E1))); -// -// LOG(LINFO, ("Caveat = ", GetConfigValue(display, config, EGL_CONFIG_CAVEAT))); -// LOG(LINFO, ("Conformant = ", GetConfigValue(display, config, EGL_CONFORMANT))); -// LOG(LINFO, ("Transparent = ", GetConfigValue(display, config, EGL_TRANSPARENT_TYPE))); -//} - -} // namespace - -EGLint * AndroidOGLContextFactory::GetSupportedAttributes() -{ - EGLint * attribs = getMultisampleAttributesList(); - if (GetConfigCount(m_display, attribs) > 0) - return attribs; - - attribs = getNVCoverageAttributesList(); - if (GetConfigCount(m_display, attribs) > 0) - { - m_useCSAA = true; - return attribs; - } - - return getConfigAttributesList(); -} - bool AndroidOGLContextFactory::createWindowSurface() { EGLConfig configs[40]; int count = 0; - EGLint * attribs = GetSupportedAttributes(); - VERIFY(eglChooseConfig(m_display, attribs, configs, 40, &count) == EGL_TRUE, ()); - ASSERT(count > 0, ("No one OGL config found")); + VERIFY(eglChooseConfig(m_display, getConfigAttributesList(), configs, 40, &count) == EGL_TRUE, ()); + ASSERT(count > 0, ("Didn't find any configs.")); sort(&configs[0], &configs[count], ConfigComparator(m_display)); for (int i = 0; i < count; ++i) { EGLConfig currentConfig = configs[i]; - if (GetConfigValue(m_display, currentConfig, EGL_RED_SIZE) != 5) - continue; EGLint format; eglGetConfigAttrib(m_display, currentConfig, EGL_NATIVE_VISUAL_ID, &format); diff --git a/android/jni/com/mapswithme/opengl/androidoglcontextfactory.hpp b/android/jni/com/mapswithme/opengl/androidoglcontextfactory.hpp index f962c89ed1..4de3bdfe69 100644 --- a/android/jni/com/mapswithme/opengl/androidoglcontextfactory.hpp +++ b/android/jni/com/mapswithme/opengl/androidoglcontextfactory.hpp @@ -2,7 +2,7 @@ #include "../core/jni_helper.hpp" #include "androidoglcontext.hpp" -#include "../../../drape/oglcontextfactory.hpp" +#include "drape/oglcontextfactory.hpp" namespace android { @@ -29,7 +29,6 @@ public: private: bool QuerySurfaceSize(); - EGLint * GetSupportedAttributes(); private: bool createWindowSurface(); @@ -49,7 +48,6 @@ private: int m_surfaceHeight; bool m_windowSurfaceValid; - bool m_useCSAA; }; } // namespace android diff --git a/drape/oglcontext.hpp b/drape/oglcontext.hpp index d3c2384a3d..ea28215670 100644 --- a/drape/oglcontext.hpp +++ b/drape/oglcontext.hpp @@ -12,7 +12,6 @@ public: virtual void setDefaultFramebuffer() = 0; /// @ param w, h - pixel size of render target (logical size * visual scale) virtual void resize(int /*w*/, int /*h*/) {} - virtual int additionClearFlags() { return 0; } virtual void setRenderingEnabled(bool enabled) {} };