Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@betrevisan
Copy link
Contributor

@betrevisan betrevisan commented Jul 30, 2022

The changes proposed in this PR enable dirty region management within the Embedder API for OpenGL rendering backends. That is, embedders will only render the regions that changed in between frames rather than rendering the entire screen every time. These changes provide a framework for reducing raster time and energy consumption across all embedders using the Flutter Embedder API, immediately affecting OpenGL-based embedders such as the ones implemented for Linux and Windows platforms. In the future, after support for Metal is added, MacOS platforms should also be benefitted.

The implementation adds a new struct, FlutterDamage, to the Embedder API and updates the present and FBO callbacks to handle the necessary information for dirty region management. More specifically to OpenGL, the Embedder GL Surface and the GL Skia GPU have been updated to take damaged regions into account.

The relevant tests have been included inside the embedder_unittests_gl files.

I also ran a local benchmark using this implementation of the embedder with partial repaint within an example of a screen with a loading spinner in the center. The version not using partial repaint had an average present time of 4,171μs/frame while the version using partial repaint had an average present time of 2,457μs/frame.

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide] and the [C++, Objective-C, Java style guides].
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See [testing the engine] for instructions on
    writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the [CLA].
  • All existing and new tests are passing.

@flutter-dashboard flutter-dashboard bot added embedder Related to the embedder API platform-android labels Jul 30, 2022
@betrevisan betrevisan requested review from bdero and iskakaushik July 30, 2022 01:52
Copy link
Contributor

@iskakaushik iskakaushik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some initial feedback.

@betrevisan betrevisan marked this pull request as ready for review August 1, 2022 18:11
@betrevisan betrevisan requested a review from chinmaygarde August 1, 2022 18:11
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

typedef void (*FlutterFrameBufferWithDamageCallback)(
void* /* user data */,
const intptr_t /* fbo id */,
FlutterDamage* /* existing damage */);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chinmaygarde this is an out parameter, the embedder populates this struct, but it has a list of rects in it. Do you have any recommendations of how the embedder can supply a buffer for the engine to fill out?

/// responsible for providing populate_existing_damage_callback with the FBO's
/// ID. Not specifying populate_existing_damage_callback will result in full
/// repaint (i.e. rendering all the pixels on the screen at every frame).
FlutterFrameBufferWithDamageCallback populate_existing_damage_callback;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove: _callback at the end.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good! I updated the name to populate_existing_damage.

Copy link
Contributor

@iskakaushik iskakaushik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor rename suggestion, but LGTM otherwise

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App embedder Related to the embedder API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants