Why the layers of surfaceflinger are drew vertically filpped

46 views
Skip to first unread message

林作健

unread,
Sep 2, 2015, 1:23:18 PM9/2/15
to android-porting
Hi recently when I am digging surfaceflinger's code, I found this service draw its layer vertically flipped. Using the method like 1.0f minus top. I feel confused and wonder why it is done like that. Can anyone explain it? Thanks.

Shree Kumar

unread,
Sep 3, 2015, 8:33:21 PM9/3/15
to manji...@gmail.com, android-porting

I suppose you are referring to the OpenGL texture coordinate system.

Surfaceflinger uses OpenGL ES and textures. Surfaces are stored as textures. 

When SurfaceFlinger needs to draw a surface, the coordinates need to be mapped from pixel X,Y to texture X,Y. In OpenGL, (0,0) is bottom left and (1,1) is top right. Note that the coordinates are normalized to fall in the range 0..1, plus the Y axis is actually reversed! That's why you see the one minus for y coordinates...

--Shree

On 02-Sep-2015 10:53 pm, "林作健" <manji...@gmail.com> wrote:
Hi recently when I am digging surfaceflinger's code, I found this service draw its layer vertically flipped. Using the method like 1.0f minus top. I feel confused and wonder why it is done like that. Can anyone explain it? Thanks.

--
--
unsubscribe: android-porti...@googlegroups.com
website: http://groups.google.com/group/android-porting

---
You received this message because you are subscribed to the Google Groups "android-porting" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-porti...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages