-
Notifications
You must be signed in to change notification settings - Fork 7.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Skip a frame if there is no action updated or event dispatched #6178
Conversation
…duce power consumption
@ricardoquesada : I know this is a very premature and risky feature, but if we can do on-demand frame update eventually, I think it could reduce cocos2d-x engine's power consumption substantially. |
Great feature. We implemented it for cocos2d-x v2.
|
I like the idea, but I think the current patch is not covering all the possible updates. Anyway, I think reducing the power consumption is a great feature. What other things should we do in order to say that cocos2d is eco-friendly ? :) As an example: How about networking ? can we improve our network library to be eco-friendly ? |
Thanks! @ricardoquesada, I will run more tests to verify if it works on all cases. |
@thoechsmann ,That's great, Can you join to improve this PR? |
@ricardoquesada is right. This patch didn't cover all |
@@ -274,6 +278,11 @@ void Director::drawScene() | |||
_eventDispatcher->dispatchEvent(_eventAfterUpdate); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dumganhar : if we set dirty bit in scheduler->update(), The dirty bit will be set every frame. So, We have to set it in scheduler target update() function, such as ActionManager, or other targets. This approach is more precise, but application code have to set the dirty bit if it has custom scheduler update(). Another choice is set dirty bit for all custom update(), it's less precise, but simpler.
We introduced a global variable that was set to true if a property of a CCNode changed. You only seem to cover scheduled actions. What happens if you set e.g. the position of a sprite. It will not trigger a redraw. |
@thoechsmann : In such case, Does Application code need set the dirty flag manually, or engine can detect the property change? |
The Application should never be responsible for this. Otherwise there will be tons of problems. It must be handled inside of cocos. Maybe Ric has a better idea, but I would add code to CCNode. flag must be set to dirty if you add/remove a child or set properties like position, color, … In most (but not all) cases it can be set when _transformUpdated is set. Other things to keep in mind is that you cannot stop rendering after one frame when there are no more changes. This will not work on all android devices. We rendered always 3 frames after the last change. I think two frames should be enough, but we got problems with that. I can merge in our changes in V3 and make a pull request so you can take a look at the changes. On 09 Apr 2014, at 11:29, heliclei notifications@github.com wrote:
|
@thoechsmann: Thank you very much! I haven't test android device yet. |
yes, the best way to do it is in visit. and visit should return a boolean indicating whether or not the scene is dirty. We are already passing the |
That's great! @ricardoquesada 👍 |
Dear heliclei: |
To reduce power consumption