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

Side by Side Diff: cc/layers/video_layer_impl_unittest.cc

Issue 388643002: Rotation into Video Layer + Content Transform (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed uneeded parameter. Created 6 years, 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "cc/layers/video_layer_impl.h" 5 #include "cc/layers/video_layer_impl.h"
6 6
7 #include "cc/layers/video_frame_provider_client_impl.h" 7 #include "cc/layers/video_frame_provider_client_impl.h"
8 #include "cc/output/context_provider.h" 8 #include "cc/output/context_provider.h"
9 #include "cc/output/output_surface.h" 9 #include "cc/output/output_surface.h"
10 #include "cc/quads/draw_quad.h"
10 #include "cc/test/fake_video_frame_provider.h" 11 #include "cc/test/fake_video_frame_provider.h"
11 #include "cc/test/layer_test_common.h" 12 #include "cc/test/layer_test_common.h"
12 #include "cc/trees/single_thread_proxy.h" 13 #include "cc/trees/single_thread_proxy.h"
13 #include "media/base/video_frame.h" 14 #include "media/base/video_frame.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 16
16 namespace cc { 17 namespace cc {
17 namespace { 18 namespace {
18 19
19 TEST(VideoLayerImplTest, Occlusion) { 20 TEST(VideoLayerImplTest, Occlusion) {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 87
87 VideoFrameProviderClientImpl* client = 88 VideoFrameProviderClientImpl* client =
88 static_cast<VideoFrameProviderClientImpl*>(provider.client()); 89 static_cast<VideoFrameProviderClientImpl*>(provider.client());
89 ASSERT_TRUE(client); 90 ASSERT_TRUE(client);
90 EXPECT_FALSE(client->active_video_layer()); 91 EXPECT_FALSE(client->active_video_layer());
91 92
92 video_layer_impl->DidBecomeActive(); 93 video_layer_impl->DidBecomeActive();
93 EXPECT_EQ(video_layer_impl, client->active_video_layer()); 94 EXPECT_EQ(video_layer_impl, client->active_video_layer());
94 } 95 }
95 96
97 TEST(VideoLayerImplTest, Rotated0) {
98 gfx::Size layer_size(100, 50);
99 gfx::Size viewport_size(1000, 500);
100
101 LayerTestCommon::LayerImplTest impl;
102 DebugScopedSetImplThreadAndMainThreadBlocked thread(impl.proxy());
103
104 scoped_refptr<media::VideoFrame> video_frame =
105 media::VideoFrame::CreateFrame(media::VideoFrame::YV12,
106 gfx::Size(20, 10),
107 gfx::Rect(20, 10),
108 gfx::Size(20, 10),
109 base::TimeDelta());
110 FakeVideoFrameProvider provider;
111 provider.set_frame(video_frame);
112
113 VideoLayerImpl* video_layer_impl =
114 impl.AddChildToRoot<VideoLayerImpl>(&provider);
115 video_layer_impl->SetBounds(layer_size);
116 video_layer_impl->SetContentBounds(layer_size);
117 video_layer_impl->SetDrawsContent(true);
118
119 {
120 SCOPED_TRACE("0 Degree Rotation");
121 video_layer_impl->set_video_rotation(media::VIDEO_ROTATION_0);
122 impl.CalcDrawProps(viewport_size);
123 gfx::Rect occluded;
124 impl.AppendQuadsWithOcclusion(video_layer_impl, occluded);
125
126 EXPECT_EQ(1u, impl.quad_list().size());
127 EXPECT_EQ(gfx::Size(100, 50), impl.quad_list()[0]->rect.size());
128
129 gfx::Point3F p1(0, 100, 0);
130 gfx::Point3F p2(50, 0, 0);
131 impl.quad_list()[0]->quadTransform().TransformPoint(&p1);
132 impl.quad_list()[0]->quadTransform().TransformPoint(&p2);
133 EXPECT_EQ(gfx::Point3F(0, 100, 0), p1);
134 EXPECT_EQ(gfx::Point3F(50, 0, 0), p2);
135 }
136 }
137
138 TEST(VideoLayerImplTest, Rotated90) {
139 gfx::Size layer_size(100, 50);
140 gfx::Size viewport_size(1000, 500);
141
142 LayerTestCommon::LayerImplTest impl;
143 DebugScopedSetImplThreadAndMainThreadBlocked thread(impl.proxy());
144
145 scoped_refptr<media::VideoFrame> video_frame =
146 media::VideoFrame::CreateFrame(media::VideoFrame::YV12,
147 gfx::Size(20, 10),
148 gfx::Rect(20, 10),
149 gfx::Size(20, 10),
150 base::TimeDelta());
151 FakeVideoFrameProvider provider;
152 provider.set_frame(video_frame);
153
154 VideoLayerImpl* video_layer_impl =
155 impl.AddChildToRoot<VideoLayerImpl>(&provider);
156 video_layer_impl->SetBounds(layer_size);
157 video_layer_impl->SetContentBounds(layer_size);
158 video_layer_impl->SetDrawsContent(true);
159
160 {
161 SCOPED_TRACE("90 Degree Rotation");
162 video_layer_impl->set_video_rotation(media::VIDEO_ROTATION_90);
163 impl.CalcDrawProps(viewport_size);
164 gfx::Rect occluded;
165 impl.AppendQuadsWithOcclusion(video_layer_impl, occluded);
166
167 EXPECT_EQ(1u, impl.quad_list().size());
168 EXPECT_EQ(gfx::Size(50, 100), impl.quad_list()[0]->rect.size());
169
170 gfx::Point3F p1(0, 100, 0);
171 gfx::Point3F p2(50, 0, 0);
172 impl.quad_list()[0]->quadTransform().TransformPoint(&p1);
173 impl.quad_list()[0]->quadTransform().TransformPoint(&p2);
174 EXPECT_EQ(gfx::Point3F(0, 0, 0), p1);
175 EXPECT_EQ(gfx::Point3F(100, 50, 0), p2);
176 }
177 }
178
179 TEST(VideoLayerImplTest, Rotated180) {
180 gfx::Size layer_size(100, 50);
181 gfx::Size viewport_size(1000, 500);
182
183 LayerTestCommon::LayerImplTest impl;
184 DebugScopedSetImplThreadAndMainThreadBlocked thread(impl.proxy());
185
186 scoped_refptr<media::VideoFrame> video_frame =
187 media::VideoFrame::CreateFrame(media::VideoFrame::YV12,
188 gfx::Size(20, 10),
189 gfx::Rect(20, 10),
190 gfx::Size(20, 10),
191 base::TimeDelta());
192 FakeVideoFrameProvider provider;
193 provider.set_frame(video_frame);
194
195 VideoLayerImpl* video_layer_impl =
196 impl.AddChildToRoot<VideoLayerImpl>(&provider);
197 video_layer_impl->SetBounds(layer_size);
198 video_layer_impl->SetContentBounds(layer_size);
199 video_layer_impl->SetDrawsContent(true);
200
201 {
202 SCOPED_TRACE("180 Degree Rotation");
203 video_layer_impl->set_video_rotation(media::VIDEO_ROTATION_180);
204 impl.CalcDrawProps(viewport_size);
205 gfx::Rect occluded;
206 impl.AppendQuadsWithOcclusion(video_layer_impl, occluded);
207
208 EXPECT_EQ(1u, impl.quad_list().size());
209 EXPECT_EQ(gfx::Size(100, 50), impl.quad_list()[0]->rect.size());
210
211 gfx::Point3F p1(0, 50, 0);
212 gfx::Point3F p2(100, 0, 0);
213 impl.quad_list()[0]->quadTransform().TransformPoint(&p1);
214 impl.quad_list()[0]->quadTransform().TransformPoint(&p2);
215 EXPECT_EQ(gfx::Point3F(100, 0, 0), p1);
216 EXPECT_EQ(gfx::Point3F(0, 50, 0), p2);
217 }
218 }
219
220 TEST(VideoLayerImplTest, Rotated270) {
221 gfx::Size layer_size(100, 50);
222 gfx::Size viewport_size(1000, 500);
223
224 LayerTestCommon::LayerImplTest impl;
225 DebugScopedSetImplThreadAndMainThreadBlocked thread(impl.proxy());
226
227 scoped_refptr<media::VideoFrame> video_frame =
228 media::VideoFrame::CreateFrame(media::VideoFrame::YV12,
229 gfx::Size(20, 10),
230 gfx::Rect(20, 10),
231 gfx::Size(20, 10),
232 base::TimeDelta());
233 FakeVideoFrameProvider provider;
234 provider.set_frame(video_frame);
235
236 VideoLayerImpl* video_layer_impl =
237 impl.AddChildToRoot<VideoLayerImpl>(&provider);
238 video_layer_impl->SetBounds(layer_size);
239 video_layer_impl->SetContentBounds(layer_size);
240 video_layer_impl->SetDrawsContent(true);
241
242 {
243 SCOPED_TRACE("270 Degree Rotation");
244 video_layer_impl->set_video_rotation(media::VIDEO_ROTATION_270);
245 impl.CalcDrawProps(viewport_size);
246 gfx::Rect occluded;
247 impl.AppendQuadsWithOcclusion(video_layer_impl, occluded);
248
249 EXPECT_EQ(1u, impl.quad_list().size());
250 EXPECT_EQ(gfx::Size(50, 100), impl.quad_list()[0]->rect.size());
251
252 gfx::Point3F p1(0, 100, 0);
253 gfx::Point3F p2(50, 0, 0);
254 impl.quad_list()[0]->quadTransform().TransformPoint(&p1);
255 impl.quad_list()[0]->quadTransform().TransformPoint(&p2);
256 EXPECT_EQ(gfx::Point3F(100, 50, 0), p1);
257 EXPECT_EQ(gfx::Point3F(0, 0, 0), p2);
258 }
259 }
260
96 } // namespace 261 } // namespace
97 } // namespace cc 262 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698