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

Side by Side Diff: remoting/base/codec_test.cc

Issue 7992011: Move us fully from gfx:: over to skia types for consistency. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix for bad DEPS Created 9 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/base/capture_data.cc ('k') | remoting/base/decoder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "media/base/video_frame.h" 9 #include "media/base/video_frame.h"
10 #include "remoting/base/base_mock_objects.h" 10 #include "remoting/base/base_mock_objects.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 158
159 void VerifyResults() { 159 void VerifyResults() {
160 if (!strict_) 160 if (!strict_)
161 return; 161 return;
162 162
163 ASSERT_TRUE(capture_data_.get()); 163 ASSERT_TRUE(capture_data_.get());
164 164
165 // Test the content of the update rect. 165 // Test the content of the update rect.
166 ASSERT_EQ(rects_.size(), update_rects_.size()); 166 ASSERT_EQ(rects_.size(), update_rects_.size());
167 for (size_t i = 0; i < update_rects_.size(); ++i) { 167 for (size_t i = 0; i < update_rects_.size(); ++i) {
168 SkIRect &r = rects_[i]; 168 EXPECT_EQ(rects_[i], update_rects_[i]);
169 gfx::Rect rect(r.fLeft, r.fTop, r.width(), r.height());
170 EXPECT_EQ(rect, update_rects_[i]);
171 169
172 EXPECT_EQ(frame_->stride(0), capture_data_->data_planes().strides[0]); 170 EXPECT_EQ(frame_->stride(0), capture_data_->data_planes().strides[0]);
173 const int stride = frame_->stride(0); 171 const int stride = frame_->stride(0);
174 const int offset = stride * update_rects_[i].y() + 172 const int offset = stride * update_rects_[i].fTop +
175 kBytesPerPixel * update_rects_[i].x(); 173 kBytesPerPixel * update_rects_[i].fLeft;
176 const uint8* original = capture_data_->data_planes().data[0] + offset; 174 const uint8* original = capture_data_->data_planes().data[0] + offset;
177 const uint8* decoded = frame_->data(0) + offset; 175 const uint8* decoded = frame_->data(0) + offset;
178 const int row_size = kBytesPerPixel * update_rects_[i].width(); 176 const int row_size = kBytesPerPixel * update_rects_[i].width();
179 for (int y = 0; y < update_rects_[i].height(); ++y) { 177 for (int y = 0; y < update_rects_[i].height(); ++y) {
180 EXPECT_EQ(0, memcmp(original, decoded, row_size)) 178 EXPECT_EQ(0, memcmp(original, decoded, row_size))
181 << "Row " << y << " is different"; 179 << "Row " << y << " is different";
182 original += stride; 180 original += stride;
183 decoded += stride; 181 decoded += stride;
184 } 182 }
185 } 183 }
186 } 184 }
187 185
188 private: 186 private:
189 bool strict_; 187 bool strict_;
190 std::deque<SkIRect> rects_; 188 std::deque<SkIRect> rects_;
191 UpdatedRects update_rects_; 189 RectVector update_rects_;
192 Decoder* decoder_; 190 Decoder* decoder_;
193 scoped_refptr<media::VideoFrame> frame_; 191 scoped_refptr<media::VideoFrame> frame_;
194 scoped_refptr<CaptureData> capture_data_; 192 scoped_refptr<CaptureData> capture_data_;
195 193
196 DISALLOW_COPY_AND_ASSIGN(DecoderTester); 194 DISALLOW_COPY_AND_ASSIGN(DecoderTester);
197 }; 195 };
198 196
199 // The EncoderTester provides a hook for retrieving the data, and passing the 197 // The EncoderTester provides a hook for retrieving the data, and passing the
200 // message to other subprograms for validaton. 198 // message to other subprograms for validaton.
201 class EncoderTester { 199 class EncoderTester {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 (*memory)[i] = rand() % 256; 248 (*memory)[i] = rand() % 256;
251 } 249 }
252 250
253 DataPlanes planes; 251 DataPlanes planes;
254 memset(planes.data, 0, sizeof(planes.data)); 252 memset(planes.data, 0, sizeof(planes.data));
255 memset(planes.strides, 0, sizeof(planes.strides)); 253 memset(planes.strides, 0, sizeof(planes.strides));
256 planes.data[0] = *memory; 254 planes.data[0] = *memory;
257 planes.strides[0] = kWidth * kBytesPerPixel; 255 planes.strides[0] = kWidth * kBytesPerPixel;
258 256
259 scoped_refptr<CaptureData> data = 257 scoped_refptr<CaptureData> data =
260 new CaptureData(planes, gfx::Size(kWidth, kHeight), format); 258 new CaptureData(planes, SkISize::Make(kWidth, kHeight), format);
261 return data; 259 return data;
262 } 260 }
263 261
264 static void TestEncodingRects(Encoder* encoder, 262 static void TestEncodingRects(Encoder* encoder,
265 EncoderTester* tester, 263 EncoderTester* tester,
266 scoped_refptr<CaptureData> data, 264 scoped_refptr<CaptureData> data,
267 const SkIRect* rects, int count) { 265 const SkIRect* rects, int count) {
268 data->mutable_dirty_region().setEmpty(); 266 data->mutable_dirty_region().setEmpty();
269 for (int i = 0; i < count; ++i) { 267 for (int i = 0; i < count; ++i) {
270 data->mutable_dirty_region().op(rects[i], SkRegion::kUnion_Op); 268 data->mutable_dirty_region().op(rects[i], SkRegion::kUnion_Op);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 kTestRects + 1, 1); 346 kTestRects + 1, 1);
349 TestEncodingRects(encoder, &encoder_tester, &decoder_tester, data, 347 TestEncodingRects(encoder, &encoder_tester, &decoder_tester, data,
350 kTestRects + 2, 1); 348 kTestRects + 2, 1);
351 TestEncodingRects(encoder, &encoder_tester, &decoder_tester, data, 349 TestEncodingRects(encoder, &encoder_tester, &decoder_tester, data,
352 kTestRects + 3, 2); 350 kTestRects + 3, 2);
353 } 351 }
354 352
355 } // namespace remoting 353 } // namespace remoting
356 354
357 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::DecoderTester); 355 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::DecoderTester);
OLDNEW
« no previous file with comments | « remoting/base/capture_data.cc ('k') | remoting/base/decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698