Your Digital Media Has Never Looked So Good

 
User avatar
Komag
Topic Author
Posts: 808
Joined: Fri Aug 22, 2014 3:42 am

Brief summary of advantages of ditching classic Rokus?

Fri Apr 03, 2015 6:42 am

I understand it's time to move on and no longer support old Rokus limited to the old firmware 3.1 - what I'd like is a brief overview of the most useful or important functions and abilities that 3.1 COULDN'T do, which I can now start to use in my 2D API game. Here are a few I know of:

- roAssociativeArray - Count()
- roAudioResource - "On Roku "Classic" models, roAudioResource does not support mixing of sounds." So now I don't have to worry about that.
- roString - ifStringOps - Replace()

What about roTextureManager?

My problem is that since I was planning to release for classic models too, I pretty much always ignored newer abilities if they weren't compatible, so now I'd like to "catch up"!

So what else are key things?
 
User avatar
TheEndless
** Valued Community Member **
Posts: 9231
Joined: Mon Oct 04, 2004 10:15 am
Location: US
Contact:

Re: Brief summary of advantages of ditching classic Rokus?

Fri Apr 03, 2015 9:41 am

To name a few, based on what I have explicit legacy checks for in my code...
  • roAppInfo
  • SetTimedMetaDataForKeys for roAudioPlayer and roVideoPlayer
  • roCaptionRenderer for roVideoPlayer
  • roChannelStore
  • Numerous additions to roDeviceInfo
  • Opacity in ifDraw2D.DrawObject
  • Loading and Error posters on roGridScreen
  • Cookie support in ifHttpAgent (though I have my own cookie parser that I just more)
  • RetainBodyOnError on roUrlTransfer
  • Breadcrumb text on roListScreen
  • SmallIconUrl on roListScreen
  • Localization support
  • roTextScreen
  • roTextureManager
  • FormatJSON()
  • Button separators on roMessageDialog
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)
 
User avatar
NewManLiving
Posts: 452
Joined: Fri Aug 02, 2013 6:14 pm

Re: Brief summary of advantages of ditching classic Rokus?

Fri Apr 03, 2015 12:17 pm

A lot less remote controls and little boxes all over the place
My Channels: 2D API Framework Presentation: https://owner.roku.com/add/2M9LCVC
Updated: 11-11-2015 - Completed Keyboard interface
The Joel Channel ( Final Beta )
 
User avatar
TheEndless
** Valued Community Member **
Posts: 9231
Joined: Mon Oct 04, 2004 10:15 am
Location: US
Contact:

Re: Brief summary of advantages of ditching classic Rokus?

Fri Apr 03, 2015 12:53 pm

NewManLiving wrote:
A lot less remote controls and little boxes all over the place

Hehe.. remember when all you had was a Roku 3? :p
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)
 
User avatar
NewManLiving
Posts: 452
Joined: Fri Aug 02, 2013 6:14 pm

Re: Brief summary of advantages of ditching classic Rokus?

Fri Apr 03, 2015 1:49 pm

Yes I remember. Now I have everything except the ROKU TV. Maybe you can give me some insight. I believe it has a 1G processor but no open GL. If I'm correct how is the performance compared to the new stick which I have come to appreciate
It is great to take with you as you mentioned on another post. I find that with 1,2 and LTE I have to make some adjustments with the 2D to keep things flowing. Been able to get good results especially with a redesign that uses less drawtext and employs region offsetting whenever possible as opposed to coordinate offsetting. Those two things gave me a 85-90 comparable look and feel to the higher models. I have a carousel in one app that fades in and out and to do this I was using an offset and a fade at the same time. Was a real dog. But when I changed it to region offsetting and region fading there was a huge difference just a slight jerk from time to time. Even my grid works good since it was mostly region offsetting to begin with. But I had to remove some of the open gl region tricks that I learned
My Channels: 2D API Framework Presentation: https://owner.roku.com/add/2M9LCVC
Updated: 11-11-2015 - Completed Keyboard interface
The Joel Channel ( Final Beta )
 
