Merge changes 26766,26767 into eclair
* changes: turn dithering off if it's not needed fix [2142193] disable GL_LINEAR when not needed
This commit is contained in:
@@ -51,7 +51,8 @@ Layer::Layer(SurfaceFlinger* flinger, DisplayID display,
|
|||||||
const sp<Client>& c, int32_t i)
|
const sp<Client>& c, int32_t i)
|
||||||
: LayerBaseClient(flinger, display, c, i),
|
: LayerBaseClient(flinger, display, c, i),
|
||||||
mSecure(false),
|
mSecure(false),
|
||||||
mNeedsBlending(true)
|
mNeedsBlending(true),
|
||||||
|
mNeedsDithering(false)
|
||||||
{
|
{
|
||||||
// no OpenGL operation is possible here, since we might not be
|
// no OpenGL operation is possible here, since we might not be
|
||||||
// in the OpenGL thread.
|
// in the OpenGL thread.
|
||||||
@@ -106,10 +107,16 @@ status_t Layer::ditch()
|
|||||||
status_t Layer::setBuffers( uint32_t w, uint32_t h,
|
status_t Layer::setBuffers( uint32_t w, uint32_t h,
|
||||||
PixelFormat format, uint32_t flags)
|
PixelFormat format, uint32_t flags)
|
||||||
{
|
{
|
||||||
|
// this surfaces pixel format
|
||||||
PixelFormatInfo info;
|
PixelFormatInfo info;
|
||||||
status_t err = getPixelFormatInfo(format, &info);
|
status_t err = getPixelFormatInfo(format, &info);
|
||||||
if (err) return err;
|
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;
|
uint32_t bufferFlags = 0;
|
||||||
if (flags & ISurfaceComposer::eSecure)
|
if (flags & ISurfaceComposer::eSecure)
|
||||||
bufferFlags |= Buffer::SECURE;
|
bufferFlags |= Buffer::SECURE;
|
||||||
@@ -119,6 +126,12 @@ status_t Layer::setBuffers( uint32_t w, uint32_t h,
|
|||||||
mHeight = h;
|
mHeight = h;
|
||||||
mSecure = (bufferFlags & Buffer::SECURE) ? true : false;
|
mSecure = (bufferFlags & Buffer::SECURE) ? true : false;
|
||||||
mNeedsBlending = (info.h_alpha - info.l_alpha) > 0;
|
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;
|
mBufferFlags = bufferFlags;
|
||||||
for (size_t i=0 ; i<NUM_BUFFERS ; i++) {
|
for (size_t i=0 ; i<NUM_BUFFERS ; i++) {
|
||||||
mBuffers[i] = new Buffer();
|
mBuffers[i] = new Buffer();
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ public:
|
|||||||
virtual void unlockPageFlip(const Transform& planeTransform, Region& outDirtyRegion);
|
virtual void unlockPageFlip(const Transform& planeTransform, Region& outDirtyRegion);
|
||||||
virtual void finishPageFlip();
|
virtual void finishPageFlip();
|
||||||
virtual bool needsBlending() const { return mNeedsBlending; }
|
virtual bool needsBlending() const { return mNeedsBlending; }
|
||||||
|
virtual bool needsDithering() const { return mNeedsDithering; }
|
||||||
virtual bool isSecure() const { return mSecure; }
|
virtual bool isSecure() const { return mSecure; }
|
||||||
virtual sp<Surface> createSurface() const;
|
virtual sp<Surface> createSurface() const;
|
||||||
virtual status_t ditch();
|
virtual status_t ditch();
|
||||||
@@ -109,6 +110,7 @@ private:
|
|||||||
bool mSecure;
|
bool mSecure;
|
||||||
int32_t mFrontBufferIndex;
|
int32_t mFrontBufferIndex;
|
||||||
bool mNeedsBlending;
|
bool mNeedsBlending;
|
||||||
|
bool mNeedsDithering;
|
||||||
Region mPostedDirtyRegion;
|
Region mPostedDirtyRegion;
|
||||||
sp<FreezeLock> mFreezeLock;
|
sp<FreezeLock> mFreezeLock;
|
||||||
PixelFormat mFormat;
|
PixelFormat mFormat;
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ LayerBase::LayerBase(SurfaceFlinger* flinger, DisplayID display)
|
|||||||
: dpy(display), contentDirty(false),
|
: dpy(display), contentDirty(false),
|
||||||
mFlinger(flinger),
|
mFlinger(flinger),
|
||||||
mTransformed(false),
|
mTransformed(false),
|
||||||
|
mUseLinearFiltering(false),
|
||||||
mOrientation(0),
|
mOrientation(0),
|
||||||
mTransactionFlags(0),
|
mTransactionFlags(0),
|
||||||
mPremultipliedAlpha(true),
|
mPremultipliedAlpha(true),
|
||||||
@@ -208,7 +209,19 @@ uint32_t LayerBase::doTransaction(uint32_t flags)
|
|||||||
flags |= eVisibleRegion;
|
flags |= eVisibleRegion;
|
||||||
this->contentDirty = true;
|
this->contentDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (temp.sequence != front.sequence) {
|
||||||
|
const bool linearFiltering = mUseLinearFiltering;
|
||||||
|
mUseLinearFiltering = 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Commit the transaction
|
// Commit the transaction
|
||||||
commitTransaction(flags & eRestartTransaction);
|
commitTransaction(flags & eRestartTransaction);
|
||||||
return flags;
|
return flags;
|
||||||
@@ -332,13 +345,8 @@ GLuint LayerBase::createTexture() const
|
|||||||
glBindTexture(GL_TEXTURE_2D, textureName);
|
glBindTexture(GL_TEXTURE_2D, textureName);
|
||||||
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
if (mFlags & DisplayHardware::SLOW_CONFIG) {
|
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
|
||||||
} else {
|
|
||||||
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
|
||||||
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
|
||||||
}
|
|
||||||
return textureName;
|
return textureName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -385,14 +393,6 @@ void LayerBase::drawWithOpenGL(const Region& clip, const Texture& texture) const
|
|||||||
|
|
||||||
glEnable(GL_TEXTURE_2D);
|
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)) {
|
if (UNLIKELY(s.alpha < 0xFF)) {
|
||||||
// We have an alpha-modulation. We need to modulate all
|
// We have an alpha-modulation. We need to modulate all
|
||||||
// texture components by alpha because we're always using
|
// texture components by alpha because we're always using
|
||||||
@@ -434,12 +434,6 @@ void LayerBase::drawWithOpenGL(const Region& clip, const Texture& texture) const
|
|||||||
Region::const_iterator it = clip.begin();
|
Region::const_iterator it = clip.begin();
|
||||||
Region::const_iterator const end = clip.end();
|
Region::const_iterator const end = clip.end();
|
||||||
if (it != end) {
|
if (it != end) {
|
||||||
// always use high-quality filtering with fast configurations
|
|
||||||
bool fast = !(mFlags & DisplayHardware::SLOW_CONFIG);
|
|
||||||
if (!fast && s.flags & ISurfaceComposer::eLayerFilter) {
|
|
||||||
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
|
||||||
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
|
||||||
}
|
|
||||||
const GLfixed texCoords[4][2] = {
|
const GLfixed texCoords[4][2] = {
|
||||||
{ 0, 0 },
|
{ 0, 0 },
|
||||||
{ 0, 0x10000 },
|
{ 0, 0x10000 },
|
||||||
@@ -481,11 +475,6 @@ void LayerBase::drawWithOpenGL(const Region& clip, const Texture& texture) const
|
|||||||
glScissor(r.left, sy, r.width(), r.height());
|
glScissor(r.left, sy, r.width(), r.height());
|
||||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fast && s.flags & ISurfaceComposer::eLayerFilter) {
|
|
||||||
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
|
||||||
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
|
||||||
}
|
|
||||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -512,6 +501,19 @@ void LayerBase::validateTexture(GLint textureName) const
|
|||||||
glBindTexture(GL_TEXTURE_2D, textureName);
|
glBindTexture(GL_TEXTURE_2D, textureName);
|
||||||
// TODO: reload the texture if needed
|
// TODO: reload the texture if needed
|
||||||
// this is currently done in loadTexture() below
|
// this is currently done in loadTexture() below
|
||||||
|
if (mUseLinearFiltering) {
|
||||||
|
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
|
} else {
|
||||||
|
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,
|
void LayerBase::loadTexture(Texture* texture, GLint textureName,
|
||||||
|
|||||||
@@ -187,6 +187,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual bool needsBlending() const { return false; }
|
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
|
* transformed -- true is this surface needs a to be transformed
|
||||||
*/
|
*/
|
||||||
@@ -254,6 +259,7 @@ protected:
|
|||||||
|
|
||||||
// cached during validateVisibility()
|
// cached during validateVisibility()
|
||||||
bool mTransformed;
|
bool mTransformed;
|
||||||
|
bool mUseLinearFiltering;
|
||||||
int32_t mOrientation;
|
int32_t mOrientation;
|
||||||
GLfixed mVertices[4][2];
|
GLfixed mVertices[4][2];
|
||||||
Rect mTransformedBounds;
|
Rect mTransformedBounds;
|
||||||
|
|||||||
@@ -1497,11 +1497,12 @@ status_t SurfaceFlinger::dump(int fd, const Vector<String16>& args)
|
|||||||
"+ %s %p\n"
|
"+ %s %p\n"
|
||||||
" "
|
" "
|
||||||
"z=%9d, pos=(%4d,%4d), size=(%4d,%4d), "
|
"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",
|
"alpha=0x%02x, flags=0x%08x, tr=[%.2f, %.2f][%.2f, %.2f]\n",
|
||||||
layer->getTypeID(), layer.get(),
|
layer->getTypeID(), layer.get(),
|
||||||
s.z, layer->tx(), layer->ty(), s.w, s.h,
|
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.alpha, s.flags,
|
||||||
s.transform[0], s.transform[1],
|
s.transform[0], s.transform[1],
|
||||||
s.transform[2], s.transform[3]);
|
s.transform[2], s.transform[3]);
|
||||||
|
|||||||
@@ -50,6 +50,14 @@ public:
|
|||||||
ROT_INVALID = 0x80000000
|
ROT_INVALID = 0x80000000
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum type_mask {
|
||||||
|
IDENTITY = 0,
|
||||||
|
TRANSLATE = 0x1,
|
||||||
|
SCALE = 0x2,
|
||||||
|
AFFINE = 0x4,
|
||||||
|
PERSPECTIVE = 0x8
|
||||||
|
};
|
||||||
|
|
||||||
bool transformed() const;
|
bool transformed() const;
|
||||||
int32_t getOrientation() const;
|
int32_t getOrientation() const;
|
||||||
bool preserveRects() const;
|
bool preserveRects() const;
|
||||||
|
|||||||
Reference in New Issue
Block a user