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 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.
|
||||
|
@ -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.
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -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");
|
||||
|
||||
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);
|
||||
|
@ -286,6 +286,9 @@ int SurfaceTextureClient::perform(int operation, va_list args)
|
||||
case NATIVE_WINDOW_UNLOCK_AND_POST:
|
||||
res = dispatchUnlockAndPost(args);
|
||||
break;
|
||||
case NATIVE_WINDOW_SET_SCALING_MODE:
|
||||
res = dispatchSetScalingMode(args);
|
||||
break;
|
||||
default:
|
||||
res = NAME_NOT_FOUND;
|
||||
break;
|
||||
@ -340,6 +343,11 @@ int SurfaceTextureClient::dispatchSetBuffersFormat(va_list args) {
|
||||
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 transform = va_arg(args, int);
|
||||
return setBuffersTransform(transform);
|
||||
@ -456,6 +464,18 @@ int SurfaceTextureClient::setBuffersFormat(int format)
|
||||
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)
|
||||
{
|
||||
LOGV("SurfaceTextureClient::setBuffersTransform");
|
||||
|
@ -299,18 +299,38 @@ int FramebufferNativeWindow::perform(ANativeWindow* window,
|
||||
{
|
||||
switch (operation) {
|
||||
case NATIVE_WINDOW_SET_USAGE:
|
||||
case NATIVE_WINDOW_SET_BUFFERS_FORMAT:
|
||||
// TODO: we should implement this
|
||||
return NO_ERROR;
|
||||
case NATIVE_WINDOW_CONNECT:
|
||||
// TODO: we should implement this
|
||||
return NO_ERROR;
|
||||
case NATIVE_WINDOW_DISCONNECT:
|
||||
break;
|
||||
// TODO: we should implement this
|
||||
return NO_ERROR;
|
||||
case NATIVE_WINDOW_LOCK:
|
||||
return INVALID_OPERATION;
|
||||
case NATIVE_WINDOW_UNLOCK_AND_POST:
|
||||
return INVALID_OPERATION;
|
||||
default:
|
||||
return NAME_NOT_FOUND;
|
||||
case NATIVE_WINDOW_SET_CROP:
|
||||
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;
|
||||
case NATIVE_WINDOW_SET_SCALING_MODE:
|
||||
return INVALID_OPERATION;
|
||||
}
|
||||
return NO_ERROR;
|
||||
return NAME_NOT_FOUND;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user