Change External Texture Rotation To Clockwise
Chrome extracts transform matrix from video container and set clock-wise
rotation degree in the VideoFrameMetadata. Dawn uses Counter-Clock wise rotation
right now but accept chrome's VideoFrameMetadata.transform directly.
So this CL changes the rotation direction to clock-wise to align with chrome
behaviour.
Bug: chromium:1514732
Change-Id: Ieec2ba02245597548c36bfb2deaa51d927b56081
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/169141
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Shaobo Yan <shaobo.yan@intel.com>
diff --git a/src/dawn/dawn.json b/src/dawn/dawn.json
index db09714..a60df8e 100644
--- a/src/dawn/dawn.json
+++ b/src/dawn/dawn.json
@@ -1544,6 +1544,7 @@
"external texture rotation":{
"category": "enum",
"tags": ["dawn"],
+ "_comment": "ANGLEs are clockwise rotation degrees and not trigonometric.",
"values": [
{"value": 0, "name": "rotate 0 degrees"},
{"value": 1, "name": "rotate 90 degrees"},
diff --git a/src/dawn/native/ExternalTexture.cpp b/src/dawn/native/ExternalTexture.cpp
index 5214760..f1e185b 100644
--- a/src/dawn/native/ExternalTexture.cpp
+++ b/src/dawn/native/ExternalTexture.cpp
@@ -279,8 +279,8 @@
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:
@@ -289,8 +289,9 @@
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 502a42e..2551450 100644
--- a/src/dawn/tests/end2end/ExternalTextureTests.cpp
+++ b/src/dawn/tests/end2end/ExternalTextureTests.cpp
@@ -586,20 +586,20 @@
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::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::kRed,
- utils::RGBA8::kGreen, utils::RGBA8::kBlue, utils::RGBA8::kBlack},
+ {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::kGreen,
- utils::RGBA8::kRed, utils::RGBA8::kBlack, utils::RGBA8::kBlue},
+ {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::kBlue,
- utils::RGBA8::kBlack, utils::RGBA8::kRed, utils::RGBA8::kGreen}}};
+ {wgpu::ExternalTextureRotation::Rotate270Degrees, true, utils::RGBA8::kGreen,
+ utils::RGBA8::kRed, utils::RGBA8::kBlack, utils::RGBA8::kBlue}}};
for (const RotationExpectation& exp : expectations) {
// Pipeline Creation
@@ -770,20 +770,20 @@
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::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::kRed,
- utils::RGBA8::kGreen, utils::RGBA8::kBlue, utils::RGBA8::kBlack},
+ {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::kGreen,
- utils::RGBA8::kRed, utils::RGBA8::kBlack, utils::RGBA8::kBlue},
+ {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::kBlue,
- utils::RGBA8::kBlack, utils::RGBA8::kRed, utils::RGBA8::kGreen}}};
+ {wgpu::ExternalTextureRotation::Rotate270Degrees, true, utils::RGBA8::kGreen,
+ utils::RGBA8::kRed, utils::RGBA8::kBlack, utils::RGBA8::kBlue}}};
for (const RotationExpectation& exp : expectations) {
// Pipeline Creation
@@ -933,10 +933,10 @@
{{kWidth / 4, kHeight / 4},
{kWidth / 2, kHeight / 2},
wgpu::ExternalTextureRotation::Rotate90Degrees,
- utils::RGBA8::kWhite,
- utils::RGBA8::kBlue,
+ utils::RGBA8::kRed,
utils::RGBA8::kGreen,
- utils::RGBA8::kRed},
+ utils::RGBA8::kBlue,
+ utils::RGBA8::kWhite},
{{kWidth / 4, kHeight / 4},
{kWidth / 2, kHeight / 2},
wgpu::ExternalTextureRotation::Rotate180Degrees,
@@ -947,10 +947,10 @@
{{kWidth / 4, kHeight / 4},
{kWidth / 2, kHeight / 2},
wgpu::ExternalTextureRotation::Rotate270Degrees,
- utils::RGBA8::kRed,
- utils::RGBA8::kGreen,
+ utils::RGBA8::kWhite,
utils::RGBA8::kBlue,
- utils::RGBA8::kWhite},
+ utils::RGBA8::kGreen,
+ utils::RGBA8::kRed},
}};
for (const CropExpectation& exp : expectations) {
@@ -1123,10 +1123,10 @@
{{kWidth / 4, kHeight / 4},
{kWidth / 2, kHeight / 2},
wgpu::ExternalTextureRotation::Rotate90Degrees,
- utils::RGBA8::kWhite,
- utils::RGBA8::kBlue,
+ utils::RGBA8::kRed,
utils::RGBA8::kGreen,
- utils::RGBA8::kRed},
+ utils::RGBA8::kBlue,
+ utils::RGBA8::kWhite},
{{kWidth / 4, kHeight / 4},
{kWidth / 2, kHeight / 2},
wgpu::ExternalTextureRotation::Rotate180Degrees,
@@ -1137,10 +1137,10 @@
{{kWidth / 4, kHeight / 4},
{kWidth / 2, kHeight / 2},
wgpu::ExternalTextureRotation::Rotate270Degrees,
- utils::RGBA8::kRed,
- utils::RGBA8::kGreen,
+ utils::RGBA8::kWhite,
utils::RGBA8::kBlue,
- utils::RGBA8::kWhite}}};
+ utils::RGBA8::kGreen,
+ utils::RGBA8::kRed}}};
for (const CropExpectation& exp : expectations) {
// Pipeline Creation