Developers

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
kelweb87
Visitor

RAF custom buffer layer won't rotate.

I'm trying to implement a custom buffer screen for my RAF implementation. I'm placing an image of a spinner on the screen and using the "setAdBufferRenderCallback" method to update the TargetRotation of my spinner. When printing out the value i can see it update as expected but the spinner doesn't actually rotate. Even setting the default TargetRotation value doesn't seem to do anything? This same logic was implemented using roImageCanvas in our non-SceneGraph app and it worked fine. Any ideas why it now wouldn't work?

Here is my code

function setupBufferScreen(adIface)
    displaySize = CreateObject("roDeviceInfo").getDisplaySize()
    cW = displaySize.w
    cH = displaySize.h
    bg = getSpinnerBG(cW, cH)
    spinner = getSpinnerLayer(cW, cH)
    adIface.setAdBufferScreenLayer(0, bg)
    adIface.setAdBufferScreenLayer(1, spinner)
    adIface.setAdBufferRenderCallback(bufferScreenCallback, {}, 0)
end function

function bufferScreenCallback(state as Dynamic, eventType as String, ctx as Dynamic)
    if eventType = "Progress"
        ctx.canvasLayers[1].TargetRotation = ctx.progress
        ? "TARGET ROTATION: "; ctx.canvasLayers[1].TargetRotation
    end if
end function

function getSpinnerBG(cW, cH)
    spinnerBGSize = 125
    spinnerBGLayout = {
        x        : Int((cW / 2) - (spinnerBGSize / 2))
        y        : Int((cH / 2) - (spinnerBGSize / 2))
        w        : spinnerBGSize
        h        : spinnerBGSize
    }

    return {
        Color: "#101010"
        CompositionMode: "Source"
        TargetRect: spinnerBGLayout
    }
end function

function getSpinnerLayer(cW, cH)
    spinnerSize = 100
    spinnerX = Int((cW / 2) - (spinnerSize / 2))
    spinnerY = Int((cH / 2) - (spinnerSize / 2))
    spinnerTargetRect = {
        x: spinnerX,
        y: spinnerY,
        w: spinnerSize,
        h: spinnerSize
    }
    return {
        url: "pkg://images/spinner.png",
        TargetRect: spinnerTargetRect,
        TargetTranslation: { x: spinnerX, y: spinnerY },
        TargetRotation: 90,
        CompositionMode: "Source"
    }
end function


Here is the output in the console:

