Skip to content

Commit df6410d

Browse files
pixelflingerAndroid (Google) Code Review
authored andcommitted
Merge "Fix [3513017] in lockscreen but showing empty launcher (live wallpaper) only" into gingerbread
2 parents 6b6869d + 951d3fe commit df6410d

File tree

7 files changed

+76
-31
lines changed

7 files changed

+76
-31
lines changed

include/utils/RefBase.h

Lines changed: 48 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,10 @@ template<typename T> class wp;
3131

3232
// ---------------------------------------------------------------------------
3333

34-
#define COMPARE(_op_) \
34+
#define COMPARE_WEAK(_op_) \
3535
inline bool operator _op_ (const sp<T>& o) const { \
3636
return m_ptr _op_ o.m_ptr; \
3737
} \
38-
inline bool operator _op_ (const wp<T>& o) const { \
39-
return m_ptr _op_ o.m_ptr; \
40-
} \
4138
inline bool operator _op_ (const T* o) const { \
4239
return m_ptr _op_ o; \
4340
} \
@@ -46,12 +43,18 @@ inline bool operator _op_ (const sp<U>& o) const { \
4643
return m_ptr _op_ o.m_ptr; \
4744
} \
4845
template<typename U> \
49-
inline bool operator _op_ (const wp<U>& o) const { \
46+
inline bool operator _op_ (const U* o) const { \
47+
return m_ptr _op_ o; \
48+
}
49+
50+
#define COMPARE(_op_) \
51+
COMPARE_WEAK(_op_) \
52+
inline bool operator _op_ (const wp<T>& o) const { \
5053
return m_ptr _op_ o.m_ptr; \
5154
} \
5255
template<typename U> \
53-
inline bool operator _op_ (const U* o) const { \
54-
return m_ptr _op_ o; \
56+
inline bool operator _op_ (const wp<U>& o) const { \
57+
return m_ptr _op_ o.m_ptr; \
5558
}
5659

5760
// ---------------------------------------------------------------------------
@@ -274,13 +277,43 @@ class wp
274277
inline T* unsafe_get() const { return m_ptr; }
275278

276279
// Operators
277-
278-
COMPARE(==)
279-
COMPARE(!=)
280-
COMPARE(>)
281-
COMPARE(<)
282-
COMPARE(<=)
283-
COMPARE(>=)
280+
281+
COMPARE_WEAK(==)
282+
COMPARE_WEAK(!=)
283+
COMPARE_WEAK(>)
284+
COMPARE_WEAK(<)
285+
COMPARE_WEAK(<=)
286+
COMPARE_WEAK(>=)
287+
288+
inline bool operator == (const wp<T>& o) const {
289+
return (m_ptr == o.m_ptr) && (m_refs == o.m_refs);
290+
}
291+
template<typename U>
292+
inline bool operator == (const wp<U>& o) const {
293+
return m_ptr == o.m_ptr;
294+
}
295+
296+
inline bool operator > (const wp<T>& o) const {
297+
return (m_ptr == o.m_ptr) ? (m_refs > o.m_refs) : (m_ptr > o.m_ptr);
298+
}
299+
template<typename U>
300+
inline bool operator > (const wp<U>& o) const {
301+
return (m_ptr == o.m_ptr) ? (m_refs > o.m_refs) : (m_ptr > o.m_ptr);
302+
}
303+
304+
inline bool operator < (const wp<T>& o) const {
305+
return (m_ptr == o.m_ptr) ? (m_refs < o.m_refs) : (m_ptr < o.m_ptr);
306+
}
307+
template<typename U>
308+
inline bool operator < (const wp<U>& o) const {
309+
return (m_ptr == o.m_ptr) ? (m_refs < o.m_refs) : (m_ptr < o.m_ptr);
310+
}
311+
inline bool operator != (const wp<T>& o) const { return m_refs != o.m_refs; }
312+
template<typename U> inline bool operator != (const wp<U>& o) const { return !operator == (o); }
313+
inline bool operator <= (const wp<T>& o) const { return !operator > (o); }
314+
template<typename U> inline bool operator <= (const wp<U>& o) const { return !operator > (o); }
315+
inline bool operator >= (const wp<T>& o) const { return !operator < (o); }
316+
template<typename U> inline bool operator >= (const wp<U>& o) const { return !operator < (o); }
284317

285318
private:
286319
template<typename Y> friend class sp;
@@ -294,6 +327,7 @@ template <typename T>
294327
TextOutput& operator<<(TextOutput& to, const wp<T>& val);
295328

296329
#undef COMPARE
330+
#undef COMPARE_WEAK
297331

298332
// ---------------------------------------------------------------------------
299333
// No user serviceable parts below here.

services/surfaceflinger/Layer.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ void Layer::onRemoved()
120120

121121
sp<LayerBaseClient::Surface> Layer::createSurface() const
122122
{
123-
return mSurface;
123+
sp<Surface> sur(new SurfaceLayer(mFlinger, const_cast<Layer *>(this)));
124+
return sur;
124125
}
125126

126127
status_t Layer::ditch()
@@ -130,10 +131,6 @@ status_t Layer::ditch()
130131
// the layer is not on screen anymore. free as much resources as possible
131132
mFreezeLock.clear();
132133

133-
EGLDisplay dpy(mFlinger->graphicPlane(0).getEGLDisplay());
134-
mBufferManager.destroy(dpy);
135-
mSurface.clear();
136-
137134
Mutex::Autolock _l(mLock);
138135
mWidth = mHeight = 0;
139136
return NO_ERROR;
@@ -178,7 +175,6 @@ status_t Layer::setBuffers( uint32_t w, uint32_t h,
178175
int layerRedsize = info.getSize(PixelFormatInfo::INDEX_RED);
179176
mNeedsDithering = layerRedsize > displayRedSize;
180177

181-
mSurface = new SurfaceLayer(mFlinger, this);
182178
return NO_ERROR;
183179
}
184180

services/surfaceflinger/Layer.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,6 @@ class Layer : public LayerBaseClient
211211
ClientRef mUserClientRef;
212212

213213
// constants
214-
sp<Surface> mSurface;
215214
PixelFormat mFormat;
216215
const GLExtensions& mGLExtensions;
217216
bool mNeedsBlending;

services/surfaceflinger/LayerBase.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,9 @@ int32_t LayerBaseClient::sIdentity = 1;
527527

528528
LayerBaseClient::LayerBaseClient(SurfaceFlinger* flinger, DisplayID display,
529529
const sp<Client>& client)
530-
: LayerBase(flinger, display), mClientRef(client),
530+
: LayerBase(flinger, display),
531+
mHasSurface(false),
532+
mClientRef(client),
531533
mIdentity(uint32_t(android_atomic_inc(&sIdentity)))
532534
{
533535
}
@@ -544,14 +546,20 @@ sp<LayerBaseClient::Surface> LayerBaseClient::getSurface()
544546
{
545547
sp<Surface> s;
546548
Mutex::Autolock _l(mLock);
547-
s = mClientSurface.promote();
548-
if (s == 0) {
549-
s = createSurface();
550-
mClientSurface = s;
551-
}
549+
550+
LOG_ALWAYS_FATAL_IF(mHasSurface,
551+
"LayerBaseClient::getSurface() has already been called");
552+
553+
mHasSurface = true;
554+
s = createSurface();
555+
mClientSurfaceBinder = s->asBinder();
552556
return s;
553557
}
554558

559+
wp<IBinder> LayerBaseClient::getSurfaceBinder() const {
560+
return mClientSurfaceBinder;
561+
}
562+
555563
sp<LayerBaseClient::Surface> LayerBaseClient::createSurface() const
556564
{
557565
return new Surface(mFlinger, mIdentity,

services/surfaceflinger/LayerBase.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ class LayerBaseClient : public LayerBase
285285
virtual ~LayerBaseClient();
286286

287287
sp<Surface> getSurface();
288+
wp<IBinder> getSurfaceBinder() const;
288289
virtual sp<Surface> createSurface() const;
289290
virtual sp<LayerBaseClient> getLayerBaseClient() const {
290291
return const_cast<LayerBaseClient*>(this); }
@@ -330,7 +331,8 @@ class LayerBaseClient : public LayerBase
330331

331332
private:
332333
mutable Mutex mLock;
333-
mutable wp<Surface> mClientSurface;
334+
mutable bool mHasSurface;
335+
wp<IBinder> mClientSurfaceBinder;
334336
const wp<Client> mClientRef;
335337
// only read
336338
const uint32_t mIdentity;

services/surfaceflinger/LayerDim.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,14 @@ void LayerDim::onDraw(const Region& clip) const
6767
const GLfloat alpha = s.alpha/255.0f;
6868
const uint32_t fbHeight = hw.getHeight();
6969
glDisable(GL_DITHER);
70-
glEnable(GL_BLEND);
71-
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
70+
71+
if (s.alpha == 0xFF) {
72+
glDisable(GL_BLEND);
73+
} else {
74+
glEnable(GL_BLEND);
75+
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
76+
}
77+
7278
glColor4f(0, 0, 0, alpha);
7379

7480
#if defined(GL_OES_EGL_image_external)

services/surfaceflinger/SurfaceFlinger.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,7 @@ status_t SurfaceFlinger::removeLayer_l(const sp<LayerBase>& layerBase)
10541054
{
10551055
sp<LayerBaseClient> lbc(layerBase->getLayerBaseClient());
10561056
if (lbc != 0) {
1057-
mLayerMap.removeItem( lbc->getSurface()->asBinder() );
1057+
mLayerMap.removeItem( lbc->getSurfaceBinder() );
10581058
}
10591059
ssize_t index = mCurrentState.layersSortedByZ.remove(layerBase);
10601060
if (index >= 0) {

0 commit comments

Comments
 (0)