Skip to content

Commit 1955a5c

Browse files
pixelflingerAndroid (Google) Code Review
authored andcommitted
Merge "partially fix [3306150] HTML5 video with H/W acceleration blackout (DO NOT MERGE)" into gingerbread
2 parents d0441f9 + 68d3478 commit 1955a5c

File tree

5 files changed

+60
-2
lines changed

5 files changed

+60
-2
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 | %2d | 0x%08x\n",
66+
snprintf(buffer, SIZE, "%10p: %7.2f KiB | %4u (%4u) x %4u | %8X | 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/LayerBase.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,12 @@ void LayerBase::dump(String8& result, char* buffer, size_t SIZE) const
519519
result.append(buffer);
520520
}
521521

522+
void LayerBase::shortDump(String8& result, char* scratch, size_t size) const
523+
{
524+
LayerBase::dump(result, scratch, size);
525+
}
526+
527+
522528
// ---------------------------------------------------------------------------
523529

524530
int32_t LayerBaseClient::sIdentity = 1;
@@ -570,6 +576,12 @@ void LayerBaseClient::dump(String8& result, char* buffer, size_t SIZE) const
570576
result.append(buffer);
571577
}
572578

579+
580+
void LayerBaseClient::shortDump(String8& result, char* scratch, size_t size) const
581+
{
582+
LayerBaseClient::dump(result, scratch, size);
583+
}
584+
573585
// ---------------------------------------------------------------------------
574586

575587
LayerBaseClient::Surface::Surface(

services/surfaceflinger/LayerBase.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ class LayerBase : public RefBase
211211

212212
/** always call base class first */
213213
virtual void dump(String8& result, char* scratch, size_t size) const;
214+
virtual void shortDump(String8& result, char* scratch, size_t size) const;
214215

215216

216217
enum { // flags for doTransaction()
@@ -330,6 +331,7 @@ class LayerBaseClient : public LayerBase
330331

331332
protected:
332333
virtual void dump(String8& result, char* scratch, size_t size) const;
334+
virtual void shortDump(String8& result, char* scratch, size_t size) const;
333335

334336
private:
335337
mutable Mutex mLock;

services/surfaceflinger/SurfaceFlinger.cpp

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1082,8 +1082,12 @@ status_t SurfaceFlinger::removeLayer_l(const sp<LayerBase>& layerBase)
10821082

10831083
status_t SurfaceFlinger::purgatorizeLayer_l(const sp<LayerBase>& layerBase)
10841084
{
1085-
// remove the layer from the main list (through a transaction).
1085+
// First add the layer to the purgatory list, which makes sure it won't
1086+
// go away, then remove it from the main list (through a transaction).
10861087
ssize_t err = removeLayer_l(layerBase);
1088+
if (err >= 0) {
1089+
mLayerPurgatory.add(layerBase);
1090+
}
10871091

10881092
layerBase->onRemoved();
10891093

@@ -1354,6 +1358,19 @@ status_t SurfaceFlinger::destroySurface(const sp<LayerBaseClient>& layer)
13541358
* to use the purgatory.
13551359
*/
13561360
status_t err = flinger->removeLayer_l(l);
1361+
if (err == NAME_NOT_FOUND) {
1362+
// The surface wasn't in the current list, which means it was
1363+
// removed already, which means it is in the purgatory,
1364+
// and need to be removed from there.
1365+
// This needs to happen from the main thread since its dtor
1366+
// must run from there (b/c of OpenGL ES). Additionally, we
1367+
// can't really acquire our internal lock from
1368+
// destroySurface() -- see postMessage() below.
1369+
ssize_t idx = flinger->mLayerPurgatory.remove(l);
1370+
LOGE_IF(idx < 0,
1371+
"layer=%p is not in the purgatory list", l.get());
1372+
}
1373+
13571374
LOGE_IF(err<0 && err != NAME_NOT_FOUND,
13581375
"error removing layer=%p (%s)", l.get(), strerror(-err));
13591376
return true;
@@ -1469,8 +1486,13 @@ status_t SurfaceFlinger::dump(int fd, const Vector<String16>& args)
14691486
result.append(buffer);
14701487
}
14711488

1489+
/*
1490+
* Dump the visible layer list
1491+
*/
14721492
const LayerVector& currentLayers = mCurrentState.layersSortedByZ;
14731493
const size_t count = currentLayers.size();
1494+
snprintf(buffer, SIZE, "Visible layers (count = %d)\n", count);
1495+
result.append(buffer);
14741496
for (size_t i=0 ; i<count ; i++) {
14751497
const sp<LayerBase>& layer(currentLayers[i]);
14761498
layer->dump(result, buffer, SIZE);
@@ -1480,6 +1502,24 @@ status_t SurfaceFlinger::dump(int fd, const Vector<String16>& args)
14801502
layer->visibleRegionScreen.dump(result, "visibleRegionScreen");
14811503
}
14821504

1505+
/*
1506+
* Dump the layers in the purgatory
1507+
*/
1508+
1509+
const size_t purgatorySize = mLayerPurgatory.size();
1510+
snprintf(buffer, SIZE, "Purgatory state (%d entries)\n", purgatorySize);
1511+
result.append(buffer);
1512+
for (size_t i=0 ; i<purgatorySize ; i++) {
1513+
const sp<LayerBase>& layer(mLayerPurgatory.itemAt(i));
1514+
layer->shortDump(result, buffer, SIZE);
1515+
}
1516+
1517+
/*
1518+
* Dump SurfaceFlinger global state
1519+
*/
1520+
1521+
snprintf(buffer, SIZE, "SurfaceFlinger global state\n");
1522+
result.append(buffer);
14831523
mWormholeRegion.dump(result, "WormholeRegion");
14841524
const DisplayHardware& hw(graphicPlane(0).displayHardware());
14851525
snprintf(buffer, SIZE,
@@ -1505,6 +1545,9 @@ status_t SurfaceFlinger::dump(int fd, const Vector<String16>& args)
15051545
result.append(buffer);
15061546
}
15071547

1548+
/*
1549+
* Dump gralloc state
1550+
*/
15081551
const GraphicBufferAllocator& alloc(GraphicBufferAllocator::get());
15091552
alloc.dump(result);
15101553

services/surfaceflinger/SurfaceFlinger.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ class SurfaceFlinger :
371371
volatile int32_t mTransactionFlags;
372372
volatile int32_t mTransactionCount;
373373
Condition mTransactionCV;
374+
SortedVector< sp<LayerBase> > mLayerPurgatory;
374375
bool mResizeTransationPending;
375376

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

0 commit comments

Comments
 (0)