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/util/EglSurfaceTexture.h b/services/camera/virtualcamera/util/EglSurfaceTexture.h
index 14dc7d6..faad7c4 100644
--- a/services/camera/virtualcamera/util/EglSurfaceTexture.h
+++ b/services/camera/virtualcamera/util/EglSurfaceTexture.h
@@ -57,6 +57,17 @@
// Returns EGL texture id of the texture.
GLuint updateTexture();
+ // Returns EGL texture id of the underlying texture.
+ GLuint getTextureId() const;
+
+ // Returns 4x4 transformation matrix in column-major order,
+ // which should be applied to EGL texture coordinates
+ // before sampling from the texture backed by android native buffer,
+ // so the corresponding region of the underlying buffer is sampled.
+ //
+ // See SurfaceTexture.getTransformMatrix for more details.
+ std::array<float, 16> getTransformMatrix();
+
private:
sp<IGraphicBufferProducer> mBufferProducer;
sp<IGraphicBufferConsumer> mBufferConsumer;