Apply transformation matrix to texture coordinates.
SurfaceTexture provides transformation matrix which should
be used to transform texture coordinates before sampling
to account for possible coordinate differences in the
underlying native buffer.
This was causing the texture to be flipped when rendered.
Also fix the square coordinates which caused stretching.
Bug: 301023410
Test: atest virtual_camera_tests
Test: atest CtsVirtualCameraTestCases
Test: manual with sample app & canvas + video
Change-Id: Ib7fd2bb03e6686ada193ea67541f051d981f2bad
diff --git a/services/camera/virtualcamera/VirtualCameraRenderThread.cc b/services/camera/virtualcamera/VirtualCameraRenderThread.cc
index 79c91ef..25fe61b 100644
--- a/services/camera/virtualcamera/VirtualCameraRenderThread.cc
+++ b/services/camera/virtualcamera/VirtualCameraRenderThread.cc
@@ -542,8 +542,12 @@
} else {
const bool renderSuccess =
isYuvFormat(static_cast<PixelFormat>(textureBuffer->getPixelFormat()))
- ? mEglTextureYuvProgram->draw(mEglSurfaceTexture->updateTexture())
- : mEglTextureRgbProgram->draw(mEglSurfaceTexture->updateTexture());
+ ? mEglTextureYuvProgram->draw(
+ mEglSurfaceTexture->getTextureId(),
+ mEglSurfaceTexture->getTransformMatrix())
+ : mEglTextureRgbProgram->draw(
+ mEglSurfaceTexture->getTextureId(),
+ mEglSurfaceTexture->getTransformMatrix());
if (!renderSuccess) {
ALOGE("%s: Failed to render texture", __func__);
return cameraStatus(Status::INTERNAL_ERROR);