Skip to content
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
  • Loading branch information...
1 parent be52390 commit f0619dfba52adeb97dac26e5749eda06187f5834 @AndroidMeda AndroidMeda committed with Whitehawkx Apr 4, 2012
View
12 services/surfaceflinger/Layer.cpp
@@ -182,10 +182,14 @@ status_t Layer::setBuffers( uint32_t w, uint32_t h,
mSurfaceTexture->setDefaultBufferSize(w, h);
mSurfaceTexture->setDefaultBufferFormat(format);
- // we use the red index
- int displayRedSize = displayInfo.getSize(PixelFormatInfo::INDEX_RED);
- int layerRedsize = info.getSize(PixelFormatInfo::INDEX_RED);
- mNeedsDithering = layerRedsize > displayRedSize;
+ 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;
}
View
13 services/surfaceflinger/LayerBase.cpp
@@ -400,6 +400,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();
@@ -461,6 +462,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);
@@ -524,6 +531,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();
View
8 services/surfaceflinger/SurfaceFlinger.cpp
@@ -112,7 +112,8 @@ SurfaceFlinger::SurfaceFlinger()
mCanSkipComposition(false),
#endif
mConsoleSignals(0),
- mSecureFrameBuffer(0)
+ mSecureFrameBuffer(0),
+ mUseDithering(false)
{
init();
}
@@ -132,13 +133,18 @@ 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());
}
LOGI_IF(mDebugRegion, "showupdates enabled");
LOGI_IF(mDebugBackground, "showbackground enabled");
LOGI_IF(mDebugDDMS, "DDMS debugging enabled");
+ LOGI_IF(mUseDithering, "use dithering");
}
SurfaceFlinger::~SurfaceFlinger()
View
4 services/surfaceflinger/SurfaceFlinger.h
@@ -221,6 +221,8 @@ class SurfaceFlinger :
GLuint getProtectedTexName() const { return mProtectedTexName; }
+ inline int getUseDithering() const { return mUseDithering; }
+
class MessageDestroyGLTexture : public MessageBase {
GLuint texture;
@@ -439,6 +441,8 @@ class SurfaceFlinger :
// only written in the main thread, only read in other threads
volatile int32_t mSecureFrameBuffer;
+
+ bool mUseDithering;
};
// ---------------------------------------------------------------------------

0 comments on commit f0619df

Please sign in to comment.
Something went wrong with that request. Please try again.