summaryrefslogtreecommitdiff
path: root/libs/gui/SurfaceTexture.cpp
diff options
context:
space:
mode:
author Jamie Gennis <jgennis@google.com> 2011-06-12 17:03:06 -0700
committer Jamie Gennis <jgennis@google.com> 2011-06-13 10:50:12 -0700
commiteadfb673e7b346af02a925ad04494100db1ebbf7 (patch)
tree6ff88f77a6762f00a868807706f1e995d16373ae /libs/gui/SurfaceTexture.cpp
parentfe93010446e68c747f4af727cbc48eaf63131689 (diff)
SurfaceTexture: fix a getTransformMatrix crash.
This change moves the computation of the transform matrix out of getTransformMatrix and instead performs the computation when updateTexImage gets called. This is needed in order for getTransformMatrix to succeed even if the buffers have been freed (e.g. by changing the buffer count) because the computation depends upon the properties of the current GraphicBuffer. Change-Id: Ied541ab8747b7ad604f862717135f9a16a816be9 Bug: 4490420
Diffstat (limited to 'libs/gui/SurfaceTexture.cpp')
-rw-r--r--libs/gui/SurfaceTexture.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/libs/gui/SurfaceTexture.cpp b/libs/gui/SurfaceTexture.cpp
index ee97dcfa9c63..2cda4c82dbcf 100644
--- a/libs/gui/SurfaceTexture.cpp
+++ b/libs/gui/SurfaceTexture.cpp
@@ -96,6 +96,7 @@ SurfaceTexture::SurfaceTexture(GLuint tex) :
sp<ISurfaceComposer> composer(ComposerService::getComposerService());
mGraphicBufferAlloc = composer->createGraphicBufferAlloc();
mNextCrop.makeInvalid();
+ memcpy(mCurrentTransformMatrix, mtxIdentity, sizeof(mCurrentTransformMatrix));
}
SurfaceTexture::~SurfaceTexture() {
@@ -547,6 +548,7 @@ status_t SurfaceTexture::updateTexImage() {
mCurrentCrop = mSlots[buf].mCrop;
mCurrentTransform = mSlots[buf].mTransform;
mCurrentTimestamp = mSlots[buf].mTimestamp;
+ computeCurrentTransformMatrix();
mDequeueCondition.signal();
} else {
// We always bind the texture even if we don't update its contents.
@@ -596,8 +598,12 @@ GLenum SurfaceTexture::getCurrentTextureTarget() const {
}
void SurfaceTexture::getTransformMatrix(float mtx[16]) {
- LOGV("SurfaceTexture::getTransformMatrix");
Mutex::Autolock lock(mMutex);
+ memcpy(mtx, mCurrentTransformMatrix, sizeof(mCurrentTransformMatrix));
+}
+
+void SurfaceTexture::computeCurrentTransformMatrix() {
+ LOGV("SurfaceTexture::computeCurrentTransformMatrix");
float xform[16];
for (int i = 0; i < 16; i++) {
@@ -684,7 +690,7 @@ void SurfaceTexture::getTransformMatrix(float mtx[16]) {
// coordinate of 0, so SurfaceTexture must behave the same way. We don't
// want to expose this to applications, however, so we must add an
// additional vertical flip to the transform after all the other transforms.
- mtxMul(mtx, mtxFlipV, mtxBeforeFlipV);
+ mtxMul(mCurrentTransformMatrix, mtxFlipV, mtxBeforeFlipV);
}
nsecs_t SurfaceTexture::getTimestamp() {