From cc934763c3fc789f53edb64de16fc36d43c3705d Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Wed, 23 Sep 2009 19:16:27 -0700 Subject: turn dithering off if it's not needed --- libs/surfaceflinger/Layer.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'libs/surfaceflinger/Layer.cpp') diff --git a/libs/surfaceflinger/Layer.cpp b/libs/surfaceflinger/Layer.cpp index 8dfc2cf..67ddcf9 100644 --- a/libs/surfaceflinger/Layer.cpp +++ b/libs/surfaceflinger/Layer.cpp @@ -51,7 +51,8 @@ Layer::Layer(SurfaceFlinger* flinger, DisplayID display, const sp& c, int32_t i) : LayerBaseClient(flinger, display, c, i), mSecure(false), - mNeedsBlending(true) + mNeedsBlending(true), + mNeedsDithering(false) { // no OpenGL operation is possible here, since we might not be // in the OpenGL thread. @@ -106,10 +107,16 @@ status_t Layer::ditch() status_t Layer::setBuffers( uint32_t w, uint32_t h, PixelFormat format, uint32_t flags) { + // this surfaces pixel format PixelFormatInfo info; status_t err = getPixelFormatInfo(format, &info); if (err) return err; + // the display's pixel format + const DisplayHardware& hw(graphicPlane(0).displayHardware()); + PixelFormatInfo displayInfo; + getPixelFormatInfo(hw.getFormat(), &displayInfo); + uint32_t bufferFlags = 0; if (flags & ISurfaceComposer::eSecure) bufferFlags |= Buffer::SECURE; @@ -119,6 +126,12 @@ status_t Layer::setBuffers( uint32_t w, uint32_t h, mHeight = h; mSecure = (bufferFlags & Buffer::SECURE) ? true : false; mNeedsBlending = (info.h_alpha - info.l_alpha) > 0; + + // we use the red index + int displayRedSize = displayInfo.getSize(PixelFormatInfo::INDEX_RED); + int layerRedsize = info.getSize(PixelFormatInfo::INDEX_RED); + mNeedsDithering = layerRedsize > displayRedSize; + mBufferFlags = bufferFlags; for (size_t i=0 ; i