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

[skwasm] Use displayWidth/displayHeight instead of codedWidth/codedHeight #56686

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/web_ui/lib/src/engine/skwasm/skwasm_impl/codecs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class SkwasmImageDecoder extends BrowserImageDecoder {

@override
ui.Image generateImageFromVideoFrame(VideoFrame frame) {
final int width = frame.codedWidth.toInt();
final int height = frame.codedHeight.toInt();
final int width = frame.displayWidth.toInt();
final int height = frame.displayHeight.toInt();
final SkwasmSurface surface = (renderer as SkwasmRenderer).surface;
return SkwasmImage(imageCreateFromTextureSource(
frame as JSObject,
Expand Down
13 changes: 13 additions & 0 deletions lib/web_ui/test/ui/image_golden_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,19 @@ Future<void> testMain() async {
return info.image;
});

test('decode rotated jpeg', () async {
// This image (from skia's test images) has a rotated orientation in its exif data.
// This should result in a 3024x4032 image, not 4032x3024 image.
final ui.Codec codec = await renderer.instantiateImageCodecFromUrl(
Uri(path: '/test_images/iphone_15.jpeg')
);
expect(codec.frameCount, 1);

final ui.FrameInfo info = await codec.getNextFrame();
expect(info.image.width, 3024);
expect(info.image.height, 4032);
});

// This API doesn't work in headless Firefox due to requiring WebGL
// See https://github.com/flutter/flutter/issues/109265
if (!isFirefox) {
Expand Down