User avatar
TheEndless
** Valued Community Member **
Posts: 9231
Joined: Mon Oct 04, 2004 10:15 am
Location: US
Contact:

Re: Brief summary of advantages of ditching classic Rokus?

Fri Apr 03, 2015 2:08 pm

NewManLiving wrote:
Yes I remember. Now I have everything except the ROKU TV. Maybe you can give me some insight. I believe it has a 1G processor but no open GL. If I'm correct how is the performance compared to the new stick which I have come to appreciate

It's a good bit faster than the stick. I'd probably put it about halfway between the stick and the Roku 3, performance wise.
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)
 
User avatar
Komag
Topic Author
Posts: 808
Joined: Fri Aug 22, 2014 3:42 am

Re: Brief summary of advantages of ditching classic Rokus?

Mon Apr 06, 2015 11:58 am

NewManLiving wrote:
...Been able to get good results especially with a redesign that uses less drawtext and employs region offsetting whenever possible as opposed to coordinate offsetting. Those two things gave me a 85-90 comparable look and feel to the higher models. I have a carousel in one app that fades in and out and to do this I was using an offset and a fade at the same time. Was a real dog. But when I changed it to region offsetting and region fading there was a huge difference just a slight jerk from time to time...


This sounds promising to me 8) Can you explain a bit more what you mean by region offsetting/fading vs coordinate offsetting and fading? How were you doing the fading before and after, and what is the offsetting you're talking about? :?:
 
MatroxRT
Posts: 27
Joined: Thu Mar 12, 2015 2:03 pm

Re: Brief summary of advantages of ditching classic Rokus?

Mon Apr 06, 2015 3:59 pm

TheEndless wrote:
NewManLiving wrote:
A lot less remote controls and little boxes all over the place

Hehe.. remember when all you had was a Roku 3? :p


This must be why they refreshed the Roku 2/3 this week. Well... the Devs will have more room on their desks now, so we need them to buy a few more new Roku's. :)

Speaking of which, how do either of you organize your Roku's on your desk?
 
User avatar
NewManLiving
Posts: 452
Joined: Fri Aug 02, 2013 6:14 pm

Re: Brief summary of advantages of ditching classic Rokus?

Mon Apr 06, 2015 5:17 pm

NewManLiving wrote:
...Been able to get good results especially with a redesign that uses less drawtext and employs region offsetting whenever possible as opposed to coordinate offsetting. Those two things gave me a 85-90 comparable look and feel to the higher models. I have a carousel in one app that fades in and out and to do this I was using an offset and a fade at the same time. Was a real dog. But when I changed it to region offsetting and region fading there was a huge difference just a slight jerk from time to time...


This sounds promising to me 8) Can you explain a bit more what you mean by region offsetting/fading vs coordinate offsetting and fading? How were you doing the fading before and after, and what is the offsetting you're talking about? :?:


Region offsetting involves using a bitmap as a buffer for a row of posters, or in the case of a menu, a page of text lines. Or in animation a buffer of frames. The concept involves pretty much the same as I described in my m pointer post. The grid example uses region offsetting as opposed to coordinate offsetting to move the grid as the user scrolls. In a more complex form you can make the buffer virtual and keep adding to it while keeping the virtual portion hidden with the size of the region. So if you have a five poster row say 100x100 you would create a bitmap buffer 100x5 + 100 for the virtual portion. The region size would be 100x100 thus hiding the virtual portion. As the user scrolls the new poster is written to the buffer and then goes into a easing loop to move or offset only the region. So what happens is that since the region is now moving the poster at the left is scrolled out of the region and the new poster is exposed. This involves only one drawobject. On the other hand if you went through a loop of poster bitmaps and drew them each time the user scrolls then you would have a great deal of drawing going on as you recalculated each x coordinate in your easing loop and had to redraw each poster as the coordinates changed. This slows things down substantially on the slower boxes
My Channels: 2D API Framework Presentation: https://owner.roku.com/add/2M9LCVC
Updated: 11-11-2015 - Completed Keyboard interface
The Joel Channel ( Final Beta )
 
