diff options
author | Mathias Agopian <mathias@google.com> | 2009-09-09 17:47:15 -0700 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2009-09-09 17:47:15 -0700 |
commit | e7c11d770ab44656d32330ba585489bd284b4a47 (patch) | |
tree | f3db961a4fadec5bb7cd9157d20a65192f2e3f41 /libs/surfaceflinger | |
parent | 16b72bbbc985cba7c59f52bf6969b4015f185830 (diff) | |
download | frameworks_base-e7c11d770ab44656d32330ba585489bd284b4a47.zip frameworks_base-e7c11d770ab44656d32330ba585489bd284b4a47.tar.gz frameworks_base-e7c11d770ab44656d32330ba585489bd284b4a47.tar.bz2 |
fix [2102410] Home Screen is not displayed in the background in Landscape Mode
the blurring code now handles NPOT textures.
Diffstat (limited to 'libs/surfaceflinger')
-rw-r--r-- | libs/surfaceflinger/LayerBlur.cpp | 43 | ||||
-rw-r--r-- | libs/surfaceflinger/LayerBlur.h | 3 |
2 files changed, 35 insertions, 11 deletions
diff --git a/libs/surfaceflinger/LayerBlur.cpp b/libs/surfaceflinger/LayerBlur.cpp index 00abd5a..e14f35b 100644 --- a/libs/surfaceflinger/LayerBlur.cpp +++ b/libs/surfaceflinger/LayerBlur.cpp @@ -24,6 +24,7 @@ #include <GLES/gl.h> #include <GLES/glext.h> +#include "clz.h" #include "BlurFilter.h" #include "LayerBlur.h" #include "SurfaceFlinger.h" @@ -40,7 +41,8 @@ const char* const LayerBlur::typeID = "LayerBlur"; LayerBlur::LayerBlur(SurfaceFlinger* flinger, DisplayID display, const sp<Client>& client, int32_t i) : LayerBaseClient(flinger, display, client, i), mCacheDirty(true), - mRefreshCache(true), mCacheAge(0), mTextureName(-1U) + mRefreshCache(true), mCacheAge(0), mTextureName(-1U), + mWidthScale(1.0f), mHeightScale(1.0f) { } @@ -164,11 +166,26 @@ void LayerBlur::onDraw(const Region& clip) const bl.format = GGL_PIXEL_FORMAT_RGB_565; bl.data = (GGLubyte*)pixels; blurFilter(&bl, 8, 2); - - // NOTE: this works only because we have POT. we'd have to round the - // texture size up, otherwise. - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, - GL_RGB, GL_UNSIGNED_SHORT_5_6_5, pixels); + + if (mFlags & (DisplayHardware::NPOT_EXTENSION)) { + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, + GL_RGB, GL_UNSIGNED_SHORT_5_6_5, pixels); + mWidthScale = 1.0f / w; + mHeightScale =-1.0f / h; + mYOffset = 0; + } else { + GLuint tw = 1 << (31 - clz(w)); + GLuint th = 1 << (31 - clz(h)); + if (tw < w) tw <<= 1; + if (th < h) th <<= 1; + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, tw, th, 0, + GL_RGB, GL_UNSIGNED_SHORT_5_6_5, NULL); + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, + GL_RGB, GL_UNSIGNED_SHORT_5_6_5, pixels); + mWidthScale = 1.0f / tw; + mHeightScale =-1.0f / th; + mYOffset = th-h; + } free((void*)pixels); } @@ -184,7 +201,12 @@ void LayerBlur::onDraw(const Region& clip) const glDisable(GL_BLEND); } - glDisable(GL_DITHER); + if (mFlags & DisplayHardware::SLOW_CONFIG) { + glDisable(GL_DITHER); + } else { + glEnable(GL_DITHER); + } + glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); @@ -194,8 +216,8 @@ void LayerBlur::onDraw(const Region& clip) const // This is a very rare scenario. glMatrixMode(GL_TEXTURE); glLoadIdentity(); - glScalef(1.0f/w, -1.0f/h, 1); - glTranslatef(-x, -y, 0); + glScalef(mWidthScale, mHeightScale, 1); + glTranslatef(-x, mYOffset - y, 0); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glVertexPointer(2, GL_FIXED, 0, mVertices); glTexCoordPointer(2, GL_FIXED, 0, mVertices); @@ -205,6 +227,7 @@ void LayerBlur::onDraw(const Region& clip) const glScissor(r.left, sy, r.width(), r.height()); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); } + glDisableClientState(GL_TEXTURE_COORD_ARRAY); } else { // NOTE: this is marginally faster with the software gl, because // glReadPixels() reads the fb bottom-to-top, however we'll @@ -221,8 +244,6 @@ void LayerBlur::onDraw(const Region& clip) const } } } - - glDisableClientState(GL_TEXTURE_COORD_ARRAY); } // --------------------------------------------------------------------------- diff --git a/libs/surfaceflinger/LayerBlur.h b/libs/surfaceflinger/LayerBlur.h index 0c3e6eb..bf36ae4 100644 --- a/libs/surfaceflinger/LayerBlur.h +++ b/libs/surfaceflinger/LayerBlur.h @@ -56,6 +56,9 @@ private: mutable bool mAutoRefreshPending; nsecs_t mCacheAge; mutable GLuint mTextureName; + mutable GLfloat mWidthScale; + mutable GLfloat mHeightScale; + mutable GLfloat mYOffset; }; // --------------------------------------------------------------------------- |