Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f2fb6760 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes Id5d858d2,I901d1486

* changes:
  Tidy up GL resources
  Moving RenderEngineTest to Value-parameterized tests
parents eb3f8108 2725c097
Loading
Loading
Loading
Loading
+20 −1
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
 */

//#define LOG_NDEBUG 0
#include "EGL/egl.h"
#undef LOG_TAG
#define LOG_TAG "RenderEngine"
#define ATRACE_TAG ATRACE_TAG_GRAPHICS
@@ -446,19 +447,37 @@ GLESRenderEngine::GLESRenderEngine(const RenderEngineCreationArgs& args, EGLDisp
                                          mPlaceholderBuffer, attributes);
    ALOGE_IF(mPlaceholderImage == EGL_NO_IMAGE_KHR, "Failed to create placeholder image: %#x",
             eglGetError());

    mShadowTexture = std::make_unique<GLShadowTexture>();
}

GLESRenderEngine::~GLESRenderEngine() {
    // Destroy the image manager first.
    mImageManager = nullptr;
    mShadowTexture = nullptr;
    cleanFramebufferCache();
    ProgramCache::getInstance().purgeCaches();
    std::lock_guard<std::mutex> lock(mRenderingMutex);
    glDisableVertexAttribArray(Program::position);
    unbindFrameBuffer(mDrawingBuffer.get());
    mDrawingBuffer = nullptr;
    eglDestroyImageKHR(mEGLDisplay, mPlaceholderImage);
    mImageCache.clear();
    if (mStubSurface != EGL_NO_SURFACE) {
        eglDestroySurface(mEGLDisplay, mStubSurface);
    }
    if (mProtectedStubSurface != EGL_NO_SURFACE) {
        eglDestroySurface(mEGLDisplay, mProtectedStubSurface);
    }
    if (mEGLContext != EGL_NO_CONTEXT) {
        eglDestroyContext(mEGLDisplay, mEGLContext);
    }
    if (mProtectedEGLContext != EGL_NO_CONTEXT) {
        eglDestroyContext(mEGLDisplay, mProtectedEGLContext);
    }
    eglMakeCurrent(mEGLDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
    eglTerminate(mEGLDisplay);
    eglReleaseThread();
}

std::unique_ptr<Framebuffer> GLESRenderEngine::createFramebuffer() {
@@ -1800,7 +1819,7 @@ void GLESRenderEngine::handleShadow(const FloatRect& casterRect, float casterCor

    mState.cornerRadius = 0.0f;
    mState.drawShadows = true;
    setupLayerTexturing(mShadowTexture.getTexture());
    setupLayerTexturing(mShadowTexture->getTexture());
    drawMesh(mesh);
    mState.drawShadows = false;
}
+2 −2
Original line number Diff line number Diff line
@@ -193,7 +193,7 @@ private:
    GLuint mVpWidth;
    GLuint mVpHeight;
    Description mState;
    GLShadowTexture mShadowTexture;
    std::unique_ptr<GLShadowTexture> mShadowTexture = nullptr;

    mat4 mSrgbToXyz;
    mat4 mDisplayP3ToXyz;
@@ -294,7 +294,7 @@ private:
    friend class BlurFilter;
    friend class GenericProgram;
    std::unique_ptr<FlushTracer> mFlushTracer;
    std::unique_ptr<ImageManager> mImageManager = std::make_unique<ImageManager>(this);
    std::unique_ptr<ImageManager> mImageManager;
};

} // namespace gl
+1 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ GLFramebuffer::GLFramebuffer(GLESRenderEngine& engine)
}

GLFramebuffer::~GLFramebuffer() {
    setNativeWindowBuffer(nullptr, false, false);
    glDeleteFramebuffers(1, &mFramebufferName);
    glDeleteTextures(1, &mTextureName);
}
+8 −0
Original line number Diff line number Diff line
@@ -82,6 +82,14 @@ Program::Program(const ProgramCache::Key& /*needs*/, const char* vertex, const c
    }
}

Program::~Program() {
    glDetachShader(mProgram, mVertexShader);
    glDetachShader(mProgram, mFragmentShader);
    glDeleteShader(mVertexShader);
    glDeleteShader(mFragmentShader);
    glDeleteProgram(mProgram);
}

bool Program::isValid() const {
    return mInitialized;
}
+1 −1
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ public:
    };

    Program(const ProgramCache::Key& needs, const char* vertex, const char* fragment);
    ~Program() = default;
    ~Program();

    /* whether this object is usable */
    bool isValid() const;
Loading