Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <deque> | 5 #include <deque> |
| 6 #include <stdlib.h> | 6 #include <stdlib.h> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 350 for (int i = 0; i < count; ++i) { | 350 for (int i = 0; i < count; ++i) { |
| 351 data->mutable_dirty_region().op(rects[i], SkRegion::kUnion_Op); | 351 data->mutable_dirty_region().op(rects[i], SkRegion::kUnion_Op); |
| 352 } | 352 } |
| 353 tester->AddRects(rects, count); | 353 tester->AddRects(rects, count); |
| 354 | 354 |
| 355 encoder->Encode(data, true, base::Bind( | 355 encoder->Encode(data, true, base::Bind( |
| 356 &VideoEncoderTester::DataAvailable, base::Unretained(tester))); | 356 &VideoEncoderTester::DataAvailable, base::Unretained(tester))); |
| 357 } | 357 } |
| 358 | 358 |
| 359 void TestVideoEncoder(VideoEncoder* encoder, bool strict) { | 359 void TestVideoEncoder(VideoEncoder* encoder, bool strict) { |
| 360 SkISize kSize = SkISize::Make(320, 240); | 360 int kSizes[] = {320, 319, 317, 240, 160}; |
|
simonmorris
2012/10/19 15:48:08
int -> const int ?
Wez
2012/10/19 20:56:53
Done.
| |
| 361 | 361 |
| 362 VideoEncoderMessageTester message_tester; | 362 VideoEncoderMessageTester message_tester; |
| 363 message_tester.set_strict(strict); | 363 message_tester.set_strict(strict); |
| 364 | 364 |
| 365 VideoEncoderTester tester(&message_tester); | 365 VideoEncoderTester tester(&message_tester); |
| 366 | 366 |
| 367 scoped_array<uint8> memory; | 367 scoped_array<uint8> memory; |
| 368 scoped_refptr<CaptureData> data = | |
| 369 PrepareEncodeData(kSize, media::VideoFrame::RGB32, &memory); | |
| 370 | 368 |
| 371 std::vector<std::vector<SkIRect> > test_rect_lists = MakeTestRectLists(kSize); | 369 for (size_t xi = 0; xi < arraysize(kSizes); ++xi) { |
| 372 for (size_t i = 0; i < test_rect_lists.size(); ++i) { | 370 for (size_t yi = 0; yi < arraysize(kSizes); ++yi) { |
|
Sergey Ulanov
2012/10/19 17:50:26
whoa, it's 25 tests total. How much time does it t
Wez
2012/10/19 20:56:53
I've reduced it to sixteen sizes; I want to test f
| |
| 373 const std::vector<SkIRect>& test_rects = test_rect_lists[i]; | 371 SkISize size = SkISize::Make(kSizes[xi], kSizes[yi]); |
| 374 TestEncodingRects(encoder, &tester, data, | 372 scoped_refptr<CaptureData> data = |
| 375 &test_rects[0], test_rects.size()); | 373 PrepareEncodeData(size, media::VideoFrame::RGB32, &memory); |
|
Sergey Ulanov
2012/10/19 17:50:26
style police: 4 spaces indent here please.
Wez
2012/10/19 20:56:53
Done.
| |
| 374 | |
| 375 std::vector<std::vector<SkIRect> > test_rect_lists = | |
| 376 MakeTestRectLists(size); | |
| 377 for (size_t i = 0; i < test_rect_lists.size(); ++i) { | |
| 378 const std::vector<SkIRect>& test_rects = test_rect_lists[i]; | |
| 379 TestEncodingRects(encoder, &tester, data, | |
| 380 &test_rects[0], test_rects.size()); | |
| 381 } | |
| 382 } | |
| 376 } | 383 } |
| 377 } | 384 } |
| 378 | 385 |
| 379 static void TestEncodeDecodeRects(VideoEncoder* encoder, | 386 static void TestEncodeDecodeRects(VideoEncoder* encoder, |
| 380 VideoEncoderTester* encoder_tester, | 387 VideoEncoderTester* encoder_tester, |
| 381 VideoDecoderTester* decoder_tester, | 388 VideoDecoderTester* decoder_tester, |
| 382 scoped_refptr<CaptureData> data, | 389 scoped_refptr<CaptureData> data, |
| 383 const SkIRect* rects, int count) { | 390 const SkIRect* rects, int count) { |
| 384 data->mutable_dirty_region().setRects(rects, count); | 391 data->mutable_dirty_region().setRects(rects, count); |
| 385 encoder_tester->AddRects(rects, count); | 392 encoder_tester->AddRects(rects, count); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 487 // Check that the decoder correctly re-renders the frame if its client | 494 // Check that the decoder correctly re-renders the frame if its client |
| 488 // invalidates the frame. | 495 // invalidates the frame. |
| 489 decoder_tester.ResetRenderedData(); | 496 decoder_tester.ResetRenderedData(); |
| 490 decoder->Invalidate(view_size, SkRegion(view_rect)); | 497 decoder->Invalidate(view_size, SkRegion(view_rect)); |
| 491 decoder_tester.RenderFrame(); | 498 decoder_tester.RenderFrame(); |
| 492 decoder_tester.VerifyResultsApprox(expected_view_data.get(), | 499 decoder_tester.VerifyResultsApprox(expected_view_data.get(), |
| 493 max_error_limit, mean_error_limit); | 500 max_error_limit, mean_error_limit); |
| 494 } | 501 } |
| 495 | 502 |
| 496 } // namespace remoting | 503 } // namespace remoting |
| OLD | NEW |