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

Commit 33567404 authored by Mathias Agopian's avatar Mathias Agopian Committed by Android (Google) Code Review
Browse files

Merge changes I4d50e985,Iaa2baa66

* changes:
  use SurfaceTexture new scaling mode in SF
  Add set_scaling_mode() to ANativeWindow.
parents 58791ddd 933389f7
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -87,6 +87,7 @@ protected:

    virtual status_t setCrop(const Rect& reg) = 0;
    virtual status_t setTransform(uint32_t transform) = 0;
    virtual status_t setScalingMode(int mode) = 0;

    // getAllocator retrieves the binder object that must be referenced as long
    // as the GraphicBuffers dequeued from this ISurfaceTexture are referenced.
+21 −3
Original line number Diff line number Diff line
@@ -88,6 +88,7 @@ public:
    virtual void cancelBuffer(int buf);
    virtual status_t setCrop(const Rect& reg);
    virtual status_t setTransform(uint32_t transform);
    virtual status_t setScalingMode(int mode);

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

@@ -185,6 +186,9 @@ public:
    // getCurrentTransform returns the transform of the current buffer
    uint32_t getCurrentTransform() const;

    // getCurrentScalingMode returns the scaling mode of the current buffer
    uint32_t getCurrentScalingMode() const;

    // dump our state in a String
    void dump(String8& result) const;
    void dump(String8& result, const char* prefix, char* buffer, size_t SIZE) const;
@@ -220,6 +224,7 @@ private:
              mBufferState(BufferSlot::FREE),
              mRequestBufferCalled(false),
              mTransform(0),
              mScalingMode(NATIVE_WINDOW_SCALING_MODE_FREEZE),
              mTimestamp(0) {
            mCrop.makeInvalid();
        }
@@ -281,6 +286,11 @@ private:
        // slot.
        uint32_t mTransform;

        // mScalingMode is the current scaling mode for this buffer slot. This
        // gets set to mNextScalingMode each time queueBuffer gets called for
        // this slot.
        uint32_t mScalingMode;

        // mTimestamp is the current timestamp for this buffer slot. This gets
        // to set by queueBuffer each time this slot is queued.
        int64_t mTimestamp;
@@ -337,20 +347,24 @@ private:
    sp<GraphicBuffer> mCurrentTextureBuf;

    // mCurrentCrop is the crop rectangle that applies to the current texture.
    // It gets set to mLastQueuedCrop each time updateTexImage is called.
    // It gets set each time updateTexImage is called.
    Rect mCurrentCrop;

    // mCurrentTransform is the transform identifier for the current texture. It
    // gets set to mLastQueuedTransform each time updateTexImage is called.
    // gets set each time updateTexImage is called.
    uint32_t mCurrentTransform;

    // mCurrentScalingMode is the scaling mode for the current texture. It gets
    // set to each time updateTexImage is called.
    uint32_t mCurrentScalingMode;

    // mCurrentTransformMatrix is the transform matrix for the current texture.
    // It gets computed by computeTransformMatrix each time updateTexImage is
    // called.
    float mCurrentTransformMatrix[16];

    // mCurrentTimestamp is the timestamp for the current texture. It
    // gets set to mLastQueuedTimestamp each time updateTexImage is called.
    // gets set each time updateTexImage is called.
    int64_t mCurrentTimestamp;

    // mNextCrop is the crop rectangle that will be used for the next buffer
@@ -361,6 +375,10 @@ private:
    // buffer that gets queued. It is set by calling setTransform.
    uint32_t mNextTransform;

    // mNextScalingMode is the scaling mode that will be used for the next
    // buffers that get queued. It is set by calling setScalingMode.
    int mNextScalingMode;

    // mTexName is the name of the OpenGL texture to which streamed images will
    // be bound when updateTexImage is called. It is set at construction time
    // changed with a call to setTexName.
+2 −0
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ private:
    int dispatchSetBuffersGeometry(va_list args);
    int dispatchSetBuffersDimensions(va_list args);
    int dispatchSetBuffersFormat(va_list args);
    int dispatchSetScalingMode(va_list args);
    int dispatchSetBuffersTransform(va_list args);
    int dispatchSetBuffersTimestamp(va_list args);
    int dispatchSetCrop(va_list args);