User avatar
NewManLiving
Posts: 452
Joined: Fri Aug 02, 2013 6:14 pm

Re: Brief summary of advantages of ditching classic Rokus?

Mon Apr 06, 2015 6:00 pm

Sorry had to go. In the example I described the carousel has three such buffers each holding different perspectives of the carousel. So that was really choppy. Scrolling by coordinate offsetting would probably not be so bad with just one row at a time. But the more you add and anything else you add into the easing loop such as fades takes a toll on the low end boxes. So for me region offsetting proved to be a great deal smoother and faster.
My Channels: 2D API Framework Presentation: https://owner.roku.com/add/2M9LCVC
Updated: 11-11-2015 - Completed Keyboard interface
The Joel Channel ( Final Beta )
 
User avatar
Komag
Topic Author
Posts: 808
Joined: Fri Aug 22, 2014 3:42 am

Re: Brief summary of advantages of ditching classic Rokus?

Tue Apr 07, 2015 2:34 am

Okay, I see what you mean. It almost sounds like the roCompositor example "Scrolling a bitmap". If I understand correctly, this also sounds like basically what NewAnimatedSprite does internally, just loads one wide picture containing all the "frames", and offsets the region when needed for the next frame.

How does this come into play with text menus though? Are you moving the menu around somewhere, or in what way do you reduce the slowdown effect of drawing a lot of text?
 
User avatar
NewManLiving
Posts: 452
Joined: Fri Aug 02, 2013 6:14 pm

Re: Brief summary of advantages of ditching classic Rokus?

Tue Apr 07, 2015 10:48 am

Written and run on the LT 2700X which is my lowest support model at this moment. Use up/dn, fwd, rev, and ok
Test it on your Lower models. Will not run on legacy I believe
Demonstrates the difference between region and coordinate offsetting. I pulled this out of my framework and stripped out a
bunch of code including the compositor so please forgive any mistakes. It is not necessary to use a compositor for region offsetting.
To keep it quick and simple for myself I have kept it in object format. I know this is hard for some to understand right now but all you really
need to do is look at the scrolling functions to see the differences. The scrolling_list_scroll_down_offset, scrolling_list_scroll_up_offset
are the functions that perform y coordinate changes and extraneous drawtext calls. The scrolling functions ending in region
perform the same function using far less code and only one drawtext call. To toggle between the two, press the OK button.
The program starts out with region offsetting. The true value of region offsetting is with older devices, especially those without
access to Open GL. Even the slower devices with Open GL perform far better. As you go up the performance scale there is not
really much of a perceptible difference. Unfortunately, until all under-performing devices are phased out there is the need
to be more optimal with your coding if you want to get the best results. In more complex applications which overlay selectors
have fades, or have multiple columns for a spreadsheet style, the performance really takes a hit. For me right now this seems
to be the best way. But I'm still learning myself. I have commented only where It pertains to the subject. It may well be that the
real difference is the amount of code involved that causes the most significant performance hit



Sub Main() 

   ' Global Channel object - This is where I keep globals
   m.APPChannel = NewTestChannel()
   m.APPChannel.Create()
   
   ' Instance of scrolling list
   l_list = NewScrollingList()
   if not l_list.Create( GetData() )
      print "l_list.Create Failed"
      return
   end if
   
   ' The list's modal event loop
   l_list.EventLoop()
   
   ' Cleanup
   l_list.Release( True )
   l_list.Clear()
   l_list = Invalid
   
   m.APPChannel.Release()
   m.APPChannel.Clear()
   m.APPChannel = Invalid
 
End Sub

' Get some test data
Function GetData() As Object
   l_data = CreateObject( "roArray", 1000, False )
   for l_i = 1 to 100
      l_str = ( 100 - l_i ).ToStr() + " Test Menu Display Line " + l_i.ToStr()
      l_data.Push( l_str )
   end for
   return l_data
End Function

