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

Unified Diff: remoting/base/codec_test.cc

Issue 9277001: Replace RectVectors with SkRegions in Decoder. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Pick nits. Created 8 years, 11 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | remoting/base/decoder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/base/codec_test.cc
diff --git a/remoting/base/codec_test.cc b/remoting/base/codec_test.cc
index efe7055058cba36e04e5bb7c3b2b3ba0b69299e0..a75127ce717bc924bc6d316a53f4865171c7c7ac 100644
--- a/remoting/base/codec_test.cc
+++ b/remoting/base/codec_test.cc
@@ -132,8 +132,8 @@ class DecoderTester {
}
void Reset() {
- rects_.clear();
- update_rects_.clear();
+ expected_region_.setEmpty();
+ update_region_.setEmpty();
}
void ReceivedPacket(VideoPacket* packet) {
@@ -142,7 +142,7 @@ class DecoderTester {
ASSERT_NE(Decoder::DECODE_ERROR, result);
if (result == Decoder::DECODE_DONE) {
- decoder_->GetUpdatedRects(&update_rects_);
+ decoder_->GetUpdatedRegion(&update_region_);
}
}
@@ -155,7 +155,9 @@ class DecoderTester {
}
void AddRects(const SkIRect* rects, int count) {
- rects_.insert(rects_.begin() + rects_.size(), rects, rects + count);
+ SkRegion new_rects;
+ new_rects.setRects(rects, count);
+ expected_region_.op(new_rects, SkRegion::kUnion_Op);
}
void VerifyResults() {
@@ -164,19 +166,17 @@ class DecoderTester {
ASSERT_TRUE(capture_data_.get());
- // Test the content of the update rect.
- ASSERT_EQ(rects_.size(), update_rects_.size());
- for (size_t i = 0; i < update_rects_.size(); ++i) {
- EXPECT_EQ(rects_[i], update_rects_[i]);
-
+ // Test the content of the update region.
+ EXPECT_EQ(expected_region_, update_region_);
+ for (SkRegion::Iterator i(update_region_); !i.done(); i.next()) {
EXPECT_EQ(frame_->stride(0), capture_data_->data_planes().strides[0]);
const int stride = frame_->stride(0);
- const int offset = stride * update_rects_[i].fTop +
- kBytesPerPixel * update_rects_[i].fLeft;
+ const int offset = stride * i.rect().top() +
+ kBytesPerPixel * i.rect().left();
const uint8* original = capture_data_->data_planes().data[0] + offset;
const uint8* decoded = frame_->data(0) + offset;
- const int row_size = kBytesPerPixel * update_rects_[i].width();
- for (int y = 0; y < update_rects_[i].height(); ++y) {
+ const int row_size = kBytesPerPixel * i.rect().width();
+ for (int y = 0; y < i.rect().height(); ++y) {
EXPECT_EQ(0, memcmp(original, decoded, row_size))
<< "Row " << y << " is different";
original += stride;
@@ -187,8 +187,8 @@ class DecoderTester {
private:
bool strict_;
- std::deque<SkIRect> rects_;
- RectVector update_rects_;
+ SkRegion expected_region_;
+ SkRegion update_region_;
Decoder* decoder_;
scoped_refptr<media::VideoFrame> frame_;
scoped_refptr<CaptureData> capture_data_;
@@ -292,28 +292,24 @@ void TestEncoder(Encoder* encoder, bool strict) {
TestEncodingRects(encoder, &tester, data, kTestRects + 3, 2);
}
-static void TestEncodingRects(Encoder* encoder,
- EncoderTester* encoder_tester,
- DecoderTester* decoder_tester,
- scoped_refptr<CaptureData> data,
- const SkIRect* rects, int count) {
- data->mutable_dirty_region().setEmpty();
- for (int i = 0; i < count; ++i) {
- data->mutable_dirty_region().op(rects[i], SkRegion::kUnion_Op);
- }
+static void TestEncodeDecodeRects(Encoder* encoder,
+ EncoderTester* encoder_tester,
+ DecoderTester* decoder_tester,
+ scoped_refptr<CaptureData> data,
+ const SkIRect* rects, int count) {
+ data->mutable_dirty_region().setRects(rects, count);
encoder_tester->AddRects(rects, count);
decoder_tester->AddRects(rects, count);
- // Generate random data for the updated rects.
+ // Generate random data for the updated region.
srand(0);
for (int i = 0; i < count; ++i) {
- const SkIRect& rect = rects[i];
const int bytes_per_pixel = GetBytesPerPixel(data->pixel_format());
- const int row_size = bytes_per_pixel * rect.width();
+ const int row_size = bytes_per_pixel * rects[i].width();
uint8* memory = data->data_planes().data[0] +
- data->data_planes().strides[0] * rect.fTop +
- bytes_per_pixel * rect.fLeft;
- for (int y = 0; y < rect.height(); ++y) {
+ data->data_planes().strides[0] * rects[i].top() +
+ bytes_per_pixel * rects[i].left();
+ for (int y = 0; y < rects[i].height(); ++y) {
for (int x = 0; x < row_size; ++x)
memory[x] = rand() % 256;
memory += data->data_planes().strides[0];
@@ -342,14 +338,14 @@ void TestEncoderDecoder(Encoder* encoder, Decoder* decoder, bool strict) {
decoder_tester.set_capture_data(data);
encoder_tester.set_decoder_tester(&decoder_tester);
- TestEncodingRects(encoder, &encoder_tester, &decoder_tester, data,
- kTestRects, 1);
- TestEncodingRects(encoder, &encoder_tester, &decoder_tester, data,
- kTestRects + 1, 1);
- TestEncodingRects(encoder, &encoder_tester, &decoder_tester, data,
- kTestRects + 2, 1);
- TestEncodingRects(encoder, &encoder_tester, &decoder_tester, data,
- kTestRects + 3, 2);
+ TestEncodeDecodeRects(encoder, &encoder_tester, &decoder_tester, data,
+ kTestRects, 1);
+ TestEncodeDecodeRects(encoder, &encoder_tester, &decoder_tester, data,
+ kTestRects + 1, 1);
+ TestEncodeDecodeRects(encoder, &encoder_tester, &decoder_tester, data,
+ kTestRects + 2, 1);
+ TestEncodeDecodeRects(encoder, &encoder_tester, &decoder_tester, data,
+ kTestRects + 3, 2);
}
} // namespace remoting
« no previous file with comments | « no previous file | remoting/base/decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698