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 <noreply+kokoro@google.com>
Commit-Queue: Brandon1 Jones <brandon1.jones@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Brandon Jones 2023-01-30 18:26:11 +00:00 committed by Dawn LUCI CQ
parent 6767a8998e
commit 574b94e566
2 changed files with 99 additions and 101 deletions

View File

@ -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;
}

View File

@ -382,24 +382,23 @@ TEST_P(ExternalTextureTests, RotateAndOrFlipSinglePlane) {
utils::RGBA8 lowerRightColor;
};
std::array<RotationExpectation, 8> 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<RotationExpectation, 8> 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<RotationExpectation, 8> 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<CropExpectation, 9> 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<CropExpectation, 9> 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