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

Commit 7b3c3b4a authored by Hep Happy's avatar Hep Happy Committed by Sang Tae Park
Browse files

surfaceflinger: Enable dithering if persist.sys.use_dithering=1

* fixes color banding
* needs reboots after changed (caches variable for performance)

Change-Id: I66de607b149ec4e01967febeec234ef2994d20a4
parent dc88584a
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -182,10 +182,14 @@ status_t Layer::setBuffers( uint32_t w, uint32_t h,
    mSurfaceTexture->setDefaultBufferSize(w, h);
    mSurfaceTexture->setDefaultBufferFormat(format);

    if (mFlinger->getUseDithering()) {
        // we use the red index
        int displayRedSize = displayInfo.getSize(PixelFormatInfo::INDEX_RED);
        int layerRedsize = info.getSize(PixelFormatInfo::INDEX_RED);
        mNeedsDithering = layerRedsize > displayRedSize;
    } else {
        mNeedsDithering = false;
    }

    return NO_ERROR;
}
+13 −0
Original line number Diff line number Diff line
@@ -406,6 +406,7 @@ void LayerBase::clearWithOpenGL(const Region& clip, GLclampf red,
    glDisable(GL_TEXTURE_EXTERNAL_OES);
    glDisable(GL_TEXTURE_2D);
    glDisable(GL_BLEND);
    glDisable(GL_DITHER);

    Region::const_iterator it = clip.begin();
    Region::const_iterator const end = clip.end();
@@ -467,6 +468,12 @@ void LayerBase::drawWithOpenGL(const Region& clip) const
    texCoords[3].u = 1;
    texCoords[3].v = 1;

    if (needsDithering()) {
        glEnable(GL_DITHER);
    } else {
        glDisable(GL_DITHER);
    }

    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    glVertexPointer(2, GL_FLOAT, 0, mVertices);
    glTexCoordPointer(2, GL_FLOAT, 0, texCoords);
@@ -530,6 +537,12 @@ void LayerBase::drawS3DUIWithOpenGL(const Region& clip) const
    texCoords[3].u = 1;
    texCoords[3].v = 1;

    if (needsDithering()) {
        glEnable(GL_DITHER);
    } else {
        glDisable(GL_DITHER);
    }

    glEnableClientState(GL_TEXTURE_COORD_ARRAY);

    Region::const_iterator it = clip.begin();
+7 −1
Original line number Diff line number Diff line
@@ -112,7 +112,8 @@ SurfaceFlinger::SurfaceFlinger()
        mCanSkipComposition(false),
#endif
        mConsoleSignals(0),
        mSecureFrameBuffer(0)
        mSecureFrameBuffer(0),
        mUseDithering(false)
{
    init();
}
@@ -132,6 +133,10 @@ void SurfaceFlinger::init()

    property_get("debug.sf.ddms", value, "0");
    mDebugDDMS = atoi(value);

    property_get("persist.sys.use_dithering", value, "0");
    mUseDithering = atoi(value) == 1;

    if (mDebugDDMS) {
        DdmConnection::start(getServiceName());
    }
@@ -139,6 +144,7 @@ void SurfaceFlinger::init()
    LOGI_IF(mDebugRegion,       "showupdates enabled");
    LOGI_IF(mDebugBackground,   "showbackground enabled");
    LOGI_IF(mDebugDDMS,         "DDMS debugging enabled");
    LOGI_IF(mUseDithering,      "use dithering");
}

SurfaceFlinger::~SurfaceFlinger()
+4 −0
Original line number Diff line number Diff line
@@ -221,6 +221,8 @@ public:

    GLuint getProtectedTexName() const { return mProtectedTexName; }

    inline int  getUseDithering() const { return mUseDithering; }


    class MessageDestroyGLTexture : public MessageBase {
        GLuint texture;
@@ -442,6 +444,8 @@ private:

   // only written in the main thread, only read in other threads
   volatile     int32_t                     mSecureFrameBuffer;

                bool                        mUseDithering;
};

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