Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
NewManLiving
Visitor

Undocumented roRegion Services ?

Apparently you can create an roRegion using the roScreen as its source bitmap, although the resolution/scaling is off. It also appears that roRegion exposes an ifDraw2d interface , resolving it perhaps by calling it's source objects ifDraw2d interface. I created an roRegion using roScreen as its source and then called the (non-documented)
roRegion.DrawObject, roRegion.DrawRect , all of which appears to work. (I don't see any of this documented, but did come across a post on this forum). I am particularly interested in creating regions right from the roScreen buffer which apparently works except for the scaling that is returned. I have not played with any of the pretranslation or scaling flags or rendering functions to see if I could fix it. Any light on this ??? it could possibly help those of us struggling with memory issues. Now I tried all this while a compositor was sitting on top of the screen so I don't know if I would have had different results without the compositor. But before I continue experimenting, I would like some feedback if possible. Perhaps there is some other documentation that I should be looking at
My Channels: 2D API Framework Presentation: https://owner.roku.com/add/2M9LCVC
Updated: 11-11-2015 - Completed Keyboard interface
The Joel Channel ( Final Beta )
0 Kudos
12 REPLIES 12
TheEndless
Channel Surfer

Re: Undocumented roRegion Services ?

"NewManLiving" wrote:
Apparently you can create an roRegion using the roScreen as its source bitmap, although the resolution/scaling is off.

What do you mean by this?
"NewManLiving" wrote:
It also appears that roRegion exposes an ifDraw2d interface , resolving it perhaps by calling it's source objects ifDraw2d interface.

It is undocumented, but roRegion does implement ifDraw2d, and it's the only (easy) way to do clipping when drawing directly to a bitmap or screen.
"NewManLiving" wrote:
I am particularly interested in creating regions right from the roScreen buffer which apparently works except for the scaling that is returned.

I've never had luck trying to draw a portion of the screen to a bitmap or the screen. This is what I was eluding to in the previous thread. In theory it should work, though. Again, could you explain what you mean by "except for the scaling that is returned"?
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
NewManLiving
Visitor

Re: Undocumented roRegion Services ?

Well I have been considering what you were talking about. And I do see your point. I have been isolated using only ROKU 3. So, I figured if roScreen is theoretically similar to roBitamp, let me try to get a region from it. So I created l_region = CreateObject("roRegion", myRoScreen, x, y, w, h, ) where I use my roScreen instance instead of a bitmap. Well it returned type(roRegion), so I took that region and drew it back onto the screen. It drew the area that I had specified except the length was stretched somewhat longer (actually it was a section of a grid that I am working on - I want to fade in/out a new grid and I thought about what you said, Also I did modify my thinking about drawing directly to the screen; it does have its benefits - thanks to you) anyway, it drew the exact replica of the grid but the cells were stretched out about 25 % longer. So before I go crazy trying to rectify this I thought I would ask. Of course this is ROKU 3 so I don't know what anything else would return. I am setting up a 2x box as I stated earlier ( as there is one available to me ). A friend is using it and I am helping him with a grid - so I need to know the differences
My Channels: 2D API Framework Presentation: https://owner.roku.com/add/2M9LCVC
Updated: 11-11-2015 - Completed Keyboard interface
The Joel Channel ( Final Beta )
0 Kudos
NewManLiving
Visitor

Re: Undocumented roRegion Services ?

After further investigation this phenomenon exists in conjunction with a compositor and sprites. Whatever the topmost ( or most recently created sprite. Don't know for sure yet) happens to be this call: region = CreateObject( "roRegion", roScreen, 0, 0, roScreen.GetWidth(), roScreen.GetHeight() ) will capture the sprite and scale it accordingly. If the sprite is small, say 100 * 100 it will stretch it across the display in both directions. In the case of my grid I was able to scale the region down to be the same size as the original and write it back to the screen. Of course this does not appear to be Kosher, but the bottom line is: It is doable and can help tremendously with animating areas of the screen without having to create additional overhead. I did try this with just an roScreen not using a compositor/sprite and the results were not the same
My Channels: 2D API Framework Presentation: https://owner.roku.com/add/2M9LCVC
Updated: 11-11-2015 - Completed Keyboard interface
The Joel Channel ( Final Beta )
0 Kudos
TheEndless
Channel Surfer

Re: Undocumented roRegion Services ?

"NewManLiving" wrote:
After further investigation this phenomenon exists in conjunction with a compositor and sprites. Whatever the topmost ( or most recently created sprite. Don't know for sure yet) happens to be this call: region = CreateObject( "roRegion", roScreen, 0, 0, roScreen.GetWidth(), roScreen.GetHeight() ) will capture the sprite and scale it accordingly. If the sprite is small, say 100 * 100 it will stretch it across the display in both directions. In the case of my grid I was able to scale the region down to be the same size as the original and write it back to the screen. Of course this does not appear to be Kosher, but the bottom line is: It is doable and can help tremendously with animating areas of the screen without having to create additional overhead. I did try this with just an roScreen not using a compositor/sprite and the results were not the same

Interesting. Sounds like the behavior might have changed a little since the last time I tried it. I bet you could use it to do some cool wipe style transitions without having to redraw the previous frame.

I'm also curious how it would behave if you drew the region on top of itself... kind of like doing a bitmap.DrawObject(0, 0, bitmap)... Might have to give that a try 😛
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
NewManLiving
Visitor

Re: Undocumented roRegion Services ?

Yes I agree there is a lot you can do with it , but we do not have the 'official' blessing to use it and it may be an anomaly which will break the channel in further releases of the SDK. It really is a must have as you have pointed out in previous posts. It always makes me wonder what really is in the SDK that only the 'privy' know.
My Channels: 2D API Framework Presentation: https://owner.roku.com/add/2M9LCVC
Updated: 11-11-2015 - Completed Keyboard interface
The Joel Channel ( Final Beta )
0 Kudos
TheEndless
Channel Surfer

Re: Undocumented roRegion Services ?

Now here's a nice discovery! You can pass an roRegion to roCompositor.SetDrawTo(), and it will correctly clip to that region. If you enable alpha on that region, and set the background color of the compositor to fully transparent (&H00000000), then the compositor will correctly blend to whatever is drawn to the screen behind it. Thinking about a different compositor for different areas of the screen... This compositor thing is becoming more and more appealing...
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
NewManLiving
Visitor

Re: Undocumented roRegion Services ?

That would make sense since you can pass a bitmap. Never thought about a region
I am also suspecting that what I mentioned above really only applies to the
Last item drawn to the screen -a pixel or a grid. using a compositor or not
Wouldn't matter. I'm going to test it. If that's the case you can draw something
Onto the screen and then return a region for what you just drew
I think this because no matter what I have on the screen the region even if it's
The entire screen just picks up the last item drawn and stretches it
Don't know if this occurs between swapbuffers or not. Today I am working
But I'm glad you are looking at it. That is interesting
My Channels: 2D API Framework Presentation: https://owner.roku.com/add/2M9LCVC
Updated: 11-11-2015 - Completed Keyboard interface
The Joel Channel ( Final Beta )
0 Kudos
RokuJoel
Binge Watcher

Re: Undocumented roRegion Services ?

"NewManLiving" wrote:
but we do not have the 'official' blessing to use it


I believe this is the way it was intended, the screen itself is essentially an roBitmap, although specialized and you should be able to treat it as such for the most part.

"NewManLiving" wrote:
It always makes me wonder what really is in the SDK that only the 'privy' know.


1. Components and functions that have been build for internal use and have not been API reviewed.
2. ... or that engineering plans to revise significantly
3. Custom components, developed for specific business partners which we may or may not eventually release to developers - the general philosophy is that we will eventually release most, unless they fall under #2.

- Joel
0 Kudos
TheEndless
Channel Surfer

Re: Undocumented roRegion Services ?

"RokuJoel" wrote:
"NewManLiving" wrote:
but we do not have the 'official' blessing to use it


I believe this is the way it was intended, the screen itself is essentially an roBitmap, although specialized and you should be able to treat it as such for the most part.

"NewManLiving" wrote:
It always makes me wonder what really is in the SDK that only the 'privy' know.


1. Components and functions that have been build for internal use and have not been API reviewed.
2. ... or that engineering plans to revise significantly
3. Custom components, developed for specific business partners which we may or may not eventually release to developers - the general philosophy is that we will eventually release most, unless they fall under #2.

- Joel

Hey Joel, any idea why the documentation for roRegion doesn't indicate that it implements the ifDraw2D interface (which was the catalyst for this thread), and why the roCompositor.SetDrawTo() method documentation specifically states that only works with roScreen and roBitmap, instead of anything that implements ifDraw2D?
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos