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/EglProgram.h b/services/camera/virtualcamera/util/EglProgram.h
index 1b5f2cd..1a9d300 100644
--- a/services/camera/virtualcamera/util/EglProgram.h
+++ b/services/camera/virtualcamera/util/EglProgram.h
@@ -17,6 +17,8 @@
 #ifndef ANDROID_COMPANION_VIRTUALCAMERA_EGLPROGRAM_H
 #define ANDROID_COMPANION_VIRTUALCAMERA_EGLPROGRAM_H
 
+#include <array>
+
 #include "GLES/gl.h"
 
 namespace android {
@@ -59,7 +61,15 @@
 
   EglTextureProgram(TextureFormat textureFormat = TextureFormat::YUV);
 
-  bool draw(GLuint textureId);
+  // Draw texture over whole viewport, applying transformMatrix to texture
+  // coordinates.
+  //
+  // Transform matrix is 4x4 matrix represented in column-major order and is
+  // applied to texture coordinates in (s,t,0,1), s,t from <0,1> range prior to
+  // sampling:
+  //
+  // textureCoord = transformMatrix * vec4(s,t,0,1).xy
+  bool draw(GLuint textureId, const std::array<float, 16>& transformMatrix);
 };
 
 }  // namespace virtualcamera