summaryrefslogtreecommitdiffstats
path: root/libs/surfaceflinger/LayerBuffer.h
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-01-09 17:51:23 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-01-09 17:51:23 -0800
commit276293246ea9cbc0a578a7697cc48930376ec0e9 (patch)
tree03804488c60dda65699333d2311c8d1842ec4b65 /libs/surfaceflinger/LayerBuffer.h
parente09fd9e819c23dc90bca68375645e15544861330 (diff)
downloadframeworks_native-276293246ea9cbc0a578a7697cc48930376ec0e9.zip
frameworks_native-276293246ea9cbc0a578a7697cc48930376ec0e9.tar.gz
frameworks_native-276293246ea9cbc0a578a7697cc48930376ec0e9.tar.bz2
auto import from //branches/cupcake/...@125939
Diffstat (limited to 'libs/surfaceflinger/LayerBuffer.h')
-rw-r--r--libs/surfaceflinger/LayerBuffer.h134
1 files changed, 101 insertions, 33 deletions
diff --git a/libs/surfaceflinger/LayerBuffer.h b/libs/surfaceflinger/LayerBuffer.h
index 3e616f2..63ec2cf 100644
--- a/libs/surfaceflinger/LayerBuffer.h
+++ b/libs/surfaceflinger/LayerBuffer.h
@@ -33,10 +33,24 @@ namespace android {
class MemoryDealer;
class Region;
-class Overlay;
+class OverlayRef;
class LayerBuffer : public LayerBaseClient
{
+ class Source : public LightRefBase<Source> {
+ public:
+ Source(LayerBuffer& layer);
+ virtual ~Source();
+ virtual void onDraw(const Region& clip) const;
+ virtual void onTransaction(uint32_t flags);
+ virtual void onVisibilityResolved(const Transform& planeTransform);
+ virtual void postBuffer(ssize_t offset);
+ virtual void unregisterBuffers();
+ protected:
+ LayerBuffer& mLayer;
+ };
+
+
public:
static const uint32_t typeInfo;
static const char* const typeID;
@@ -51,39 +65,31 @@ public:
virtual sp<LayerBaseClient::Surface> getSurface() const;
virtual void onDraw(const Region& clip) const;
+ virtual uint32_t doTransaction(uint32_t flags);
virtual void unlockPageFlip(const Transform& planeTransform, Region& outDirtyRegion);
status_t registerBuffers(int w, int h, int hstride, int vstride,
PixelFormat format, const sp<IMemoryHeap>& heap);
void postBuffer(ssize_t offset);
void unregisterBuffers();
- sp<Overlay> createOverlay(uint32_t w, uint32_t h, int32_t format);
- void invalidate();
- void invalidateLocked();
+ sp<OverlayRef> createOverlay(uint32_t w, uint32_t h, int32_t format);
+
+ sp<Source> getSource() const;
+ void setNeedsBlending(bool blending);
+ const Rect& getTransformedBounds() const {
+ return mTransformedBounds;
+ }
private:
-
- struct NativeBuffer
- {
+ struct NativeBuffer {
copybit_image_t img;
copybit_rect_t crop;
};
- class Buffer
- {
+ class Buffer : public LightRefBase<Buffer> {
public:
Buffer(const sp<IMemoryHeap>& heap, ssize_t offset,
int w, int h, int hs, int vs, int f);
- inline void incStrong(void*) const {
- android_atomic_inc(&mCount);
- }
- inline void decStrong(void*) const {
- int32_t c = android_atomic_dec(&mCount);
- //LOGE_IF(c<1, "Buffer::decStrong() called too many times");
- if (c == 1) {
- delete this;
- }
- }
inline status_t getStatus() const {
return mHeap!=0 ? NO_ERROR : NO_INIT;
}
@@ -91,15 +97,87 @@ private:
return mNativeBuffer;
}
protected:
+ friend class LightRefBase<Buffer>;
Buffer& operator = (const Buffer& rhs);
Buffer(const Buffer& rhs);
~Buffer();
- mutable volatile int32_t mCount;
private:
sp<IMemoryHeap> mHeap;
NativeBuffer mNativeBuffer;
};
+ class BufferSource : public Source {
+ public:
+ BufferSource(LayerBuffer& layer,
+ int w, int h, int hstride, int vstride,
+ PixelFormat format, const sp<IMemoryHeap>& heap);
+ virtual ~BufferSource();
+
+ status_t getStatus() const { return mStatus; }
+ sp<Buffer> getBuffer() const;
+ void setBuffer(const sp<Buffer>& buffer);
+
+ virtual void onDraw(const Region& clip) const;
+ virtual void postBuffer(ssize_t offset);
+ virtual void unregisterBuffers();
+ private:
+ mutable Mutex mLock;
+ sp<IMemoryHeap> mHeap;
+ sp<Buffer> mBuffer;
+ status_t mStatus;
+ int mWidth;
+ int mHeight;
+ int mHStride;
+ int mVStride;
+ int mFormat;
+ mutable sp<MemoryDealer> mTemporaryDealer;
+ mutable LayerBitmap mTempBitmap;
+ mutable GLuint mTextureName;
+ };
+
+ class OverlaySource : public Source {
+ public:
+ OverlaySource(LayerBuffer& layer,
+ sp<OverlayRef>* overlayRef,
+ uint32_t w, uint32_t h, int32_t format);
+ virtual ~OverlaySource();
+ virtual void onTransaction(uint32_t flags);
+ virtual void onVisibilityResolved(const Transform& planeTransform);
+ private:
+ void serverDestroy();
+ class OverlayChanel : public BnOverlay {
+ mutable Mutex mLock;
+ sp<OverlaySource> mSource;
+ virtual void destroy() {
+ sp<OverlaySource> source;
+ { // scope for the lock;
+ Mutex::Autolock _l(mLock);
+ source = mSource;
+ mSource.clear();
+ }
+ if (source != 0) {
+ source->serverDestroy();
+ }
+ }
+ public:
+ OverlayChanel(const sp<OverlaySource>& source)
+ : mSource(source) {
+ }
+ };
+ friend class OverlayChanel;
+ bool mVisibilityChanged;
+
+ overlay_t* mOverlay;
+ overlay_handle_t const *mOverlayHandle;
+ uint32_t mWidth;
+ uint32_t mHeight;
+ int32_t mFormat;
+ int32_t mWidthStride;
+ int32_t mHeightStride;
+ mutable Mutex mLock;
+ };
+
+
class SurfaceBuffer : public LayerBaseClient::Surface
{
public:
@@ -109,7 +187,7 @@ private:
PixelFormat format, const sp<IMemoryHeap>& heap);
virtual void postBuffer(ssize_t offset);
virtual void unregisterBuffers();
- virtual sp<Overlay> createOverlay(
+ virtual sp<OverlayRef> createOverlay(
uint32_t w, uint32_t h, int32_t format);
void disown();
private:
@@ -122,24 +200,14 @@ private:
};
friend class SurfaceFlinger;
- sp<Buffer> getBuffer() const;
- void setBuffer(const sp<Buffer>& buffer);
sp<SurfaceBuffer> getClientSurface() const;
mutable Mutex mLock;
- sp<IMemoryHeap> mHeap;
- sp<Buffer> mBuffer;
- int mWidth;
- int mHeight;
- int mHStride;
- int mVStride;
- int mFormat;
- mutable GLuint mTextureName;
+ sp<Source> mSource;
+
bool mInvalidate;
bool mNeedsBlending;
mutable wp<SurfaceBuffer> mClientSurface;
- mutable sp<MemoryDealer> mTemporaryDealer;
- mutable LayerBitmap mTempBitmap;
};
// ---------------------------------------------------------------------------