summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJamie Gennis <jgennis@google.com>2011-01-28 18:21:54 -0800
committerJamie Gennis <jgennis@google.com>2011-01-28 18:21:54 -0800
commit2ece4cdc3fd0f8a45a889c711dba7165729e8ca5 (patch)
treea76c7f3eed692edcce369a6ae198202fdd1c7500
parent0982dc6488a921d9d54d23b9180a9acf33c61526 (diff)
downloadframeworks_base-2ece4cdc3fd0f8a45a889c711dba7165729e8ca5.zip
frameworks_base-2ece4cdc3fd0f8a45a889c711dba7165729e8ca5.tar.gz
frameworks_base-2ece4cdc3fd0f8a45a889c711dba7165729e8ca5.tar.bz2
Reset ANativeWindow crop on buffer geometry changes.
This changes the ANativeWindow API and the two implementations to reset the window's crop rectangle to be uncropped when the window's buffer geometry is changed. Bug: 3359604 Change-Id: I64283dc8382ae687787ec0bebe6a5d5b4a0dcd6b
-rw-r--r--include/ui/egl/android_natives.h2
-rw-r--r--libs/gui/SurfaceTextureClient.cpp17
-rw-r--r--libs/surfaceflinger_client/Surface.cpp15
-rw-r--r--services/surfaceflinger/LayerBase.cpp8
4 files changed, 26 insertions, 16 deletions
diff --git a/include/ui/egl/android_natives.h b/include/ui/egl/android_natives.h
index 654d0f3..fdc8105 100644
--- a/include/ui/egl/android_natives.h
+++ b/include/ui/egl/android_natives.h
@@ -315,6 +315,8 @@ static inline int native_window_set_buffer_count(
* If all parameters are 0, the normal behavior is restored. That is,
* dequeued buffers following this call will be sized to the window's size.
*
+ * Calling this function will reset the window crop to a NULL value, which
+ * disables cropping of the buffers.
*/
static inline int native_window_set_buffers_geometry(
ANativeWindow* window,
diff --git a/libs/gui/SurfaceTextureClient.cpp b/libs/gui/SurfaceTextureClient.cpp
index c0e4e0f..50cbdb8 100644
--- a/libs/gui/SurfaceTextureClient.cpp
+++ b/libs/gui/SurfaceTextureClient.cpp
@@ -238,13 +238,15 @@ int SurfaceTextureClient::setCrop(Rect const* rect)
LOGV("SurfaceTextureClient::setCrop");
Mutex::Autolock lock(mMutex);
- // empty/invalid rects are not allowed
- if (rect->isEmpty())
- return BAD_VALUE;
+ Rect realRect;
+ if (rect == NULL || rect->isEmpty()) {
+ realRect = Rect(0, 0);
+ } else {
+ realRect = *rect;
+ }
status_t err = mSurfaceTexture->setCrop(*rect);
- LOGE_IF(err, "ISurfaceTexture::setCrop(...) returned %s",
- strerror(-err));
+ LOGE_IF(err, "ISurfaceTexture::setCrop(...) returned %s", strerror(-err));
return err;
}
@@ -280,7 +282,10 @@ int SurfaceTextureClient::setBuffersGeometry(int w, int h, int format)
mReqHeight = h;
mReqFormat = format;
- return NO_ERROR;
+ status_t err = mSurfaceTexture->setCrop(Rect(0, 0));
+ LOGE_IF(err, "ISurfaceTexture::setCrop(...) returned %s", strerror(-err));
+
+ return err;
}
int SurfaceTextureClient::setBuffersTransform(int transform)
diff --git a/libs/surfaceflinger_client/Surface.cpp b/libs/surfaceflinger_client/Surface.cpp
index e21bab7..1e9bd74 100644
--- a/libs/surfaceflinger_client/Surface.cpp
+++ b/libs/surfaceflinger_client/Surface.cpp
@@ -827,13 +827,15 @@ int Surface::disconnect(int api)
int Surface::crop(Rect const* rect)
{
- // empty/invalid rects are not allowed
- if (rect->isEmpty())
- return BAD_VALUE;
-
Mutex::Autolock _l(mSurfaceLock);
// TODO: validate rect size
- mNextBufferCrop = *rect;
+
+ if (rect == NULL || rect->isEmpty()) {
+ mNextBufferCrop = Rect(0,0);
+ } else {
+ mNextBufferCrop = *rect;
+ }
+
return NO_ERROR;
}
@@ -884,6 +886,9 @@ int Surface::setBuffersGeometry(int w, int h, int format)
// EGLConfig validation.
mFormat = format;
}
+
+ mNextBufferCrop = Rect(0,0);
+
return NO_ERROR;
}
diff --git a/services/surfaceflinger/LayerBase.cpp b/services/surfaceflinger/LayerBase.cpp
index 8d83f0b..86057f8 100644
--- a/services/surfaceflinger/LayerBase.cpp
+++ b/services/surfaceflinger/LayerBase.cpp
@@ -498,11 +498,9 @@ void LayerBase::drawWithOpenGL(const Region& clip, const Texture& texture) const
}
void LayerBase::setBufferCrop(const Rect& crop) {
- if (!crop.isEmpty()) {
- if (mBufferCrop != crop) {
- mBufferCrop = crop;
- mFlinger->invalidateHwcGeometry();
- }
+ if (mBufferCrop != crop) {
+ mBufferCrop = crop;
+ mFlinger->invalidateHwcGeometry();
}
}