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

Commit c10d9d90 authored by Mathias Agopian's avatar Mathias Agopian
Browse files

clean-up. get rid ofunused code and members in Surface[Control].cpp

Change-Id: Ia7790ae28af2c2ac99eae01c2c5044ace4a490a4
parent 97c602c5
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -79,8 +79,8 @@ protected:
    // must be monotonically increasing. Its other properties (zero point, etc)
    // are client-dependent, and should be documented by the client.
    //
    // outWidth, outHeight and outTransform are filed with the default width
    // default height of the window and current transform applied to buffers,
    // outWidth, outHeight and outTransform are filled with the default width
    // and height of the window and current transform applied to buffers,
    // respectively.
    virtual status_t queueBuffer(int slot, int64_t timestamp,
            uint32_t* outWidth, uint32_t* outHeight, uint32_t* outTransform) = 0;
+0 −3
Original line number Diff line number Diff line
@@ -45,9 +45,6 @@ public:
    struct surface_data_t {
        int32_t             token;
        int32_t             identity;
        uint32_t            width;
        uint32_t            height;
        uint32_t            format;
        status_t readFromParcel(const Parcel& parcel);
        status_t writeToParcel(Parcel* parcel) const;
    };
+2 −31
Original line number Diff line number Diff line
@@ -57,7 +57,6 @@ public:
    static bool isSameSurface(
            const sp<SurfaceControl>& lhs, const sp<SurfaceControl>& rhs);
        
    uint32_t    getFlags() const { return mFlags; }
    uint32_t    getIdentity() const { return mIdentity; }

    // release surface data from java
@@ -86,25 +85,13 @@ private:
    SurfaceControl& operator = (SurfaceControl& rhs);
    SurfaceControl(const SurfaceControl& rhs);

    
    friend class SurfaceComposerClient;

    // camera and camcorder need access to the ISurface binder interface for preview
    friend class CameraService;
    friend class MediaRecorder;
    // mediaplayer needs access to ISurface for display
    friend class MediaPlayer;
    // for testing
    friend class Test;
    // videoEditor preview classes
    friend class VideoEditorPreviewController;
    friend class Surface;

    SurfaceControl(
            const sp<SurfaceComposerClient>& client,
            const sp<ISurface>& surface,
            const ISurfaceComposerClient::surface_data_t& data,
            uint32_t w, uint32_t h, PixelFormat format, uint32_t flags);
            const ISurfaceComposerClient::surface_data_t& data);

    ~SurfaceControl();

@@ -115,10 +102,6 @@ private:
    sp<ISurface>                mSurface;
    SurfaceID                   mToken;
    uint32_t                    mIdentity;
    uint32_t                    mWidth;
    uint32_t                    mHeight;
    PixelFormat                 mFormat;
    uint32_t                    mFlags;
    mutable Mutex               mLock;
    
    mutable sp<Surface>         mSurfaceData;
@@ -139,17 +122,13 @@ public:
        uint32_t    reserved[2];
    };

    static status_t writeToParcel(
            const sp<Surface>& control, Parcel* parcel);

    static status_t writeToParcel(const sp<Surface>& control, Parcel* parcel);
    static sp<Surface> readFromParcel(const Parcel& data);

    static bool isValid(const sp<Surface>& surface) {
        return (surface != 0) && surface->isValid();
    }

    bool        isValid();
    uint32_t    getFlags() const    { return mFlags; }
    uint32_t    getIdentity() const { return mIdentity; }
    sp<ISurfaceTexture> getSurfaceTexture();

@@ -176,22 +155,14 @@ private:
     *  private stuff...
     */
    void init();
    status_t validate(bool inCancelBuffer = false) const;

    static void cleanCachedSurfacesLocked();

    virtual int query(int what, int* value) const;

    // constants
    status_t                    mInitCheck;
    sp<ISurface>                mSurface;
    uint32_t                    mIdentity;
    PixelFormat                 mFormat;
    uint32_t                    mFlags;

    // query() must be called from dequeueBuffer() thread
    uint32_t                    mWidth;
    uint32_t                    mHeight;

    // A cache of Surface objects that have been deserialized into this process.
    static Mutex sCachedSurfacesLock;
