Make sure to use filtering while in fixed-size mode

This commit is contained in:
Mathias Agopian 2010-05-26 22:08:52 -07:00
parent 38ece279ea
commit a7f669256f
5 changed files with 26 additions and 8 deletions

View File

@ -209,6 +209,19 @@ void Layer::onDraw(const Region& clip) const
drawWithOpenGL(clip, tex);
}
bool Layer::needsFiltering() const
{
if (!(mFlags & DisplayHardware::SLOW_CONFIG)) {
// NOTE: there is a race here, because mFixedSize is updated in a
// binder transaction. however, it doesn't really matter since it is
// evaluated each time we draw. To be perfectly correct, this flag
// would have to be associated with a buffer.
if (mFixedSize)
return true;
}
return LayerBase::needsFiltering();
}
status_t Layer::setBufferCount(int bufferCount)
{

View File

@ -67,6 +67,7 @@ public:
virtual void finishPageFlip();
virtual bool needsBlending() const { return mNeedsBlending; }
virtual bool needsDithering() const { return mNeedsDithering; }
virtual bool needsFiltering() const;
virtual bool isSecure() const { return mSecure; }
virtual sp<Surface> createSurface() const;
virtual status_t ditch();

View File

@ -43,7 +43,7 @@ LayerBase::LayerBase(SurfaceFlinger* flinger, DisplayID display)
: dpy(display), contentDirty(false),
mFlinger(flinger),
mTransformed(false),
mUseLinearFiltering(false),
mNeedsFiltering(false),
mOrientation(0),
mLeft(0), mTop(0),
mTransactionFlags(0),
@ -214,13 +214,12 @@ uint32_t LayerBase::doTransaction(uint32_t flags)
flags |= eVisibleRegion;
this->contentDirty = true;
const bool linearFiltering = mUseLinearFiltering;
mUseLinearFiltering = false;
mNeedsFiltering = false;
if (!(mFlags & DisplayHardware::SLOW_CONFIG)) {
// we may use linear filtering, if the matrix scales us
const uint8_t type = temp.transform.getType();
if (!temp.transform.preserveRects() || (type >= Transform::SCALE)) {
mUseLinearFiltering = true;
mNeedsFiltering = true;
}
}
}
@ -466,7 +465,7 @@ void LayerBase::validateTexture(GLint textureName) const
glBindTexture(GL_TEXTURE_2D, textureName);
// TODO: reload the texture if needed
// this is currently done in loadTexture() below
if (mUseLinearFiltering) {
if (needsFiltering()) {
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
} else {

View File

@ -176,6 +176,11 @@ public:
*/
virtual bool needsDithering() const { return false; }
/**
* needsLinearFiltering - true if this surface needs filtering
*/
virtual bool needsFiltering() const { return mNeedsFiltering; }
/**
* transformed -- true is this surface needs a to be transformed
*/
@ -232,7 +237,7 @@ protected:
// cached during validateVisibility()
bool mTransformed;
bool mUseLinearFiltering;
bool mNeedsFiltering;
int32_t mOrientation;
GLfloat mVertices[4][2];
Rect mTransformedBounds;

View File

@ -118,7 +118,7 @@ uint32_t LayerBuffer::doTransaction(uint32_t flags)
source->onTransaction(flags);
uint32_t res = LayerBase::doTransaction(flags);
// we always want filtering for these surfaces
mUseLinearFiltering = !(mFlags & DisplayHardware::SLOW_CONFIG);
mNeedsFiltering = !(mFlags & DisplayHardware::SLOW_CONFIG);
return res;
}
@ -542,7 +542,7 @@ status_t LayerBuffer::BufferSource::initTempBuffer() const
// figure out if we need linear filtering
if (buffers.w * h == buffers.h * w) {
// same pixel area, don't use filtering
mLayer.mUseLinearFiltering = false;
mLayer.mNeedsFiltering = false;
}
// Allocate a temporary buffer and create the corresponding EGLImageKHR