Jump to content

Cost of Drawing / Reducing paint refresh rate


Solzhenitsyn

Recommended Posts

Just had a thought. If you wanted to limit your refresh rate to say 10fps.

 

Instead of redrawing each time in your onpaint. Have an Image stored in memory, then ever 1/10th of a second update it in your paint code.

 

So some code off the top of my head. functions wont be right and you will have to put everything that you currently do in redrawImage and have it output to a single image of just the stuff to be drawn.

currenttime = System.currentTimeMilliseconds();
if(nextdrawtime-currenttime <= 0)
{
	storedImage = redrawImage();
	nextdrawtime = currenttime+100;
}

g.draw(storedImage); // I know that won't be correct call, on phone and don't use paint much

 

That would mean every 100ms it updates the storedImage with the new stuff that should be on screen then draws it. If its less than 100ms since last redraw of image, just draw image from memory, which should be a lot less resource intensive then doing all of the other stuff. In theory at least, just an idea, no clue if it will have intended effect.

Edited by venetox
Link to comment
Share on other sites

Just add a timer and find the average frequency of the paint and only paint every x time.

 

In LoL, it's based on every time DX EndScene is called, which is effectively measured through FPS. So if your FPS is 300, there's no sense in drawing 300x a second when your monitor is only 60 Hz.

 

It's capped at 60  (I think) FPS.

I wouldn't recommend going this way, everything will look stuttered.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...