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

Side by Side Diff: remoting/base/encoder_vp8_unittest.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/encoder_vp8.cc ('k') | remoting/base/util.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 <limits> 5 #include <limits>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "remoting/base/capture_data.h" 10 #include "remoting/base/capture_data.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 EncoderVp8 encoder; 43 EncoderVp8 encoder;
44 EncoderCallback callback; 44 EncoderCallback callback;
45 45
46 std::vector<uint8> buffer(width * height * kBytesPerPixel); 46 std::vector<uint8> buffer(width * height * kBytesPerPixel);
47 DataPlanes planes; 47 DataPlanes planes;
48 planes.data[0] = &buffer.front(); 48 planes.data[0] = &buffer.front();
49 planes.strides[0] = width; 49 planes.strides[0] = width;
50 50
51 scoped_refptr<CaptureData> capture_data(new CaptureData( 51 scoped_refptr<CaptureData> capture_data(new CaptureData(
52 planes, gfx::Size(width, height), media::VideoFrame::RGB32)); 52 planes, SkISize::Make(width, height), media::VideoFrame::RGB32));
53 encoder.Encode(capture_data, false, 53 encoder.Encode(capture_data, false,
54 NewCallback(&callback, &EncoderCallback::DataAvailable)); 54 NewCallback(&callback, &EncoderCallback::DataAvailable));
55 55
56 height /= 2; 56 height /= 2;
57 capture_data = new CaptureData(planes, gfx::Size(width, height), 57 capture_data = new CaptureData(planes, SkISize::Make(width, height),
58 media::VideoFrame::RGB32); 58 media::VideoFrame::RGB32);
59 encoder.Encode(capture_data, false, 59 encoder.Encode(capture_data, false,
60 NewCallback(&callback, &EncoderCallback::DataAvailable)); 60 NewCallback(&callback, &EncoderCallback::DataAvailable));
61 } 61 }
62 62
63 TEST(EncoderVp8Test, AlignAndClipRect) { 63 TEST(EncoderVp8Test, AlignAndClipRect) {
64 // Simple test case (no clipping). 64 // Simple test case (no clipping).
65 gfx::Rect r1(100, 200, 300, 400); 65 SkIRect r1(SkIRect::MakeXYWH(100, 200, 300, 400));
66 EXPECT_EQ(EncoderVp8::AlignAndClipRect(r1, kIntMax, kIntMax), r1); 66 EXPECT_EQ(EncoderVp8::AlignAndClipRect(r1, kIntMax, kIntMax), r1);
67 67
68 // Should expand outward to r1. 68 // Should expand outward to r1.
69 gfx::Rect r2(101, 201, 298, 398); 69 SkIRect r2(SkIRect::MakeXYWH(101, 201, 298, 398));
70 EXPECT_EQ(EncoderVp8::AlignAndClipRect(r2, kIntMax, kIntMax), r1); 70 EXPECT_EQ(EncoderVp8::AlignAndClipRect(r2, kIntMax, kIntMax), r1);
71 71
72 // Test clipping to screen size. 72 // Test clipping to screen size.
73 EXPECT_EQ(EncoderVp8::AlignAndClipRect(r1, 110, 220), 73 EXPECT_EQ(EncoderVp8::AlignAndClipRect(r1, 110, 220),
74 gfx::Rect(100, 200, 10, 20)); 74 SkIRect::MakeXYWH(100, 200, 10, 20));
75 75
76 // Rectangle completely off-screen. 76 // Rectangle completely off-screen.
77 EXPECT_TRUE(EncoderVp8::AlignAndClipRect(r1, 50, 50).IsEmpty()); 77 EXPECT_TRUE(EncoderVp8::AlignAndClipRect(r1, 50, 50).isEmpty());
78 78
79 // Clipping to odd-sized screen. An unlikely case, and we might not deal 79 // Clipping to odd-sized screen. An unlikely case, and we might not deal
80 // with it cleanly in the encoder (we possibly lose 1px at right & bottom 80 // with it cleanly in the encoder (we possibly lose 1px at right & bottom
81 // of screen). 81 // of screen).
82 EXPECT_EQ(EncoderVp8::AlignAndClipRect(r1, 199, 299), 82 EXPECT_EQ(EncoderVp8::AlignAndClipRect(r1, 199, 299),
83 gfx::Rect(100, 200, 98, 98)); 83 SkIRect::MakeXYWH(100, 200, 98, 98));
84 } 84 }
85 85
86 } // namespace remoting 86 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/base/encoder_vp8.cc ('k') | remoting/base/util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698