' Channel object used for globals and theme definitions
Function NewTestChannel() As Object

   return {
      BackgroundClr: Invalid
      Device: Invalid
      DisplayWidth:  0 
      DisplayHeight: 0
     
      Screen: Invalid
      Port: Invalid
     
      FontRegistry: Invalid
      DefalutFontR: Invalid
     
      Create: test_channel_create
      Initialize: test_channel_initialize
      Release: test_channel_release
   }
 
End Function

Function test_channel_create() As Boolean
   if m.Initialize() then return True
   m.Release()
   return False
End Function

Function test_channel_release() As Void
   m.FontRegistry = Invalid
   m.DefaultFontR = Invalid
   m.Screen = Invalid
   m.Port   = Invalid
   m.Device = Invalid
End Function

Function test_channel_initialize() As Boolean

   m.BackgroundClr = &hE4D0B7FF
   m.TextColor = &h7A0000FF
   
   m.Device = CreateObject( "roDeviceInfo" )
   l_ds = m.Device.GetDisplaySize()
   m.DisplayWidth  = l_ds.w
   m.DisplayHeight = l_ds.h
   
   m.FontRegistry = CreateObject( "roFontRegistry" )
   m.DefaultFontR = m.FontRegistry.GetDefaultFont( 26, False, False )
 
   m.Screen = CreateObject( "roScreen", True, m.DisplayWidth, m.DisplayHeight )
   m.Port = CreateObject( "roMessagePort" )
   m.Screen.SetMessagePort( m.Port )
   m.Screen.Clear( m.BackgroundClr )
   m.Screen.SwapBuffers()
   
   return True
End Function

' Scrolling list object
Function NewScrollingList() As Object

   return {
   
   APPChannel: m.APPChannel
   Screen:     m.APPChannel.Screen
   Port:       m.APPChannel.Port
   
   IsEase: True
   
   Data: Invalid
   DataCount: 0
 
   DisplayIndexTop: 0
   DisplayIndexBot: 0
   
   X: 0
   Y: 0
   RowHeight:  0
   PageSize:   0
   PageHeight: 0
   
   BkgClr:   Invalid
   TextClr:  Invalid
   TextFont: Invalid
   
   BufferBitmap: Invalid
   BufferRegion: Invalid
   BufferSprite: Invalid
   BufferWidth:  0
   BufferHeight: 0
   
   Create:     scrolling_list_create
   Initialize: scrolling_list_initialize
   Release:    scrolling_list_release
   DrawPage:   scrolling_list_draw_page
   ScrollDown: scrolling_list_scroll_down_offset
   ScrollUp:   scrolling_list_scroll_up_offset
   EventLoop:  scrolling_list_event_loop
   }
   
End Function

Function scrolling_list_create( a_data As Object ) As Boolean
   if m.Initialize( a_data ) then return True
   m.Release( True )
   return False
End Function

