Merge change 24333 into eclair

* changes:
  rename Mutexes to make the code easier to follow
This commit is contained in:
Android (Google) Code Review
2009-09-09 03:28:47 -07:00
2 changed files with 21 additions and 19 deletions

View File

@@ -354,7 +354,7 @@ void LayerBuffer::BufferSource::postBuffer(ssize_t offset)
{ {
ISurface::BufferHeap buffers; ISurface::BufferHeap buffers;
{ // scope for the lock { // scope for the lock
Mutex::Autolock _l(mLock); Mutex::Autolock _l(mBufferSourceLock);
buffers = mBufferHeap; buffers = mBufferHeap;
if (buffers.heap != 0) { if (buffers.heap != 0) {
const size_t memorySize = buffers.heap->getSize(); const size_t memorySize = buffers.heap->getSize();
@@ -379,7 +379,7 @@ void LayerBuffer::BufferSource::postBuffer(ssize_t offset)
void LayerBuffer::BufferSource::unregisterBuffers() void LayerBuffer::BufferSource::unregisterBuffers()
{ {
Mutex::Autolock _l(mLock); Mutex::Autolock _l(mBufferSourceLock);
mBufferHeap.heap.clear(); mBufferHeap.heap.clear();
mBuffer.clear(); mBuffer.clear();
mLayer.invalidate(); mLayer.invalidate();
@@ -387,13 +387,13 @@ void LayerBuffer::BufferSource::unregisterBuffers()
sp<LayerBuffer::Buffer> LayerBuffer::BufferSource::getBuffer() const sp<LayerBuffer::Buffer> LayerBuffer::BufferSource::getBuffer() const
{ {
Mutex::Autolock _l(mLock); Mutex::Autolock _l(mBufferSourceLock);
return mBuffer; return mBuffer;
} }
void LayerBuffer::BufferSource::setBuffer(const sp<LayerBuffer::Buffer>& buffer) void LayerBuffer::BufferSource::setBuffer(const sp<LayerBuffer::Buffer>& buffer)
{ {
Mutex::Autolock _l(mLock); Mutex::Autolock _l(mBufferSourceLock);
mBuffer = buffer; mBuffer = buffer;
} }
@@ -583,7 +583,7 @@ LayerBuffer::OverlaySource::OverlaySource(LayerBuffer& layer,
mOverlayHandle = overlay->getHandleRef(overlay); mOverlayHandle = overlay->getHandleRef(overlay);
// NOTE: here it's okay to acquire a reference to "this"m as long as // NOTE: here it's okay to acquire a reference to "this" as long as
// the reference is not released before we leave the ctor. // the reference is not released before we leave the ctor.
sp<OverlayChannel> channel = new OverlayChannel(this); sp<OverlayChannel> channel = new OverlayChannel(this);
@@ -601,7 +601,6 @@ LayerBuffer::OverlaySource::~OverlaySource()
void LayerBuffer::OverlaySource::onDraw(const Region& clip) const void LayerBuffer::OverlaySource::onDraw(const Region& clip) const
{ {
GLclampx color = 0x000018; //dark blue
GLclampx red = 0; GLclampx red = 0;
GLclampx green = 0; GLclampx green = 0;
GLclampx blue = 0x1818; GLclampx blue = 0x1818;
@@ -633,7 +632,7 @@ void LayerBuffer::OverlaySource::onVisibilityResolved(
int h = bounds.height(); int h = bounds.height();
// we need a lock here to protect "destroy" // we need a lock here to protect "destroy"
Mutex::Autolock _l(mLock); Mutex::Autolock _l(mOverlaySourceLock);
if (mOverlay) { if (mOverlay) {
overlay_control_device_t* overlay_dev = mOverlayDevice; overlay_control_device_t* overlay_dev = mOverlayDevice;
overlay_dev->setPosition(overlay_dev, mOverlay, x,y,w,h); overlay_dev->setPosition(overlay_dev, mOverlay, x,y,w,h);
@@ -654,7 +653,7 @@ void LayerBuffer::OverlaySource::serverDestroy()
void LayerBuffer::OverlaySource::destroyOverlay() void LayerBuffer::OverlaySource::destroyOverlay()
{ {
// we need a lock here to protect "onVisibilityResolved" // we need a lock here to protect "onVisibilityResolved"
Mutex::Autolock _l(mLock); Mutex::Autolock _l(mOverlaySourceLock);
if (mOverlay) { if (mOverlay) {
overlay_control_device_t* overlay_dev = mOverlayDevice; overlay_control_device_t* overlay_dev = mOverlayDevice;
overlay_dev->destroyOverlay(overlay_dev, mOverlay); overlay_dev->destroyOverlay(overlay_dev, mOverlay);

View File

@@ -124,7 +124,7 @@ private:
virtual void unregisterBuffers(); virtual void unregisterBuffers();
virtual bool transformed() const; virtual bool transformed() const;
private: private:
mutable Mutex mLock; mutable Mutex mBufferSourceLock;
sp<Buffer> mBuffer; sp<Buffer> mBuffer;
status_t mStatus; status_t mStatus;
ISurface::BufferHeap mBufferHeap; ISurface::BufferHeap mBufferHeap;
@@ -146,13 +146,17 @@ private:
private: private:
void serverDestroy(); void serverDestroy();
void destroyOverlay(); void destroyOverlay();
class OverlayChannel : public BnOverlay { class OverlayChannel : public BnOverlay {
mutable Mutex mLock; public:
sp<OverlaySource> mSource; OverlayChannel(const sp<OverlaySource>& source)
: mSource(source) {
}
private:
virtual void destroy() { virtual void destroy() {
sp<OverlaySource> source; sp<OverlaySource> source;
{ // scope for the lock; { // scope for the lock;
Mutex::Autolock _l(mLock); Mutex::Autolock _l(mDestroyLock);
source = mSource; source = mSource;
mSource.clear(); mSource.clear();
} }
@@ -160,11 +164,10 @@ private:
source->serverDestroy(); source->serverDestroy();
} }
} }
public: mutable Mutex mDestroyLock;
OverlayChannel(const sp<OverlaySource>& source) sp<OverlaySource> mSource;
: mSource(source) {
}
}; };
friend class OverlayChannel; friend class OverlayChannel;
bool mVisibilityChanged; bool mVisibilityChanged;
@@ -176,7 +179,7 @@ private:
int32_t mFormat; int32_t mFormat;
int32_t mWidthStride; int32_t mWidthStride;
int32_t mHeightStride; int32_t mHeightStride;
mutable Mutex mLock; mutable Mutex mOverlaySourceLock;
bool mInitialized; bool mInitialized;
}; };