NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public Developers v
« Previous 1 11 12 13 14 15 … 93 Next »
More "efficient" redraw?

 
  • 0 Vote(s) - 0 Average
More "efficient" redraw?
whurlston
Offline

Posting Freak

Posts: 7,885
Threads: 102
Joined: Nov 2006
#31
2012-01-10, 12:34 AM
Try using a UIStatic instead of a UIElement:

Screensaver.xml:
Code:
<Skin>
  [B][I][COLOR="#FF0000"]<Element name="SSBG" location="0,0" size="100,100" alpha="255">
    <Rect location="0,0" size="100,100" fillColor="Black"/>
  </Element>[/COLOR][/I][/B]
  <Element name="Content" location="0,0" size="75,75" alpha="255">
     ...
  </Element>
</Skin>
Screensaver.cs (only showing differences)
Code:
private UiElement _Black = null;
        [I][B][color=#FF0000]private UiStatic _Black2 = null;[/color][/B][/I]
        private UiStatic _Content = null;

         public ScreensaverPopup(SkinHelper skinHelper, string backgroundElementName, Hashtable args, IPluginCallback callback)
            : base(skinHelper, backgroundElementName, args, callback)
        {
          ...
           _Black = new UiElement("screensaver-black", new RectangleF(0, 0, 100, 100), black, 255);
           [I] [B][color=#FF0000]_Black2 = new UiStatic("SSBG", new Hashtable(), skinHelper);[/color][/B][/I]
            _Content = new UiStatic("Content", _Args, skinHelper);
           ...
        }

        public override List<UiElement> GetRenderList()
        {
            System.Diagnostics.Debug.WriteLine("TESTREDRAW: GetRenderList (popup) " + DateTime.Now.Second);
            Logger.Info("TESTREDRAW: GetRenderList (popup) " + DateTime.Now.Second);
            List<UiElement> renderList = base.GetRenderList();
            [I][B][COLOR="#FF0000"]//renderList.Add(_Black);
            renderList.AddRange(_Black2.GetRenderList());[/COLOR][/B][/I]
            renderList.AddRange(_Content.GetRenderList());
            return renderList;
        }

Ideally though, I would resize _Content and just put the background rectangle there. That way you only have to render _Content.
whurlston
Offline

Posting Freak

Posts: 7,885
Threads: 102
Joined: Nov 2006
#32
2012-01-10, 12:45 AM
Also (IIRC), UIStatic elements will get rerendered automatically if there is a text change, so you would only need to return base.NeedsRendering.
cncb
Offline

Senior Member

Posts: 729
Threads: 112
Joined: Aug 2011
#33
2012-01-10, 05:48 PM
Thanks, but according to sub, currently the only way to black out the entire screen (including the date/time in the corner) is to use the specially named UIElement as in '_Black'.
My Plugins: PhotoFilter, MusicMonkey, Windows Desktop Gadget
whurlston
Offline

Posting Freak

Posts: 7,885
Threads: 102
Joined: Nov 2006
#34
2012-01-10, 06:05 PM
Ah, right you are!

It actually turned out to be a simple fix however. I only needed to make a one line code addition to ScreensaverPopup.cs from the original project you posted (and uncommented an if statement):

Code:
public override bool NeedsRendering()
        {
            [B][color=#FF0000]_Black.forceRefresh = _Refresh;[/color][/B]
            if (_Refresh)
            {
                _Refresh = false;
                return true;
            }
            else
                return false;
        }
cncb
Offline

Senior Member

Posts: 729
Threads: 112
Joined: Aug 2011
#35
2012-01-10, 06:54 PM
whurlston Wrote:It actually turned out to be a simple fix however. I only needed to make a one line code addition to ScreensaverPopup.cs from the original project you posted (and uncommented an if statement):

I made these changes and still have the problem (let it run for several seconds and you should see it happen eventually too). I think there may be a problem in the core causing this.
My Plugins: PhotoFilter, MusicMonkey, Windows Desktop Gadget
whurlston
Offline

Posting Freak

Posts: 7,885
Threads: 102
Joined: Nov 2006
#36
2012-01-10, 07:06 PM
Interesting. I had only tested it for a few seconds previously and it seemed to work. This time, I let it run for over a minute and it worked fine (only calling GetRenderList once per second) but at exactly the one minute mark, it starts calling it multiple times per second.
whurlston
Offline

Posting Freak

Posts: 7,885
Threads: 102
Joined: Nov 2006
#37
2012-01-13, 11:14 PM
Update to my last post:

It's not at the one minute mark that the issue occurs; it happens on the minute. If you start the "screensaver" popup at 1:00:35, the problem occurs 25 seconds later at 1:01:00. If you start the popup at 1:00:55, the problem occurs 5 seconds later. I can confirm that both the main plugin and the popup are both returning "false" for NeedsRendering() but GetRenderList() gets called anyway.

Why this is happening is above my paygrade.
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,789
Threads: 769
Joined: Nov 2003
#38
2012-01-14, 12:44 AM
I started taking a look at this. One initial thing I noticed is that you're rendering on a background thread, which is likely to cause problems (and did cause native exceptions for me in the debugger).

Instead of using the timer, you should just set a DateTime to the time you want the next update to occur, then in NeedsRendering() check to see if that time has been reached, if so do the update and set the DateTime for the next update etc.
cncb
Offline

Senior Member

Posts: 729
Threads: 112
Joined: Aug 2011
#39
2012-01-14, 03:00 AM
sub Wrote:I started taking a look at this. One initial thing I noticed is that you're rendering on a background thread, which is likely to cause problems (and did cause native exceptions for me in the debugger).

Ok, I didn't realize that changing the "Args" in a background thread would cause the actual rendering to take place in the background thread.
My Plugins: PhotoFilter, MusicMonkey, Windows Desktop Gadget
cncb
Offline

Senior Member

Posts: 729
Threads: 112
Joined: Aug 2011
#40
2012-01-14, 06:55 PM
whurlston Wrote:It's not at the one minute mark that the issue occurs; it happens on the minute. If you start the "screensaver" popup at 1:00:35, the problem occurs 25 seconds later at 1:01:00. If you start the popup at 1:00:55, the problem occurs 5 seconds later. I can confirm that both the main plugin and the popup are both returning "false" for NeedsRendering() but GetRenderList() gets called anyway.

sub, This is exactly what I'm seeing too. I stopped using the Timer and am using the DateTime check in NeedsRendering() like you suggested and it still happens on the minute mark as whurlston discovered.

A few general questions:
1) How often is NeedsRendering() called?
2) If GetRenderList() is supposed to be static, why is it called every time a render takes place instead of the list being "cached"? Or do you expect the plugin code to cache the list instead of recreating each time?
My Plugins: PhotoFilter, MusicMonkey, Windows Desktop Gadget
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)

Pages (6): « Previous 1 2 3 4 5 6 Next »


Possibly Related Threads…
Thread Author Replies Views Last Post
  how to force redraw? Wakalaka 3 1,780 2007-03-27, 09:58 AM
Last Post: psycik

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode