am 9080125f: Merge change 25393 into eclair
Merge commit '9080125f6753ca830b091b0103759612036be786' into eclair-plus-aosp
* commit '9080125f6753ca830b091b0103759612036be786':
fix again [2102410] Home Screen is not displayed in the background in Landscape Mode
This commit is contained in:
@@ -111,6 +111,50 @@ struct BlurColor565
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <int FACTOR = 0>
|
||||||
|
struct BlurColor888X
|
||||||
|
{
|
||||||
|
typedef uint32_t type;
|
||||||
|
int r, g, b;
|
||||||
|
inline BlurColor888X() { }
|
||||||
|
inline BlurColor888X(uint32_t v) {
|
||||||
|
v = BLUR_RGBA_TO_HOST(v);
|
||||||
|
r = v & 0xFF;
|
||||||
|
g = (v >> 8) & 0xFF;
|
||||||
|
b = (v >> 16) & 0xFF;
|
||||||
|
}
|
||||||
|
inline void clear() { r=g=b=0; }
|
||||||
|
inline uint32_t to(int shift, int last, int dither) const {
|
||||||
|
int R = r;
|
||||||
|
int G = g;
|
||||||
|
int B = b;
|
||||||
|
if (UNLIKELY(last)) {
|
||||||
|
if (FACTOR>0) {
|
||||||
|
int L = (R+G+G+B)>>2;
|
||||||
|
R += ((L - R) * FACTOR) >> 8;
|
||||||
|
G += ((L - G) * FACTOR) >> 8;
|
||||||
|
B += ((L - B) * FACTOR) >> 8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
R >>= shift;
|
||||||
|
G >>= shift;
|
||||||
|
B >>= shift;
|
||||||
|
return BLUR_HOST_TO_RGBA((0xFF<<24) | (B<<16) | (G<<8) | R);
|
||||||
|
}
|
||||||
|
inline BlurColor888X& operator += (const BlurColor888X& rhs) {
|
||||||
|
r += rhs.r;
|
||||||
|
g += rhs.g;
|
||||||
|
b += rhs.b;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
inline BlurColor888X& operator -= (const BlurColor888X& rhs) {
|
||||||
|
r -= rhs.r;
|
||||||
|
g -= rhs.g;
|
||||||
|
b -= rhs.b;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
struct BlurGray565
|
struct BlurGray565
|
||||||
{
|
{
|
||||||
typedef uint16_t type;
|
typedef uint16_t type;
|
||||||
@@ -316,7 +360,13 @@ status_t blurFilter(
|
|||||||
int kernelSizeUser,
|
int kernelSizeUser,
|
||||||
int repeat)
|
int repeat)
|
||||||
{
|
{
|
||||||
return blurFilter< BlurColor565<0x80> >(image, image, kernelSizeUser, repeat);
|
status_t err = BAD_VALUE;
|
||||||
|
if (image->format == GGL_PIXEL_FORMAT_RGB_565) {
|
||||||
|
err = blurFilter< BlurColor565<0x80> >(image, image, kernelSizeUser, repeat);
|
||||||
|
} else if (image->format == GGL_PIXEL_FORMAT_RGBX_8888) {
|
||||||
|
err = blurFilter< BlurColor888X<0x80> >(image, image, kernelSizeUser, repeat);
|
||||||
|
}
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace android
|
} // namespace android
|
||||||
|
|||||||
@@ -40,9 +40,9 @@ const char* const LayerBlur::typeID = "LayerBlur";
|
|||||||
|
|
||||||
LayerBlur::LayerBlur(SurfaceFlinger* flinger, DisplayID display,
|
LayerBlur::LayerBlur(SurfaceFlinger* flinger, DisplayID display,
|
||||||
const sp<Client>& client, int32_t i)
|
const sp<Client>& client, int32_t i)
|
||||||
: LayerBaseClient(flinger, display, client, i), mCacheDirty(true),
|
: 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)
|
mWidthScale(1.0f), mHeightScale(1.0f)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,6 +136,13 @@ void LayerBlur::onDraw(const Region& clip) const
|
|||||||
// create the texture name the first time
|
// create the texture name the first time
|
||||||
// can't do that in the ctor, because it runs in another thread.
|
// can't do that in the ctor, because it runs in another thread.
|
||||||
glGenTextures(1, &mTextureName);
|
glGenTextures(1, &mTextureName);
|
||||||
|
glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES, &mReadFormat);
|
||||||
|
glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE_OES, &mReadType);
|
||||||
|
if (mReadFormat != GL_RGB || mReadType != GL_UNSIGNED_SHORT_5_6_5) {
|
||||||
|
mReadFormat = GL_RGBA;
|
||||||
|
mReadType = GL_UNSIGNED_BYTE;
|
||||||
|
mBlurFormat = GGL_PIXEL_FORMAT_RGBX_8888;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Region::const_iterator it = clip.begin();
|
Region::const_iterator it = clip.begin();
|
||||||
@@ -143,33 +150,39 @@ void LayerBlur::onDraw(const Region& clip) const
|
|||||||
if (it != end) {
|
if (it != end) {
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
glBindTexture(GL_TEXTURE_2D, mTextureName);
|
glBindTexture(GL_TEXTURE_2D, mTextureName);
|
||||||
|
|
||||||
if (mRefreshCache) {
|
if (mRefreshCache) {
|
||||||
mRefreshCache = false;
|
mRefreshCache = false;
|
||||||
mAutoRefreshPending = false;
|
mAutoRefreshPending = false;
|
||||||
|
|
||||||
// allocate enough memory for 4-bytes (2 pixels) aligned data
|
int32_t pixelSize = 4;
|
||||||
const int32_t s = (w + 1) & ~1;
|
int32_t s = w;
|
||||||
uint16_t* const pixels = (uint16_t*)malloc(s*h*2);
|
if (mReadType == GL_UNSIGNED_SHORT_5_6_5) {
|
||||||
|
// allocate enough memory for 4-bytes (2 pixels) aligned data
|
||||||
|
s = (w + 1) & ~1;
|
||||||
|
pixelSize = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t* const pixels = (uint16_t*)malloc(s*h*pixelSize);
|
||||||
|
|
||||||
// This reads the frame-buffer, so a h/w GL would have to
|
// This reads the frame-buffer, so a h/w GL would have to
|
||||||
// finish() its rendering first. we don't want to do that
|
// finish() its rendering first. we don't want to do that
|
||||||
// too often. Read data is 4-bytes aligned.
|
// too often. Read data is 4-bytes aligned.
|
||||||
glReadPixels(X, Y, w, h, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, pixels);
|
glReadPixels(X, Y, w, h, mReadFormat, mReadType, pixels);
|
||||||
|
|
||||||
// blur that texture.
|
// blur that texture.
|
||||||
GGLSurface bl;
|
GGLSurface bl;
|
||||||
bl.version = sizeof(GGLSurface);
|
bl.version = sizeof(GGLSurface);
|
||||||
bl.width = w;
|
bl.width = w;
|
||||||
bl.height = h;
|
bl.height = h;
|
||||||
bl.stride = s;
|
bl.stride = s;
|
||||||
bl.format = GGL_PIXEL_FORMAT_RGB_565;
|
bl.format = mBlurFormat;
|
||||||
bl.data = (GGLubyte*)pixels;
|
bl.data = (GGLubyte*)pixels;
|
||||||
blurFilter(&bl, 8, 2);
|
blurFilter(&bl, 8, 2);
|
||||||
|
|
||||||
if (mFlags & (DisplayHardware::NPOT_EXTENSION)) {
|
if (mFlags & (DisplayHardware::NPOT_EXTENSION)) {
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0,
|
glTexImage2D(GL_TEXTURE_2D, 0, mReadFormat, w, h, 0,
|
||||||
GL_RGB, GL_UNSIGNED_SHORT_5_6_5, pixels);
|
mReadFormat, mReadType, pixels);
|
||||||
mWidthScale = 1.0f / w;
|
mWidthScale = 1.0f / w;
|
||||||
mHeightScale =-1.0f / h;
|
mHeightScale =-1.0f / h;
|
||||||
mYOffset = 0;
|
mYOffset = 0;
|
||||||
@@ -178,10 +191,10 @@ void LayerBlur::onDraw(const Region& clip) const
|
|||||||
GLuint th = 1 << (31 - clz(h));
|
GLuint th = 1 << (31 - clz(h));
|
||||||
if (tw < w) tw <<= 1;
|
if (tw < w) tw <<= 1;
|
||||||
if (th < h) th <<= 1;
|
if (th < h) th <<= 1;
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, tw, th, 0,
|
glTexImage2D(GL_TEXTURE_2D, 0, mReadFormat, tw, th, 0,
|
||||||
GL_RGB, GL_UNSIGNED_SHORT_5_6_5, NULL);
|
mReadFormat, mReadType, NULL);
|
||||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h,
|
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h,
|
||||||
GL_RGB, GL_UNSIGNED_SHORT_5_6_5, pixels);
|
mReadFormat, mReadType, pixels);
|
||||||
mWidthScale = 1.0f / tw;
|
mWidthScale = 1.0f / tw;
|
||||||
mHeightScale =-1.0f / th;
|
mHeightScale =-1.0f / th;
|
||||||
mYOffset = th-h;
|
mYOffset = th-h;
|
||||||
@@ -189,7 +202,7 @@ void LayerBlur::onDraw(const Region& clip) const
|
|||||||
|
|
||||||
free((void*)pixels);
|
free((void*)pixels);
|
||||||
}
|
}
|
||||||
|
|
||||||
const State& s = drawingState();
|
const State& s = drawingState();
|
||||||
if (UNLIKELY(s.alpha < 0xFF)) {
|
if (UNLIKELY(s.alpha < 0xFF)) {
|
||||||
const GGLfixed alpha = (s.alpha << 16)/255;
|
const GGLfixed alpha = (s.alpha << 16)/255;
|
||||||
|
|||||||
@@ -59,6 +59,9 @@ private:
|
|||||||
mutable GLfloat mWidthScale;
|
mutable GLfloat mWidthScale;
|
||||||
mutable GLfloat mHeightScale;
|
mutable GLfloat mHeightScale;
|
||||||
mutable GLfloat mYOffset;
|
mutable GLfloat mYOffset;
|
||||||
|
mutable GLint mReadFormat;
|
||||||
|
mutable GLint mReadType;
|
||||||
|
mutable uint32_t mBlurFormat;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user