Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2ee3ec24 authored by Mathias Agopian's avatar Mathias Agopian Committed by Android Git Automerger
Browse files

am 9bce8737: more surfaceflinger cleanups

parents 559377e9 1b5e1021
Loading
Loading
Loading
Loading
+33 −6
Original line number Diff line number Diff line
@@ -47,11 +47,6 @@ template <typename T> inline T min(T a, T b) {

// ---------------------------------------------------------------------------

const uint32_t Layer::typeInfo = LayerBaseClient::typeInfo | 4;
const char* const Layer::typeID = "Layer";

// ---------------------------------------------------------------------------

Layer::Layer(SurfaceFlinger* flinger, DisplayID display, 
        const sp<Client>& c, int32_t i)
    :   LayerBaseClient(flinger, display, c, i),
@@ -572,7 +567,7 @@ void Layer::unlockPageFlip(
    }
    if (visibleRegionScreen.isEmpty()) {
        // an invisible layer should not hold a freeze-lock
        // (because it may never be updated and thereore never release it)
        // (because it may never be updated and therefore never release it)
        mFreezeLock.clear();
    }
}
@@ -585,6 +580,38 @@ void Layer::finishPageFlip()
            this, mFrontBufferIndex);
}


void Layer::dump(String8& result, char* buffer, size_t SIZE) const
{
    LayerBaseClient::dump(result, buffer, SIZE);

    SharedBufferStack::Statistics stats = lcblk->getStats();
    result.append( lcblk->dump("      ") );
    sp<const GraphicBuffer> buf0(getBuffer(0));
    sp<const GraphicBuffer> buf1(getBuffer(1));
    uint32_t w0=0, h0=0, s0=0;
    uint32_t w1=0, h1=0, s1=0;
    if (buf0 != 0) {
        w0 = buf0->getWidth();
        h0 = buf0->getHeight();
        s0 = buf0->getStride();
    }
    if (buf1 != 0) {
        w1 = buf1->getWidth();
        h1 = buf1->getHeight();
        s1 = buf1->getStride();
    }
    snprintf(buffer, SIZE,
            "      "
            "format=%2d, [%3ux%3u:%3u] [%3ux%3u:%3u],"
            " freezeLock=%p, dq-q-time=%u us\n",
            pixelFormat(),
            w0, h0, s0, w1, h1, s1,
            getFreezeLock().get(), stats.totalTime);

    result.append(buffer);
}

// ---------------------------------------------------------------------------

