| Index: webrtc/modules/desktop_capture/desktop_frame_rotator_unittest.cc
|
| diff --git a/webrtc/modules/desktop_capture/desktop_frame_rotator_unittest.cc b/webrtc/modules/desktop_capture/desktop_frame_rotator_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..3fc3542e2d53bd05c698b2ab479997257e453ee8
|
| --- /dev/null
|
| +++ b/webrtc/modules/desktop_capture/desktop_frame_rotator_unittest.cc
|
| @@ -0,0 +1,610 @@
|
| +/*
|
| + * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
|
| + *
|
| + * Use of this source code is governed by a BSD-style license
|
| + * that can be found in the LICENSE file in the root of the source
|
| + * tree. An additional intellectual property rights grant can be found
|
| + * in the file PATENTS. All contributing project authors may
|
| + * be found in the AUTHORS file in the root of the source tree.
|
| + */
|
| +
|
| +#include "webrtc/modules/desktop_capture/desktop_frame_rotator.h"
|
| +
|
| +#include "webrtc/modules/desktop_capture/desktop_frame.h"
|
| +#include "webrtc/modules/desktop_capture/desktop_region.h"
|
| +#include "webrtc/modules/desktop_capture/rgba_color.h"
|
| +#include "webrtc/test/gtest.h"
|
| +
|
| +namespace webrtc {
|
| +
|
| +TEST(DesktopFrameRotatorTest, CopyRect3x4) {
|
| + // A DesktopFrame of 4-pixel width by 3-pixel height.
|
| + BasicDesktopFrame frame(DesktopSize(4, 3));
|
| + for (int i = 0; i < 4; i++) {
|
| + for (int j = 0; j < 3; j++) {
|
| + frame.Paint(DesktopVector(i, j), RgbaColor(4 * j + i));
|
| + }
|
| + }
|
| + // The frame is
|
| + // +---+---+---+---+
|
| + // | 0 | 1 | 2 | 3 |
|
| + // +---+---+---+---+
|
| + // | 4 | 5 | 6 | 7 |
|
| + // +---+---+---+---+
|
| + // | 8 | 9 |10 |11 |
|
| + // +---+---+---+---+
|
| +
|
| + {
|
| + BasicDesktopFrame target(DesktopSize(4, 3));
|
| + ASSERT_TRUE(CopyUnrotatedRectTo(frame,
|
| + DesktopRect::MakeSize(frame.size()),
|
| + Rotation::CLOCK_WISE_0,
|
| + &target));
|
| + ASSERT_TRUE(frame.DataEquals(target));
|
| +
|
| + BasicDesktopFrame target2(DesktopSize(4, 3));
|
| + ASSERT_TRUE(CopyRotatedRectTo(frame,
|
| + DesktopRect::MakeSize(frame.size()),
|
| + Rotation::CLOCK_WISE_0,
|
| + &target2));
|
| + ASSERT_TRUE(frame.DataEquals(target2));
|
| + }
|
| +
|
| + // After Rotating clock-wise 90 degree
|
| + // +---+---+---+
|
| + // | 8 | 4 | 0 |
|
| + // +---+---+---+
|
| + // | 9 | 5 | 1 |
|
| + // +---+---+---+
|
| + // |10 | 6 | 2 |
|
| + // +---+---+---+
|
| + // |11 | 7 | 3 |
|
| + // +---+---+---+
|
| + {
|
| + BasicDesktopFrame expected(DesktopSize(3, 4));
|
| + expected.Paint(DesktopVector(0, 0), RgbaColor(8));
|
| + expected.Paint(DesktopVector(0, 1), RgbaColor(9));
|
| + expected.Paint(DesktopVector(0, 2), RgbaColor(10));
|
| + expected.Paint(DesktopVector(0, 3), RgbaColor(11));
|
| + expected.Paint(DesktopVector(1, 0), RgbaColor(4));
|
| + expected.Paint(DesktopVector(1, 1), RgbaColor(5));
|
| + expected.Paint(DesktopVector(1, 2), RgbaColor(6));
|
| + expected.Paint(DesktopVector(1, 3), RgbaColor(7));
|
| + expected.Paint(DesktopVector(2, 0), RgbaColor(0));
|
| + expected.Paint(DesktopVector(2, 1), RgbaColor(1));
|
| + expected.Paint(DesktopVector(2, 2), RgbaColor(2));
|
| + expected.Paint(DesktopVector(2, 3), RgbaColor(3));
|
| +
|
| + BasicDesktopFrame target(DesktopSize(3, 4));
|
| + ASSERT_TRUE(CopyUnrotatedRectTo(frame,
|
| + DesktopRect::MakeSize(frame.size()),
|
| + Rotation::CLOCK_WISE_90,
|
| + &target));
|
| + ASSERT_TRUE(target.DataEquals(expected));
|
| +
|
| + BasicDesktopFrame target2(DesktopSize(3, 4));
|
| + ASSERT_TRUE(CopyRotatedRectTo(frame,
|
| + DesktopRect::MakeSize(target2.size()),
|
| + Rotation::CLOCK_WISE_90,
|
| + &target2));
|
| + ASSERT_TRUE(target2.DataEquals(expected));
|
| + }
|
| +
|
| + // After Rotating clock-wise 180 degree
|
| + // +---+---+---+---+
|
| + // |11 |10 | 9 | 8 |
|
| + // +---+---+---+---+
|
| + // | 7 | 6 | 5 | 4 |
|
| + // +---+---+---+---+
|
| + // | 3 | 2 | 1 | 0 |
|
| + // +---+---+---+---+
|
| + {
|
| + BasicDesktopFrame expected(DesktopSize(4, 3));
|
| + expected.Paint(DesktopVector(0, 0), RgbaColor(11));
|
| + expected.Paint(DesktopVector(1, 0), RgbaColor(10));
|
| + expected.Paint(DesktopVector(2, 0), RgbaColor(9));
|
| + expected.Paint(DesktopVector(3, 0), RgbaColor(8));
|
| + expected.Paint(DesktopVector(0, 1), RgbaColor(7));
|
| + expected.Paint(DesktopVector(1, 1), RgbaColor(6));
|
| + expected.Paint(DesktopVector(2, 1), RgbaColor(5));
|
| + expected.Paint(DesktopVector(3, 1), RgbaColor(4));
|
| + expected.Paint(DesktopVector(0, 2), RgbaColor(3));
|
| + expected.Paint(DesktopVector(1, 2), RgbaColor(2));
|
| + expected.Paint(DesktopVector(2, 2), RgbaColor(1));
|
| + expected.Paint(DesktopVector(3, 2), RgbaColor(0));
|
| +
|
| + BasicDesktopFrame target(DesktopSize(4, 3));
|
| + ASSERT_TRUE(CopyUnrotatedRectTo(frame,
|
| + DesktopRect::MakeSize(frame.size()),
|
| + Rotation::CLOCK_WISE_180,
|
| + &target));
|
| + ASSERT_TRUE(target.DataEquals(expected));
|
| +
|
| + BasicDesktopFrame target2(DesktopSize(4, 3));
|
| + ASSERT_TRUE(CopyRotatedRectTo(frame,
|
| + DesktopRect::MakeSize(target2.size()),
|
| + Rotation::CLOCK_WISE_180,
|
| + &target2));
|
| + ASSERT_TRUE(target2.DataEquals(expected));
|
| + }
|
| +
|
| + // After Rotating clock-wise 270 degree
|
| + // +---+---+---+
|
| + // | 3 | 7 |11 |
|
| + // +---+---+---+
|
| + // | 2 | 6 |10 |
|
| + // +---+---+---+
|
| + // | 1 | 5 | 9 |
|
| + // +---+---+---+
|
| + // | 0 | 4 | 8 |
|
| + // +---+---+---+
|
| + {
|
| + BasicDesktopFrame expected(DesktopSize(3, 4));
|
| + expected.Paint(DesktopVector(0, 0), RgbaColor(3));
|
| + expected.Paint(DesktopVector(0, 1), RgbaColor(2));
|
| + expected.Paint(DesktopVector(0, 2), RgbaColor(1));
|
| + expected.Paint(DesktopVector(0, 3), RgbaColor(0));
|
| + expected.Paint(DesktopVector(1, 0), RgbaColor(7));
|
| + expected.Paint(DesktopVector(1, 1), RgbaColor(6));
|
| + expected.Paint(DesktopVector(1, 2), RgbaColor(5));
|
| + expected.Paint(DesktopVector(1, 3), RgbaColor(4));
|
| + expected.Paint(DesktopVector(2, 0), RgbaColor(11));
|
| + expected.Paint(DesktopVector(2, 1), RgbaColor(10));
|
| + expected.Paint(DesktopVector(2, 2), RgbaColor(9));
|
| + expected.Paint(DesktopVector(2, 3), RgbaColor(8));
|
| +
|
| + BasicDesktopFrame target(DesktopSize(3, 4));
|
| + ASSERT_TRUE(CopyUnrotatedRectTo(frame,
|
| + DesktopRect::MakeSize(frame.size()),
|
| + Rotation::CLOCK_WISE_270,
|
| + &target));
|
| + ASSERT_TRUE(target.DataEquals(expected));
|
| +
|
| + BasicDesktopFrame target2(DesktopSize(3, 4));
|
| + ASSERT_TRUE(CopyRotatedRectTo(frame,
|
| + DesktopRect::MakeSize(target2.size()),
|
| + Rotation::CLOCK_WISE_270,
|
| + &target2));
|
| + ASSERT_TRUE(target2.DataEquals(expected));
|
| + }
|
| +}
|
| +
|
| +TEST(DesktopFrameRotatorTest, CopyRect3x5) {
|
| + // A DesktopFrame of 5-pixel width by 3-pixel height.
|
| + BasicDesktopFrame frame(DesktopSize(5, 3));
|
| + for (int i = 0; i < 5; i++) {
|
| + for (int j = 0; j < 3; j++) {
|
| + frame.Paint(DesktopVector(i, j), RgbaColor(5 * j + i));
|
| + }
|
| + }
|
| + // The frame is
|
| + // +---+---+---+---+---+
|
| + // | 0 | 1 | 2 | 3 | 4 |
|
| + // +---+---+---+---+---+
|
| + // | 5 | 6 | 7 | 8 | 9 |
|
| + // +---+---+---+---+---+
|
| + // |10 |11 |12 |13 |14 |
|
| + // +---+---+---+---+---+
|
| +
|
| + {
|
| + BasicDesktopFrame target(DesktopSize(5, 3));
|
| + ASSERT_TRUE(CopyUnrotatedRectTo(frame,
|
| + DesktopRect::MakeSize(frame.size()),
|
| + Rotation::CLOCK_WISE_0,
|
| + &target));
|
| + ASSERT_TRUE(frame.DataEquals(target));
|
| +
|
| + BasicDesktopFrame target2(DesktopSize(5, 3));
|
| + ASSERT_TRUE(CopyRotatedRectTo(frame,
|
| + DesktopRect::MakeSize(frame.size()),
|
| + Rotation::CLOCK_WISE_0,
|
| + &target2));
|
| + ASSERT_TRUE(frame.DataEquals(target2));
|
| + }
|
| +
|
| + // After Rotating clock-wise 90 degree
|
| + // +---+---+---+
|
| + // |10 | 5 | 0 |
|
| + // +---+---+---+
|
| + // |11 | 6 | 1 |
|
| + // +---+---+---+
|
| + // |12 | 7 | 2 |
|
| + // +---+---+---+
|
| + // |13 | 8 | 3 |
|
| + // +---+---+---+
|
| + // |14 | 9 | 4 |
|
| + // +---+---+---+
|
| + {
|
| + BasicDesktopFrame expected(DesktopSize(3, 5));
|
| + expected.Paint(DesktopVector(0, 0), RgbaColor(10));
|
| + expected.Paint(DesktopVector(0, 1), RgbaColor(11));
|
| + expected.Paint(DesktopVector(0, 2), RgbaColor(12));
|
| + expected.Paint(DesktopVector(0, 3), RgbaColor(13));
|
| + expected.Paint(DesktopVector(0, 4), RgbaColor(14));
|
| + expected.Paint(DesktopVector(1, 0), RgbaColor(5));
|
| + expected.Paint(DesktopVector(1, 1), RgbaColor(6));
|
| + expected.Paint(DesktopVector(1, 2), RgbaColor(7));
|
| + expected.Paint(DesktopVector(1, 3), RgbaColor(8));
|
| + expected.Paint(DesktopVector(1, 4), RgbaColor(9));
|
| + expected.Paint(DesktopVector(2, 0), RgbaColor(0));
|
| + expected.Paint(DesktopVector(2, 1), RgbaColor(1));
|
| + expected.Paint(DesktopVector(2, 2), RgbaColor(2));
|
| + expected.Paint(DesktopVector(2, 3), RgbaColor(3));
|
| + expected.Paint(DesktopVector(2, 4), RgbaColor(4));
|
| +
|
| + BasicDesktopFrame target(DesktopSize(3, 5));
|
| + ASSERT_TRUE(CopyUnrotatedRectTo(frame,
|
| + DesktopRect::MakeSize(frame.size()),
|
| + Rotation::CLOCK_WISE_90,
|
| + &target));
|
| + ASSERT_TRUE(target.DataEquals(expected));
|
| +
|
| + BasicDesktopFrame target2(DesktopSize(3, 5));
|
| + ASSERT_TRUE(CopyRotatedRectTo(frame,
|
| + DesktopRect::MakeSize(target2.size()),
|
| + Rotation::CLOCK_WISE_90,
|
| + &target2));
|
| + ASSERT_TRUE(target2.DataEquals(expected));
|
| + }
|
| +
|
| + // After Rotating clock-wise 180 degree
|
| + // +---+---+---+---+---+
|
| + // |14 |13 |12 |11 |10 |
|
| + // +---+---+---+---+---+
|
| + // | 9 | 8 | 7 | 6 | 5 |
|
| + // +---+---+---+---+---+
|
| + // | 4 | 3 | 2 | 1 | 0 |
|
| + // +---+---+---+---+---+
|
| + {
|
| + BasicDesktopFrame expected(DesktopSize(5, 3));
|
| + expected.Paint(DesktopVector(0, 0), RgbaColor(14));
|
| + expected.Paint(DesktopVector(1, 0), RgbaColor(13));
|
| + expected.Paint(DesktopVector(2, 0), RgbaColor(12));
|
| + expected.Paint(DesktopVector(3, 0), RgbaColor(11));
|
| + expected.Paint(DesktopVector(4, 0), RgbaColor(10));
|
| + expected.Paint(DesktopVector(0, 1), RgbaColor(9));
|
| + expected.Paint(DesktopVector(1, 1), RgbaColor(8));
|
| + expected.Paint(DesktopVector(2, 1), RgbaColor(7));
|
| + expected.Paint(DesktopVector(3, 1), RgbaColor(6));
|
| + expected.Paint(DesktopVector(4, 1), RgbaColor(5));
|
| + expected.Paint(DesktopVector(0, 2), RgbaColor(4));
|
| + expected.Paint(DesktopVector(1, 2), RgbaColor(3));
|
| + expected.Paint(DesktopVector(2, 2), RgbaColor(2));
|
| + expected.Paint(DesktopVector(3, 2), RgbaColor(1));
|
| + expected.Paint(DesktopVector(4, 2), RgbaColor(0));
|
| +
|
| + BasicDesktopFrame target(DesktopSize(5, 3));
|
| + ASSERT_TRUE(CopyUnrotatedRectTo(frame,
|
| + DesktopRect::MakeSize(frame.size()),
|
| + Rotation::CLOCK_WISE_180,
|
| + &target));
|
| + ASSERT_TRUE(target.DataEquals(expected));
|
| +
|
| + BasicDesktopFrame target2(DesktopSize(5, 3));
|
| + ASSERT_TRUE(CopyRotatedRectTo(frame,
|
| + DesktopRect::MakeSize(target2.size()),
|
| + Rotation::CLOCK_WISE_180,
|
| + &target2));
|
| + ASSERT_TRUE(target2.DataEquals(expected));
|
| + }
|
| +
|
| + // After Rotating clock-wise 270 degree
|
| + // +---+---+---+
|
| + // | 4 | 9 |14 |
|
| + // +---+---+---+
|
| + // | 3 | 8 |13 |
|
| + // +---+---+---+
|
| + // | 2 | 7 |12 |
|
| + // +---+---+---+
|
| + // | 1 | 6 |11 |
|
| + // +---+---+---+
|
| + // | 0 | 5 |10 |
|
| + // +---+---+---+
|
| + {
|
| + BasicDesktopFrame expected(DesktopSize(3, 5));
|
| + expected.Paint(DesktopVector(0, 0), RgbaColor(4));
|
| + expected.Paint(DesktopVector(0, 1), RgbaColor(3));
|
| + expected.Paint(DesktopVector(0, 2), RgbaColor(2));
|
| + expected.Paint(DesktopVector(0, 3), RgbaColor(1));
|
| + expected.Paint(DesktopVector(0, 4), RgbaColor(0));
|
| + expected.Paint(DesktopVector(1, 0), RgbaColor(9));
|
| + expected.Paint(DesktopVector(1, 1), RgbaColor(8));
|
| + expected.Paint(DesktopVector(1, 2), RgbaColor(7));
|
| + expected.Paint(DesktopVector(1, 3), RgbaColor(6));
|
| + expected.Paint(DesktopVector(1, 4), RgbaColor(5));
|
| + expected.Paint(DesktopVector(2, 0), RgbaColor(14));
|
| + expected.Paint(DesktopVector(2, 1), RgbaColor(13));
|
| + expected.Paint(DesktopVector(2, 2), RgbaColor(12));
|
| + expected.Paint(DesktopVector(2, 3), RgbaColor(11));
|
| + expected.Paint(DesktopVector(2, 4), RgbaColor(10));
|
| +
|
| + BasicDesktopFrame target(DesktopSize(3, 5));
|
| + ASSERT_TRUE(CopyUnrotatedRectTo(frame,
|
| + DesktopRect::MakeSize(frame.size()),
|
| + Rotation::CLOCK_WISE_270,
|
| + &target));
|
| + ASSERT_TRUE(target.DataEquals(expected));
|
| +
|
| + BasicDesktopFrame target2(DesktopSize(3, 5));
|
| + ASSERT_TRUE(CopyRotatedRectTo(frame,
|
| + DesktopRect::MakeSize(target2.size()),
|
| + Rotation::CLOCK_WISE_270,
|
| + &target2));
|
| + ASSERT_TRUE(target2.DataEquals(expected));
|
| + }
|
| +}
|
| +
|
| +TEST(DesktopFrameRotatorTest, PartialCopyRect3x5) {
|
| + // A DesktopFrame of 5-pixel width by 3-pixel height.
|
| + BasicDesktopFrame frame(DesktopSize(5, 3));
|
| + for (int i = 0; i < 5; i++) {
|
| + for (int j = 0; j < 3; j++) {
|
| + frame.Paint(DesktopVector(i, j), RgbaColor(5 * j + i));
|
| + }
|
| + }
|
| + // The frame is
|
| + // +---+---+---+---+---+
|
| + // | 0 | 1 | 2 | 3 | 4 |
|
| + // +---+---+---+---+---+
|
| + // | 5 | 6 | 7 | 8 | 9 |
|
| + // +---+---+---+---+---+
|
| + // |10 |11 |12 |13 |14 |
|
| + // +---+---+---+---+---+
|
| +
|
| + {
|
| + BasicDesktopFrame expected(DesktopSize(5, 3));
|
| + expected.Clear();
|
| + expected.Paint(DesktopVector(1, 1), RgbaColor(6));
|
| + expected.Paint(DesktopVector(2, 1), RgbaColor(7));
|
| + expected.Paint(DesktopVector(3, 1), RgbaColor(8));
|
| +
|
| + BasicDesktopFrame target(DesktopSize(5, 3));
|
| + target.Clear();
|
| + ASSERT_TRUE(CopyUnrotatedRectTo(frame,
|
| + DesktopRect::MakeXYWH(1, 1, 3, 1),
|
| + Rotation::CLOCK_WISE_0,
|
| + &target));
|
| + ASSERT_TRUE(target.DataEquals(expected));
|
| +
|
| + BasicDesktopFrame target2(DesktopSize(5, 3));
|
| + target2.Clear();
|
| + ASSERT_TRUE(CopyRotatedRectTo(frame,
|
| + DesktopRect::MakeXYWH(1, 1, 3, 1),
|
| + Rotation::CLOCK_WISE_0,
|
| + &target2));
|
| + ASSERT_TRUE(target2.DataEquals(expected));
|
| +
|
| + expected.Paint(DesktopVector(1, 0), RgbaColor(1));
|
| + expected.Paint(DesktopVector(2, 0), RgbaColor(2));
|
| + expected.Paint(DesktopVector(3, 0), RgbaColor(3));
|
| +
|
| + target.Clear();
|
| + ASSERT_TRUE(CopyUnrotatedRectTo(frame,
|
| + DesktopRect::MakeXYWH(1, 0, 3, 2),
|
| + Rotation::CLOCK_WISE_0,
|
| + &target));
|
| + ASSERT_TRUE(target.DataEquals(expected));
|
| +
|
| + target2.Clear();
|
| + ASSERT_TRUE(CopyRotatedRectTo(frame,
|
| + DesktopRect::MakeXYWH(1, 0, 3, 2),
|
| + Rotation::CLOCK_WISE_0,
|
| + &target2));
|
| + ASSERT_TRUE(target2.DataEquals(expected));
|
| + }
|
| +
|
| + // After Rotating clock-wise 90 degree
|
| + // +---+---+---+
|
| + // |10 | 5 | 0 |
|
| + // +---+---+---+
|
| + // |11 | 6 | 1 |
|
| + // +---+---+---+
|
| + // |12 | 7 | 2 |
|
| + // +---+---+---+
|
| + // |13 | 8 | 3 |
|
| + // +---+---+---+
|
| + // |14 | 9 | 4 |
|
| + // +---+---+---+
|
| + {
|
| + BasicDesktopFrame expected(DesktopSize(3, 5));
|
| + expected.Clear();
|
| + expected.Paint(DesktopVector(1, 1), RgbaColor(6));
|
| + expected.Paint(DesktopVector(1, 2), RgbaColor(7));
|
| + expected.Paint(DesktopVector(1, 3), RgbaColor(8));
|
| +
|
| + BasicDesktopFrame target(DesktopSize(3, 5));
|
| + target.Clear();
|
| + ASSERT_TRUE(CopyUnrotatedRectTo(frame,
|
| + DesktopRect::MakeXYWH(1, 1, 3, 1),
|
| + Rotation::CLOCK_WISE_90,
|
| + &target));
|
| + ASSERT_TRUE(target.DataEquals(expected));
|
| +
|
| + BasicDesktopFrame target2(DesktopSize(3, 5));
|
| + target2.Clear();
|
| + ASSERT_TRUE(CopyRotatedRectTo(frame,
|
| + DesktopRect::MakeXYWH(1, 1, 1, 3),
|
| + Rotation::CLOCK_WISE_90,
|
| + &target2));
|
| + ASSERT_TRUE(target2.DataEquals(expected));
|
| +
|
| + expected.Paint(DesktopVector(0, 1), RgbaColor(11));
|
| + expected.Paint(DesktopVector(0, 2), RgbaColor(12));
|
| + expected.Paint(DesktopVector(0, 3), RgbaColor(13));
|
| +
|
| + target.Clear();
|
| + ASSERT_TRUE(CopyUnrotatedRectTo(frame,
|
| + DesktopRect::MakeXYWH(1, 1, 3, 2),
|
| + Rotation::CLOCK_WISE_90,
|
| + &target));
|
| + ASSERT_TRUE(target.DataEquals(expected));
|
| +
|
| + target2.Clear();
|
| + ASSERT_TRUE(CopyRotatedRectTo(frame,
|
| + DesktopRect::MakeXYWH(0, 1, 2, 3),
|
| + Rotation::CLOCK_WISE_90,
|
| + &target2));
|
| + ASSERT_TRUE(target2.DataEquals(expected));
|
| + }
|
| +
|
| + // After Rotating clock-wise 180 degree
|
| + // +---+---+---+---+---+
|
| + // |14 |13 |12 |11 |10 |
|
| + // +---+---+---+---+---+
|
| + // | 9 | 8 | 7 | 6 | 5 |
|
| + // +---+---+---+---+---+
|
| + // | 4 | 3 | 2 | 1 | 0 |
|
| + // +---+---+---+---+---+
|
| + {
|
| + BasicDesktopFrame expected(DesktopSize(5, 3));
|
| + expected.Clear();
|
| + expected.Paint(DesktopVector(1, 1), RgbaColor(8));
|
| + expected.Paint(DesktopVector(2, 1), RgbaColor(7));
|
| + expected.Paint(DesktopVector(3, 1), RgbaColor(6));
|
| +
|
| + BasicDesktopFrame target(DesktopSize(5, 3));
|
| + target.Clear();
|
| + ASSERT_TRUE(CopyUnrotatedRectTo(frame,
|
| + DesktopRect::MakeXYWH(1, 1, 3, 1),
|
| + Rotation::CLOCK_WISE_180,
|
| + &target));
|
| + ASSERT_TRUE(target.DataEquals(expected));
|
| +
|
| + BasicDesktopFrame target2(DesktopSize(5, 3));
|
| + target2.Clear();
|
| + ASSERT_TRUE(CopyRotatedRectTo(frame,
|
| + DesktopRect::MakeXYWH(1, 1, 3, 1),
|
| + Rotation::CLOCK_WISE_180,
|
| + &target2));
|
| + ASSERT_TRUE(target2.DataEquals(expected));
|
| +
|
| + expected.Paint(DesktopVector(1, 0), RgbaColor(13));
|
| + expected.Paint(DesktopVector(2, 0), RgbaColor(12));
|
| + expected.Paint(DesktopVector(3, 0), RgbaColor(11));
|
| +
|
| + target.Clear();
|
| + ASSERT_TRUE(CopyUnrotatedRectTo(frame,
|
| + DesktopRect::MakeXYWH(1, 1, 3, 2),
|
| + Rotation::CLOCK_WISE_180,
|
| + &target));
|
| + ASSERT_TRUE(target.DataEquals(expected));
|
| +
|
| + target2.Clear();
|
| + ASSERT_TRUE(CopyRotatedRectTo(frame,
|
| + DesktopRect::MakeXYWH(1, 0, 3, 2),
|
| + Rotation::CLOCK_WISE_180,
|
| + &target2));
|
| + ASSERT_TRUE(target2.DataEquals(expected));
|
| + }
|
| +
|
| + // After Rotating clock-wise 270 degree
|
| + // +---+---+---+
|
| + // | 4 | 9 |14 |
|
| + // +---+---+---+
|
| + // | 3 | 8 |13 |
|
| + // +---+---+---+
|
| + // | 2 | 7 |12 |
|
| + // +---+---+---+
|
| + // | 1 | 6 |11 |
|
| + // +---+---+---+
|
| + // | 0 | 5 |10 |
|
| + // +---+---+---+
|
| + {
|
| + BasicDesktopFrame expected(DesktopSize(3, 5));
|
| + expected.Clear();
|
| + expected.Paint(DesktopVector(1, 1), RgbaColor(8));
|
| + expected.Paint(DesktopVector(1, 2), RgbaColor(7));
|
| + expected.Paint(DesktopVector(1, 3), RgbaColor(6));
|
| +
|
| + BasicDesktopFrame target(DesktopSize(3, 5));
|
| + target.Clear();
|
| + ASSERT_TRUE(CopyUnrotatedRectTo(frame,
|
| + DesktopRect::MakeXYWH(1, 1, 3, 1),
|
| + Rotation::CLOCK_WISE_270,
|
| + &target));
|
| + ASSERT_TRUE(target.DataEquals(expected));
|
| +
|
| + BasicDesktopFrame target2(DesktopSize(3, 5));
|
| + target2.Clear();
|
| + ASSERT_TRUE(CopyRotatedRectTo(frame,
|
| + DesktopRect::MakeXYWH(1, 1, 1, 3),
|
| + Rotation::CLOCK_WISE_270,
|
| + &target2));
|
| + ASSERT_TRUE(target2.DataEquals(expected));
|
| +
|
| + expected.Paint(DesktopVector(0, 1), RgbaColor(3));
|
| + expected.Paint(DesktopVector(0, 2), RgbaColor(2));
|
| + expected.Paint(DesktopVector(0, 3), RgbaColor(1));
|
| +
|
| + target.Clear();
|
| + ASSERT_TRUE(CopyUnrotatedRectTo(frame,
|
| + DesktopRect::MakeXYWH(1, 0, 3, 2),
|
| + Rotation::CLOCK_WISE_270,
|
| + &target));
|
| + ASSERT_TRUE(target.DataEquals(expected));
|
| +
|
| + target2.Clear();
|
| + ASSERT_TRUE(CopyRotatedRectTo(frame,
|
| + DesktopRect::MakeXYWH(0, 1, 2, 3),
|
| + Rotation::CLOCK_WISE_270,
|
| + &target2));
|
| + ASSERT_TRUE(target2.DataEquals(expected));
|
| + }
|
| +}
|
| +
|
| +// On a typical machine (Intel(R) Xeon(R) E5-1650 v3 @ 3.50GHz, with O2
|
| +// optimization, the following case uses ~2.8s to finish. It means entirely
|
| +// rotating one 2048 x 1536, which is a large enough number to cover most of
|
| +// desktop computer users, uses around 28ms.
|
| +TEST(DesktopFrameRotatorTest, DISABLED_PerformanceTest) {
|
| + BasicDesktopFrame frame(DesktopSize(2048, 1536));
|
| + BasicDesktopFrame target(DesktopSize(1536, 2048));
|
| + BasicDesktopFrame target2(DesktopSize(2048, 1536));
|
| + for (int i = 0; i < 100; i++) {
|
| + ASSERT_TRUE(CopyRotatedRectTo(frame,
|
| + DesktopRect::MakeSize(target.size()),
|
| + Rotation::CLOCK_WISE_90,
|
| + &target));
|
| + ASSERT_TRUE(CopyRotatedRectTo(frame,
|
| + DesktopRect::MakeSize(target.size()),
|
| + Rotation::CLOCK_WISE_270,
|
| + &target));
|
| + ASSERT_TRUE(CopyRotatedRectTo(frame,
|
| + DesktopRect::MakeSize(target2.size()),
|
| + Rotation::CLOCK_WISE_0,
|
| + &target2));
|
| + ASSERT_TRUE(CopyRotatedRectTo(frame,
|
| + DesktopRect::MakeSize(target2.size()),
|
| + Rotation::CLOCK_WISE_180,
|
| + &target2));
|
| + }
|
| +}
|
| +
|
| +// On a typical machine (Intel(R) Xeon(R) E5-1650 v3 @ 3.50GHz, with O2
|
| +// optimization, the following case uses ~22s to finish. It means entirely
|
| +// rotating one 4096 x 3072 uses around 220ms.
|
| +TEST(DesktopFrameRotatorTest, DISABLED_PerformanceTestOnLargeScreen) {
|
| + BasicDesktopFrame frame(DesktopSize(4096, 3072));
|
| + BasicDesktopFrame target(DesktopSize(3072, 4096));
|
| + BasicDesktopFrame target2(DesktopSize(4096, 3072));
|
| + for (int i = 0; i < 100; i++) {
|
| + ASSERT_TRUE(CopyRotatedRectTo(frame,
|
| + DesktopRect::MakeSize(target.size()),
|
| + Rotation::CLOCK_WISE_90,
|
| + &target));
|
| + ASSERT_TRUE(CopyRotatedRectTo(frame,
|
| + DesktopRect::MakeSize(target.size()),
|
| + Rotation::CLOCK_WISE_270,
|
| + &target));
|
| + ASSERT_TRUE(CopyRotatedRectTo(frame,
|
| + DesktopRect::MakeSize(target2.size()),
|
| + Rotation::CLOCK_WISE_0,
|
| + &target2));
|
| + ASSERT_TRUE(CopyRotatedRectTo(frame,
|
| + DesktopRect::MakeSize(target2.size()),
|
| + Rotation::CLOCK_WISE_180,
|
| + &target2));
|
| + }
|
| +}
|
| +
|
| +} // namespace webrtc
|
|
|