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

Commit 0841cfb4 authored by Mathias Agopian's avatar Mathias Agopian Committed by Android Git Automerger
Browse files

am 5be7de5f: Merge "fix a bug where fading in/out of opaque 32-bits windows...

am 5be7de5f: Merge "fix a bug where fading in/out of opaque 32-bits windows wasn\'t working" into kraken
parents e3225b0f 6d2f3973
Loading
Loading
Loading
Loading
+7 −19
Original line number Diff line number Diff line
@@ -379,33 +379,21 @@ void LayerBase::drawWithOpenGL(const Region& clip, const Texture& texture) const
    
    glEnable(GL_TEXTURE_2D);

    GLenum src = mPremultipliedAlpha ? GL_ONE : GL_SRC_ALPHA;
    if (UNLIKELY(s.alpha < 0xFF)) {
        // We have an alpha-modulation. We need to modulate all
        // texture components by alpha because we're always using 
        // premultiplied alpha.
        
        // If the texture doesn't have an alpha channel we can
        // use REPLACE and switch to non premultiplied alpha
        // blending (SRCA/ONE_MINUS_SRCA).
        
        GLenum env, src;
        if (needsBlending()) {
            env = GL_MODULATE;
            src = mPremultipliedAlpha ? GL_ONE : GL_SRC_ALPHA;
        } else {
            env = GL_REPLACE;
            src = GL_SRC_ALPHA;
        }
        const GLfloat alpha = s.alpha * (1.0f/255.0f);
        if (mPremultipliedAlpha) {
            glColor4f(alpha, alpha, alpha, alpha);
        } else {
            glColor4f(1, 1, 1, alpha);
        }
        glEnable(GL_BLEND);
        glBlendFunc(src, GL_ONE_MINUS_SRC_ALPHA);
        glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, env);
        glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
    } else {
        glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
        glColor4f(1, 1, 1, 1);
        glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
        if (needsBlending()) {
            GLenum src = mPremultipliedAlpha ? GL_ONE : GL_SRC_ALPHA;
            glEnable(GL_BLEND);
            glBlendFunc(src, GL_ONE_MINUS_SRC_ALPHA);
        } else {
+12 −3
Original line number Diff line number Diff line
@@ -122,11 +122,20 @@ status_t GraphicBuffer::reallocate(uint32_t w, uint32_t h, PixelFormat f,
status_t GraphicBuffer::initSize(uint32_t w, uint32_t h, PixelFormat format,
        uint32_t reqUsage)
{
    if (format == PIXEL_FORMAT_RGBX_8888)
        format = PIXEL_FORMAT_RGBA_8888;

    GraphicBufferAllocator& allocator = GraphicBufferAllocator::get();
    status_t err = allocator.alloc(w, h, format, reqUsage, &handle, &stride);

    if (err<0 && format == PIXEL_FORMAT_RGBX_8888) {
        /*
         * There is currently a bug with some gralloc implementations
         * not supporting RGBX_8888. In this case, we revert to using RGBA_8888
         * which is not exactly the same, as GL_REPLACE will yield a different
         * result.
         */
        format = PIXEL_FORMAT_RGBA_8888;
        err = allocator.alloc(w, h, format, reqUsage, &handle, &stride);
    }

    if (err == NO_ERROR) {
        this->width  = w;
        this->height = h;