From cbb1a95819ec302ae15e4a1162a8b1349ae5c33e Mon Sep 17 00:00:00 2001 From: Jamie Gennis Date: Tue, 8 May 2012 17:05:52 -0700 Subject: [PATCH] SurfaceFlinger: tell SurfaceTex about filtering This change makes SurfaceFlinger set the filtering-enable on each layer's SurfaceTexture before querying the texture matrix to use for GLES composition. Change-Id: I40c3defd73ebf96e3cabb3bfdb1fc97f2036753a --- services/surfaceflinger/Layer.cpp | 21 +++++++++++---------- services/surfaceflinger/Layer.h | 1 - 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index e15e73310..c73d56eb5 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -317,16 +317,24 @@ void Layer::onDraw(const Region& clip) const } if (!isProtected()) { + // TODO: we could be more subtle with isFixedSize() + const bool useFiltering = getFiltering() || needsFiltering() || isFixedSize(); + + // Query the texture matrix given our current filtering mode. + float textureMatrix[16]; + mSurfaceTexture->setFilteringEnabled(useFiltering); + mSurfaceTexture->getTransformMatrix(textureMatrix); + + // Set things up for texturing. glBindTexture(GL_TEXTURE_EXTERNAL_OES, mTextureName); GLenum filter = GL_NEAREST; - if (getFiltering() || needsFiltering() || isFixedSize() || isCropped()) { - // TODO: we could be more subtle with isFixedSize() + if (useFiltering) { filter = GL_LINEAR; } glTexParameterx(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, filter); glTexParameterx(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, filter); glMatrixMode(GL_TEXTURE); - glLoadMatrixf(mTextureMatrix); + glLoadMatrixf(textureMatrix); glMatrixMode(GL_MODELVIEW); glDisable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_EXTERNAL_OES); @@ -494,13 +502,6 @@ void Layer::lockPageFlip(bool& recomputeVisibleRegions) mFlinger->invalidateHwcGeometry(); } - GLfloat textureMatrix[16]; - mSurfaceTexture->getTransformMatrix(textureMatrix); - if (memcmp(textureMatrix, mTextureMatrix, sizeof(textureMatrix))) { - memcpy(mTextureMatrix, textureMatrix, sizeof(textureMatrix)); - mFlinger->invalidateHwcGeometry(); - } - uint32_t bufWidth = mActiveBuffer->getWidth(); uint32_t bufHeight = mActiveBuffer->getHeight(); if (oldActiveBuffer != NULL) { diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h index 9a0484859..1188621b8 100644 --- a/services/surfaceflinger/Layer.h +++ b/services/surfaceflinger/Layer.h @@ -114,7 +114,6 @@ private: // main thread sp mActiveBuffer; - GLfloat mTextureMatrix[16]; Rect mCurrentCrop; uint32_t mCurrentTransform; uint32_t mCurrentScalingMode;