diff options
author | Jamie Gennis <jgennis@google.com> | 2012-05-07 13:50:11 -0700 |
---|---|---|
committer | Jamie Gennis <jgennis@google.com> | 2012-05-08 17:08:33 -0700 |
commit | d72f233ffa125856a44976a50a66ceb669f49ab2 (patch) | |
tree | fbc8f965d4601b08825c86aa040450b60471ffa3 /libs/gui/SurfaceTexture.cpp | |
parent | 59332804306c054082a39e9b004146bd03ae1d30 (diff) | |
download | frameworks_native-d72f233ffa125856a44976a50a66ceb669f49ab2.zip frameworks_native-d72f233ffa125856a44976a50a66ceb669f49ab2.tar.gz frameworks_native-d72f233ffa125856a44976a50a66ceb669f49ab2.tar.bz2 |
libgui: Add support for post-xform crops.
This change adds support for specifying a crop rectangle to a
SurfaceTextureClient that is in post-transformed coordinate space.
Change-Id: I247901de343e71b32850f7ae3bac62dfa612ad3d
Bug: 6299171
Diffstat (limited to 'libs/gui/SurfaceTexture.cpp')
-rw-r--r-- | libs/gui/SurfaceTexture.cpp | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/libs/gui/SurfaceTexture.cpp b/libs/gui/SurfaceTexture.cpp index a6ca085..73f7c54 100644 --- a/libs/gui/SurfaceTexture.cpp +++ b/libs/gui/SurfaceTexture.cpp @@ -294,7 +294,6 @@ status_t SurfaceTexture::updateTexImage() { mCurrentTransform = item.mTransform; mCurrentScalingMode = item.mScalingMode; mCurrentTimestamp = item.mTimestamp; - mCurrentActiveRect = item.mActiveRect; computeCurrentTransformMatrix(); } else { if (err < 0) { @@ -534,8 +533,9 @@ void SurfaceTexture::computeCurrentTransformMatrix() { } sp<GraphicBuffer>& buf(mCurrentTextureBuf); + Rect cropRect = mCurrentCrop; float tx, ty, sx, sy; - if (!mCurrentCrop.isEmpty()) { + if (!cropRect.isEmpty()) { // In order to prevent bilinear sampling at the of the crop rectangle we // may need to shrink it by 2 texels in each direction. Normally this // would just need to take 1/2 a texel off each end, but because the @@ -552,14 +552,16 @@ void SurfaceTexture::computeCurrentTransformMatrix() { // correct edge behavior. 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()); + float bufferWidth = buf->getWidth(); + float bufferHeight = buf->getHeight(); + + tx = (float(cropRect.left) + shrinkAmount) / bufferWidth; + ty = (float(bufferHeight - cropRect.bottom) + shrinkAmount) / + bufferHeight; + sx = (float(cropRect.width()) - (2.0f * shrinkAmount)) / + bufferWidth; + sy = (float(cropRect.height()) - (2.0f * shrinkAmount)) / + bufferHeight; } else { tx = 0.0f; ty = 0.0f; @@ -653,11 +655,6 @@ Rect SurfaceTexture::getCurrentCrop() const { return outCrop; } -Rect SurfaceTexture::getCurrentActiveRect() const { - Mutex::Autolock lock(mMutex); - return mCurrentActiveRect; -} - uint32_t SurfaceTexture::getCurrentTransform() const { Mutex::Autolock lock(mMutex); return mCurrentTransform; |