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

[darwin] Update pixel format handling in FlutterTexture#52326

Merged
auto-submit[bot] merged 2 commits into
flutter-team-archive:mainfrom
bc-lee:feature/cvpixelbuffer-type
Apr 24, 2024
Merged

[darwin] Update pixel format handling in FlutterTexture#52326
auto-submit[bot] merged 2 commits into
flutter-team-archive:mainfrom
bc-lee:feature/cvpixelbuffer-type

Conversation

@bc-lee

@bc-lee bc-lee commented Apr 23, 2024

Copy link
Copy Markdown
Contributor

CVPixelBuffers from the application can have arbitrary pixel formats. However, current implementation doesn't support all pixel formats. To address this, add a comment to the FlutterTexture class to clarify which pixel formats are supported. Also, reject unsupported pixel formats so that the application can handle them properly.

Fixes #147242.

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 listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or 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.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

CVPixelBuffers from the application can have arbitrary pixel formats.
However, current implementation doesn't support all pixel formats.
To address this, add a comment to the FlutterTexture class to clarify
which pixel formats are supported. Also, reject unsupported pixel
formats so that the application can handle them properly.

Fixes #147242.
image = [self wrapNV12ExternalPixelBuffer:pixelBuffer context:context];
} else {
} else if (_pixelFormat == kCVPixelFormatType_32BGRA) {
image = [self wrapRGBAExternalPixelBuffer:pixelBuffer context:context];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This method is incorrectly named. Perhaps rename to wrapBGRAExternalPixelBuffer:context: too? Internally, it does assume BGRA as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done. Note that [FlutterDarwinExternalTextureSkImageWrapper: wrapRGBATexture:grContext:width:height:] also has RGBA in its name. I'm not sure renaming all of them to use BGRA is a good idea, but I'm open to suggestions.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If its not already a public method and the name is more fitting, go for it!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was considering renaming the wrapRGBATexture method, but I think it is better to keep the method name as it is.

Link1 Link2

We have kYUVA and kRGBA as the two possible values for FlutterMetalExternalTexturePixelFormat, and the function I mentioned above is used along with the enum, FlutterMetalExternalTexturePixelFormat. So it sounds like renaming would be more confusing.

It was requested to rename during the review, so I did it.
@bc-lee

bc-lee commented Apr 24, 2024

Copy link
Copy Markdown
Contributor Author

Fell free to merge this PR. Thanks for reviewing!

@jonahwilliams jonahwilliams left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@jonahwilliams jonahwilliams added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 24, 2024
@auto-submit auto-submit Bot merged commit c330ca8 into flutter-team-archive:main Apr 24, 2024
@bc-lee bc-lee deleted the feature/cvpixelbuffer-type branch April 24, 2024 22:39
auto-submit Bot pushed a commit to flutter/flutter that referenced this pull request Apr 24, 2024
flutter-team-archive/engine@b5d5832...b30c0a7

2024-04-24 15619084+vashworth@users.noreply.github.com Remove UIAccessibilityTraitKeyboardKey to fix touch typing (flutter-team-archive/engine#52333)
2024-04-24 bdero@google.com [Impeller] Remove libtess2 from libflutter. (flutter-team-archive/engine#52357)
2024-04-24 skia-flutter-autoroll@skia.org Roll Skia from 510b6766d907 to afcc1db27593 (2 revisions) (flutter-team-archive/engine#52367)
2024-04-24 yjbanov@google.com [web:tests] switch to new HTML DOM matcher (flutter-team-archive/engine#52354)
2024-04-24 jonahwilliams@google.com [Impeller] use spec constant for gaussian shader, rename, and reuse vertex sources. (flutter-team-archive/engine#52361)
2024-04-24 jonahwilliams@google.com [Impeller] delete points compute shader. (flutter-team-archive/engine#52346)
2024-04-24 byoungchan.lee@gmx.com [darwin] Update pixel format handling in FlutterTexture (flutter-team-archive/engine#52326)
2024-04-24 jonahwilliams@google.com [Impeller] make drawAtlas always use porterduff or vertices_uber shader (flutter-team-archive/engine#52348)
2024-04-24 magder@google.com Migrate ios_surface files to ARC (flutter-team-archive/engine#52139)
2024-04-24 skia-flutter-autoroll@skia.org Roll Dart SDK from f470eaaf6e6d to 38c43a01a51e (1 revision) (flutter-team-archive/engine#52365)
2024-04-24 skia-flutter-autoroll@skia.org Roll Skia from b5dd23bd29df to 510b6766d907 (16 revisions) (flutter-team-archive/engine#52364)
2024-04-24 jason-simmons@users.noreply.github.com Fix some warnings reported by recent versions of clang-tidy (flutter-team-archive/engine#52349)
2024-04-24 skia-flutter-autoroll@skia.org Roll Skia from e15464e6e982 to b5dd23bd29df (1 revision) (flutter-team-archive/engine#52353)
2024-04-24 skia-flutter-autoroll@skia.org Roll Dart SDK from 5227dc5103f6 to f470eaaf6e6d (1 revision) (flutter-team-archive/engine#52359)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC jimgraham@google.com,rmistry@google.com,zra@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

affects: desktop autosubmit Merge PR when tree becomes green via auto submit App platform-ios platform-macos

Development

Successfully merging this pull request may close these issues.

[macOS/iOS] FlutterTextureRegistry accepts only a few CVPixelBuffer formats. It should be documented.

4 participants