Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(665)

Side by Side Diff: webrtc/modules/desktop_capture/desktop_frame_rotator_unittest.cc

Issue 2500883004: Add DesktopFrame rotation functions (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include "webrtc/modules/desktop_capture/desktop_frame_rotator.h"
12
13 #include "webrtc/modules/desktop_capture/desktop_frame.h"
14 #include "webrtc/modules/desktop_capture/desktop_region.h"
15 #include "webrtc/modules/desktop_capture/rgba_color.h"
16 #include "webrtc/test/gtest.h"
17
18 namespace webrtc {
19
20 TEST(DesktopFrameRotatorTest, CopyRect3x4) {
21 // A DesktopFrame of 4-pixel width by 3-pixel height.
22 BasicDesktopFrame frame(DesktopSize(4, 3));
23 for (int i = 0; i < 4; i++) {
24 for (int j = 0; j < 3; j++) {
25 frame.Paint(DesktopVector(i, j), RgbaColor(4 * j + i));
26 }
27 }
28 // The frame is
29 // +---+---+---+---+
30 // | 0 | 1 | 2 | 3 |
31 // +---+---+---+---+
32 // | 4 | 5 | 6 | 7 |
33 // +---+---+---+---+
34 // | 8 | 9 |10 |11 |
35 // +---+---+---+---+
36
37 {
38 BasicDesktopFrame target(DesktopSize(4, 3));
39 ASSERT_TRUE(CopyUnrotatedRectTo(frame,
40 DesktopRect::MakeSize(frame.size()),
41 Rotation::CLOCK_WISE_0,
42 &target));
43 ASSERT_TRUE(frame.DataEquals(target));
44
45 BasicDesktopFrame target2(DesktopSize(4, 3));
46 ASSERT_TRUE(CopyRotatedRectTo(frame,
47 DesktopRect::MakeSize(frame.size()),
48 Rotation::CLOCK_WISE_0,
49 &target2));
50 ASSERT_TRUE(frame.DataEquals(target2));
51 }
52
53 // After Rotating clock-wise 90 degree
54 // +---+---+---+
55 // | 8 | 4 | 0 |
56 // +---+---+---+
57 // | 9 | 5 | 1 |
58 // +---+---+---+
59 // |10 | 6 | 2 |
60 // +---+---+---+
61 // |11 | 7 | 3 |
62 // +---+---+---+
63 {
64 BasicDesktopFrame expected(DesktopSize(3, 4));
65 expected.Paint(DesktopVector(0, 0), RgbaColor(8));
66 expected.Paint(DesktopVector(0, 1), RgbaColor(9));
67 expected.Paint(DesktopVector(0, 2), RgbaColor(10));
68 expected.Paint(DesktopVector(0, 3), RgbaColor(11));
69 expected.Paint(DesktopVector(1, 0), RgbaColor(4));
70 expected.Paint(DesktopVector(1, 1), RgbaColor(5));
71 expected.Paint(DesktopVector(1, 2), RgbaColor(6));
72 expected.Paint(DesktopVector(1, 3), RgbaColor(7));
73 expected.Paint(DesktopVector(2, 0), RgbaColor(0));
74 expected.Paint(DesktopVector(2, 1), RgbaColor(1));
75 expected.Paint(DesktopVector(2, 2), RgbaColor(2));
76 expected.Paint(DesktopVector(2, 3), RgbaColor(3));
77
78 BasicDesktopFrame target(DesktopSize(3, 4));
79 ASSERT_TRUE(CopyUnrotatedRectTo(frame,
80 DesktopRect::MakeSize(frame.size()),
81 Rotation::CLOCK_WISE_90,
82 &target));
83 ASSERT_TRUE(target.DataEquals(expected));
84
85 BasicDesktopFrame target2(DesktopSize(3, 4));
86 ASSERT_TRUE(CopyRotatedRectTo(frame,
87 DesktopRect::MakeSize(target2.size()),
88 Rotation::CLOCK_WISE_90,
89 &target2));
90 ASSERT_TRUE(target2.DataEquals(expected));
91 }
92
93 // After Rotating clock-wise 180 degree
94 // +---+---+---+---+
95 // |11 |10 | 9 | 8 |
96 // +---+---+---+---+
97 // | 7 | 6 | 5 | 4 |
98 // +---+---+---+---+
99 // | 3 | 2 | 1 | 0 |
100 // +---+---+---+---+
101 {
102 BasicDesktopFrame expected(DesktopSize(4, 3));
103 expected.Paint(DesktopVector(0, 0), RgbaColor(11));
104 expected.Paint(DesktopVector(1, 0), RgbaColor(10));
105 expected.Paint(DesktopVector(2, 0), RgbaColor(9));
106 expected.Paint(DesktopVector(3, 0), RgbaColor(8));
107 expected.Paint(DesktopVector(0, 1), RgbaColor(7));
108 expected.Paint(DesktopVector(1, 1), RgbaColor(6));
109 expected.Paint(DesktopVector(2, 1), RgbaColor(5));
110 expected.Paint(DesktopVector(3, 1), RgbaColor(4));
111 expected.Paint(DesktopVector(0, 2), RgbaColor(3));
112 expected.Paint(DesktopVector(1, 2), RgbaColor(2));
113 expected.Paint(DesktopVector(2, 2), RgbaColor(1));
114 expected.Paint(DesktopVector(3, 2), RgbaColor(0));
115
116 BasicDesktopFrame target(DesktopSize(4, 3));
117 ASSERT_TRUE(CopyUnrotatedRectTo(frame,
118 DesktopRect::MakeSize(frame.size()),
119 Rotation::CLOCK_WISE_180,
120 &target));
121 ASSERT_TRUE(target.DataEquals(expected));
122
123 BasicDesktopFrame target2(DesktopSize(4, 3));
124 ASSERT_TRUE(CopyRotatedRectTo(frame,
125 DesktopRect::MakeSize(target2.size()),
126 Rotation::CLOCK_WISE_180,
127 &target2));
128 ASSERT_TRUE(target2.DataEquals(expected));
129 }
130
131 // After Rotating clock-wise 270 degree
132 // +---+---+---+
133 // | 3 | 7 |11 |
134 // +---+---+---+
135 // | 2 | 6 |10 |
136 // +---+---+---+
137 // | 1 | 5 | 9 |
138 // +---+---+---+
139 // | 0 | 4 | 8 |
140 // +---+---+---+
141 {
142 BasicDesktopFrame expected(DesktopSize(3, 4));
143 expected.Paint(DesktopVector(0, 0), RgbaColor(3));
144 expected.Paint(DesktopVector(0, 1), RgbaColor(2));
145 expected.Paint(DesktopVector(0, 2), RgbaColor(1));
146 expected.Paint(DesktopVector(0, 3), RgbaColor(0));
147 expected.Paint(DesktopVector(1, 0), RgbaColor(7));
148 expected.Paint(DesktopVector(1, 1), RgbaColor(6));
149 expected.Paint(DesktopVector(1, 2), RgbaColor(5));
150 expected.Paint(DesktopVector(1, 3), RgbaColor(4));
151 expected.Paint(DesktopVector(2, 0), RgbaColor(11));
152 expected.Paint(DesktopVector(2, 1), RgbaColor(10));
153 expected.Paint(DesktopVector(2, 2), RgbaColor(9));
154 expected.Paint(DesktopVector(2, 3), RgbaColor(8));
155
156 BasicDesktopFrame target(DesktopSize(3, 4));
157 ASSERT_TRUE(CopyUnrotatedRectTo(frame,
158 DesktopRect::MakeSize(frame.size()),
159 Rotation::CLOCK_WISE_270,
160 &target));
161 ASSERT_TRUE(target.DataEquals(expected));
162
163 BasicDesktopFrame target2(DesktopSize(3, 4));
164 ASSERT_TRUE(CopyRotatedRectTo(frame,
165 DesktopRect::MakeSize(target2.size()),
166 Rotation::CLOCK_WISE_270,
167 &target2));
168 ASSERT_TRUE(target2.DataEquals(expected));
169 }
170 }
171
172 TEST(DesktopFrameRotatorTest, CopyRect3x5) {
173 // A DesktopFrame of 5-pixel width by 3-pixel height.
174 BasicDesktopFrame frame(DesktopSize(5, 3));
175 for (int i = 0; i < 5; i++) {
176 for (int j = 0; j < 3; j++) {
177 frame.Paint(DesktopVector(i, j), RgbaColor(5 * j + i));
178 }
179 }
180 // The frame is
181 // +---+---+---+---+---+
182 // | 0 | 1 | 2 | 3 | 4 |
183 // +---+---+---+---+---+
184 // | 5 | 6 | 7 | 8 | 9 |
185 // +---+---+---+---+---+
186 // |10 |11 |12 |13 |14 |
187 // +---+---+---+---+---+
188
189 {
190 BasicDesktopFrame target(DesktopSize(5, 3));
191 ASSERT_TRUE(CopyUnrotatedRectTo(frame,
192 DesktopRect::MakeSize(frame.size()),
193 Rotation::CLOCK_WISE_0,
194 &target));
195 ASSERT_TRUE(frame.DataEquals(target));
196
197 BasicDesktopFrame target2(DesktopSize(5, 3));
198 ASSERT_TRUE(CopyRotatedRectTo(frame,
199 DesktopRect::MakeSize(frame.size()),
200 Rotation::CLOCK_WISE_0,
201 &target2));
202 ASSERT_TRUE(frame.DataEquals(target2));
203 }
204
205 // After Rotating clock-wise 90 degree
206 // +---+---+---+
207 // |10 | 5 | 0 |
208 // +---+---+---+
209 // |11 | 6 | 1 |
210 // +---+---+---+
211 // |12 | 7 | 2 |
212 // +---+---+---+
213 // |13 | 8 | 3 |
214 // +---+---+---+
215 // |14 | 9 | 4 |
216 // +---+---+---+
217 {
218 BasicDesktopFrame expected(DesktopSize(3, 5));
219 expected.Paint(DesktopVector(0, 0), RgbaColor(10));
220 expected.Paint(DesktopVector(0, 1), RgbaColor(11));
221 expected.Paint(DesktopVector(0, 2), RgbaColor(12));
222 expected.Paint(DesktopVector(0, 3), RgbaColor(13));
223 expected.Paint(DesktopVector(0, 4), RgbaColor(14));
224 expected.Paint(DesktopVector(1, 0), RgbaColor(5));
225 expected.Paint(DesktopVector(1, 1), RgbaColor(6));
226 expected.Paint(DesktopVector(1, 2), RgbaColor(7));
227 expected.Paint(DesktopVector(1, 3), RgbaColor(8));
228 expected.Paint(DesktopVector(1, 4), RgbaColor(9));
229 expected.Paint(DesktopVector(2, 0), RgbaColor(0));
230 expected.Paint(DesktopVector(2, 1), RgbaColor(1));
231 expected.Paint(DesktopVector(2, 2), RgbaColor(2));
232 expected.Paint(DesktopVector(2, 3), RgbaColor(3));
233 expected.Paint(DesktopVector(2, 4), RgbaColor(4));
234
235 BasicDesktopFrame target(DesktopSize(3, 5));
236 ASSERT_TRUE(CopyUnrotatedRectTo(frame,
237 DesktopRect::MakeSize(frame.size()),
238 Rotation::CLOCK_WISE_90,
239 &target));
240 ASSERT_TRUE(target.DataEquals(expected));
241
242 BasicDesktopFrame target2(DesktopSize(3, 5));
243 ASSERT_TRUE(CopyRotatedRectTo(frame,
244 DesktopRect::MakeSize(target2.size()),
245 Rotation::CLOCK_WISE_90,
246 &target2));
247 ASSERT_TRUE(target2.DataEquals(expected));
248 }
249
250 // After Rotating clock-wise 180 degree
251 // +---+---+---+---+---+
252 // |14 |13 |12 |11 |10 |
253 // +---+---+---+---+---+
254 // | 9 | 8 | 7 | 6 | 5 |
255 // +---+---+---+---+---+
256 // | 4 | 3 | 2 | 1 | 0 |
257 // +---+---+---+---+---+
258 {
259 BasicDesktopFrame expected(DesktopSize(5, 3));
260 expected.Paint(DesktopVector(0, 0), RgbaColor(14));
261 expected.Paint(DesktopVector(1, 0), RgbaColor(13));
262 expected.Paint(DesktopVector(2, 0), RgbaColor(12));
263 expected.Paint(DesktopVector(3, 0), RgbaColor(11));
264 expected.Paint(DesktopVector(4, 0), RgbaColor(10));
265 expected.Paint(DesktopVector(0, 1), RgbaColor(9));
266 expected.Paint(DesktopVector(1, 1), RgbaColor(8));
267 expected.Paint(DesktopVector(2, 1), RgbaColor(7));
268 expected.Paint(DesktopVector(3, 1), RgbaColor(6));
269 expected.Paint(DesktopVector(4, 1), RgbaColor(5));
270 expected.Paint(DesktopVector(0, 2), RgbaColor(4));
271 expected.Paint(DesktopVector(1, 2), RgbaColor(3));
272 expected.Paint(DesktopVector(2, 2), RgbaColor(2));
273 expected.Paint(DesktopVector(3, 2), RgbaColor(1));
274 expected.Paint(DesktopVector(4, 2), RgbaColor(0));
275
276 BasicDesktopFrame target(DesktopSize(5, 3));
277 ASSERT_TRUE(CopyUnrotatedRectTo(frame,
278 DesktopRect::MakeSize(frame.size()),
279 Rotation::CLOCK_WISE_180,
280 &target));
281 ASSERT_TRUE(target.DataEquals(expected));
282
283 BasicDesktopFrame target2(DesktopSize(5, 3));
284 ASSERT_TRUE(CopyRotatedRectTo(frame,
285 DesktopRect::MakeSize(target2.size()),
286 Rotation::CLOCK_WISE_180,
287 &target2));
288 ASSERT_TRUE(target2.DataEquals(expected));
289 }
290
291 // After Rotating clock-wise 270 degree
292 // +---+---+---+
293 // | 4 | 9 |14 |
294 // +---+---+---+
295 // | 3 | 8 |13 |
296 // +---+---+---+
297 // | 2 | 7 |12 |
298 // +---+---+---+
299 // | 1 | 6 |11 |
300 // +---+---+---+
301 // | 0 | 5 |10 |
302 // +---+---+---+
303 {
304 BasicDesktopFrame expected(DesktopSize(3, 5));
305 expected.Paint(DesktopVector(0, 0), RgbaColor(4));
306 expected.Paint(DesktopVector(0, 1), RgbaColor(3));
307 expected.Paint(DesktopVector(0, 2), RgbaColor(2));
308 expected.Paint(DesktopVector(0, 3), RgbaColor(1));
309 expected.Paint(DesktopVector(0, 4), RgbaColor(0));
310 expected.Paint(DesktopVector(1, 0), RgbaColor(9));
311 expected.Paint(DesktopVector(1, 1), RgbaColor(8));
312 expected.Paint(DesktopVector(1, 2), RgbaColor(7));
313 expected.Paint(DesktopVector(1, 3), RgbaColor(6));
314 expected.Paint(DesktopVector(1, 4), RgbaColor(5));
315 expected.Paint(DesktopVector(2, 0), RgbaColor(14));
316 expected.Paint(DesktopVector(2, 1), RgbaColor(13));
317 expected.Paint(DesktopVector(2, 2), RgbaColor(12));
318 expected.Paint(DesktopVector(2, 3), RgbaColor(11));
319 expected.Paint(DesktopVector(2, 4), RgbaColor(10));
320
321 BasicDesktopFrame target(DesktopSize(3, 5));
322 ASSERT_TRUE(CopyUnrotatedRectTo(frame,
323 DesktopRect::MakeSize(frame.size()),
324 Rotation::CLOCK_WISE_270,
325 &target));
326 ASSERT_TRUE(target.DataEquals(expected));
327
328 BasicDesktopFrame target2(DesktopSize(3, 5));
329 ASSERT_TRUE(CopyRotatedRectTo(frame,
330 DesktopRect::MakeSize(target2.size()),
331 Rotation::CLOCK_WISE_270,
332 &target2));
333 ASSERT_TRUE(target2.DataEquals(expected));
334 }
335 }
336
337 TEST(DesktopFrameRotatorTest, PartialCopyRect3x5) {
338 // A DesktopFrame of 5-pixel width by 3-pixel height.
339 BasicDesktopFrame frame(DesktopSize(5, 3));
340 for (int i = 0; i < 5; i++) {
341 for (int j = 0; j < 3; j++) {
342 frame.Paint(DesktopVector(i, j), RgbaColor(5 * j + i));
343 }
344 }
345 // The frame is
346 // +---+---+---+---+---+
347 // | 0 | 1 | 2 | 3 | 4 |
348 // +---+---+---+---+---+
349 // | 5 | 6 | 7 | 8 | 9 |
350 // +---+---+---+---+---+
351 // |10 |11 |12 |13 |14 |
352 // +---+---+---+---+---+
353
354 {
355 BasicDesktopFrame expected(DesktopSize(5, 3));
356 expected.Clear();
357 expected.Paint(DesktopVector(1, 1), RgbaColor(6));
358 expected.Paint(DesktopVector(2, 1), RgbaColor(7));
359 expected.Paint(DesktopVector(3, 1), RgbaColor(8));
360
361 BasicDesktopFrame target(DesktopSize(5, 3));
362 target.Clear();
363 ASSERT_TRUE(CopyUnrotatedRectTo(frame,
364 DesktopRect::MakeXYWH(1, 1, 3, 1),
365 Rotation::CLOCK_WISE_0,
366 &target));
367 ASSERT_TRUE(target.DataEquals(expected));
368
369 BasicDesktopFrame target2(DesktopSize(5, 3));
370 target2.Clear();
371 ASSERT_TRUE(CopyRotatedRectTo(frame,
372 DesktopRect::MakeXYWH(1, 1, 3, 1),
373 Rotation::CLOCK_WISE_0,
374 &target2));
375 ASSERT_TRUE(target2.DataEquals(expected));
376
377 expected.Paint(DesktopVector(1, 0), RgbaColor(1));
378 expected.Paint(DesktopVector(2, 0), RgbaColor(2));
379 expected.Paint(DesktopVector(3, 0), RgbaColor(3));
380
381 target.Clear();
382 ASSERT_TRUE(CopyUnrotatedRectTo(frame,
383 DesktopRect::MakeXYWH(1, 0, 3, 2),
384 Rotation::CLOCK_WISE_0,
385 &target));
386 ASSERT_TRUE(target.DataEquals(expected));
387
388 target2.Clear();
389 ASSERT_TRUE(CopyRotatedRectTo(frame,
390 DesktopRect::MakeXYWH(1, 0, 3, 2),
391 Rotation::CLOCK_WISE_0,
392 &target2));
393 ASSERT_TRUE(target2.DataEquals(expected));
394 }
395
396 // After Rotating clock-wise 90 degree
397 // +---+---+---+
398 // |10 | 5 | 0 |
399 // +---+---+---+
400 // |11 | 6 | 1 |
401 // +---+---+---+
402 // |12 | 7 | 2 |
403 // +---+---+---+
404 // |13 | 8 | 3 |
405 // +---+---+---+
406 // |14 | 9 | 4 |
407 // +---+---+---+
408 {
409 BasicDesktopFrame expected(DesktopSize(3, 5));
410 expected.Clear();
411 expected.Paint(DesktopVector(1, 1), RgbaColor(6));
412 expected.Paint(DesktopVector(1, 2), RgbaColor(7));
413 expected.Paint(DesktopVector(1, 3), RgbaColor(8));
414
415 BasicDesktopFrame target(DesktopSize(3, 5));
416 target.Clear();
417 ASSERT_TRUE(CopyUnrotatedRectTo(frame,
418 DesktopRect::MakeXYWH(1, 1, 3, 1),
419 Rotation::CLOCK_WISE_90,
420 &target));
421 ASSERT_TRUE(target.DataEquals(expected));
422
423 BasicDesktopFrame target2(DesktopSize(3, 5));
424 target2.Clear();
425 ASSERT_TRUE(CopyRotatedRectTo(frame,
426 DesktopRect::MakeXYWH(1, 1, 1, 3),
427 Rotation::CLOCK_WISE_90,
428 &target2));
429 ASSERT_TRUE(target2.DataEquals(expected));
430
431 expected.Paint(DesktopVector(0, 1), RgbaColor(11));
432 expected.Paint(DesktopVector(0, 2), RgbaColor(12));
433 expected.Paint(DesktopVector(0, 3), RgbaColor(13));
434
435 target.Clear();
436 ASSERT_TRUE(CopyUnrotatedRectTo(frame,
437 DesktopRect::MakeXYWH(1, 1, 3, 2),
438 Rotation::CLOCK_WISE_90,
439 &target));
440 ASSERT_TRUE(target.DataEquals(expected));
441
442 target2.Clear();
443 ASSERT_TRUE(CopyRotatedRectTo(frame,
444 DesktopRect::MakeXYWH(0, 1, 2, 3),
445 Rotation::CLOCK_WISE_90,
446 &target2));
447 ASSERT_TRUE(target2.DataEquals(expected));
448 }
449
450 // After Rotating clock-wise 180 degree
451 // +---+---+---+---+---+
452 // |14 |13 |12 |11 |10 |
453 // +---+---+---+---+---+
454 // | 9 | 8 | 7 | 6 | 5 |
455 // +---+---+---+---+---+
456 // | 4 | 3 | 2 | 1 | 0 |
457 // +---+---+---+---+---+
458 {
459 BasicDesktopFrame expected(DesktopSize(5, 3));
460 expected.Clear();
461 expected.Paint(DesktopVector(1, 1), RgbaColor(8));
462 expected.Paint(DesktopVector(2, 1), RgbaColor(7));
463 expected.Paint(DesktopVector(3, 1), RgbaColor(6));
464
465 BasicDesktopFrame target(DesktopSize(5, 3));
466 target.Clear();
467 ASSERT_TRUE(CopyUnrotatedRectTo(frame,
468 DesktopRect::MakeXYWH(1, 1, 3, 1),
469 Rotation::CLOCK_WISE_180,
470 &target));
471 ASSERT_TRUE(target.DataEquals(expected));
472
473 BasicDesktopFrame target2(DesktopSize(5, 3));
474 target2.Clear();
475 ASSERT_TRUE(CopyRotatedRectTo(frame,
476 DesktopRect::MakeXYWH(1, 1, 3, 1),
477 Rotation::CLOCK_WISE_180,
478 &target2));
479 ASSERT_TRUE(target2.DataEquals(expected));
480
481 expected.Paint(DesktopVector(1, 0), RgbaColor(13));
482 expected.Paint(DesktopVector(2, 0), RgbaColor(12));
483 expected.Paint(DesktopVector(3, 0), RgbaColor(11));
484
485 target.Clear();
486 ASSERT_TRUE(CopyUnrotatedRectTo(frame,
487 DesktopRect::MakeXYWH(1, 1, 3, 2),
488 Rotation::CLOCK_WISE_180,
489 &target));
490 ASSERT_TRUE(target.DataEquals(expected));
491
492 target2.Clear();
493 ASSERT_TRUE(CopyRotatedRectTo(frame,
494 DesktopRect::MakeXYWH(1, 0, 3, 2),
495 Rotation::CLOCK_WISE_180,
496 &target2));
497 ASSERT_TRUE(target2.DataEquals(expected));
498 }
499
500 // After Rotating clock-wise 270 degree
501 // +---+---+---+
502 // | 4 | 9 |14 |
503 // +---+---+---+
504 // | 3 | 8 |13 |
505 // +---+---+---+
506 // | 2 | 7 |12 |
507 // +---+---+---+
508 // | 1 | 6 |11 |
509 // +---+---+---+
510 // | 0 | 5 |10 |
511 // +---+---+---+
512 {
513 BasicDesktopFrame expected(DesktopSize(3, 5));
514 expected.Clear();
515 expected.Paint(DesktopVector(1, 1), RgbaColor(8));
516 expected.Paint(DesktopVector(1, 2), RgbaColor(7));
517 expected.Paint(DesktopVector(1, 3), RgbaColor(6));
518
519 BasicDesktopFrame target(DesktopSize(3, 5));
520 target.Clear();
521 ASSERT_TRUE(CopyUnrotatedRectTo(frame,
522 DesktopRect::MakeXYWH(1, 1, 3, 1),
523 Rotation::CLOCK_WISE_270,
524 &target));
525 ASSERT_TRUE(target.DataEquals(expected));
526
527 BasicDesktopFrame target2(DesktopSize(3, 5));
528 target2.Clear();
529 ASSERT_TRUE(CopyRotatedRectTo(frame,
530 DesktopRect::MakeXYWH(1, 1, 1, 3),
531 Rotation::CLOCK_WISE_270,
532 &target2));
533 ASSERT_TRUE(target2.DataEquals(expected));
534
535 expected.Paint(DesktopVector(0, 1), RgbaColor(3));
536 expected.Paint(DesktopVector(0, 2), RgbaColor(2));
537 expected.Paint(DesktopVector(0, 3), RgbaColor(1));
538
539 target.Clear();
540 ASSERT_TRUE(CopyUnrotatedRectTo(frame,
541 DesktopRect::MakeXYWH(1, 0, 3, 2),
542 Rotation::CLOCK_WISE_270,
543 &target));
544 ASSERT_TRUE(target.DataEquals(expected));
545
546 target2.Clear();
547 ASSERT_TRUE(CopyRotatedRectTo(frame,
548 DesktopRect::MakeXYWH(0, 1, 2, 3),
549 Rotation::CLOCK_WISE_270,
550 &target2));
551 ASSERT_TRUE(target2.DataEquals(expected));
552 }
553 }
554
555 // On a typical machine (Intel(R) Xeon(R) E5-1650 v3 @ 3.50GHz, with O2
556 // optimization, the following case uses ~2.8s to finish. It means entirely
557 // rotating one 2048 x 1536, which is a large enough number to cover most of
558 // desktop computer users, uses around 28ms.
559 TEST(DesktopFrameRotatorTest, DISABLED_PerformanceTest) {
560 BasicDesktopFrame frame(DesktopSize(2048, 1536));
561 BasicDesktopFrame target(DesktopSize(1536, 2048));
562 BasicDesktopFrame target2(DesktopSize(2048, 1536));
563 for (int i = 0; i < 100; i++) {
564 ASSERT_TRUE(CopyRotatedRectTo(frame,
565 DesktopRect::MakeSize(target.size()),
566 Rotation::CLOCK_WISE_90,
567 &target));
568 ASSERT_TRUE(CopyRotatedRectTo(frame,
569 DesktopRect::MakeSize(target.size()),
570 Rotation::CLOCK_WISE_270,
571 &target));
572 ASSERT_TRUE(CopyRotatedRectTo(frame,
573 DesktopRect::MakeSize(target2.size()),
574 Rotation::CLOCK_WISE_0,
575 &target2));
576 ASSERT_TRUE(CopyRotatedRectTo(frame,
577 DesktopRect::MakeSize(target2.size()),
578 Rotation::CLOCK_WISE_180,
579 &target2));
580 }
581 }
582
583 // On a typical machine (Intel(R) Xeon(R) E5-1650 v3 @ 3.50GHz, with O2
584 // optimization, the following case uses ~22s to finish. It means entirely
585 // rotating one 4096 x 3072 uses around 220ms.
586 TEST(DesktopFrameRotatorTest, DISABLED_PerformanceTestOnLargeScreen) {
587 BasicDesktopFrame frame(DesktopSize(4096, 3072));
588 BasicDesktopFrame target(DesktopSize(3072, 4096));
589 BasicDesktopFrame target2(DesktopSize(4096, 3072));
590 for (int i = 0; i < 100; i++) {
591 ASSERT_TRUE(CopyRotatedRectTo(frame,
592 DesktopRect::MakeSize(target.size()),
593 Rotation::CLOCK_WISE_90,
594 &target));
595 ASSERT_TRUE(CopyRotatedRectTo(frame,
596 DesktopRect::MakeSize(target.size()),
597 Rotation::CLOCK_WISE_270,
598 &target));
599 ASSERT_TRUE(CopyRotatedRectTo(frame,
600 DesktopRect::MakeSize(target2.size()),
601 Rotation::CLOCK_WISE_0,
602 &target2));
603 ASSERT_TRUE(CopyRotatedRectTo(frame,
604 DesktopRect::MakeSize(target2.size()),
605 Rotation::CLOCK_WISE_180,
606 &target2));
607 }
608 }
609
610 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698