Skip to content

Commit 3302922

Browse files
pixelflingerAndroid (Google) Code Review
authored andcommitted
Merge "revert the surface purgatory list and dependent changes." into gingerbread
2 parents b710a50 + cf8b945 commit 3302922

File tree

8 files changed

+19
-88
lines changed

8 files changed

+19
-88
lines changed

libs/ui/GraphicBufferAllocator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void GraphicBufferAllocator::dump(String8& result) const
6363
const size_t c = list.size();
6464
for (size_t i=0 ; i<c ; i++) {
6565
const alloc_rec_t& rec(list.valueAt(i));
66-
snprintf(buffer, SIZE, "%10p: %7.2f KiB | %4u (%4u) x %4u | %8X | 0x%08x\n",
66+
snprintf(buffer, SIZE, "%10p: %7.2f KiB | %4u (%4u) x %4u | %2d | 0x%08x\n",
6767
list.keyAt(i), rec.size/1024.0f,
6868
rec.w, rec.s, rec.h, rec.format, rec.usage);
6969
result.append(buffer);

services/surfaceflinger/Layer.cpp

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

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

127126
status_t Layer::ditch()
@@ -131,6 +130,10 @@ status_t Layer::ditch()
131130
// the layer is not on screen anymore. free as much resources as possible
132131
mFreezeLock.clear();
133132

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

181+
mSurface = new SurfaceLayer(mFlinger, this);
178182
return NO_ERROR;
179183
}
180184

services/surfaceflinger/Layer.h

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

213213
// constants
214+
sp<Surface> mSurface;
214215
PixelFormat mFormat;
215216
const GLExtensions& mGLExtensions;
216217
bool mNeedsBlending;

services/surfaceflinger/LayerBase.cpp

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -515,21 +515,13 @@ void LayerBase::dump(String8& result, char* buffer, size_t SIZE) const
515515
result.append(buffer);
516516
}
517517

518-
void LayerBase::shortDump(String8& result, char* scratch, size_t size) const
519-
{
520-
LayerBase::dump(result, scratch, size);
521-
}
522-
523-
524518
// ---------------------------------------------------------------------------
525519

526520
int32_t LayerBaseClient::sIdentity = 1;
527521

528522
LayerBaseClient::LayerBaseClient(SurfaceFlinger* flinger, DisplayID display,
529523
const sp<Client>& client)
530-
: LayerBase(flinger, display),
531-
mHasSurface(false),
532-
mClientRef(client),
524+
: LayerBase(flinger, display), mClientRef(client),
533525
mIdentity(uint32_t(android_atomic_inc(&sIdentity)))
534526
{
535527
}
@@ -546,20 +538,14 @@ sp<LayerBaseClient::Surface> LayerBaseClient::getSurface()
546538
{
547539
sp<Surface> s;
548540
Mutex::Autolock _l(mLock);
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();
541+
s = mClientSurface.promote();
542+
if (s == 0) {
543+
s = createSurface();
544+
mClientSurface = s;
545+
}
556546
return s;
557547
}
558548

