diff options
Diffstat (limited to 'libs/surfaceflinger/LayerBase.h')
-rw-r--r-- | libs/surfaceflinger/LayerBase.h | 131 |
1 files changed, 38 insertions, 93 deletions
diff --git a/libs/surfaceflinger/LayerBase.h b/libs/surfaceflinger/LayerBase.h index 62ec839..1a07f32 100644 --- a/libs/surfaceflinger/LayerBase.h +++ b/libs/surfaceflinger/LayerBase.h @@ -29,7 +29,7 @@ #include <ui/Region.h> #include <ui/Overlay.h> -#include <surfaceflinger/ISurfaceFlingerClient.h> +#include <surfaceflinger/ISurfaceComposerClient.h> #include <private/surfaceflinger/SharedBufferStack.h> #include <private/surfaceflinger/LayerState.h> @@ -45,41 +45,17 @@ class DisplayHardware; class Client; class GraphicBuffer; class GraphicPlane; +class LayerBaseClient; class SurfaceFlinger; +class Texture; // --------------------------------------------------------------------------- class LayerBase : public RefBase { - // poor man's dynamic_cast below - template<typename T> - struct getTypeInfoOfAnyType { - static uint32_t get() { return T::typeInfo; } - }; - - template<typename T> - struct getTypeInfoOfAnyType<T*> { - static uint32_t get() { return getTypeInfoOfAnyType<T>::get(); } - }; - public: - static const uint32_t typeInfo; - static const char* const typeID; - virtual char const* getTypeID() const { return typeID; } - virtual uint32_t getTypeInfo() const { return typeInfo; } - - template<typename T> - static T dynamicCast(LayerBase* base) { - uint32_t mostDerivedInfo = base->getTypeInfo(); - uint32_t castToInfo = getTypeInfoOfAnyType<T>::get(); - if ((mostDerivedInfo & castToInfo) == castToInfo) - return static_cast<T>(base); - return 0; - } + LayerBase(SurfaceFlinger* flinger, DisplayID display); - - LayerBase(SurfaceFlinger* flinger, DisplayID display); - DisplayID dpy; mutable bool contentDirty; Region visibleRegionScreen; @@ -125,6 +101,10 @@ public: void invalidate(); + virtual sp<LayerBaseClient> getLayerBaseClient() const { return 0; } + + virtual const char* getTypeId() const { return "LayerBase"; } + /** * draw - performs some global clipping optimizations * and calls onDraw(). @@ -199,9 +179,9 @@ public: virtual bool needsDithering() const { return false; } /** - * transformed -- true is this surface needs a to be transformed + * needsLinearFiltering - true if this surface needs filtering */ - virtual bool transformed() const { return mTransformed; } + virtual bool needsFiltering() const { return mNeedsFiltering; } /** * isSecure - true if this surface is secure, that is if it prevents @@ -217,7 +197,10 @@ public: * current list */ virtual void onRemoved() { }; - + /** always call base class first */ + virtual void dump(String8& result, char* scratch, size_t size) const; + + enum { // flags for doTransaction() eVisibleRegion = 0x00000002, }; @@ -241,44 +224,18 @@ protected: const GraphicPlane& graphicPlane(int dpy) const; GraphicPlane& graphicPlane(int dpy); - GLuint createTexture() const; - - struct Texture { - Texture() : name(-1U), width(0), height(0), - image(EGL_NO_IMAGE_KHR), transform(0), - NPOTAdjust(false), dirty(true) { } - GLuint name; - GLuint width; - GLuint height; - GLuint potWidth; - GLuint potHeight; - GLfloat wScale; - GLfloat hScale; - EGLImageKHR image; - uint32_t transform; - bool NPOTAdjust; - bool dirty; - }; - - void clearWithOpenGL(const Region& clip, GLclampx r, GLclampx g, - GLclampx b, GLclampx alpha) const; + void clearWithOpenGL(const Region& clip, GLclampf r, GLclampf g, + GLclampf b, GLclampf alpha) const; void clearWithOpenGL(const Region& clip) const; void drawWithOpenGL(const Region& clip, const Texture& texture) const; - void loadTexture(Texture* texture, - const Region& dirty, const GGLSurface& t) const; - status_t initializeEglImage( - const sp<GraphicBuffer>& buffer, Texture* texture); - - bool isSupportedYuvFormat(int format) const; sp<SurfaceFlinger> mFlinger; uint32_t mFlags; // cached during validateVisibility() - bool mTransformed; - bool mUseLinearFiltering; + bool mNeedsFiltering; int32_t mOrientation; - GLfixed mVertices[4][2]; + GLfloat mVertices[4][2]; Rect mTransformedBounds; int mLeft; int mTop; @@ -313,42 +270,25 @@ class LayerBaseClient : public LayerBase { public: class Surface; - static const uint32_t typeInfo; - static const char* const typeID; - virtual char const* getTypeID() const { return typeID; } - virtual uint32_t getTypeInfo() const { return typeInfo; } - - // lcblk is (almost) only accessed from the main SF thread, in the places - // where it's not, a reference to Client must be held - SharedBufferServer* lcblk; - LayerBaseClient(SurfaceFlinger* flinger, DisplayID display, - const sp<Client>& client, int32_t i); + LayerBaseClient(SurfaceFlinger* flinger, DisplayID display, + const sp<Client>& client); virtual ~LayerBaseClient(); - virtual void onFirstRef(); - - const wp<Client> client; - inline uint32_t getIdentity() const { return mIdentity; } - inline int32_t clientIndex() const { return mIndex; } - int32_t serverIndex() const; - - sp<Surface> getSurface(); virtual sp<Surface> createSurface() const; - - virtual void onRemoved(); + virtual sp<LayerBaseClient> getLayerBaseClient() const { + return const_cast<LayerBaseClient*>(this); } + virtual const char* getTypeId() const { return "LayerBaseClient"; } + uint32_t getIdentity() const { return mIdentity; } - class Surface : public BnSurface - { + class Surface : public BnSurface { public: - int32_t getToken() const { return mToken; } int32_t getIdentity() const { return mIdentity; } protected: - Surface(const sp<SurfaceFlinger>& flinger, - SurfaceID id, int identity, + Surface(const sp<SurfaceFlinger>& flinger, int identity, const sp<LayerBaseClient>& owner); virtual ~Surface(); virtual status_t onTransact(uint32_t code, const Parcel& data, @@ -356,7 +296,10 @@ public: sp<LayerBaseClient> getOwner() const; private: - virtual sp<GraphicBuffer> requestBuffer(int index, int usage); + virtual sp<GraphicBuffer> requestBuffer(int bufferIdx, + uint32_t w, uint32_t h, uint32_t format, uint32_t usage); + virtual status_t setBufferCount(int bufferCount); + virtual status_t registerBuffers(const ISurface::BufferHeap& buffers); virtual void postBuffer(ssize_t offset); virtual void unregisterBuffers(); @@ -366,20 +309,22 @@ public: protected: friend class LayerBaseClient; sp<SurfaceFlinger> mFlinger; - int32_t mToken; int32_t mIdentity; wp<LayerBaseClient> mOwner; }; friend class Surface; +protected: + virtual void dump(String8& result, char* scratch, size_t size) const; + private: - int32_t mIndex; - mutable Mutex mLock; - mutable wp<Surface> mClientSurface; + mutable Mutex mLock; + mutable wp<Surface> mClientSurface; + const wp<Client> mClientRef; // only read - const uint32_t mIdentity; - static int32_t sIdentity; + const uint32_t mIdentity; + static int32_t sIdentity; }; // --------------------------------------------------------------------------- |