diff options
author | Mathias Agopian <mathias@google.com> | 2009-09-23 19:16:27 -0700 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2009-09-23 19:16:27 -0700 |
commit | cc934763c3fc789f53edb64de16fc36d43c3705d (patch) | |
tree | 5e9f508326cbaa27bd1fd255324dfcd4026badbf /libs | |
parent | 44cac134655d5c3b2eeab2e42792c70a7aa8b92f (diff) | |
download | frameworks_base-cc934763c3fc789f53edb64de16fc36d43c3705d.zip frameworks_base-cc934763c3fc789f53edb64de16fc36d43c3705d.tar.gz frameworks_base-cc934763c3fc789f53edb64de16fc36d43c3705d.tar.bz2 |
turn dithering off if it's not needed
Diffstat (limited to 'libs')
-rw-r--r-- | libs/surfaceflinger/Layer.cpp | 15 | ||||
-rw-r--r-- | libs/surfaceflinger/Layer.h | 2 | ||||
-rw-r--r-- | libs/surfaceflinger/LayerBase.cpp | 14 | ||||
-rw-r--r-- | libs/surfaceflinger/LayerBase.h | 5 | ||||
-rw-r--r-- | libs/surfaceflinger/SurfaceFlinger.cpp | 5 |
5 files changed, 30 insertions, 11 deletions
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<Client>& 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<NUM_BUFFERS ; i++) { mBuffers[i] = new Buffer(); diff --git a/libs/surfaceflinger/Layer.h b/libs/surfaceflinger/Layer.h index 2e8173d..6c7b27b 100644 --- a/libs/surfaceflinger/Layer.h +++ b/libs/surfaceflinger/Layer.h @@ -68,6 +68,7 @@ public: virtual void unlockPageFlip(const Transform& planeTransform, Region& outDirtyRegion); virtual void finishPageFlip(); virtual bool needsBlending() const { return mNeedsBlending; } + virtual bool needsDithering() const { return mNeedsDithering; } virtual bool isSecure() const { return mSecure; } virtual sp<Surface> createSurface() const; virtual status_t ditch(); @@ -109,6 +110,7 @@ private: bool mSecure; int32_t mFrontBufferIndex; bool mNeedsBlending; + bool mNeedsDithering; Region mPostedDirtyRegion; sp<FreezeLock> mFreezeLock; PixelFormat mFormat; diff --git a/libs/surfaceflinger/LayerBase.cpp b/libs/surfaceflinger/LayerBase.cpp index 8b9a842..5a93b2d 100644 --- a/libs/surfaceflinger/LayerBase.cpp +++ b/libs/surfaceflinger/LayerBase.cpp @@ -393,14 +393,6 @@ void LayerBase::drawWithOpenGL(const Region& clip, const Texture& texture) const glEnable(GL_TEXTURE_2D); - // Dithering... - bool fast = !(mFlags & DisplayHardware::SLOW_CONFIG); - if (fast || s.flags & ISurfaceComposer::eLayerDither) { - glEnable(GL_DITHER); - } else { - glDisable(GL_DITHER); - } - if (UNLIKELY(s.alpha < 0xFF)) { // We have an alpha-modulation. We need to modulate all // texture components by alpha because we're always using @@ -516,6 +508,12 @@ void LayerBase::validateTexture(GLint textureName) const glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); } + + if (needsDithering()) { + glEnable(GL_DITHER); + } else { + glDisable(GL_DITHER); + } } void LayerBase::loadTexture(Texture* texture, GLint textureName, diff --git a/libs/surfaceflinger/LayerBase.h b/libs/surfaceflinger/LayerBase.h index 2a07bf1..233737d 100644 --- a/libs/surfaceflinger/LayerBase.h +++ b/libs/surfaceflinger/LayerBase.h @@ -188,6 +188,11 @@ public: virtual bool needsBlending() const { return false; } /** + * needsDithering - true if this surface needs dithering + */ + virtual bool needsDithering() const { return false; } + + /** * transformed -- true is this surface needs a to be transformed */ virtual bool transformed() const { return mTransformed; } diff --git a/libs/surfaceflinger/SurfaceFlinger.cpp b/libs/surfaceflinger/SurfaceFlinger.cpp index e87b563..a0b48d4 100644 --- a/libs/surfaceflinger/SurfaceFlinger.cpp +++ b/libs/surfaceflinger/SurfaceFlinger.cpp @@ -1497,11 +1497,12 @@ status_t SurfaceFlinger::dump(int fd, const Vector<String16>& args) "+ %s %p\n" " " "z=%9d, pos=(%4d,%4d), size=(%4d,%4d), " - "needsBlending=%1d, invalidate=%1d, " + "needsBlending=%1d, needsDithering=%1d, invalidate=%1d, " "alpha=0x%02x, flags=0x%08x, tr=[%.2f, %.2f][%.2f, %.2f]\n", layer->getTypeID(), layer.get(), s.z, layer->tx(), layer->ty(), s.w, s.h, - layer->needsBlending(), layer->contentDirty, + layer->needsBlending(), layer->needsDithering(), + layer->contentDirty, s.alpha, s.flags, s.transform[0], s.transform[1], s.transform[2], s.transform[3]); |