Function scrolling_list_initialize( a_data As Object ) As Boolean

   m.Release()
   
   ' Assign the configuration data
   m.TextFont  = m.APPChannel.DefaultFontR
   m.TextClr   = m.APPChannel.TextColor
   m.BkgClr    = m.APPChannel.BackgroundClr
   m.PageSize  = 20
   
   m.DataCount = a_data.Count()
   ' Row Height
   m.TextHeight = m.TextFont.GetOneLineHeight()
   m.RowHeight  = m.TextHeight
   m.PageHeight = m.PageSize * m.RowHeight
 
   ' Determine buffer width
   l_maxWidth = m.APPChannel.DisplayWidth
   m.BufferWidth = 0
   m.Data = NewContainer( m.DataCount )
   l_i = 0
   
   for each l_str in a_data
      l_d = m.Data[ l_i ]
      l_d.SText = l_str
      l_d.TextClr = m.TextClr
      l_d.W = m.TextFont.GetOneLineWidth( l_str, l_maxWidth )
      if m.BufferWidth < l_d.W then m.BufferWidth = l_d.W
      l_i = l_i + 1
   end for

  ' Buffer Height is the page height + a rowHeight virtual row. With region offseting you use additional
  ' memory to maintain an off-region portion of the bitmap.  With coordinate offsetting this is not
  ' needed as you are not wrapping around the region and can start your drawing outside the bounds of
  ' the bitmap (see scrolling functions for more detail )
   m.BufferHeight = m.PageHeight + m.RowHeight
   
   'Finally, create the bitmap buffer
   m.BufferBitmap = CreateObject( "roBitmap", { width: m.BufferWidth, height: m.BufferHeight , AlphaEnable: True } )
   if m.BufferBitmap = Invalid
      print "Unable To Create m.BufferBitmap"
      return False
   end if
 
   ' The buffer region is only what will be displayed on the screen, not the virtual area
   ' Once the virtual area is written to, then the region is offsetted into that area thus
   ' scrolling out one row and scrolling in another
   m.BufferRegion = CreateObject( "roRegion", m.BufferBitmap, 0, 0, m.BufferWidth, m.PageHeight )
   if m.BufferRegion = Invalid
      print "Unable To Create m.BufferRegion"
      return False
   end if
   m.BufferRegion.SetWrap( True )
 
   m.X = int( m.APPChannel.DisplayWidth  / 2 - m.BufferWidth / 2 )
   m.Y = int( m.APPChannel.DisplayHeight / 2 - m.PageHeight / 2 )
   m.DisplayIndexTop = 0
   m.DisplayIndexBot = m.DisplayIndexTop

   m.ScrollDown = scrolling_list_scroll_down_region
   m.ScrollUp   = scrolling_list_scroll_up_region
   m.IsEase = True
   
   m.DrawPage()
   
   return True
   
End Function

Function scrolling_list_release( a_isReleaseAll = False As Boolean ) As Void

   m.BufferBitmap = Invalid
   m.BufferRegion = Invalid
 
   if m.Data <> Invalid
      m.Data.Clear()
      m.Data = Invalid
      m.DataCount = 0
   end if
   
   m.TextFont = Invalid
           
   if a_isReleaseAll
      m.APPChannel  = Invalid
      m.Screen      = Invalid
      m.Port        = Invalid
   end if
   
   return

End Function

' Draw page function draws are page on an as needed bases
Function scrolling_list_draw_page( a_isDrawAll = True As Boolean ) As Boolean

   if m.BufferBitmap = Invalid then return False
   m.BufferBitmap.Clear( m.BkgClr )
 
   l_y = 0
   l_index = m.DisplayIndexTop
 
   for l_i = 1 to m.PageSize
      l_d   = m.Data[ l_index ]
      l_d.Y = l_y
      m.BufferBitmap.DrawText( l_d.SText, l_d.X, l_d.Y, l_d.TextClr, m.TextFont )
      l_y = l_y + m.RowHeight
      l_index = l_index + 1
      if l_index >= m.DataCount then l_index = 0
   end for
   
   m.BufferBitmap.Finish()
   
   l_index = l_index - 1
   if l_index < 0 then l_index = m.DataCount - 1
   m.DisplayIndexBot = l_index
 
   if a_isDrawAll then
      m.Screen.Clear( m.BkgClr )
      m.Screen.DrawObject( m.X, m.Y, m.BufferRegion )
      m.Screen.SwapBuffers()
   end if
   
   return True
End Function

