diff options
Diffstat (limited to 'libs')
| -rw-r--r-- | libs/gui/SurfaceTexture.cpp | 88 | ||||
| -rw-r--r-- | libs/rs/rsAllocation.cpp | 1 | ||||
| -rw-r--r-- | libs/rs/rsThreadIO.cpp | 4 | ||||
| -rw-r--r-- | libs/rs/rsg_generator.c | 4 |
4 files changed, 65 insertions, 32 deletions
diff --git a/libs/gui/SurfaceTexture.cpp b/libs/gui/SurfaceTexture.cpp index 447de76508cd..1dadd5389154 100644 --- a/libs/gui/SurfaceTexture.cpp +++ b/libs/gui/SurfaceTexture.cpp @@ -166,6 +166,9 @@ status_t SurfaceTexture::queueBuffer(int buf) { mLastQueued = buf; mLastQueuedCrop = mNextCrop; mLastQueuedTransform = mNextTransform; + if (mFrameAvailableListener != 0) { + mFrameAvailableListener->onFrameAvailable(); + } return OK; } @@ -237,43 +240,68 @@ void SurfaceTexture::getTransformMatrix(float mtx[16]) { LOGV("SurfaceTexture::updateTexImage"); Mutex::Autolock lock(mMutex); - float* xform = mtxIdentity; - switch (mCurrentTransform) { - case 0: - xform = mtxIdentity; - break; - case NATIVE_WINDOW_TRANSFORM_FLIP_H: - xform = mtxFlipH; - break; - case NATIVE_WINDOW_TRANSFORM_FLIP_V: - xform = mtxFlipV; - break; - case NATIVE_WINDOW_TRANSFORM_ROT_90: - xform = mtxRot90; - break; - case NATIVE_WINDOW_TRANSFORM_ROT_180: - xform = mtxRot180; - break; - case NATIVE_WINDOW_TRANSFORM_ROT_270: - xform = mtxRot270; - break; - default: - LOGE("getTransformMatrix: unknown transform: %d", mCurrentTransform); + float xform[16]; + for (int i = 0; i < 16; i++) { + xform[i] = mtxIdentity[i]; + } + if (mCurrentTransform & NATIVE_WINDOW_TRANSFORM_FLIP_H) { + float result[16]; + mtxMul(result, xform, mtxFlipH); + for (int i = 0; i < 16; i++) { + xform[i] = result[i]; + } + } + if (mCurrentTransform & NATIVE_WINDOW_TRANSFORM_FLIP_V) { + float result[16]; + mtxMul(result, xform, mtxFlipV); + for (int i = 0; i < 16; i++) { + xform[i] = result[i]; + } + } + if (mCurrentTransform & NATIVE_WINDOW_TRANSFORM_ROT_90) { + float result[16]; + mtxMul(result, xform, mtxRot90); + for (int i = 0; i < 16; i++) { + xform[i] = result[i]; + } } sp<GraphicBuffer>& buf(mSlots[mCurrentTexture].mGraphicBuffer); - float tx = float(mCurrentCrop.left) / float(buf->getWidth()); - float ty = float(mCurrentCrop.bottom) / float(buf->getHeight()); - float sx = float(mCurrentCrop.width()) / float(buf->getWidth()); - float sy = float(mCurrentCrop.height()) / float(buf->getHeight()); + float tx, ty, sx, sy; + if (!mCurrentCrop.isEmpty()) { + tx = float(mCurrentCrop.left) / float(buf->getWidth()); + ty = float(buf->getHeight() - mCurrentCrop.bottom) / + float(buf->getHeight()); + sx = float(mCurrentCrop.width()) / float(buf->getWidth()); + sy = float(mCurrentCrop.height()) / float(buf->getHeight()); + } else { + tx = 0.0f; + ty = 0.0f; + sx = 1.0f; + sy = 1.0f; + } float crop[16] = { - sx, 0, 0, sx*tx, - 0, sy, 0, sy*ty, + sx, 0, 0, 0, + 0, sy, 0, 0, 0, 0, 1, 0, - 0, 0, 0, 1, + sx*tx, sy*ty, 0, 1, }; - mtxMul(mtx, crop, xform); + float mtxBeforeFlipV[16]; + mtxMul(mtxBeforeFlipV, crop, xform); + + // SurfaceFlinger expects the top of its window textures to be at a Y + // 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); +} + +void SurfaceTexture::setFrameAvailableListener( + const sp<FrameAvailableListener>& l) { + LOGV("SurfaceTexture::setFrameAvailableListener"); + Mutex::Autolock lock(mMutex); + mFrameAvailableListener = l; } void SurfaceTexture::freeAllBuffers() { diff --git a/libs/rs/rsAllocation.cpp b/libs/rs/rsAllocation.cpp index 6e4c22eab230..41c9fe2d016c 100644 --- a/libs/rs/rsAllocation.cpp +++ b/libs/rs/rsAllocation.cpp @@ -212,6 +212,7 @@ void Allocation::update2DTexture(const void *ptr, uint32_t xoff, uint32_t yoff, GLenum type = mType->getElement()->getComponent().getGLType(); GLenum format = mType->getElement()->getComponent().getGLFormat(); GLenum target = (GLenum)getGLTarget(); + rsAssert(mTextureID); glBindTexture(target, mTextureID); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); GLenum t = GL_TEXTURE_2D; diff --git a/libs/rs/rsThreadIO.cpp b/libs/rs/rsThreadIO.cpp index 1c6c5ac426bb..001ac5529e20 100644 --- a/libs/rs/rsThreadIO.cpp +++ b/libs/rs/rsThreadIO.cpp @@ -53,6 +53,10 @@ bool ThreadIO::playCoreCommands(Context *con, bool waitForCommand) { waitForCommand = false; //LOGV("playCoreCommands 3 %i %i", cmdID, cmdSize); + if (cmdID >= (sizeof(gPlaybackFuncs) / sizeof(void *))) { + rsAssert(cmdID < (sizeof(gPlaybackFuncs) / sizeof(void *))); + LOGE("playCoreCommands error con %p, cmd %i", con, cmdID); + } gPlaybackFuncs[cmdID](con, data); mToCore.next(); } diff --git a/libs/rs/rsg_generator.c b/libs/rs/rsg_generator.c index 1e468bb985e4..4ac5b7fce136 100644 --- a/libs/rs/rsg_generator.c +++ b/libs/rs/rsg_generator.c @@ -219,7 +219,7 @@ void printPlaybackCpp(FILE *f) { fprintf(f, "};\n\n"); } - fprintf(f, "RsPlaybackFunc gPlaybackFuncs[] = {\n"); + fprintf(f, "RsPlaybackFunc gPlaybackFuncs[%i] = {\n", apiCount + 1); fprintf(f, " NULL,\n"); for (ct=0; ct < apiCount; ct++) { fprintf(f, " %s%s,\n", "rsp_", apis[ct].name); @@ -265,7 +265,7 @@ int main(int argc, char **argv) { printFuncDecls(f, "rsi_", 1); printPlaybackFuncs(f, "rsp_"); fprintf(f, "\n\ntypedef void (*RsPlaybackFunc)(Context *, const void *);\n"); - fprintf(f, "extern RsPlaybackFunc gPlaybackFuncs[];\n"); + fprintf(f, "extern RsPlaybackFunc gPlaybackFuncs[%i];\n", apiCount + 1); fprintf(f, "}\n"); fprintf(f, "}\n"); |