Merge change 24334 into eclair
* changes: fix [2037525] Fail to start camera after adb sync new Camera
This commit is contained in:
@@ -133,6 +133,14 @@ bool LayerBuffer::transformed() const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LayerBuffer::serverDestroy()
|
||||||
|
{
|
||||||
|
sp<Source> source(clearSource());
|
||||||
|
if (source != 0) {
|
||||||
|
source->destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This creates a "buffer" source for this surface
|
* This creates a "buffer" source for this surface
|
||||||
*/
|
*/
|
||||||
@@ -413,7 +421,7 @@ void LayerBuffer::BufferSource::onDraw(const Region& clip) const
|
|||||||
|
|
||||||
status_t err = NO_ERROR;
|
status_t err = NO_ERROR;
|
||||||
NativeBuffer src(ourBuffer->getBuffer());
|
NativeBuffer src(ourBuffer->getBuffer());
|
||||||
const Rect& transformedBounds = mLayer.getTransformedBounds();
|
const Rect transformedBounds(mLayer.getTransformedBounds());
|
||||||
copybit_device_t* copybit = mBlitEngine;
|
copybit_device_t* copybit = mBlitEngine;
|
||||||
|
|
||||||
if (copybit) {
|
if (copybit) {
|
||||||
@@ -493,7 +501,7 @@ void LayerBuffer::BufferSource::onDraw(const Region& clip) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const Rect& transformedBounds = mLayer.getTransformedBounds();
|
const Rect transformedBounds(mLayer.getTransformedBounds());
|
||||||
const copybit_rect_t& drect =
|
const copybit_rect_t& drect =
|
||||||
reinterpret_cast<const copybit_rect_t&>(transformedBounds);
|
reinterpret_cast<const copybit_rect_t&>(transformedBounds);
|
||||||
const State& s(mLayer.drawingState());
|
const State& s(mLayer.drawingState());
|
||||||
@@ -583,9 +591,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" as long as
|
sp<OverlayChannel> channel = new OverlayChannel( &layer );
|
||||||
// the reference is not released before we leave the ctor.
|
|
||||||
sp<OverlayChannel> channel = new OverlayChannel(this);
|
|
||||||
|
|
||||||
*overlayRef = new OverlayRef(mOverlayHandle, channel,
|
*overlayRef = new OverlayRef(mOverlayHandle, channel,
|
||||||
mWidth, mHeight, mFormat, mWidthStride, mHeightStride);
|
mWidth, mHeight, mFormat, mWidthStride, mHeightStride);
|
||||||
@@ -625,7 +631,7 @@ void LayerBuffer::OverlaySource::onVisibilityResolved(
|
|||||||
if (mVisibilityChanged || !mInitialized) {
|
if (mVisibilityChanged || !mInitialized) {
|
||||||
mVisibilityChanged = false;
|
mVisibilityChanged = false;
|
||||||
mInitialized = true;
|
mInitialized = true;
|
||||||
const Rect& bounds = mLayer.getTransformedBounds();
|
const Rect bounds(mLayer.getTransformedBounds());
|
||||||
int x = bounds.left;
|
int x = bounds.left;
|
||||||
int y = bounds.top;
|
int y = bounds.top;
|
||||||
int w = bounds.width();
|
int w = bounds.width();
|
||||||
@@ -644,17 +650,11 @@ void LayerBuffer::OverlaySource::onVisibilityResolved(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayerBuffer::OverlaySource::serverDestroy()
|
void LayerBuffer::OverlaySource::destroy()
|
||||||
{
|
|
||||||
mLayer.clearSource();
|
|
||||||
destroyOverlay();
|
|
||||||
}
|
|
||||||
|
|
||||||
void LayerBuffer::OverlaySource::destroyOverlay()
|
|
||||||
{
|
{
|
||||||
// we need a lock here to protect "onVisibilityResolved"
|
// we need a lock here to protect "onVisibilityResolved"
|
||||||
Mutex::Autolock _l(mOverlaySourceLock);
|
Mutex::Autolock _l(mOverlaySourceLock);
|
||||||
if (mOverlay) {
|
if (mOverlay && mOverlayDevice) {
|
||||||
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);
|
||||||
mOverlay = 0;
|
mOverlay = 0;
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ class LayerBuffer : public LayerBaseClient
|
|||||||
virtual void postBuffer(ssize_t offset);
|
virtual void postBuffer(ssize_t offset);
|
||||||
virtual void unregisterBuffers();
|
virtual void unregisterBuffers();
|
||||||
virtual bool transformed() const;
|
virtual bool transformed() const;
|
||||||
|
virtual void destroy() { }
|
||||||
protected:
|
protected:
|
||||||
LayerBuffer& mLayer;
|
LayerBuffer& mLayer;
|
||||||
};
|
};
|
||||||
@@ -81,10 +82,12 @@ public:
|
|||||||
sp<Source> getSource() const;
|
sp<Source> getSource() const;
|
||||||
sp<Source> clearSource();
|
sp<Source> clearSource();
|
||||||
void setNeedsBlending(bool blending);
|
void setNeedsBlending(bool blending);
|
||||||
const Rect& getTransformedBounds() const {
|
Rect getTransformedBounds() const {
|
||||||
return mTransformedBounds;
|
return mTransformedBounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void serverDestroy();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct NativeBuffer {
|
struct NativeBuffer {
|
||||||
copybit_image_t img;
|
copybit_image_t img;
|
||||||
@@ -123,6 +126,7 @@ private:
|
|||||||
virtual void postBuffer(ssize_t offset);
|
virtual void postBuffer(ssize_t offset);
|
||||||
virtual void unregisterBuffers();
|
virtual void unregisterBuffers();
|
||||||
virtual bool transformed() const;
|
virtual bool transformed() const;
|
||||||
|
virtual void destroy() { }
|
||||||
private:
|
private:
|
||||||
mutable Mutex mBufferSourceLock;
|
mutable Mutex mBufferSourceLock;
|
||||||
sp<Buffer> mBuffer;
|
sp<Buffer> mBuffer;
|
||||||
@@ -143,29 +147,21 @@ private:
|
|||||||
virtual void onDraw(const Region& clip) const;
|
virtual void onDraw(const Region& clip) const;
|
||||||
virtual void onTransaction(uint32_t flags);
|
virtual void onTransaction(uint32_t flags);
|
||||||
virtual void onVisibilityResolved(const Transform& planeTransform);
|
virtual void onVisibilityResolved(const Transform& planeTransform);
|
||||||
|
virtual void destroy();
|
||||||
private:
|
private:
|
||||||
void serverDestroy();
|
|
||||||
void destroyOverlay();
|
|
||||||
|
|
||||||
class OverlayChannel : public BnOverlay {
|
class OverlayChannel : public BnOverlay {
|
||||||
public:
|
wp<LayerBuffer> mLayer;
|
||||||
OverlayChannel(const sp<OverlaySource>& source)
|
|
||||||
: mSource(source) {
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
virtual void destroy() {
|
virtual void destroy() {
|
||||||
sp<OverlaySource> source;
|
sp<LayerBuffer> layer(mLayer.promote());
|
||||||
{ // scope for the lock;
|
if (layer != 0) {
|
||||||
Mutex::Autolock _l(mDestroyLock);
|
layer->serverDestroy();
|
||||||
source = mSource;
|
|
||||||
mSource.clear();
|
|
||||||
}
|
|
||||||
if (source != 0) {
|
|
||||||
source->serverDestroy();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mutable Mutex mDestroyLock;
|
public:
|
||||||
sp<OverlaySource> mSource;
|
OverlayChannel(const sp<LayerBuffer>& layer)
|
||||||
|
: mLayer(layer) {
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
friend class OverlayChannel;
|
friend class OverlayChannel;
|
||||||
|
|||||||
Reference in New Issue
Block a user