rafrndr-renderTypeChanged() - client-inserted
added child: Rectangle id: 1 subtype: Rectangle
added child: Rectangle id: 0 subtype: Rectangle
added child: Poster id: 1 subtype: Poster
check layer: 1 visible: true
check layer: 0 visible: true
added child: Rectangle id: 0 subtype: Rectangle
added child: Poster id: 1 subtype: Poster
check layer: 1 visible: true
check layer: 0 visible: true
TARGET ROTATION:  0
added child: Rectangle id: 0 subtype: Rectangle
added child: Poster id: 1 subtype: Poster
check layer: 1 visible: true
check layer: 0 visible: true
TARGET ROTATION:  6
added child: Rectangle id: 0 subtype: Rectangle
added child: Poster id: 1 subtype: Poster
check layer: 1 visible: true
check layer: 0 visible: true
TARGET ROTATION:  13
added child: Rectangle id: 0 subtype: Rectangle
added child: Poster id: 1 subtype: Poster
check layer: 1 visible: true
check layer: 0 visible: true
TARGET ROTATION:  19
added child: Rectangle id: 0 subtype: Rectangle
added child: Poster id: 1 subtype: Poster
check layer: 1 visible: true
check layer: 0 visible: true
TARGET ROTATION:  26
added child: Rectangle id: 0 subtype: Rectangle
added child: Poster id: 1 subtype: Poster
check layer: 1 visible: true
check layer: 0 visible: true
TARGET ROTATION:  33
added child: Rectangle id: 0 subtype: Rectangle
added child: Poster id: 1 subtype: Poster
check layer: 1 visible: true
check layer: 0 visible: true
TARGET ROTATION:  6
added child: Rectangle id: 0 subtype: Rectangle
added child: Poster id: 1 subtype: Poster
check layer: 1 visible: true
check layer: 0 visible: true
TARGET ROTATION:  13
added child: Rectangle id: 0 subtype: Rectangle
added child: Poster id: 1 subtype: Poster
check layer: 1 visible: true
check layer: 0 visible: true
TARGET ROTATION:  19
added child: Rectangle id: 0 subtype: Rectangle
added child: Poster id: 1 subtype: Poster
check layer: 1 visible: true
check layer: 0 visible: true
TARGET ROTATION:  26
added child: Rectangle id: 0 subtype: Rectangle
added child: Poster id: 1 subtype: Poster
check layer: 1 visible: true
check layer: 0 visible: true
TARGET ROTATION:  33
added child: Rectangle id: 0 subtype: Rectangle
added child: Poster id: 1 subtype: Poster
check layer: 1 visible: true
check layer: 0 visible: true
TARGET ROTATION:  33
added child: Rectangle id: 0 subtype: Rectangle
added child: Poster id: 1 subtype: Poster
check layer: 1 visible: true
check layer: 0 visible: true
TARGET ROTATION:  99
added child: Rectangle id: 0 subtype: Rectangle
added child: Poster id: 1 subtype: Poster
check layer: 1 visible: true
check layer: 0 visible: true
TARGET ROTATION:  99
added child: Rectangle id: 0 subtype: Rectangle
added child: Poster id: 1 subtype: Poster
check layer: 1 visible: true
check layer: 0 visible: true
TARGET ROTATION:  100
added child: Rectangle id: 0 subtype: Rectangle
added child: Poster id: 1 subtype: Poster
check layer: 1 visible: true
check layer: 0 visible: true
added child: Rectangle id: 0 subtype: Rectangle
added child: Poster id: 1 subtype: Poster
check layer: 1 visible: true
check layer: 0 visible: true
Tags (1)
0 Kudos
4 REPLIES 4
NB_
Roku Guru

Re: RAF custom buffer layer won't rotate.

Does this work when you do it outside RAF API?
Some models do not support object rotation. Try
? createObject("roDeviceInfo").GetGraphicsPlatform() 

if "opengl" - can rotate, if "directfb" - can't.
Tags (1)
0 Kudos
kelweb87
Visitor

Re: RAF custom buffer layer won't rotate.

"RokuNB" wrote:
Does this work when you do it outside RAF API?
Some models do not support object rotation. Try
? createObject("roDeviceInfo").GetGraphicsPlatform() 

if "opengl" - can rotate, if "directfb" - can't.

I've double checked and it's returning "opengl" but still no rotation.
Tags (1)
0 Kudos
Veeta
Visitor

Re: RAF custom buffer layer won't rotate.

Have you tried calling adIface.setAdBufferScreenLayer() after you change the TargetRotation?  

I notice in the roImageCanvas documentation that: "The screen is redrawn when SetLayer()is called."  Most likely you are changing the inputs but aren't triggering any rendering.
Tags (1)
0 Kudos
kelweb87
Visitor

Re: RAF custom buffer layer won't rotate.

"Veeta" wrote:
Have you tried calling adIface.setAdBufferScreenLayer() after you change the TargetRotation?  

I notice in the roImageCanvas documentation that: "The screen is redrawn when SetLayer()is called."  Most likely you are changing the inputs but aren't triggering any rendering.

I've not but I've added a 3rd layer which displays the progress amount in text and that is updating as expected so it's definitely re-rendering. Also, any default value applied to TargetRotation has no affect, it seems as though it's not possible at all.
Tags (1)
0 Kudos
Community is Temporarily in Read-Only Mode!

We’re upgrading Roku Community to bring you a faster, more mobile-friendly experience. You may notice limited functionality or read-only access during this time. You will not be able to log in or post new comments or kudos during this time. Read more here.

Planned Downtime:
Community will be unavailable for up to 24–48 hours during the upgrade window during the week of May 12 and you may notice reduced functionality. In the meantime, for additional assistance, visit our Support Site.

Thanks for your patience — we’re excited to share what’s next!