k

    Koneko Toujou

    1 year ago
    Does Compose draw each Composable directly to screen or does it first composite each composable to a texture which ultimately ends up on screen Eg Row Text Would Compose first draw Row directly to screen, and then draw Text directly to screen Or would Compose first draw Text to a texture, and then draw Text's texture to Row's texture, and then draw Row's texture to screen
    Zach Klippenstein (he/him) [MOD]

    Zach Klippenstein (he/him) [MOD]

    1 year ago
    Romain is probably the best person to answer this, but I can try – don’t quote me on any of this 😅. Compose works with RenderNodes. In general, composable structure doesn’t imply layer/rendernode structure, but layers can be introduced by certain APIs like the
    graphicsLayer
    modifier or
    withSaveLayer
    calls inside draw scopes. Composables draw to
    Canvas
    objects which are backed (in most cases, at least on newer android versions) by those RenderNodes. I believe there’s some relationship between a
    RenderNode
    and a display list, but i’m not sure exactly what it is. So in your example case,
    Row
    doesn’t do anything with layers so
    Text
    would end up drawing to the same
    Canvas
    as whatever calls
    Row
    would have access to.
    Adam Powell

    Adam Powell

    1 year ago
    Right, Compose UI tries to only draw to an intermediate rendering target if it has to, for example, if you're applying an alpha modifier to a complex composable
    k

    Koneko Toujou

    1 year ago
    Hmm ok
    r

    romainguy

    1 year ago
    And technically all drawing is done in a texture of some sort (a Surface)
    Android never draws directly on screen
    k

    Koneko Toujou

    1 year ago
    Yea
    r

    romainguy

    1 year ago
    But the UI toolkit tries to avoid intermediate textures as much as possible as it's expensive in terms of bandwidth.
    k

    Koneko Toujou

    1 year ago
    Oh ok
    r

    romainguy

    1 year ago
    @Zach Klippenstein (he/him) [MOD] RenderNode is basically what used to be called DisplayList. It has the same role
    k

    Koneko Toujou

    1 year ago
    Bandwidth as in RAM/GPU memory? Eg a 2k texture would take up around 8MB to 15 MB (depending on screen exact resolution) of memory assuming 4 bytes per pixel, eg ARBG or RGBA or however the pixel format And thus having a lot of intermediate textures would inflate memory in proportion to how many are required and the exact size of each texture in bytes total
    r

    romainguy

    1 year ago
    It's not so much about how much memory would be required at any given time but how much data would have to be read/written per frame
    k

    Koneko Toujou

    1 year ago
    Such as copying pixels from GPU to CPU and back to GPU?
    Or such as drawing each texture to another texture as a quad? Eg layering each texture on top of one another