From 574b94e5663016e96a868b5e048dcd627356aa93 Mon Sep 17 00:00:00 2001 From: Brandon Jones Date: Mon, 30 Jan 2023 18:26:11 +0000 Subject: [PATCH] Change External Texture Rotation To Counter-Clockwise When rotation metadata is added to videos by ffmpeg, it is specified as counter-clockwise. Dawn should follow this format to avoid confusion during integration. Bug: chromium:1316671 Change-Id: I99ff30bffb1664aafd060d9a5bb1b15845388386 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117912 Kokoro: Kokoro Commit-Queue: Brandon1 Jones Reviewed-by: Corentin Wallez --- src/dawn/native/ExternalTexture.cpp | 8 +- .../tests/end2end/ExternalTextureTests.cpp | 192 +++++++++--------- 2 files changed, 99 insertions(+), 101 deletions(-) diff --git a/src/dawn/native/ExternalTexture.cpp b/src/dawn/native/ExternalTexture.cpp index 290f4650ac..b95c90ff50 100644 --- a/src/dawn/native/ExternalTexture.cpp +++ b/src/dawn/native/ExternalTexture.cpp @@ -270,8 +270,8 @@ MaybeError ExternalTextureBase::Initialize(DeviceBase* device, case wgpu::ExternalTextureRotation::Rotate0Degrees: break; case wgpu::ExternalTextureRotation::Rotate90Degrees: - coordTransformMatrix = Mul(mat2x3{0, +1, 0, // x' = y - -1, 0, 0}, // y' = -x + coordTransformMatrix = Mul(mat2x3{0, -1, 0, // x' = -y + +1, 0, 0}, // y' = x coordTransformMatrix); break; case wgpu::ExternalTextureRotation::Rotate180Degrees: @@ -280,8 +280,8 @@ MaybeError ExternalTextureBase::Initialize(DeviceBase* device, coordTransformMatrix); break; case wgpu::ExternalTextureRotation::Rotate270Degrees: - coordTransformMatrix = Mul(mat2x3{0, -1, 0, // x' = -y - +1, 0, 0}, // y' = x + coordTransformMatrix = Mul(mat2x3{0, +1, 0, // x' = y + -1, 0, 0}, // y' = -x coordTransformMatrix); break; } diff --git a/src/dawn/tests/end2end/ExternalTextureTests.cpp b/src/dawn/tests/end2end/ExternalTextureTests.cpp index e5befeb456..1e2ee9ba11 100644 --- a/src/dawn/tests/end2end/ExternalTextureTests.cpp +++ b/src/dawn/tests/end2end/ExternalTextureTests.cpp @@ -382,24 +382,23 @@ TEST_P(ExternalTextureTests, RotateAndOrFlipSinglePlane) { utils::RGBA8 lowerRightColor; }; - std::array expectations = {{ - {wgpu::ExternalTextureRotation::Rotate0Degrees, false, utils::RGBA8::kGreen, - utils::RGBA8::kBlack, utils::RGBA8::kRed, utils::RGBA8::kBlue}, - {wgpu::ExternalTextureRotation::Rotate90Degrees, false, utils::RGBA8::kRed, - utils::RGBA8::kGreen, utils::RGBA8::kBlue, utils::RGBA8::kBlack}, - {wgpu::ExternalTextureRotation::Rotate180Degrees, false, utils::RGBA8::kBlue, - utils::RGBA8::kRed, utils::RGBA8::kBlack, utils::RGBA8::kGreen}, - {wgpu::ExternalTextureRotation::Rotate270Degrees, false, utils::RGBA8::kBlack, - utils::RGBA8::kBlue, utils::RGBA8::kGreen, utils::RGBA8::kRed}, - {wgpu::ExternalTextureRotation::Rotate0Degrees, true, utils::RGBA8::kRed, - utils::RGBA8::kBlue, utils::RGBA8::kGreen, utils::RGBA8::kBlack}, - {wgpu::ExternalTextureRotation::Rotate90Degrees, true, utils::RGBA8::kBlue, - utils::RGBA8::kBlack, utils::RGBA8::kRed, utils::RGBA8::kGreen}, - {wgpu::ExternalTextureRotation::Rotate180Degrees, true, utils::RGBA8::kBlack, - utils::RGBA8::kGreen, utils::RGBA8::kBlue, utils::RGBA8::kRed}, - {wgpu::ExternalTextureRotation::Rotate270Degrees, true, utils::RGBA8::kGreen, - utils::RGBA8::kRed, utils::RGBA8::kBlack, utils::RGBA8::kBlue}, - }}; + std::array expectations = { + {{wgpu::ExternalTextureRotation::Rotate0Degrees, false, utils::RGBA8::kGreen, + utils::RGBA8::kBlack, utils::RGBA8::kRed, utils::RGBA8::kBlue}, + {wgpu::ExternalTextureRotation::Rotate90Degrees, false, utils::RGBA8::kBlack, + utils::RGBA8::kBlue, utils::RGBA8::kGreen, utils::RGBA8::kRed}, + {wgpu::ExternalTextureRotation::Rotate180Degrees, false, utils::RGBA8::kBlue, + utils::RGBA8::kRed, utils::RGBA8::kBlack, utils::RGBA8::kGreen}, + {wgpu::ExternalTextureRotation::Rotate270Degrees, false, utils::RGBA8::kRed, + utils::RGBA8::kGreen, utils::RGBA8::kBlue, utils::RGBA8::kBlack}, + {wgpu::ExternalTextureRotation::Rotate0Degrees, true, utils::RGBA8::kRed, + utils::RGBA8::kBlue, utils::RGBA8::kGreen, utils::RGBA8::kBlack}, + {wgpu::ExternalTextureRotation::Rotate90Degrees, true, utils::RGBA8::kGreen, + utils::RGBA8::kRed, utils::RGBA8::kBlack, utils::RGBA8::kBlue}, + {wgpu::ExternalTextureRotation::Rotate180Degrees, true, utils::RGBA8::kBlack, + utils::RGBA8::kGreen, utils::RGBA8::kBlue, utils::RGBA8::kRed}, + {wgpu::ExternalTextureRotation::Rotate270Degrees, true, utils::RGBA8::kBlue, + utils::RGBA8::kBlack, utils::RGBA8::kRed, utils::RGBA8::kGreen}}}; for (const RotationExpectation& exp : expectations) { // Pipeline Creation @@ -572,20 +571,20 @@ TEST_P(ExternalTextureTests, RotateAndOrFlipMultiplanar) { std::array expectations = { {{wgpu::ExternalTextureRotation::Rotate0Degrees, false, utils::RGBA8::kGreen, utils::RGBA8::kBlack, utils::RGBA8::kRed, utils::RGBA8::kBlue}, - {wgpu::ExternalTextureRotation::Rotate90Degrees, false, utils::RGBA8::kRed, - utils::RGBA8::kGreen, utils::RGBA8::kBlue, utils::RGBA8::kBlack}, + {wgpu::ExternalTextureRotation::Rotate90Degrees, false, utils::RGBA8::kBlack, + utils::RGBA8::kBlue, utils::RGBA8::kGreen, utils::RGBA8::kRed}, {wgpu::ExternalTextureRotation::Rotate180Degrees, false, utils::RGBA8::kBlue, utils::RGBA8::kRed, utils::RGBA8::kBlack, utils::RGBA8::kGreen}, - {wgpu::ExternalTextureRotation::Rotate270Degrees, false, utils::RGBA8::kBlack, - utils::RGBA8::kBlue, utils::RGBA8::kGreen, utils::RGBA8::kRed}, + {wgpu::ExternalTextureRotation::Rotate270Degrees, false, utils::RGBA8::kRed, + utils::RGBA8::kGreen, utils::RGBA8::kBlue, utils::RGBA8::kBlack}, {wgpu::ExternalTextureRotation::Rotate0Degrees, true, utils::RGBA8::kRed, utils::RGBA8::kBlue, utils::RGBA8::kGreen, utils::RGBA8::kBlack}, - {wgpu::ExternalTextureRotation::Rotate90Degrees, true, utils::RGBA8::kBlue, - utils::RGBA8::kBlack, utils::RGBA8::kRed, utils::RGBA8::kGreen}, + {wgpu::ExternalTextureRotation::Rotate90Degrees, true, utils::RGBA8::kGreen, + utils::RGBA8::kRed, utils::RGBA8::kBlack, utils::RGBA8::kBlue}, {wgpu::ExternalTextureRotation::Rotate180Degrees, true, utils::RGBA8::kBlack, utils::RGBA8::kGreen, utils::RGBA8::kBlue, utils::RGBA8::kRed}, - {wgpu::ExternalTextureRotation::Rotate270Degrees, true, utils::RGBA8::kGreen, - utils::RGBA8::kRed, utils::RGBA8::kBlack, utils::RGBA8::kBlue}}}; + {wgpu::ExternalTextureRotation::Rotate270Degrees, true, utils::RGBA8::kBlue, + utils::RGBA8::kBlack, utils::RGBA8::kRed, utils::RGBA8::kGreen}}}; for (const RotationExpectation& exp : expectations) { // Pipeline Creation @@ -737,10 +736,10 @@ TEST_P(ExternalTextureTests, CropSinglePlane) { {{kWidth / 4, kHeight / 4}, {kWidth / 2, kHeight / 2}, wgpu::ExternalTextureRotation::Rotate90Degrees, - utils::RGBA8::kRed, - utils::RGBA8::kGreen, + utils::RGBA8::kWhite, utils::RGBA8::kBlue, - utils::RGBA8::kWhite}, + utils::RGBA8::kGreen, + utils::RGBA8::kRed}, {{kWidth / 4, kHeight / 4}, {kWidth / 2, kHeight / 2}, wgpu::ExternalTextureRotation::Rotate180Degrees, @@ -751,10 +750,10 @@ TEST_P(ExternalTextureTests, CropSinglePlane) { {{kWidth / 4, kHeight / 4}, {kWidth / 2, kHeight / 2}, wgpu::ExternalTextureRotation::Rotate270Degrees, - utils::RGBA8::kWhite, - utils::RGBA8::kBlue, + utils::RGBA8::kRed, utils::RGBA8::kGreen, - utils::RGBA8::kRed}, + utils::RGBA8::kBlue, + utils::RGBA8::kWhite}, }}; for (const CropExpectation& exp : expectations) { @@ -883,71 +882,70 @@ TEST_P(ExternalTextureTests, CropMultiplanar) { utils::RGBA8 lowerRightColor; }; - std::array expectations = {{ - {{0, 0}, - {kWidth, kHeight}, - wgpu::ExternalTextureRotation::Rotate0Degrees, - utils::RGBA8::kBlack, - utils::RGBA8::kBlack, - utils::RGBA8::kBlack, - utils::RGBA8::kBlack}, - {{kWidth / 4, kHeight / 4}, - {kWidth / 4, kHeight / 4}, - wgpu::ExternalTextureRotation::Rotate0Degrees, - utils::RGBA8::kGreen, - utils::RGBA8::kGreen, - utils::RGBA8::kGreen, - utils::RGBA8::kGreen}, - {{kWidth / 2, kHeight / 4}, - {kWidth / 4, kHeight / 4}, - wgpu::ExternalTextureRotation::Rotate0Degrees, - utils::RGBA8::kWhite, - utils::RGBA8::kWhite, - utils::RGBA8::kWhite, - utils::RGBA8::kWhite}, - {{kWidth / 4, kHeight / 2}, - {kWidth / 4, kHeight / 4}, - wgpu::ExternalTextureRotation::Rotate0Degrees, - utils::RGBA8::kRed, - utils::RGBA8::kRed, - utils::RGBA8::kRed, - utils::RGBA8::kRed}, - {{kWidth / 2, kHeight / 2}, - {kWidth / 4, kHeight / 4}, - wgpu::ExternalTextureRotation::Rotate0Degrees, - utils::RGBA8::kBlue, - utils::RGBA8::kBlue, - utils::RGBA8::kBlue, - utils::RGBA8::kBlue}, - {{kWidth / 4, kHeight / 4}, - {kWidth / 2, kHeight / 2}, - wgpu::ExternalTextureRotation::Rotate0Degrees, - utils::RGBA8::kGreen, - utils::RGBA8::kWhite, - utils::RGBA8::kRed, - utils::RGBA8::kBlue}, - {{kWidth / 4, kHeight / 4}, - {kWidth / 2, kHeight / 2}, - wgpu::ExternalTextureRotation::Rotate90Degrees, - utils::RGBA8::kRed, - utils::RGBA8::kGreen, - utils::RGBA8::kBlue, - utils::RGBA8::kWhite}, - {{kWidth / 4, kHeight / 4}, - {kWidth / 2, kHeight / 2}, - wgpu::ExternalTextureRotation::Rotate180Degrees, - utils::RGBA8::kBlue, - utils::RGBA8::kRed, - utils::RGBA8::kWhite, - utils::RGBA8::kGreen}, - {{kWidth / 4, kHeight / 4}, - {kWidth / 2, kHeight / 2}, - wgpu::ExternalTextureRotation::Rotate270Degrees, - utils::RGBA8::kWhite, - utils::RGBA8::kBlue, - utils::RGBA8::kGreen, - utils::RGBA8::kRed}, - }}; + std::array expectations = { + {{{0, 0}, + {kWidth, kHeight}, + wgpu::ExternalTextureRotation::Rotate0Degrees, + utils::RGBA8::kBlack, + utils::RGBA8::kBlack, + utils::RGBA8::kBlack, + utils::RGBA8::kBlack}, + {{kWidth / 4, kHeight / 4}, + {kWidth / 4, kHeight / 4}, + wgpu::ExternalTextureRotation::Rotate0Degrees, + utils::RGBA8::kGreen, + utils::RGBA8::kGreen, + utils::RGBA8::kGreen, + utils::RGBA8::kGreen}, + {{kWidth / 2, kHeight / 4}, + {kWidth / 4, kHeight / 4}, + wgpu::ExternalTextureRotation::Rotate0Degrees, + utils::RGBA8::kWhite, + utils::RGBA8::kWhite, + utils::RGBA8::kWhite, + utils::RGBA8::kWhite}, + {{kWidth / 4, kHeight / 2}, + {kWidth / 4, kHeight / 4}, + wgpu::ExternalTextureRotation::Rotate0Degrees, + utils::RGBA8::kRed, + utils::RGBA8::kRed, + utils::RGBA8::kRed, + utils::RGBA8::kRed}, + {{kWidth / 2, kHeight / 2}, + {kWidth / 4, kHeight / 4}, + wgpu::ExternalTextureRotation::Rotate0Degrees, + utils::RGBA8::kBlue, + utils::RGBA8::kBlue, + utils::RGBA8::kBlue, + utils::RGBA8::kBlue}, + {{kWidth / 4, kHeight / 4}, + {kWidth / 2, kHeight / 2}, + wgpu::ExternalTextureRotation::Rotate0Degrees, + utils::RGBA8::kGreen, + utils::RGBA8::kWhite, + utils::RGBA8::kRed, + utils::RGBA8::kBlue}, + {{kWidth / 4, kHeight / 4}, + {kWidth / 2, kHeight / 2}, + wgpu::ExternalTextureRotation::Rotate90Degrees, + utils::RGBA8::kWhite, + utils::RGBA8::kBlue, + utils::RGBA8::kGreen, + utils::RGBA8::kRed}, + {{kWidth / 4, kHeight / 4}, + {kWidth / 2, kHeight / 2}, + wgpu::ExternalTextureRotation::Rotate180Degrees, + utils::RGBA8::kBlue, + utils::RGBA8::kRed, + utils::RGBA8::kWhite, + utils::RGBA8::kGreen}, + {{kWidth / 4, kHeight / 4}, + {kWidth / 2, kHeight / 2}, + wgpu::ExternalTextureRotation::Rotate270Degrees, + utils::RGBA8::kRed, + utils::RGBA8::kGreen, + utils::RGBA8::kBlue, + utils::RGBA8::kWhite}}}; for (const CropExpectation& exp : expectations) { // Pipeline Creation