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

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

unify SurfaceTexture and Surface

Change-Id: I49da2f5d8408e4cd7e148cfb777bb4ff68cd8f37
parent c04f1533
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -31,11 +31,16 @@
namespace android {
// ----------------------------------------------------------------------------

class SurfaceTextureClient;

class ISurfaceTexture : public IInterface
{
public:
    DECLARE_META_INTERFACE(SurfaceTexture);

protected:
    friend class SurfaceTextureClient;

    enum { BUFFER_NEEDS_REALLOCATION = 1 };

    // requestBuffer requests a new buffer for the given index. The server (i.e.
@@ -85,6 +90,10 @@ public:
    // Holding this binder reference prevents SurfaceFlinger from freeing the
    // buffers before the client is done with them.
    virtual sp<IBinder> getAllocator() = 0;

    // query retrieves some information for this surface
    // 'what' tokens allowed are that of android_natives.h
    virtual int query(int what, int* value) = 0;
};

// ----------------------------------------------------------------------------
+2 −0
Original line number Diff line number Diff line
@@ -76,6 +76,8 @@ public:
    virtual status_t setCrop(const Rect& reg);
    virtual status_t setTransform(uint32_t transform);

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

    // updateTexImage sets the image contents of the target texture to that of
    // the most recently queued buffer.
    //
+21 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ enum {
    SET_CROP,
    SET_TRANSFORM,
    GET_ALLOCATOR,
    QUERY,
};


@@ -132,6 +133,17 @@ public:
        remote()->transact(GET_ALLOCATOR, data, &reply);
        return reply.readStrongBinder();
    }

    virtual int query(int what, int* value) {
        Parcel data, reply;
        data.writeInterfaceToken(ISurfaceTexture::getInterfaceDescriptor());
        data.writeInt32(what);
        remote()->transact(QUERY, data, &reply);
        value[0] = reply.readInt32();
        status_t result = reply.readInt32();
        return result;
    }

};

IMPLEMENT_META_INTERFACE(SurfaceTexture, "android.gui.SurfaceTexture");
@@ -209,6 +221,15 @@ status_t BnSurfaceTexture::onTransact(
            reply->writeStrongBinder(result);
            return NO_ERROR;
        } break;
        case QUERY: {
            CHECK_INTERFACE(ISurfaceTexture, data, reply);
            int value;
            int what = data.readInt32();
            int res = query(what, &value);
            reply->writeInt32(value);
            reply->writeInt32(res);
            return NO_ERROR;
        } break;
    }
    return BBinder::onTransact(code, data, reply, flags);
}
+28 −0
Original line number Diff line number Diff line
@@ -509,6 +509,34 @@ uint32_t SurfaceTexture::getCurrentTransform() const {
    return mCurrentTransform;
}

int SurfaceTexture::query(int what, int* outValue)
{
    Mutex::Autolock lock(mMutex);
    int value;
    switch (what) {
    case NATIVE_WINDOW_WIDTH:
        value = mDefaultWidth;
        if (!mDefaultWidth && !mDefaultHeight && mCurrentTextureBuf!=0)
            value = mCurrentTextureBuf->width;
        break;
    case NATIVE_WINDOW_HEIGHT:
        value = mDefaultHeight;
        if (!mDefaultWidth && !mDefaultHeight && mCurrentTextureBuf!=0)
            value = mCurrentTextureBuf->height;
        break;
    case NATIVE_WINDOW_FORMAT:
        value = mPixelFormat;
        break;
    case NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS:
        value = mSynchronousMode ?
                (MIN_UNDEQUEUED_BUFFERS-1) : MIN_UNDEQUEUED_BUFFERS;
        break;
    default:
        return BAD_VALUE;
    }
    outValue[0] = value;
    return NO_ERROR;
}

static void mtxMul(float out[16], const float a[16], const float b[16]) {
    out[0] = a[0]*b[0] + a[4]*b[1] + a[8]*b[2] + a[12]*b[3];
+3 −15
Original line number Diff line number Diff line
@@ -159,29 +159,17 @@ int SurfaceTextureClient::queueBuffer(android_native_buffer_t* buffer) {

int SurfaceTextureClient::query(int what, int* value) const {
    LOGV("SurfaceTextureClient::query");
    Mutex::Autolock lock(mMutex);
    switch (what) {
    case NATIVE_WINDOW_WIDTH:
        *value = mQueryWidth ? mQueryWidth : mReqWidth;
        return NO_ERROR;
    case NATIVE_WINDOW_HEIGHT:
        *value = mQueryHeight ? mQueryHeight : mReqHeight;
        return NO_ERROR;
    case NATIVE_WINDOW_FORMAT:
        *value = mQueryFormat ? mQueryFormat : mReqFormat;
        return NO_ERROR;
    case NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS:
        *value = MIN_UNDEQUEUED_BUFFERS;
        return NO_ERROR;
    case NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER:
        // SurfaceTextureClient currently never queues frames to SurfaceFlinger.
        // TODO: this is not needed anymore
        *value = 0;
        return NO_ERROR;
    case NATIVE_WINDOW_CONCRETE_TYPE:
        // TODO: this is not needed anymore
        *value = NATIVE_WINDOW_SURFACE_TEXTURE_CLIENT;
        return NO_ERROR;
    }
    return BAD_VALUE;
    return mSurfaceTexture->query(what, value);
}

int SurfaceTextureClient::perform(int operation, va_list args)
Loading