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

Commit b1ab5760 authored by Mathias Agopian's avatar Mathias Agopian Committed by Android (Google) Code Review
Browse files

Merge "clean-up surfaceflinger a bit" into kraken

parents c4f41a76 78fd5010
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -266,9 +266,6 @@ void DisplayHardware::init(uint32_t dpy)
    if (strstr(gl_extensions, "GL_ARB_texture_non_power_of_two")) {
        mFlags |= NPOT_EXTENSION;
    }
    if (strstr(gl_extensions, "GL_OES_draw_texture")) {
        mFlags |= DRAW_TEXTURE_EXTENSION;
    }
#ifdef EGL_ANDROID_image_native_buffer
    if (strstr( gl_extensions, "GL_OES_EGL_image") &&
        (strstr(egl_extensions, "EGL_KHR_image_base") || 
+0 −1
Original line number Diff line number Diff line
@@ -46,7 +46,6 @@ public:
        DIRECT_TEXTURE          = 0x00000002,
        COPY_BITS_EXTENSION     = 0x00000008,
        NPOT_EXTENSION          = 0x00000100,
        DRAW_TEXTURE_EXTENSION  = 0x00000200,
        BUFFER_PRESERVED        = 0x00010000,
        PARTIAL_UPDATES         = 0x00020000,   // video driver feature
        SLOW_CONFIG             = 0x00040000,   // software
+41 −58
Original line number Diff line number Diff line
@@ -374,7 +374,7 @@ void LayerBase::clearWithOpenGL(const Region& clip, GLclampx red,
    Region::const_iterator it = clip.begin();
    Region::const_iterator const end = clip.end();
    glEnable(GL_SCISSOR_TEST);
    glVertexPointer(2, GL_FIXED, 0, mVertices);
    glVertexPointer(2, GL_FLOAT, 0, mVertices);
    while (it != end) {
        const Rect& r = *it++;
        const GLint sy = fbHeight - (r.top + r.height());
@@ -418,14 +418,14 @@ void LayerBase::drawWithOpenGL(const Region& clip, const Texture& texture) const
            env = GL_REPLACE;
            src = GL_SRC_ALPHA;
        }
        const GGLfixed alpha = (s.alpha << 16)/255;
        glColor4x(alpha, alpha, alpha, alpha);
        const GLfloat alpha = s.alpha * (1.0f/255.0f);
        glColor4f(alpha, alpha, alpha, alpha);
        glEnable(GL_BLEND);
        glBlendFunc(src, GL_ONE_MINUS_SRC_ALPHA);
        glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, env);
    } else {
        glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
        glColor4x(0x10000, 0x10000, 0x10000, 0x10000);
        glColor4f(1, 1, 1, 1);
        if (needsBlending()) {
            GLenum src = mPremultipliedAlpha ? GL_ONE : GL_SRC_ALPHA;
            glEnable(GL_BLEND);
@@ -437,15 +437,11 @@ void LayerBase::drawWithOpenGL(const Region& clip, const Texture& texture) const

    Region::const_iterator it = clip.begin();
    Region::const_iterator const end = clip.end();
    if (UNLIKELY(transformed()
            || !(mFlags & DisplayHardware::DRAW_TEXTURE_EXTENSION) )) 
    {
        //StopWatch watch("GL transformed");
        const GLfixed texCoords[4][2] = {
    const GLfloat texCoords[4][2] = {
            { 0,  0 },
                { 0,        0x10000 },
                { 0x10000,  0x10000 },
                { 0x10000,  0 }
            { 0,  1 },
            { 1,  1 },
            { 1,  0 }
    };

    glMatrixMode(GL_TEXTURE);
@@ -472,8 +468,8 @@ void LayerBase::drawWithOpenGL(const Region& clip, const Texture& texture) const
    }

    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
        glVertexPointer(2, GL_FIXED, 0, mVertices);
        glTexCoordPointer(2, GL_FIXED, 0, texCoords);
    glVertexPointer(2, GL_FLOAT, 0, mVertices);
    glTexCoordPointer(2, GL_FLOAT, 0, texCoords);

    while (it != end) {
        const Rect& r = *it++;
@@ -482,19 +478,6 @@ void LayerBase::drawWithOpenGL(const Region& clip, const Texture& texture) const
        glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
    }
    glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    } else {
        GLint crop[4] = { 0, height, width, -height };
        glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop);
        int x = tx();
        int y = ty();
        y = fbHeight - (y + height);
        while (it != end) {
            const Rect& r = *it++;
            const GLint sy = fbHeight - (r.top + r.height());
            glScissor(r.left, sy, r.width(), r.height());
            glDrawTexiOES(x, y, 0, width, height);
        }
    }
}

void LayerBase::validateTexture(GLint textureName) const
+1 −1
Original line number Diff line number Diff line
@@ -278,7 +278,7 @@ protected:
                bool            mTransformed;
                bool            mUseLinearFiltering;
                int32_t         mOrientation;
                GLfixed         mVertices[4][2];
                GLfloat         mVertices[4][2];
                Rect            mTransformedBounds;
                int             mLeft;
                int             mTop;
+15 −33
Original line number Diff line number Diff line
@@ -206,8 +206,8 @@ void LayerBlur::onDraw(const Region& clip) const

        const State& s = drawingState();
        if (UNLIKELY(s.alpha < 0xFF)) {
            const GGLfixed alpha = (s.alpha << 16)/255;
            glColor4x(0, 0, 0, alpha);
            const GLfloat alpha = s.alpha * (1.0f/255.0f);
            glColor4f(0, 0, 0, alpha);
            glEnable(GL_BLEND);
            glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
            glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
@@ -225,16 +225,13 @@ void LayerBlur::onDraw(const Region& clip) const
        glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
        glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

        if (UNLIKELY(transformed()
                || !(mFlags & DisplayHardware::DRAW_TEXTURE_EXTENSION) )) {
            // This is a very rare scenario.
        glMatrixMode(GL_TEXTURE);
        glLoadIdentity();
        glScalef(mWidthScale, mHeightScale, 1);
        glTranslatef(-x, mYOffset - y, 0);
        glEnableClientState(GL_TEXTURE_COORD_ARRAY);
            glVertexPointer(2, GL_FIXED, 0, mVertices);
            glTexCoordPointer(2, GL_FIXED, 0, mVertices);
        glVertexPointer(2, GL_FLOAT, 0, mVertices);
        glTexCoordPointer(2, GL_FLOAT, 0, mVertices);
        while (it != end) {
            const Rect& r = *it++;
            const GLint sy = fbHeight - (r.top + r.height());
@@ -242,21 +239,6 @@ void LayerBlur::onDraw(const Region& clip) const
            glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
        }
        glDisableClientState(GL_TEXTURE_COORD_ARRAY);
        } else {
            // NOTE: this is marginally faster with the software gl, because
            // glReadPixels() reads the fb bottom-to-top, however we'll
            // skip all the jaccobian computations.
            Rect r;
            GLint crop[4] = { 0, 0, w, h };
            glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop);
            y = fbHeight - (y + h);
            while (it != end) {
                const Rect& r = *it++;
                const GLint sy = fbHeight - (r.top + r.height());
                glScissor(r.left, sy, r.width(), r.height());
                glDrawTexiOES(x, y, 0, w, h);
            }
        }
    }
}

Loading