+0 −6
Original line number Diff line number Diff line
@@ -132,9 +132,6 @@ status_t ISurfaceComposerClient::surface_data_t::readFromParcel(const Parcel& pa
{
    token    = parcel.readInt32();
    identity = parcel.readInt32();
    width    = parcel.readInt32();
    height   = parcel.readInt32();
    format   = parcel.readInt32();
    return NO_ERROR;
}

@@ -142,9 +139,6 @@ status_t ISurfaceComposerClient::surface_data_t::writeToParcel(Parcel* parcel) c
{
    parcel->writeInt32(token);
    parcel->writeInt32(identity);
    parcel->writeInt32(width);
    parcel->writeInt32(height);
    parcel->writeInt32(format);
    return NO_ERROR;
}

+8 −66
Original line number Diff line number Diff line
@@ -26,15 +26,12 @@
#include <utils/Log.h>
#include <utils/threads.h>

#include <binder/IMemory.h>
#include <binder/IPCThreadState.h>

#include <gui/SurfaceTextureClient.h>

#include <ui/DisplayInfo.h>
#include <ui/GraphicBuffer.h>
#include <ui/GraphicBufferMapper.h>
#include <ui/GraphicLog.h>
#include <ui/Rect.h>

#include <surfaceflinger/ISurface.h>
@@ -42,8 +39,6 @@
#include <surfaceflinger/Surface.h>
#include <surfaceflinger/SurfaceComposerClient.h>

#include <private/surfaceflinger/LayerState.h>

namespace android {

// ============================================================================
@@ -53,12 +48,9 @@ namespace android {
SurfaceControl::SurfaceControl(
        const sp<SurfaceComposerClient>& client, 
        const sp<ISurface>& surface,
        const ISurfaceComposerClient::surface_data_t& data,
        uint32_t w, uint32_t h, PixelFormat format, uint32_t flags)
        const ISurfaceComposerClient::surface_data_t& data)
    : mClient(client), mSurface(surface),
      mToken(data.token), mIdentity(data.identity),
      mWidth(data.width), mHeight(data.height), mFormat(data.format),
      mFlags(flags)
      mToken(data.token), mIdentity(data.identity)
{
}
        
@@ -187,24 +179,12 @@ status_t SurfaceControl::writeSurfaceToParcel(
{
    sp<ISurface> sur;
    uint32_t identity = 0;
    uint32_t width = 0;
    uint32_t height = 0;
    uint32_t format = 0;
    uint32_t flags = 0;
    if (SurfaceControl::isValid(control)) {
        sur      = control->mSurface;
        identity = control->mIdentity;
        width    = control->mWidth;
        height   = control->mHeight;
        format   = control->mFormat;
        flags    = control->mFlags;
    }
    parcel->writeStrongBinder(sur!=0 ? sur->asBinder() : NULL);
    parcel->writeInt32(identity);
    parcel->writeInt32(width);
    parcel->writeInt32(height);
    parcel->writeInt32(format);
    parcel->writeInt32(flags);
    return NO_ERROR;
}

@@ -225,25 +205,17 @@ sp<Surface> SurfaceControl::getSurface() const

Surface::Surface(const sp<SurfaceControl>& surface)
    : SurfaceTextureClient(),
      mInitCheck(NO_INIT),
      mSurface(surface->mSurface),
      mIdentity(surface->mIdentity),
      mFormat(surface->mFormat), mFlags(surface->mFlags),
      mWidth(surface->mWidth), mHeight(surface->mHeight)
      mIdentity(surface->mIdentity)
{
    init();
}

Surface::Surface(const Parcel& parcel, const sp<IBinder>& ref)
    : SurfaceTextureClient(),
      mInitCheck(NO_INIT)
    : SurfaceTextureClient()
{
    mSurface    = interface_cast<ISurface>(ref);
    mIdentity   = parcel.readInt32();
    mWidth      = parcel.readInt32();
    mHeight     = parcel.readInt32();
    mFormat     = parcel.readInt32();
    mFlags      = parcel.readInt32();
    init();
}

@@ -252,31 +224,16 @@ status_t Surface::writeToParcel(
{
    sp<ISurface> sur;
    uint32_t identity = 0;
    uint32_t width = 0;
    uint32_t height = 0;
    uint32_t format = 0;
    uint32_t flags = 0;
    if (Surface::isValid(surface)) {
        sur      = surface->mSurface;
        identity = surface->mIdentity;
        width    = surface->mWidth;
        height   = surface->mHeight;
        format   = surface->mFormat;
        flags    = surface->mFlags;
    } else if (surface != 0 && surface->mSurface != 0) {
        LOGW("Parceling invalid surface with non-NULL ISurface as NULL: "
             "mSurface = %p, mIdentity = %d, mWidth = %d, mHeight = %d, "
             "mFormat = %d, mFlags = 0x%08x, mInitCheck = %d",
             surface->mSurface.get(), surface->mIdentity, surface->mWidth,
             surface->mHeight, surface->mFormat, surface->mFlags,
             surface->mInitCheck);
             "mSurface = %p, mIdentity = %d",
             surface->mSurface.get(), surface->mIdentity);
    }
    parcel->writeStrongBinder(sur!=0 ? sur->asBinder() : NULL);
    parcel->writeInt32(identity);
    parcel->writeInt32(width);
    parcel->writeInt32(height);
    parcel->writeInt32(format);
    parcel->writeInt32(flags);
    return NO_ERROR;

}
@@ -325,10 +282,6 @@ void Surface::init()
        const_cast<float&>(ANativeWindow::xdpi) = dinfo.xdpi;
        const_cast<float&>(ANativeWindow::ydpi) = dinfo.ydpi;
        const_cast<uint32_t&>(ANativeWindow::flags) = 0;

        if (surfaceTexture != NULL) {
            mInitCheck = NO_ERROR;
        }
    }
}

@@ -341,21 +294,11 @@ Surface::~Surface()
}

bool Surface::isValid() {
    return mInitCheck == NO_ERROR;
}

status_t Surface::validate(bool inCancelBuffer) const
{
    // check that we initialized ourself properly
    if (mInitCheck != NO_ERROR) {
        LOGE("invalid token (identity=%u)", mIdentity);
        return mInitCheck;
    }
    return NO_ERROR;
    return getISurfaceTexture() != NULL;
}

sp<ISurfaceTexture> Surface::getSurfaceTexture() {
    return mSurface != NULL ? mSurface->getSurfaceTexture() : NULL;
    return getISurfaceTexture();
}

sp<IBinder> Surface::asBinder() const {
@@ -367,7 +310,6 @@ sp<IBinder> Surface::asBinder() const {
int Surface::query(int what, int* value) const {
    switch (what) {
    case NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER:
        // TODO: this is not needed anymore
        *value = 1;
        return NO_ERROR;
    case NATIVE_WINDOW_CONCRETE_TYPE:
Loading