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

Unified Diff: remoting/base/codec_test.cc

Issue 9146030: Revert 118790 - Compile error due to missing operator== on SkRegion (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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
===================================================================
--- remoting/base/codec_test.cc (revision 118791)
+++ remoting/base/codec_test.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -132,8 +132,8 @@
}
void Reset() {
- expected_region_.setEmpty();
- update_region_.setEmpty();
+ rects_.clear();
+ update_rects_.clear();
}
void ReceivedPacket(VideoPacket* packet) {
@@ -142,7 +142,7 @@
ASSERT_NE(Decoder::DECODE_ERROR, result);
if (result == Decoder::DECODE_DONE) {
- decoder_->GetUpdatedRegion(&update_region_);
+ decoder_->GetUpdatedRects(&update_rects_);
}
}
@@ -155,9 +155,7 @@
}
void AddRects(const SkIRect* rects, int count) {
- SkRegion new_rects;
- new_rects.setRects(rects, count);
- expected_region_.op(new_rects, SkRegion::kUnion_Op);
+ rects_.insert(rects_.begin() + rects_.size(), rects, rects + count);
}
void VerifyResults() {
@@ -166,17 +164,19 @@
ASSERT_TRUE(capture_data_.get());
- // Test the content of the update region.
- EXPECT_EQ(expected_region_, update_region_);
- for (SkRegion::Iterator i(update_region_); !i.done(); i.next()) {
+ // 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]);
+
EXPECT_EQ(frame_->stride(0), capture_data_->data_planes().strides[0]);
const int stride = frame_->stride(0);
- const int offset = stride * i.rect().top() +
- kBytesPerPixel * i.rect().left();
+ const int offset = stride * update_rects_[i].fTop +
+ kBytesPerPixel * update_rects_[i].fLeft;
const uint8* original = capture_data_->data_planes().data[0] + offset;
const uint8* decoded = frame_->data(0) + offset;
- const int row_size = kBytesPerPixel * i.rect().width();
- for (int y = 0; y < i.rect().height(); ++y) {
+ const int row_size = kBytesPerPixel * update_rects_[i].width();
+ for (int y = 0; y < update_rects_[i].height(); ++y) {
EXPECT_EQ(0, memcmp(original, decoded, row_size))
<< "Row " << y << " is different";
original += stride;
@@ -187,8 +187,8 @@
private:
bool strict_;
- SkRegion expected_region_;
- SkRegion update_region_;
+ std::deque<SkIRect> rects_;
+ RectVector update_rects_;
Decoder* decoder_;
scoped_refptr<media::VideoFrame> frame_;
scoped_refptr<CaptureData> capture_data_;
@@ -292,24 +292,28 @@
TestEncodingRects(encoder, &tester, data, kTestRects + 3, 2);
}
-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);
+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);
+ }
encoder_tester->AddRects(rects, count);
decoder_tester->AddRects(rects, count);
- // Generate random data for the updated region.
+ // Generate random data for the updated rects.
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 * rects[i].width();
+ const int row_size = bytes_per_pixel * rect.width();
uint8* memory = data->data_planes().data[0] +
- data->data_planes().strides[0] * rects[i].top() +
- bytes_per_pixel * rects[i].left();
- for (int y = 0; y < rects[i].height(); ++y) {
+ data->data_planes().strides[0] * rect.fTop +
+ bytes_per_pixel * rect.fLeft;
+ for (int y = 0; y < rect.height(); ++y) {
for (int x = 0; x < row_size; ++x)
memory[x] = rand() % 256;
memory += data->data_planes().strides[0];
@@ -338,14 +342,14 @@
decoder_tester.set_capture_data(data);
encoder_tester.set_decoder_tester(&decoder_tester);
- 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);
+ 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);
}
} // 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