am f8e4bc9f: Merge change I0c4cec7e into eclair

Merge commit 'f8e4bc9f7789b98b54fe04df56555ca8c630df70' into eclair-mr2

* commit 'f8e4bc9f7789b98b54fe04df56555ca8c630df70':
  Attempt to fix [2152536] ANR in browser
This commit is contained in:
Mathias Agopian
2009-10-04 15:21:34 -07:00
committed by Android Git Automerger
11 changed files with 40 additions and 46 deletions

View File

@@ -142,6 +142,7 @@ public:
SharedBufferBase(SharedClient* sharedClient, int surface, int num); SharedBufferBase(SharedClient* sharedClient, int surface, int num);
~SharedBufferBase(); ~SharedBufferBase();
uint32_t getIdentity(); uint32_t getIdentity();
status_t getStatus() const;
size_t getFrontBuffer() const; size_t getFrontBuffer() const;
String8 dump(char const* prefix) const; String8 dump(char const* prefix) const;
@@ -187,14 +188,15 @@ status_t SharedBufferBase::waitForCondition(T condition)
if (err == TIMED_OUT) { if (err == TIMED_OUT) {
if (condition()) { if (condition()) {
LOGE("waitForCondition(%s) timed out (identity=%d), " LOGE("waitForCondition(%s) timed out (identity=%d), "
"but condition is true! We recovered but it " "but condition is true! We recovered but it "
"shouldn't happen." , "shouldn't happen." , T::name(),
T::name(), mSharedStack->identity); mSharedStack->identity);
break; break;
} else { } else {
LOGW("waitForCondition(%s) timed out (identity=%d). " LOGW("waitForCondition(%s) timed out "
"CPU may be pegged. trying again.", "(identity=%d, status=%d). "
T::name(), mSharedStack->identity); "CPU may be pegged. trying again.", T::name(),
mSharedStack->identity, mSharedStack->status);
} }
} else { } else {
LOGE("waitForCondition(%s) error (%s) ", LOGE("waitForCondition(%s) error (%s) ",

View File

@@ -20,17 +20,12 @@
#include <utils/Errors.h> #include <utils/Errors.h>
#include <utils/Log.h> #include <utils/Log.h>
#include <binder/MemoryBase.h>
#include <binder/IMemory.h>
#include <ui/PixelFormat.h> #include <ui/PixelFormat.h>
#include <ui/Surface.h>
#include <pixelflinger/pixelflinger.h> #include <pixelflinger/pixelflinger.h>
#include "Buffer.h" #include "Buffer.h"
#include "BufferAllocator.h" #include "BufferAllocator.h"
#include "SurfaceFlinger.h"
namespace android { namespace android {

View File

@@ -20,20 +20,11 @@
#include <stdint.h> #include <stdint.h>
#include <sys/types.h> #include <sys/types.h>
#include <hardware/gralloc.h>
#include <utils/Atomic.h>
#include <ui/PixelFormat.h> #include <ui/PixelFormat.h>
#include <ui/Rect.h> #include <ui/Rect.h>
#include <ui/Surface.h>
#include <pixelflinger/pixelflinger.h> #include <pixelflinger/pixelflinger.h>
#include <private/ui/SharedBufferStack.h>
#include <private/ui/SurfaceBuffer.h> #include <private/ui/SurfaceBuffer.h>
class copybit_image_t;
struct android_native_buffer_t; struct android_native_buffer_t;
namespace android { namespace android {
@@ -42,8 +33,6 @@ namespace android {
// Buffer // Buffer
// =========================================================================== // ===========================================================================
class NativeBuffer;
class Buffer : public SurfaceBuffer class Buffer : public SurfaceBuffer
{ {
public: public:

View File

@@ -15,8 +15,6 @@
** limitations under the License. ** limitations under the License.
*/ */
#include <sys/mman.h>
#include <cutils/ashmem.h>
#include <cutils/log.h> #include <cutils/log.h>
#include <utils/Singleton.h> #include <utils/Singleton.h>

View File

@@ -65,14 +65,6 @@ Layer::~Layer()
// the actual buffers will be destroyed here // the actual buffers will be destroyed here
} }
// called with SurfaceFlinger::mStateLock as soon as the layer is entered
// in the purgatory list
void Layer::onRemoved()
{
// wake up the condition
lcblk->setStatus(NO_INIT);
}
void Layer::destroy() void Layer::destroy()
{ {
for (size_t i=0 ; i<NUM_BUFFERS ; i++) { for (size_t i=0 ; i<NUM_BUFFERS ; i++) {

View File

@@ -85,8 +85,6 @@ private:
return mBuffers[mFrontBufferIndex]; return mBuffers[mFrontBufferIndex];
} }
virtual void onRemoved();
void reloadTexture(const Region& dirty); void reloadTexture(const Region& dirty);
sp<SurfaceBuffer> requestBuffer(int index, int usage); sp<SurfaceBuffer> requestBuffer(int index, int usage);

View File

@@ -690,6 +690,14 @@ sp<LayerBaseClient::Surface> LayerBaseClient::createSurface() const
const_cast<LayerBaseClient *>(this)); const_cast<LayerBaseClient *>(this));
} }
// called with SurfaceFlinger::mStateLock as soon as the layer is entered
// in the purgatory list
void LayerBaseClient::onRemoved()
{
// wake up the condition
lcblk->setStatus(NO_INIT);
}
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
LayerBaseClient::Surface::Surface( LayerBaseClient::Surface::Surface(
@@ -700,7 +708,6 @@ LayerBaseClient::Surface::Surface(
{ {
} }
LayerBaseClient::Surface::~Surface() LayerBaseClient::Surface::~Surface()
{ {
/* /*

View File

@@ -205,10 +205,13 @@ public:
*/ */
virtual bool isSecure() const { return false; } virtual bool isSecure() const { return false; }
/** signal this layer that it's not needed any longer. called from the /** Called from the main thread, when the surface is removed from the
* main thread */ * draw list */
virtual status_t ditch() { return NO_ERROR; } virtual status_t ditch() { return NO_ERROR; }
/** called with the state lock when the surface is removed from the
* current list */
virtual void onRemoved() { };
enum { // flags for doTransaction() enum { // flags for doTransaction()
@@ -318,7 +321,7 @@ public:
sp<Surface> getSurface(); sp<Surface> getSurface();
virtual sp<Surface> createSurface() const; virtual sp<Surface> createSurface() const;
virtual void onRemoved() { } virtual void onRemoved();
class Surface : public BnSurface class Surface : public BnSurface
{ {

View File

@@ -1073,6 +1073,8 @@ status_t SurfaceFlinger::purgatorizeLayer_l(const sp<LayerBase>& layerBase)
// remove the layer from the main list (through a transaction). // remove the layer from the main list (through a transaction).
ssize_t err = removeLayer_l(layerBase); ssize_t err = removeLayer_l(layerBase);
layerBase->onRemoved();
// it's possible that we don't find a layer, because it might // it's possible that we don't find a layer, because it might
// have been destroyed already -- this is not technically an error // have been destroyed already -- this is not technically an error
// from the user because there is a race between BClient::destroySurface(), // from the user because there is a race between BClient::destroySurface(),
@@ -1321,7 +1323,6 @@ status_t SurfaceFlinger::removeSurface(SurfaceID index)
if (layer != 0) { if (layer != 0) {
err = purgatorizeLayer_l(layer); err = purgatorizeLayer_l(layer);
if (err == NO_ERROR) { if (err == NO_ERROR) {
layer->onRemoved();
setTransactionFlags(eTransactionNeeded); setTransactionFlags(eTransactionNeeded);
} }
} }

View File

@@ -114,6 +114,12 @@ uint32_t SharedBufferBase::getIdentity()
return stack.identity; return stack.identity;
} }
status_t SharedBufferBase::getStatus() const
{
SharedBufferStack& stack( *mSharedStack );
return stack.status;
}
size_t SharedBufferBase::getFrontBuffer() const size_t SharedBufferBase::getFrontBuffer() const
{ {
SharedBufferStack& stack( *mSharedStack ); SharedBufferStack& stack( *mSharedStack );
@@ -135,7 +141,6 @@ String8 SharedBufferBase::dump(char const* prefix) const
return result; return result;
} }
// ============================================================================ // ============================================================================
// conditions and updates // conditions and updates
// ============================================================================ // ============================================================================
@@ -375,8 +380,10 @@ status_t SharedBufferServer::unlock(int buffer)
void SharedBufferServer::setStatus(status_t status) void SharedBufferServer::setStatus(status_t status)
{ {
StatusUpdate update(this, status); if (status < NO_ERROR) {
updateCondition( update ); StatusUpdate update(this, status);
updateCondition( update );
}
} }
status_t SharedBufferServer::reallocate() status_t SharedBufferServer::reallocate()

View File

@@ -733,9 +733,11 @@ status_t Surface::getBufferLocked(int index, int usage)
index, usage); index, usage);
if (buffer != 0) { // this should never happen by construction if (buffer != 0) { // this should never happen by construction
LOGE_IF(buffer->handle == NULL, LOGE_IF(buffer->handle == NULL,
"requestBuffer(%d, %08x) returned a buffer with a null handle", "Surface (identity=%d) requestBuffer(%d, %08x) returned"
index, usage); "a buffer with a null handle", mIdentity, index, usage);
if (buffer->handle != NULL) { err = mSharedBufferClient->getStatus();
LOGE_IF(err, "Surface (identity=%d) state = %d", mIdentity, err);
if (!err && buffer->handle != NULL) {
err = getBufferMapper().registerBuffer(buffer->handle); err = getBufferMapper().registerBuffer(buffer->handle);
LOGW_IF(err, "registerBuffer(...) failed %d (%s)", LOGW_IF(err, "registerBuffer(...) failed %d (%s)",
err, strerror(-err)); err, strerror(-err));