surfaceflinger: use Vulkan coordinate system
In Vulkan coordinate system, (0, 0) always maps to memory address 0.
In GL coordinate system, (0, 0) maps to the bottom-left corner. The
two agree when doing offscreen rendering. But when rendering to a
window, GL maps (0, 0) to memory address (winHeight-1)*rowStride,
because that is where the bottom-left pixel is.
Let's pick the simpler one for RenderEngine in preparation for
multiple backends. As a result, we don't need yswap when rendering
to offscreen buffers (it is hidden behind the RenderEngine API). It
also makes no sense to flip Y coordinate for both vertex postions
and the viewing volume.
Test: chrome, youtube, camera, screen rotation, screenshots, recents
Change-Id: I6d6317bac3de6f208700a67e518011362c600ced
diff --git a/libs/gui/GLConsumer.cpp b/libs/gui/GLConsumer.cpp
index 5532db4..faf02f3 100644
--- a/libs/gui/GLConsumer.cpp
+++ b/libs/gui/GLConsumer.cpp
@@ -834,10 +834,10 @@
xform = crop * xform;
}
- // SurfaceFlinger expects the top of its window textures to be at a Y
- // coordinate of 0, so GLConsumer 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.
+ // GLConsumer uses the GL convention where (0, 0) is the bottom-left
+ // corner and (1, 1) is the top-right corner. Add an additional vertical
+ // flip after all other transforms to map from GL convention to buffer
+ // queue memory layout, where (0, 0) is the top-left corner.
xform = mtxFlipV * xform;
memcpy(outTransform, xform.asArray(), sizeof(xform));