' Offsetting a region
Function scrolling_list_scroll_down_region( a_frames = 16 As Integer ) As Void

   ' Calculate our indexes into the list. You should avoid using an array as a dispaly stack
   ' but more on that if your interested. Suffice to say use a top and bottom index
   l_bd = m.Data[ m.DisplayIndexBot ]
   m.DisplayIndexBot = m.DisplayIndexBot + 1
   if m.DisplayIndexBot >= m.DataCount then m.DisplayIndexBot = 0
   
   l_d = m.Data[ m.DisplayIndexBot ]
   l_d.Y = l_bd.Y + m.RowHeight
   if l_d.Y >= m.BufferHeight then l_d.Y = 0
 
   m.DisplayIndexTop = m.DisplayIndexTop + 1
   if m.DisplayIndexTop >= m.DataCount then m.DisplayIndexTop = 0

   ' So here there is only one call to the drawing functions and the row
   ' is always written to an area of the bitmap outside the position of the region
   ' the region is then scrolled in via offsetting
   m.BufferBitmap.DrawRect( 0, l_d.Y, m.BufferWidth, m.RowHeight, m.BkgClr )
   m.BufferBitmap.DrawText( l_d.SText, l_d.X, l_d.Y, l_d.TextClr, m.TextFont )
   m.BufferBitmap.Finish()
 
   ' Ease the row into view
   l_offset  = 0
   l_prevset = 0
   l_offdiff = 0
   
   for l_i = 1 to a_frames
     
      l_offset  = int( m.RowHeight * l_i / a_frames )
      l_offdiff = l_offset - l_prevset
      l_prevset = l_offset
     
      ' So here we have a simple offsetting of the y coordinate of the region
      ' Think of it as a shopping list of items on a paper and you are my age and
      ' need a magnifying glass to look at it. You only add an item to the bottom of
      ' your shopping list and then use your magnifying glass to move down the list.  The list
      ' does not move around or change positions on the page. It's only the magnifying
      ' glass that is moving thus leaving the previous row and bringing in the next row
      m.BufferRegion.Offset( 0, l_offdiff, 0, 0 )
      m.BufferRegion.Finish()
     
      m.Screen.Clear( m.BkgClr )
      m.Screen.DrawObject( m.X, m.Y, m.BufferRegion )
      m.Screen.SwapBuffers()
   end for
   
End Function

' Same as above only the opposite direction
Function scrolling_list_scroll_up_region( a_frames = 16 As Integer ) As Void

   l_td = m.Data[ m.DisplayIndexTop ]
   m.DisplayIndexTop = m.DisplayIndexTop - 1
   if m.DisplayIndexTop < 0 then m.DisplayIndexTop = m.DataCount - 1
   
   l_d = m.Data[ m.DisplayIndexTop ]
   l_d.Y = l_td.Y - m.RowHeight
   if l_d.Y < 0 then l_d.Y = m.BufferHeight - m.RowHeight
   
   m.DisplayIndexBot = m.DisplayIndexBot - 1
   if m.DisplayIndexBot < 0 then m.DisplayIndexBot = m.DataCount - 1
   
   m.BufferBitmap.DrawRect( 0, l_d.Y, m.BufferWidth, m.RowHeight, m.BkgClr )
   m.BufferBitmap.DrawText( l_d.SText, l_d.X, l_d.Y, l_d.TextClr, m.TextFont )
   m.BufferBitmap.Finish()
 
   ' Ease the row into view
   l_offset  = 0
   l_prevset = 0
   l_offdiff = 0
 
   for l_i = 1 to a_frames
      l_offset  = int( m.RowHeight * l_i / a_frames )
      l_offdiff = l_offset - l_prevset
      l_prevset = l_offset
     
      m.BufferRegion.Offset( 0, -l_offdiff, 0, 0 )
      m.BufferRegion.Finish()
   
      m.Screen.Clear( m.BkgClr )
      m.Screen.DrawObject( m.X, m.Y, m.BufferRegion )
      m.Screen.SwapBuffers()
   end for
   
End Function