@@ -84,6 +85,7 @@ protected:
    virtual int setBufferCount(int bufferCount);
    virtual int setBuffersDimensions(int w, int h);
    virtual int setBuffersFormat(int format);
    virtual int setScalingMode(int mode);
    virtual int setBuffersTransform(int transform);
    virtual int setBuffersTimestamp(int64_t timestamp);
    virtual int setCrop(Rect const* rect);
+17 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ enum {
    SET_SYNCHRONOUS_MODE,
    CONNECT,
    DISCONNECT,
    SET_SCALING_MODE,
};


@@ -130,6 +131,15 @@ public:
        return result;
    }

    virtual status_t setScalingMode(int mode) {
        Parcel data, reply;
        data.writeInterfaceToken(ISurfaceTexture::getInterfaceDescriptor());
        data.writeInt32(mode);
        remote()->transact(SET_SCALING_MODE, data, &reply);
        status_t result = reply.readInt32();
        return result;
    }

    virtual sp<IBinder> getAllocator() {
        Parcel data, reply;
        data.writeInterfaceToken(ISurfaceTexture::getInterfaceDescriptor());
@@ -244,6 +254,13 @@ status_t BnSurfaceTexture::onTransact(
            reply->writeInt32(result);
            return NO_ERROR;
        } break;
        case SET_SCALING_MODE: {
            CHECK_INTERFACE(ISurfaceTexture, data, reply);
            int mode = data.readInt32();
            status_t result = setScalingMode(mode);
            reply->writeInt32(result);
            return NO_ERROR;
        } break;
        case GET_ALLOCATOR: {
            CHECK_INTERFACE(ISurfaceTexture, data, reply);
            sp<IBinder> result = getAllocator();
+24 −0
Original line number Diff line number Diff line
@@ -90,6 +90,7 @@ SurfaceTexture::SurfaceTexture(GLuint tex, bool allowSynchronousMode) :
    mCurrentTransform(0),
    mCurrentTimestamp(0),
    mNextTransform(0),
    mNextScalingMode(NATIVE_WINDOW_SCALING_MODE_FREEZE),
    mTexName(tex),
    mSynchronousMode(false),
    mAllowSynchronousMode(allowSynchronousMode),
@@ -453,6 +454,7 @@ status_t SurfaceTexture::queueBuffer(int buf, int64_t timestamp) {
        mSlots[buf].mBufferState = BufferSlot::QUEUED;
        mSlots[buf].mCrop = mNextCrop;
        mSlots[buf].mTransform = mNextTransform;
        mSlots[buf].mScalingMode = mNextScalingMode;
        mSlots[buf].mTimestamp = timestamp;
        mDequeueCondition.signal();
    } // scope for the lock
@@ -542,6 +544,22 @@ status_t SurfaceTexture::disconnect(int api) {
    return err;
}

status_t SurfaceTexture::setScalingMode(int mode) {
    LOGV("SurfaceTexture::setScalingMode(%d)", mode);

    switch (mode) {
        case NATIVE_WINDOW_SCALING_MODE_FREEZE:
        case NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW:
            break;
        default:
            return BAD_VALUE;
    }

    Mutex::Autolock lock(mMutex);
    mNextScalingMode = mode;
    return OK;
}

status_t SurfaceTexture::updateTexImage() {
    LOGV("SurfaceTexture::updateTexImage");
    Mutex::Autolock lock(mMutex);
@@ -602,6 +620,7 @@ status_t SurfaceTexture::updateTexImage() {
        mCurrentTextureBuf = mSlots[buf].mGraphicBuffer;
        mCurrentCrop = mSlots[buf].mCrop;
        mCurrentTransform = mSlots[buf].mTransform;
        mCurrentScalingMode = mSlots[buf].mScalingMode;
        mCurrentTimestamp = mSlots[buf].mTimestamp;
        computeCurrentTransformMatrix();

@@ -809,6 +828,11 @@ uint32_t SurfaceTexture::getCurrentTransform() const {
    return mCurrentTransform;
}

uint32_t SurfaceTexture::getCurrentScalingMode() const {
    Mutex::Autolock lock(mMutex);
    return mCurrentScalingMode;
}

int SurfaceTexture::query(int what, int* outValue)
{
    Mutex::Autolock lock(mMutex);
Loading