summaryrefslogtreecommitdiff
path: root/libs/gui/SurfaceTexture.cpp
diff options
context:
space:
mode:
author Jamie Gennis <jgennis@google.com> 2012-04-17 15:52:49 -0700
committer Android (Google) Code Review <android-gerrit@google.com> 2012-04-17 15:52:49 -0700
commit2efa4b2bb0128cd65ea8ade46f46bacaf72c194f (patch)
tree7f3fe9bc1e530e9300e6547ce0757f80c93c7e0b /libs/gui/SurfaceTexture.cpp
parentfe668f468252b8824f777ffd659e5d800283a9a1 (diff)
parent695e331f01b136155b1559b3c878b7c5bb631bc1 (diff)
Merge changes Id79430f9,I541d3046
* changes: BufferQueue: check before tracing buffer index SurfaceTexture: shrink all sides when cropping
Diffstat (limited to 'libs/gui/SurfaceTexture.cpp')
-rw-r--r--libs/gui/SurfaceTexture.cpp32
1 files changed, 10 insertions, 22 deletions
diff --git a/libs/gui/SurfaceTexture.cpp b/libs/gui/SurfaceTexture.cpp
index 0fa9ca1ed7..ed1ea4ec54 100644
--- a/libs/gui/SurfaceTexture.cpp
+++ b/libs/gui/SurfaceTexture.cpp
@@ -542,28 +542,16 @@ void SurfaceTexture::computeCurrentTransformMatrix() {
// decoder, camera, etc.) would simply not use a crop rectangle (or at
// least not tell the framework about it) so that the GPU can do the
// correct edge behavior.
- int xshrink = 0, yshrink = 0;
- if (mCurrentCrop.left > 0) {
- tx = float(mCurrentCrop.left + 1) / float(buf->getWidth());
- xshrink++;
- } else {
- tx = 0.0f;
- }
- if (mCurrentCrop.right < int32_t(buf->getWidth())) {
- xshrink++;
- }
- if (mCurrentCrop.bottom < int32_t(buf->getHeight())) {
- ty = (float(buf->getHeight() - mCurrentCrop.bottom) + 1.0f) /
- float(buf->getHeight());
- yshrink++;
- } else {
- ty = 0.0f;
- }
- if (mCurrentCrop.top > 0) {
- yshrink++;
- }
- sx = float(mCurrentCrop.width() - xshrink) / float(buf->getWidth());
- sy = float(mCurrentCrop.height() - yshrink) / float(buf->getHeight());
+ const float shrinkAmount = 1.0f; // the amount that each edge is shrunk
+
+ tx = (float(mCurrentCrop.left) + shrinkAmount) /
+ float(buf->getWidth());
+ ty = (float(buf->getHeight() - mCurrentCrop.bottom) +
+ shrinkAmount) / float(buf->getHeight());
+ sx = (float(mCurrentCrop.width()) - (2.0f * shrinkAmount)) /
+ float(buf->getWidth());
+ sy = (float(mCurrentCrop.height()) - (2.0f * shrinkAmount)) /
+ float(buf->getHeight());
} else {
tx = 0.0f;
ty = 0.0f;