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

Commit 378532fd authored by Mathias Agopian's avatar Mathias Agopian
Browse files

fix again [2102410] Home Screen is not displayed in the background in Landscape Mode

parent 4666267b
Loading
Loading
Loading
Loading
+51 −1
Original line number Original line Diff line number Diff line
@@ -111,6 +111,50 @@ struct BlurColor565
    }
    }
};
};


template <int FACTOR = 0>
struct BlurColor888X
{
    typedef uint32_t type;
    int r, g, b;    
    inline BlurColor888X() { }
    inline BlurColor888X(uint32_t v) {
        v = BLUR_RGBA_TO_HOST(v);
        r = v & 0xFF;
        g = (v >>  8) & 0xFF;
        b = (v >> 16) & 0xFF;
    }
    inline void clear() { r=g=b=0; }
    inline uint32_t to(int shift, int last, int dither) const {
        int R = r;
        int G = g;
        int B = b;
        if  (UNLIKELY(last)) {
            if (FACTOR>0) {
                int L = (R+G+G+B)>>2;
                R += ((L - R) * FACTOR) >> 8;
                G += ((L - G) * FACTOR) >> 8;
                B += ((L - B) * FACTOR) >> 8;
            }
        }
        R >>= shift;
        G >>= shift;
        B >>= shift;
        return BLUR_HOST_TO_RGBA((0xFF<<24) | (B<<16) | (G<<8) | R);
    }    
    inline BlurColor888X& operator += (const BlurColor888X& rhs) {
        r += rhs.r;
        g += rhs.g;
        b += rhs.b;
        return *this;
    }
    inline BlurColor888X& operator -= (const BlurColor888X& rhs) {
        r -= rhs.r;
        g -= rhs.g;
        b -= rhs.b;
        return *this;
    }
};

struct BlurGray565
struct BlurGray565
{
{
    typedef uint16_t type;
    typedef uint16_t type;
@@ -316,7 +360,13 @@ status_t blurFilter(
        int kernelSizeUser,
        int kernelSizeUser,
        int repeat)
        int repeat)
{
{
    return blurFilter< BlurColor565<0x80> >(image, image, kernelSizeUser, repeat);
    status_t err = BAD_VALUE;
    if (image->format == GGL_PIXEL_FORMAT_RGB_565) {
        err = blurFilter< BlurColor565<0x80> >(image, image, kernelSizeUser, repeat);
    } else if (image->format == GGL_PIXEL_FORMAT_RGBX_8888) {
        err = blurFilter< BlurColor888X<0x80> >(image, image, kernelSizeUser, repeat);
    }
    return err;
}
}


} // namespace android
} // namespace android
+30 −17
Original line number Original line Diff line number Diff line
@@ -136,6 +136,13 @@ void LayerBlur::onDraw(const Region& clip) const
        // create the texture name the first time
        // create the texture name the first time
        // can't do that in the ctor, because it runs in another thread.
        // can't do that in the ctor, because it runs in another thread.
        glGenTextures(1, &mTextureName);
        glGenTextures(1, &mTextureName);
        glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES, &mReadFormat);
        glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE_OES, &mReadType);
        if (mReadFormat != GL_RGB || mReadType != GL_UNSIGNED_SHORT_5_6_5) {
            mReadFormat = GL_RGBA;
            mReadType = GL_UNSIGNED_BYTE;
            mBlurFormat = GGL_PIXEL_FORMAT_RGBX_8888;
        }
    }
    }


    Region::const_iterator it = clip.begin();
    Region::const_iterator it = clip.begin();
@@ -148,14 +155,20 @@ void LayerBlur::onDraw(const Region& clip) const
            mRefreshCache = false;
            mRefreshCache = false;
            mAutoRefreshPending = false;
            mAutoRefreshPending = false;


            int32_t pixelSize = 4;
            int32_t s = w;
            if (mReadType == GL_UNSIGNED_SHORT_5_6_5) {
                // allocate enough memory for 4-bytes (2 pixels) aligned data
                // allocate enough memory for 4-bytes (2 pixels) aligned data
            const int32_t s = (w + 1) & ~1;
                s = (w + 1) & ~1;
            uint16_t* const pixels = (uint16_t*)malloc(s*h*2);
                pixelSize = 2;
            }

            uint16_t* const pixels = (uint16_t*)malloc(s*h*pixelSize);


            // This reads the frame-buffer, so a h/w GL would have to
            // This reads the frame-buffer, so a h/w GL would have to
            // finish() its rendering first. we don't want to do that
            // finish() its rendering first. we don't want to do that
            // too often. Read data is 4-bytes aligned.
            // too often. Read data is 4-bytes aligned.
            glReadPixels(X, Y, w, h, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, pixels);
            glReadPixels(X, Y, w, h, mReadFormat, mReadType, pixels);


            // blur that texture.
            // blur that texture.
            GGLSurface bl;
            GGLSurface bl;
@@ -163,13 +176,13 @@ void LayerBlur::onDraw(const Region& clip) const
            bl.width = w;
            bl.width = w;
            bl.height = h;
            bl.height = h;
            bl.stride = s;
            bl.stride = s;
            bl.format = GGL_PIXEL_FORMAT_RGB_565;
            bl.format = mBlurFormat;
            bl.data = (GGLubyte*)pixels;            
            bl.data = (GGLubyte*)pixels;            
            blurFilter(&bl, 8, 2);
            blurFilter(&bl, 8, 2);


            if (mFlags & (DisplayHardware::NPOT_EXTENSION)) {
            if (mFlags & (DisplayHardware::NPOT_EXTENSION)) {
                glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0,
                glTexImage2D(GL_TEXTURE_2D, 0, mReadFormat, w, h, 0,
                        GL_RGB, GL_UNSIGNED_SHORT_5_6_5, pixels);
                        mReadFormat, mReadType, pixels);
                mWidthScale  = 1.0f / w;
                mWidthScale  = 1.0f / w;
                mHeightScale =-1.0f / h;
                mHeightScale =-1.0f / h;
                mYOffset = 0;
                mYOffset = 0;
@@ -178,10 +191,10 @@ void LayerBlur::onDraw(const Region& clip) const
                GLuint th = 1 << (31 - clz(h));
                GLuint th = 1 << (31 - clz(h));
                if (tw < w) tw <<= 1;
                if (tw < w) tw <<= 1;
                if (th < h) th <<= 1;
                if (th < h) th <<= 1;
                glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, tw, th, 0,
                glTexImage2D(GL_TEXTURE_2D, 0, mReadFormat, tw, th, 0,
                        GL_RGB, GL_UNSIGNED_SHORT_5_6_5, NULL);
                        mReadFormat, mReadType, NULL);
                glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, 
                glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, 
                        GL_RGB, GL_UNSIGNED_SHORT_5_6_5, pixels);
                        mReadFormat, mReadType, pixels);
                mWidthScale  = 1.0f / tw;
                mWidthScale  = 1.0f / tw;
                mHeightScale =-1.0f / th;
                mHeightScale =-1.0f / th;
                mYOffset = th-h;
                mYOffset = th-h;
+3 −0
Original line number Original line Diff line number Diff line
@@ -59,6 +59,9 @@ private:
    mutable GLfloat mWidthScale;
    mutable GLfloat mWidthScale;
    mutable GLfloat mHeightScale;
    mutable GLfloat mHeightScale;
    mutable GLfloat mYOffset;
    mutable GLfloat mYOffset;
    mutable GLint   mReadFormat;
    mutable GLint   mReadType;
    mutable uint32_t mBlurFormat;
};
};


// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------