559-
wp<IBinder> LayerBaseClient::getSurfaceBinder() const {
560-
return mClientSurfaceBinder;
561-
}
562-
563549
sp<LayerBaseClient::Surface> LayerBaseClient::createSurface() const
564550
{
565551
return new Surface(mFlinger, mIdentity,
@@ -580,12 +566,6 @@ void LayerBaseClient::dump(String8& result, char* buffer, size_t SIZE) const
580566
result.append(buffer);
581567
}
582568

583-
584-
void LayerBaseClient::shortDump(String8& result, char* scratch, size_t size) const
585-
{
586-
LayerBaseClient::dump(result, scratch, size);
587-
}
588-
589569
// ---------------------------------------------------------------------------
590570

591571
LayerBaseClient::Surface::Surface(

services/surfaceflinger/LayerBase.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,6 @@ class LayerBase : public RefBase
206206

207207
/** always call base class first */
208208
virtual void dump(String8& result, char* scratch, size_t size) const;
209-
virtual void shortDump(String8& result, char* scratch, size_t size) const;
210209

211210

212211
enum { // flags for doTransaction()
@@ -285,7 +284,6 @@ class LayerBaseClient : public LayerBase
285284
virtual ~LayerBaseClient();
286285

287286
sp<Surface> getSurface();
288-
wp<IBinder> getSurfaceBinder() const;
289287
virtual sp<Surface> createSurface() const;
290288
virtual sp<LayerBaseClient> getLayerBaseClient() const {
291289
return const_cast<LayerBaseClient*>(this); }
@@ -327,12 +325,10 @@ class LayerBaseClient : public LayerBase
327325

328326
protected:
329327
virtual void dump(String8& result, char* scratch, size_t size) const;
330-
virtual void shortDump(String8& result, char* scratch, size_t size) const;
331328

332329
private:
333330
mutable Mutex mLock;
334-
mutable bool mHasSurface;
335-
wp<IBinder> mClientSurfaceBinder;
331+
mutable wp<Surface> mClientSurface;
336332
const wp<Client> mClientRef;
337333
// only read
338334
const uint32_t mIdentity;

services/surfaceflinger/LayerDim.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,8 @@ 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-
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-
70+
glEnable(GL_BLEND);
71+
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
7872
glColor4f(0, 0, 0, alpha);
7973

8074
#if defined(GL_OES_EGL_image_external)

services/surfaceflinger/SurfaceFlinger.cpp

Lines changed: 2 additions & 45 deletions
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->getSurfaceBinder() );
1057+
mLayerMap.removeItem( lbc->getSurface()->asBinder() );
10581058
}
10591059
ssize_t index = mCurrentState.layersSortedByZ.remove(layerBase);
10601060
if (index >= 0) {
@@ -1066,12 +1066,8 @@ status_t SurfaceFlinger::removeLayer_l(const sp<LayerBase>& layerBase)
10661066

10671067
status_t SurfaceFlinger::purgatorizeLayer_l(const sp<LayerBase>& layerBase)
10681068
{
1069-
// First add the layer to the purgatory list, which makes sure it won't
1070-
// go away, then remove it from the main list (through a transaction).
1069+
// remove the layer from the main list (through a transaction).
10711070
ssize_t err = removeLayer_l(layerBase);
1072-
if (err >= 0) {
1073-
mLayerPurgatory.add(layerBase);
1074-
}
10751071

10761072
layerBase->onRemoved();
10771073

@@ -1342,19 +1338,6 @@ status_t SurfaceFlinger::destroySurface(const sp<LayerBaseClient>& layer)
13421338
* to use the purgatory.
13431339
*/
13441340
status_t err = flinger->removeLayer_l(l);
1345-
if (err == NAME_NOT_FOUND) {
1346-
// The surface wasn't in the current list, which means it was
1347-
// removed already, which means it is in the purgatory,
1348-
// and need to be removed from there.
1349-
// This needs to happen from the main thread since its dtor
1350-
// must run from there (b/c of OpenGL ES). Additionally, we
1351-
// can't really acquire our internal lock from
1352-
// destroySurface() -- see postMessage() below.
1353-
ssize_t idx = flinger->mLayerPurgatory.remove(l);
1354-
LOGE_IF(idx < 0,
1355-
"layer=%p is not in the purgatory list", l.get());
1356-
}
1357-
13581341
LOGE_IF(err<0 && err != NAME_NOT_FOUND,
13591342
"error removing layer=%p (%s)", l.get(), strerror(-err));
13601343
return true;
@@ -1470,13 +1453,8 @@ status_t SurfaceFlinger::dump(int fd, const Vector<String16>& args)
14701453
result.append(buffer);
14711454
}
14721455

1473-
/*
1474-
* Dump the visible layer list
1475-
*/
14761456
const LayerVector& currentLayers = mCurrentState.layersSortedByZ;
14771457
const size_t count = currentLayers.size();
1478-
snprintf(buffer, SIZE, "Visible layers (count = %d)\n", count);
1479-
result.append(buffer);
14801458
for (size_t i=0 ; i<count ; i++) {
14811459
const sp<LayerBase>& layer(currentLayers[i]);
14821460
layer->dump(result, buffer, SIZE);
@@ -1486,24 +1464,6 @@ status_t SurfaceFlinger::dump(int fd, const Vector<String16>& args)
14861464
layer->visibleRegionScreen.dump(result, "visibleRegionScreen");
14871465
}
14881466

1489-
/*
1490-
* Dump the layers in the purgatory
1491-
*/
1492-
1493-
const size_t purgatorySize = mLayerPurgatory.size();
1494-
snprintf(buffer, SIZE, "Purgatory state (%d entries)\n", purgatorySize);
1495-
result.append(buffer);
1496-
for (size_t i=0 ; i<purgatorySize ; i++) {
1497-
const sp<LayerBase>& layer(mLayerPurgatory.itemAt(i));
1498-
layer->shortDump(result, buffer, SIZE);
1499-
}
1500-
1501-
/*
1502-
* Dump SurfaceFlinger global state
1503-
*/
1504-
1505-
snprintf(buffer, SIZE, "SurfaceFlinger global state\n");
1506-
result.append(buffer);
15071467
mWormholeRegion.dump(result, "WormholeRegion");
15081468
const DisplayHardware& hw(graphicPlane(0).displayHardware());
15091469
snprintf(buffer, SIZE,
@@ -1529,9 +1489,6 @@ status_t SurfaceFlinger::dump(int fd, const Vector<String16>& args)
15291489
result.append(buffer);
15301490
}
15311491

1532-
/*
1533-
* Dump gralloc state
1534-
*/
15351492
const GraphicBufferAllocator& alloc(GraphicBufferAllocator::get());
15361493
alloc.dump(result);
15371494

services/surfaceflinger/SurfaceFlinger.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,6 @@ class SurfaceFlinger :
370370
volatile int32_t mTransactionFlags;
371371
volatile int32_t mTransactionCount;
372372
Condition mTransactionCV;
373-
SortedVector< sp<LayerBase> > mLayerPurgatory;
374373
bool mResizeTransationPending;
375374

376375
// protected by mStateLock (but we could use another lock)

0 commit comments

Comments
 (0)