' Offseting the coordinates
Function scrolling_list_scroll_down_offset( a_frames = 16 As Integer ) As Void

   l_bd = m.Data[ m.DisplayIndexBot ]
   m.DisplayIndexBot = m.DisplayIndexBot + 1
   if m.DisplayIndexBot >= m.DataCount then m.DisplayIndexBot = 0
   
   ' Since you are not using region offseting here you only need to start outside
   ' the boundry of your bitmap depending upon which direction you are going in
   l_d = m.Data[ m.DisplayIndexBot ]
   l_d.Y = m.BufferHeight - m.RowHeight
   
   m.Screen.Clear( m.BkgClr )
   ' Ease the row into view
   l_offset  = 0
   l_prevset = 0
   l_offdiff = 0
   
   ' Now you have to ease offset each line in your display
   for l_i = 1 to a_frames
     
      l_offset  = int( m.RowHeight * l_i / a_frames )
      l_offdiff = l_offset - l_prevset
      l_prevset = l_offset
     
      m.BufferBitmap.Clear( m.BkgClr )
     
      ' Here we must use a loop to iterate or display indexes, change their coordinates
      ' and redraw them.  More calls, more loops and more math
      l_index = m.DisplayIndexTop
      for l_j = 1 to m.PageSize
         l_d = m.Data[ l_index ]
         l_d.Y = l_d.Y - l_offdiff
         m.BufferRegion.DrawText( l_d.SText, l_d.X, l_d.Y, l_d.TextClr, m.TextFont )
         l_index = l_index + 1
         if l_index >= m.DataCount then l_index = 0
      end for
     
     ' Then you also have to bring in the new line
     l_d = m.Data[ m.DisplayIndexBot ]
     l_d.Y = l_d.Y - l_offdiff
     m.BufferRegion.DrawText( l_d.SText, l_d.X, l_d.Y, l_d.TextClr, m.TextFont )
     m.BufferRegion.Finish()
   
     m.Screen.DrawObject( m.X, m.Y, m.BufferRegion )
     m.Screen.SwapBuffers()
   end for
   
   m.DisplayIndexTop = m.DisplayIndexTop + 1
   if m.DisplayIndexTop >= m.DataCount then m.DisplayIndexTop = 0
 
End Function


Function scrolling_list_scroll_up_offset( a_frames = 16 As Integer ) As Void

   l_td = m.Data[ m.DisplayIndexTop ]
   m.DisplayIndexTop = m.DisplayIndexTop - 1
   if m.DisplayIndexTop < 0 then m.DisplayIndexTop = m.DataCount - 1
   
   l_d = m.Data[ m.DisplayIndexTop ]
   l_d.Y = -m.RowHeight
   
    m.Screen.Clear( m.BkgClr )
   ' Ease the row into view
   l_offset  = 0
   l_prevset = 0
   l_offdiff = 0
   
   for l_i = 1 to a_frames
     
      l_offset  = int( m.RowHeight * l_i / a_frames )
      l_offdiff = l_offset - l_prevset
      l_prevset = l_offset
     
      m.BufferBitmap.Clear( m.BkgClr )
     
      l_index = m.DisplayIndexTop
      for l_j = 1 to m.PageSize
         l_d = m.Data[ l_index ]
         l_d.Y = l_d.Y + l_offdiff
         m.BufferRegion.DrawText( l_d.SText, l_d.X, l_d.Y, l_d.TextClr, m.TextFont )
         l_index = l_index + 1
         if l_index >= m.DataCount then l_index = 0
      end for
     
     l_d = m.Data[ m.DisplayIndexBot ]
     l_d.Y = l_d.Y + l_offdiff
     m.BufferRegion.DrawText( l_d.SText, l_d.X, l_d.Y, l_d.TextClr, m.TextFont )
     m.BufferRegion.Finish()
   
     m.Screen.DrawObject( m.X, m.Y, m.BufferRegion )
     m.Screen.SwapBuffers()
   end for
   
   m.DisplayIndexBot = m.DisplayIndexBot - 1
   if m.DisplayIndexBot < 0 then m.DisplayIndexBot = m.DataCount - 1
   
End Function

