Add set_scaling_mode() to ANativeWindow.
This allows to specify the scaling mode independently from the buffer size. Change-Id: Iaa2baa660445531a97d3fac192e580f4929c5d3b
This commit is contained in:
parent
0c696c1ad2
commit
7734ebfe47
@ -87,6 +87,7 @@ protected:
|
|||||||
|
|
||||||
virtual status_t setCrop(const Rect& reg) = 0;
|
virtual status_t setCrop(const Rect& reg) = 0;
|
||||||
virtual status_t setTransform(uint32_t transform) = 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
|
// getAllocator retrieves the binder object that must be referenced as long
|
||||||
// as the GraphicBuffers dequeued from this ISurfaceTexture are referenced.
|
// as the GraphicBuffers dequeued from this ISurfaceTexture are referenced.
|
||||||
|
@ -88,6 +88,7 @@ public:
|
|||||||
virtual void cancelBuffer(int buf);
|
virtual void cancelBuffer(int buf);
|
||||||
virtual status_t setCrop(const Rect& reg);
|
virtual status_t setCrop(const Rect& reg);
|
||||||
virtual status_t setTransform(uint32_t transform);
|
virtual status_t setTransform(uint32_t transform);
|
||||||
|
virtual status_t setScalingMode(int mode);
|
||||||
|
|
||||||
virtual int query(int what, int* value);
|
virtual int query(int what, int* value);
|
||||||
|
|
||||||
@ -185,6 +186,9 @@ public:
|
|||||||
// getCurrentTransform returns the transform of the current buffer
|
// getCurrentTransform returns the transform of the current buffer
|
||||||
uint32_t getCurrentTransform() const;
|
uint32_t getCurrentTransform() const;
|
||||||
|
|
||||||
|
// getCurrentScalingMode returns the scaling mode of the current buffer
|
||||||
|
uint32_t getCurrentScalingMode() const;
|
||||||
|
|
||||||
// dump our state in a String
|
// dump our state in a String
|
||||||
void dump(String8& result) const;
|
void dump(String8& result) const;
|
||||||
void dump(String8& result, const char* prefix, char* buffer, size_t SIZE) const;
|
void dump(String8& result, const char* prefix, char* buffer, size_t SIZE) const;
|
||||||
@ -220,6 +224,7 @@ private:
|
|||||||
mBufferState(BufferSlot::FREE),
|
mBufferState(BufferSlot::FREE),
|
||||||
mRequestBufferCalled(false),
|
mRequestBufferCalled(false),
|
||||||
mTransform(0),
|
mTransform(0),
|
||||||
|
mScalingMode(NATIVE_WINDOW_SCALING_MODE_FREEZE),
|
||||||
mTimestamp(0) {
|
mTimestamp(0) {
|
||||||
mCrop.makeInvalid();
|
mCrop.makeInvalid();
|
||||||
}
|
}
|
||||||
@ -281,6 +286,11 @@ private:
|
|||||||
// slot.
|
// slot.
|
||||||
uint32_t mTransform;
|
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
|
// mTimestamp is the current timestamp for this buffer slot. This gets
|
||||||
// to set by queueBuffer each time this slot is queued.
|
// to set by queueBuffer each time this slot is queued.
|
||||||
int64_t mTimestamp;
|
int64_t mTimestamp;
|
||||||
@ -337,20 +347,24 @@ private:
|
|||||||
sp<GraphicBuffer> mCurrentTextureBuf;
|
sp<GraphicBuffer> mCurrentTextureBuf;
|
||||||
|
|
||||||
// mCurrentCrop is the crop rectangle that applies to the current texture.
|
// 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;
|
Rect mCurrentCrop;
|
||||||
|
|
||||||
// mCurrentTransform is the transform identifier for the current texture. It
|
// 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;
|
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.
|
// mCurrentTransformMatrix is the transform matrix for the current texture.
|
||||||
// It gets computed by computeTransformMatrix each time updateTexImage is
|
// It gets computed by computeTransformMatrix each time updateTexImage is
|
||||||
// called.
|
// called.
|
||||||
float mCurrentTransformMatrix[16];
|
float mCurrentTransformMatrix[16];
|
||||||
|
|
||||||
// mCurrentTimestamp is the timestamp for the current texture. It
|
// 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;
|
int64_t mCurrentTimestamp;
|
||||||
|
|
||||||
// mNextCrop is the crop rectangle that will be used for the next buffer
|
// 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.
|
// buffer that gets queued. It is set by calling setTransform.
|
||||||
uint32_t mNextTransform;
|
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
|
// 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
|
// be bound when updateTexImage is called. It is set at construction time
|
||||||
// changed with a call to setTexName.
|
// changed with a call to setTexName.
|
||||||
|
@ -63,6 +63,7 @@ private:
|
|||||||
int dispatchSetBuffersGeometry(va_list args);
|
int dispatchSetBuffersGeometry(va_list args);
|
||||||
int dispatchSetBuffersDimensions(va_list args);
|
int dispatchSetBuffersDimensions(va_list args);
|
||||||
int dispatchSetBuffersFormat(va_list args);
|
int dispatchSetBuffersFormat(va_list args);
|
||||||
|
int dispatchSetScalingMode(va_list args);
|
||||||
int dispatchSetBuffersTransform(va_list args);
|
int dispatchSetBuffersTransform(va_list args);
|
||||||
int dispatchSetBuffersTimestamp(va_list args);
|
int dispatchSetBuffersTimestamp(va_list args);
|
||||||
int dispatchSetCrop(va_list args);
|
int dispatchSetCrop(va_list args);
|
||||||
@ -84,6 +85,7 @@ protected:
|
|||||||
virtual int setBufferCount(int bufferCount);
|
virtual int setBufferCount(int bufferCount);
|
||||||
virtual int setBuffersDimensions(int w, int h);
|
virtual int setBuffersDimensions(int w, int h);
|
||||||
virtual int setBuffersFormat(int format);
|
virtual int setBuffersFormat(int format);
|
||||||
|
virtual int setScalingMode(int mode);
|
||||||
virtual int setBuffersTransform(int transform);
|
virtual int setBuffersTransform(int transform);
|
||||||
virtual int setBuffersTimestamp(int64_t timestamp);
|
virtual int setBuffersTimestamp(int64_t timestamp);
|
||||||
virtual int setCrop(Rect const* rect);
|
virtual int setCrop(Rect const* rect);
|
||||||
|
@ -43,6 +43,7 @@ enum {
|
|||||||
SET_SYNCHRONOUS_MODE,
|
SET_SYNCHRONOUS_MODE,
|
||||||
CONNECT,
|
CONNECT,
|
||||||
DISCONNECT,
|
DISCONNECT,
|
||||||
|
SET_SCALING_MODE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -130,6 +131,15 @@ public:
|
|||||||
return result;
|
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() {
|
virtual sp<IBinder> getAllocator() {
|
||||||
Parcel data, reply;
|
Parcel data, reply;
|
||||||
data.writeInterfaceToken(ISurfaceTexture::getInterfaceDescriptor());
|
data.writeInterfaceToken(ISurfaceTexture::getInterfaceDescriptor());
|
||||||
@ -244,6 +254,13 @@ status_t BnSurfaceTexture::onTransact(
|
|||||||
reply->writeInt32(result);
|
reply->writeInt32(result);
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
} break;
|
} 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: {
|
case GET_ALLOCATOR: {
|
||||||
CHECK_INTERFACE(ISurfaceTexture, data, reply);
|
CHECK_INTERFACE(ISurfaceTexture, data, reply);
|
||||||
sp<IBinder> result = getAllocator();
|
sp<IBinder> result = getAllocator();
|
||||||
|
@ -90,6 +90,7 @@ SurfaceTexture::SurfaceTexture(GLuint tex, bool allowSynchronousMode) :
|
|||||||
mCurrentTransform(0),
|
mCurrentTransform(0),
|
||||||
mCurrentTimestamp(0),
|
mCurrentTimestamp(0),
|
||||||
mNextTransform(0),
|
mNextTransform(0),
|
||||||
|
mNextScalingMode(NATIVE_WINDOW_SCALING_MODE_FREEZE),
|
||||||
mTexName(tex),
|
mTexName(tex),
|
||||||
mSynchronousMode(false),
|
mSynchronousMode(false),
|
||||||
mAllowSynchronousMode(allowSynchronousMode),
|
mAllowSynchronousMode(allowSynchronousMode),
|
||||||
@ -453,6 +454,7 @@ status_t SurfaceTexture::queueBuffer(int buf, int64_t timestamp) {
|
|||||||
mSlots[buf].mBufferState = BufferSlot::QUEUED;
|
mSlots[buf].mBufferState = BufferSlot::QUEUED;
|
||||||
mSlots[buf].mCrop = mNextCrop;
|
mSlots[buf].mCrop = mNextCrop;
|
||||||
mSlots[buf].mTransform = mNextTransform;
|
mSlots[buf].mTransform = mNextTransform;
|
||||||
|
mSlots[buf].mScalingMode = mNextScalingMode;
|
||||||
mSlots[buf].mTimestamp = timestamp;
|
mSlots[buf].mTimestamp = timestamp;
|
||||||
mDequeueCondition.signal();
|
mDequeueCondition.signal();
|
||||||
} // scope for the lock
|
} // scope for the lock
|
||||||
@ -542,6 +544,22 @@ status_t SurfaceTexture::disconnect(int api) {
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
status_t SurfaceTexture::setScalingMode(int mode) {
|
||||||
|
LOGV("SurfaceTexture::setScalingMode");
|
||||||
|
|
||||||
|
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() {
|
status_t SurfaceTexture::updateTexImage() {
|
||||||
LOGV("SurfaceTexture::updateTexImage");
|
LOGV("SurfaceTexture::updateTexImage");
|
||||||
Mutex::Autolock lock(mMutex);
|
Mutex::Autolock lock(mMutex);
|
||||||
@ -602,6 +620,7 @@ status_t SurfaceTexture::updateTexImage() {
|
|||||||
mCurrentTextureBuf = mSlots[buf].mGraphicBuffer;
|
mCurrentTextureBuf = mSlots[buf].mGraphicBuffer;
|
||||||
mCurrentCrop = mSlots[buf].mCrop;
|
mCurrentCrop = mSlots[buf].mCrop;
|
||||||
mCurrentTransform = mSlots[buf].mTransform;
|
mCurrentTransform = mSlots[buf].mTransform;
|
||||||
|
mCurrentScalingMode = mSlots[buf].mScalingMode;
|
||||||
mCurrentTimestamp = mSlots[buf].mTimestamp;
|
mCurrentTimestamp = mSlots[buf].mTimestamp;
|
||||||
computeCurrentTransformMatrix();
|
computeCurrentTransformMatrix();
|
||||||
|
|
||||||
@ -809,6 +828,11 @@ uint32_t SurfaceTexture::getCurrentTransform() const {
|
|||||||
return mCurrentTransform;
|
return mCurrentTransform;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t SurfaceTexture::getCurrentScalingMode() const {
|
||||||
|
Mutex::Autolock lock(mMutex);
|
||||||
|
return mCurrentScalingMode;
|
||||||
|
}
|
||||||
|
|
||||||
int SurfaceTexture::query(int what, int* outValue)
|
int SurfaceTexture::query(int what, int* outValue)
|
||||||
{
|
{
|
||||||
Mutex::Autolock lock(mMutex);
|
Mutex::Autolock lock(mMutex);
|
||||||
|
@ -286,6 +286,9 @@ int SurfaceTextureClient::perform(int operation, va_list args)
|
|||||||
case NATIVE_WINDOW_UNLOCK_AND_POST:
|
case NATIVE_WINDOW_UNLOCK_AND_POST:
|
||||||
res = dispatchUnlockAndPost(args);
|
res = dispatchUnlockAndPost(args);
|
||||||
break;
|
break;
|
||||||
|
case NATIVE_WINDOW_SET_SCALING_MODE:
|
||||||
|
res = dispatchSetScalingMode(args);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
res = NAME_NOT_FOUND;
|
res = NAME_NOT_FOUND;
|
||||||
break;
|
break;
|
||||||
@ -340,6 +343,11 @@ int SurfaceTextureClient::dispatchSetBuffersFormat(va_list args) {
|
|||||||
return setBuffersFormat(f);
|
return setBuffersFormat(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int SurfaceTextureClient::dispatchSetScalingMode(va_list args) {
|
||||||
|
int m = va_arg(args, int);
|
||||||
|
return setScalingMode(m);
|
||||||
|
}
|
||||||
|
|
||||||
int SurfaceTextureClient::dispatchSetBuffersTransform(va_list args) {
|
int SurfaceTextureClient::dispatchSetBuffersTransform(va_list args) {
|
||||||
int transform = va_arg(args, int);
|
int transform = va_arg(args, int);
|
||||||
return setBuffersTransform(transform);
|
return setBuffersTransform(transform);
|
||||||
@ -456,6 +464,18 @@ int SurfaceTextureClient::setBuffersFormat(int format)
|
|||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int SurfaceTextureClient::setScalingMode(int mode)
|
||||||
|
{
|
||||||
|
LOGV("SurfaceTextureClient::setScalingMode");
|
||||||
|
Mutex::Autolock lock(mMutex);
|
||||||
|
// mode is validated on the server
|
||||||
|
status_t err = mSurfaceTexture->setScalingMode(mode);
|
||||||
|
LOGE_IF(err, "ISurfaceTexture::setScalingMode(%d) returned %s",
|
||||||
|
mode, strerror(-err));
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
int SurfaceTextureClient::setBuffersTransform(int transform)
|
int SurfaceTextureClient::setBuffersTransform(int transform)
|
||||||
{
|
{
|
||||||
LOGV("SurfaceTextureClient::setBuffersTransform");
|
LOGV("SurfaceTextureClient::setBuffersTransform");
|
||||||
|
@ -299,18 +299,38 @@ int FramebufferNativeWindow::perform(ANativeWindow* window,
|
|||||||
{
|
{
|
||||||
switch (operation) {
|
switch (operation) {
|
||||||
case NATIVE_WINDOW_SET_USAGE:
|
case NATIVE_WINDOW_SET_USAGE:
|
||||||
case NATIVE_WINDOW_SET_BUFFERS_FORMAT:
|
// TODO: we should implement this
|
||||||
|
return NO_ERROR;
|
||||||
case NATIVE_WINDOW_CONNECT:
|
case NATIVE_WINDOW_CONNECT:
|
||||||
|
// TODO: we should implement this
|
||||||
|
return NO_ERROR;
|
||||||
case NATIVE_WINDOW_DISCONNECT:
|
case NATIVE_WINDOW_DISCONNECT:
|
||||||
break;
|
// TODO: we should implement this
|
||||||
|
return NO_ERROR;
|
||||||
case NATIVE_WINDOW_LOCK:
|
case NATIVE_WINDOW_LOCK:
|
||||||
return INVALID_OPERATION;
|
return INVALID_OPERATION;
|
||||||
case NATIVE_WINDOW_UNLOCK_AND_POST:
|
case NATIVE_WINDOW_UNLOCK_AND_POST:
|
||||||
return INVALID_OPERATION;
|
return INVALID_OPERATION;
|
||||||
default:
|
case NATIVE_WINDOW_SET_CROP:
|
||||||
return NAME_NOT_FOUND;
|
return INVALID_OPERATION;
|
||||||
}
|
case NATIVE_WINDOW_SET_BUFFER_COUNT:
|
||||||
|
// TODO: we should implement this
|
||||||
|
return INVALID_OPERATION;
|
||||||
|
case NATIVE_WINDOW_SET_BUFFERS_GEOMETRY:
|
||||||
|
return INVALID_OPERATION;
|
||||||
|
case NATIVE_WINDOW_SET_BUFFERS_TRANSFORM:
|
||||||
|
return INVALID_OPERATION;
|
||||||
|
case NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP:
|
||||||
|
return INVALID_OPERATION;
|
||||||
|
case NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS:
|
||||||
|
return INVALID_OPERATION;
|
||||||
|
case NATIVE_WINDOW_SET_BUFFERS_FORMAT:
|
||||||
|
// TODO: we should implement this
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
|
case NATIVE_WINDOW_SET_SCALING_MODE:
|
||||||
|
return INVALID_OPERATION;
|
||||||
|
}
|
||||||
|
return NAME_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user