summaryrefslogtreecommitdiffstats
path: root/libs/gui
diff options
context:
space:
mode:
Diffstat (limited to 'libs/gui')
-rw-r--r--libs/gui/ISurfaceTexture.cpp17
-rw-r--r--libs/gui/SurfaceTexture.cpp24
-rw-r--r--libs/gui/SurfaceTextureClient.cpp20
3 files changed, 61 insertions, 0 deletions
diff --git a/libs/gui/ISurfaceTexture.cpp b/libs/gui/ISurfaceTexture.cpp
index 41434a4..b4b7492 100644
--- a/libs/gui/ISurfaceTexture.cpp
+++ b/libs/gui/ISurfaceTexture.cpp
@@ -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();
diff --git a/libs/gui/SurfaceTexture.cpp b/libs/gui/SurfaceTexture.cpp
index a12d40a..cc9f461 100644
--- a/libs/gui/SurfaceTexture.cpp
+++ b/libs/gui/SurfaceTexture.cpp
@@ -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);
diff --git a/libs/gui/SurfaceTextureClient.cpp b/libs/gui/SurfaceTextureClient.cpp
index d5b7c89..fec80ef 100644
--- a/libs/gui/SurfaceTextureClient.cpp
+++ b/libs/gui/SurfaceTextureClient.cpp
@@ -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");