more surfaceflinger cleanups
get rid of the "fake rtti" code, and use polymorphism instead.
also simplify how we log SF's state (using polymorphism)
Change-Id: I2bae7c98de4dd207a3e2b00083fa3fde7c467922
diff --git a/libs/surfaceflinger/LayerBase.h b/libs/surfaceflinger/LayerBase.h
index 4ff1927..219a53c 100644
--- a/libs/surfaceflinger/LayerBase.h
+++ b/libs/surfaceflinger/LayerBase.h
@@ -51,35 +51,9 @@
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 +99,9 @@
void invalidate();
+ virtual const char* getTypeId() const { return "LayerBase"; }
+ virtual ssize_t serverIndex() const { return -1; }
+
/**
* draw - performs some global clipping optimizations
* and calls onDraw().
@@ -217,7 +194,10 @@
* 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,
};
@@ -313,10 +293,6 @@
{
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
@@ -331,14 +307,12 @@
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 ssize_t serverIndex() const;
+ virtual void onRemoved();
+ virtual const char* getTypeId() const { return "LayerBaseClient"; }
class Surface : public BnSurface
{
@@ -373,8 +347,11 @@
friend class Surface;
+protected:
+ virtual void dump(String8& result, char* scratch, size_t size) const;
+
private:
- int32_t mIndex;
+ int32_t mIndex;
mutable Mutex mLock;
mutable wp<Surface> mClientSurface;
// only read