Function scrolling_list_event_loop() As Boolean
 
   if m.BufferBitmap = Invalid
      print "m.BufferBitmap Is Invalid"
      return False
   end if
 
   l_scrollFrameRate = 8
   l_pageFrameRate = 2
   l_scrollSpeed = 200
   
   l_bp_BK  = 0
   l_bp_UP  = 2
   l_bp_DN  = 3
   l_bp_OK  = 6
   l_bp_REV = 8
   l_bp_FWD = 9
 
   l_index = 0
   l_lastKey = -1
   l_running = True
 
   l_timer = CreateObject( "roTimeSpan" )
   
   while( l_running )
   
      l_msg = m.Port.GetMessage()
     
      if type( l_msg ) = "roUniversalControlEvent"
   
         l_index   = l_msg.GetInt()
         l_lastKey = l_index
       
         if l_index = l_bp_DN or l_index = l_bp_FWD
            m.ScrollDown( l_scrollFrameRate )
         else if l_index = l_bp_UP or l_index = l_bp_REV
            m.ScrollUp( l_scrollFrameRate )
         else if l_index = l_bp_OK
         
            m.Screen.Clear( m.BkgClr )
           
            if m.IsEase
               m.Screen.DrawText( "Switching To Coordinate Offsetting...", 100, 100, m.TextClr, m.TextFont )
               m.ScrollDown = scrolling_list_scroll_down_offset
               m.ScrollUp   = scrolling_list_scroll_up_offset
            else
               m.Screen.DrawText( "Switching To Region Offsetting...", 100, 100, m.TextClr, m.TextFont )
               m.ScrollDown = scrolling_list_scroll_down_region
               m.ScrollUp   = scrolling_list_scroll_up_region
            end if
           
            m.Screen.SwapBuffers()
            Sleep( 1500 )
           
            m.BufferRegion.Offset( 0, -m.BufferRegion.GetY(), 0, 0 )
            m.bufferregion.Finish()
           
            m.DisplayIndexTop = 0
            m.DrawPage()
            m.IsEase = not m.IsEase
            l_lastKey = -1
           
         else if l_index = l_bp_BK
            l_running = False
         else if l_index >= 100 ' All key ups are value + 100
            l_lastKey = -1
         end if
         
         l_timer.Mark()
       
      else if (  l_lastKey >= 0 and l_timer.TotalMilliseconds() >= l_scrollSpeed )
     
         if l_lastKey = l_bp_DN
            m.ScrollDown( l_scrollFrameRate )
         else if l_lastKey = l_bp_FWD
            m.ScrollDown( l_pageFrameRate )
         else if l_lastKey = l_bp_UP
            m.ScrollUp( l_scrollFrameRate )
         else if l_lastKey = l_bp_REV
            m.ScrollUp( l_pageFrameRate )
         end if
         
      end if
     
   end while
 
   return True

End Function


Function NewContainer( a_count As Integer ) As Object
   dc = CreateObject( "roArray", a_count, False )
   for l_i = 0 to a_count - 1 : dc.Push( NewData( l_i ) ) : end for     
   return dc
End Function


Function NewData( a_index As Integer ) As Object
   return {
      Index: a_index
      X: 0
      Y: 0
      W: 0
      H: 0
      SText: Invalid
      TextClr: Invalid
   }
End Function

My Channels: 2D API Framework Presentation: https://owner.roku.com/add/2M9LCVC
Updated: 11-11-2015 - Completed Keyboard interface
The Joel Channel ( Final Beta )
 
User avatar
Komag
Topic Author
Posts: 808
Joined: Fri Aug 22, 2014 3:42 am

Re: Brief summary of advantages of ditching classic Rokus?

Tue Apr 07, 2015 12:13 pm

On my Roku 2 XS there is almost no difference in this example, but man, on my new Roku 1 it's night and day, wow! :shock:
 
User avatar
NewManLiving
Posts: 452
Joined: Fri Aug 02, 2013 6:14 pm

Re: Brief summary of advantages of ditching classic Rokus?

Tue Apr 07, 2015 12:22 pm

Yeah same on my stick. Thought there would be better performance on the stick but it was just as bad as the LTE. Perfectly smooth though with region offsetting.
My Channels: 2D API Framework Presentation: https://owner.roku.com/add/2M9LCVC
Updated: 11-11-2015 - Completed Keyboard interface
The Joel Channel ( Final Beta )

Who is online

Users browsing this forum: No registered users and 13 guests