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

Commit 39d252a6 authored by Romain Guy's avatar Romain Guy
Browse files

Various OpenGL optimizations

Change-Id: Ib0742c96f10f5f50e7e5148b742c31b6c232d127
parent f44e66fc
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -171,8 +171,8 @@ void GradientCache::generateTexture(SkBitmap* bitmap, Texture* texture) {
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, bitmap->rowBytesAsPixels(), texture->height, 0,
            GL_RGBA, GL_UNSIGNED_BYTE, bitmap->getPixels());

    texture->setFilter(GL_LINEAR, GL_LINEAR);
    texture->setWrap(GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE);
    texture->setFilter(GL_LINEAR);
    texture->setWrap(GL_CLAMP_TO_EDGE);
}

}; // namespace uirenderer
+2 −2
Original line number Diff line number Diff line
@@ -108,8 +108,8 @@ Layer* LayerCache::get(const uint32_t width, const uint32_t height) {

        layer->generateTexture();
        layer->bindTexture();
        layer->setFilter(GL_NEAREST, GL_NEAREST);
        layer->setWrap(GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE, false);
        layer->setFilter(GL_NEAREST);
        layer->setWrap(GL_CLAMP_TO_EDGE, false);
        glPixelStorei(GL_UNPACK_ALIGNMENT, 4);

#if DEBUG_LAYERS
+2 −0
Original line number Diff line number Diff line
@@ -458,6 +458,8 @@ bool LayerRenderer::copyLayer(Layer* layer, SkBitmap* bitmap) {
        }

error:
        glEnable(GL_SCISSOR_TEST);

#if DEBUG_OPENGL
        if (error != GL_NO_ERROR) {
            LOGD("GL error while copying layer into bitmap = 0x%x", error);
+5 −14
Original line number Diff line number Diff line
@@ -141,13 +141,9 @@ void OpenGLRenderer::setViewport(int width, int height) {
    mFirstSnapshot->height = height;
    mFirstSnapshot->viewport.set(0, 0, width, height);

    mDirtyClip = false;

    glDisable(GL_DITHER);
    glViewport(0, 0, width, height);

    glEnable(GL_SCISSOR_TEST);
    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

    glEnableVertexAttribArray(Program::kBindingPosition);
}

@@ -161,12 +157,13 @@ void OpenGLRenderer::prepareDirty(float left, float top, float right, float bott
    mSnapshot = new Snapshot(mFirstSnapshot,
            SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag);
    mSnapshot->fbo = getTargetFbo();

    mSaveCount = 1;

    glEnable(GL_SCISSOR_TEST);
    glViewport(0, 0, mWidth, mHeight);
    glScissor(left, mSnapshot->height - bottom, right - left, bottom - top);

    mSnapshot->setClip(left, top, right, bottom);
    mDirtyClip = false;

    if (!opaque) {
        glClear(GL_COLOR_BUFFER_BIT);
@@ -214,13 +211,9 @@ void OpenGLRenderer::resume() {
    glEnable(GL_SCISSOR_TEST);
    dirtyClip();

    glDisable(GL_DITHER);

    glBindFramebuffer(GL_FRAMEBUFFER, snapshot->fbo);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

    glEnableVertexAttribArray(Program::kBindingPosition);

    mCaches.blend = true;
    glEnable(GL_BLEND);
    glBlendFunc(mCaches.lastSrcMode, mCaches.lastDstMode);
@@ -916,10 +909,8 @@ void OpenGLRenderer::clearLayerRegions() {
        setupDrawProgram();
        setupDrawPureColorUniforms();
        setupDrawModelViewTranslate(0.0f, 0.0f, 0.0f, 0.0f, true);
        setupDrawVertices(&mesh[0].position[0]);

        mCaches.unbindMeshBuffer();
        glVertexAttribPointer(mCaches.currentProgram->position, 2, GL_FLOAT, GL_FALSE,
                gVertexStride, &mesh[0].position[0]);
        glDrawArrays(GL_TRIANGLES, 0, count * 6);

        glEnable(GL_SCISSOR_TEST);
+2 −2
Original line number Diff line number Diff line
@@ -137,8 +137,8 @@ ShadowTexture* TextDropShadowCache::get(SkPaint* paint, const char* text, uint32
        glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, texture->width, texture->height, 0,
                GL_ALPHA, GL_UNSIGNED_BYTE, shadow.image);

        texture->setFilter(GL_LINEAR, GL_LINEAR);
        texture->setWrap(GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE);
        texture->setFilter(GL_LINEAR);
        texture->setWrap(GL_CLAMP_TO_EDGE);

        if (size < mMaxSize) {
            if (mDebugEnabled) {
Loading