Layer::SurfaceLayer::SurfaceLayer(const sp<SurfaceFlinger>& flinger,
+6 −6
Original line number Diff line number Diff line
@@ -46,11 +46,6 @@ const size_t NUM_BUFFERS = 2;
class Layer : public LayerBaseClient
{
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; }
    
                 Layer(SurfaceFlinger* flinger, DisplayID display,
                         const sp<Client>& client, int32_t i);

@@ -73,7 +68,7 @@ public:
    virtual status_t ditch();
    
    // only for debugging
    inline sp<GraphicBuffer> getBuffer(int i) { return mBuffers[i]; }
    inline sp<GraphicBuffer> getBuffer(int i) const { return mBuffers[i]; }
    // only for debugging
    inline const sp<FreezeLock>&  getFreezeLock() const { return mFreezeLock; }
    // only for debugging
@@ -81,6 +76,11 @@ public:
    // only for debugging
    inline int getFrontBufferIndex() const { return mFrontBufferIndex; }

    virtual const char* getTypeId() const { return "Layer"; }

protected:
    virtual void dump(String8& result, char* scratch, size_t size) const;

private:
    inline sp<GraphicBuffer> getFrontBufferLocked() {
        return mBuffers[mFrontBufferIndex];
+33 −10
Original line number Diff line number Diff line
@@ -38,14 +38,6 @@ namespace android {

// ---------------------------------------------------------------------------

const uint32_t LayerBase::typeInfo = 1;
const char* const LayerBase::typeID = "LayerBase";

const uint32_t LayerBaseClient::typeInfo = LayerBase::typeInfo | 2;
const char* const LayerBaseClient::typeID = "LayerBaseClient";

// ---------------------------------------------------------------------------

LayerBase::LayerBase(SurfaceFlinger* flinger, DisplayID display)
    : dpy(display), contentDirty(false),
      mFlinger(flinger),
@@ -681,6 +673,22 @@ status_t LayerBase::initializeEglImage(
    return err;
}

void LayerBase::dump(String8& result, char* buffer, size_t SIZE) const
{
    const Layer::State& s(drawingState());
    snprintf(buffer, SIZE,
            "+ %s %p\n"
            "      "
            "z=%9d, pos=(%4d,%4d), size=(%4d,%4d), "
            "needsBlending=%1d, needsDithering=%1d, invalidate=%1d, "
            "alpha=0x%02x, flags=0x%08x, tr=[%.2f, %.2f][%.2f, %.2f]\n",
            getTypeId(), this, s.z, tx(), ty(), s.w, s.h,
            needsBlending(), needsDithering(), contentDirty,
            s.alpha, s.flags,
            s.transform[0][0], s.transform[0][1],
            s.transform[1][0], s.transform[1][1]);
    result.append(buffer);
}

// ---------------------------------------------------------------------------

@@ -713,13 +721,13 @@ LayerBaseClient::~LayerBaseClient()
    delete lcblk;
}

int32_t LayerBaseClient::serverIndex() const 
ssize_t LayerBaseClient::serverIndex() const
{
    sp<Client> client(this->client.promote());
    if (client != 0) {
        return (client->cid<<16)|mIndex;
    }
    return 0xFFFF0000 | mIndex;
    return ssize_t(0xFFFF0000 | mIndex);
}

sp<LayerBaseClient::Surface> LayerBaseClient::getSurface()
@@ -748,6 +756,21 @@ void LayerBaseClient::onRemoved()
    lcblk->setStatus(NO_INIT);
}

void LayerBaseClient::dump(String8& result, char* buffer, size_t SIZE) const
{
    LayerBase::dump(result, buffer, SIZE);

    sp<Client> client(this->client.promote());
    snprintf(buffer, SIZE,
            "      name=%s\n"
            "      id=0x%08x, client=0x%08x, identity=%u\n",
            getName().string(),
            clientIndex(), client.get() ? client->cid : 0,
            getIdentity());

    result.append(buffer);
}

// ---------------------------------------------------------------------------

LayerBaseClient::Surface::Surface(
+15 −38
Original line number Diff line number Diff line
@@ -51,33 +51,7 @@ class SurfaceFlinger;

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);

    DisplayID           dpy;
@@ -125,6 +99,9 @@ public:

            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,6 +194,9 @@ 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,
@@ -313,10 +293,6 @@ 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
@@ -331,14 +307,12 @@ public:

    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 ssize_t     serverIndex() const;
    virtual void        onRemoved();

    virtual const char* getTypeId() const { return "LayerBaseClient"; }

    class Surface : public BnSurface 
    {
@@ -373,6 +347,9 @@ public:

    friend class Surface;

protected:
    virtual void dump(String8& result, char* scratch, size_t size) const;

private:
    int32_t         mIndex;
    mutable     Mutex           mLock;
+0 −5
Original line number Diff line number Diff line
@@ -33,11 +33,6 @@
namespace android {
// ---------------------------------------------------------------------------

const uint32_t LayerBlur::typeInfo = LayerBaseClient::typeInfo | 8;
const char* const LayerBlur::typeID = "LayerBlur";

// ---------------------------------------------------------------------------

LayerBlur::LayerBlur(SurfaceFlinger* flinger, DisplayID display,
        const sp<Client>& client, int32_t i)
    : LayerBaseClient(flinger, display, client, i), mCacheDirty(true),
Loading