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

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: Updated layer{impl} tests 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.h"
5 #include "cc/layers/video_layer_impl.h" 6 #include "cc/layers/video_layer_impl.h"
6 7
7 #include "cc/layers/video_frame_provider_client_impl.h" 8 #include "cc/layers/video_frame_provider_client_impl.h"
8 #include "cc/output/context_provider.h" 9 #include "cc/output/context_provider.h"
9 #include "cc/output/output_surface.h" 10 #include "cc/output/output_surface.h"
11 #include "cc/quads/draw_quad.h"
10 #include "cc/test/fake_video_frame_provider.h" 12 #include "cc/test/fake_video_frame_provider.h"
11 #include "cc/test/layer_test_common.h" 13 #include "cc/test/layer_test_common.h"
12 #include "cc/trees/single_thread_proxy.h" 14 #include "cc/trees/single_thread_proxy.h"
13 #include "media/base/video_frame.h" 15 #include "media/base/video_frame.h"
14 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
15 17
16 namespace cc { 18 namespace cc {
17 namespace { 19 namespace {
18 20
19 TEST(VideoLayerImplTest, Occlusion) { 21 TEST(VideoLayerImplTest, Occlusion) {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 88
87 VideoFrameProviderClientImpl* client = 89 VideoFrameProviderClientImpl* client =
88 static_cast<VideoFrameProviderClientImpl*>(provider.client()); 90 static_cast<VideoFrameProviderClientImpl*>(provider.client());
89 ASSERT_TRUE(client); 91 ASSERT_TRUE(client);
90 EXPECT_FALSE(client->active_video_layer()); 92 EXPECT_FALSE(client->active_video_layer());
91 93
92 video_layer_impl->DidBecomeActive(); 94 video_layer_impl->DidBecomeActive();
93 EXPECT_EQ(video_layer_impl, client->active_video_layer()); 95 EXPECT_EQ(video_layer_impl, client->active_video_layer());
94 } 96 }
95 97
98 TEST(VideoLayerImplTest, Rotated0) {
99 gfx::Size layer_size(100, 50);
100 gfx::Size viewport_size(1000, 500);
101
102 LayerTestCommon::LayerImplTest impl;
103 DebugScopedSetImplThreadAndMainThreadBlocked thread(impl.proxy());
104
105 scoped_refptr<media::VideoFrame> video_frame =
106 media::VideoFrame::CreateFrame(media::VideoFrame::YV12,
107 gfx::Size(20, 10),
108 gfx::Rect(20, 10),
109 gfx::Size(20, 10),
110 base::TimeDelta());
111 FakeVideoFrameProvider provider;
112 provider.set_frame(video_frame);
113
114 scoped_refptr<VideoLayer> video_layer = VideoLayer::Create(&provider);
115 video_layer->SetLayerTreeHost(impl.host());
116 video_layer->draw_properties().content_bounds = layer_size;
117 video_layer->SetBounds(layer_size);
118 video_layer->set_video_rotation(media::VIDEO_ROTATION_0);
119
120 VideoLayerImpl* video_layer_impl =
121 impl.AddChildToRoot<VideoLayerImpl>(&provider);
122
123 video_layer->PushPropertiesTo(video_layer_impl);
124
125 {
126 SCOPED_TRACE("0 Degree Rotation");
127 // video_layer_impl->set_video_rotation(media::VIDEO_ROTATION_0);
128 impl.CalcDrawProps(viewport_size);
129 gfx::Rect occluded;
130 impl.AppendQuadsWithOcclusion(video_layer_impl, occluded);
131
132 EXPECT_EQ(1u, impl.quad_list().size());
133 EXPECT_EQ(gfx::Size(100, 50), impl.quad_list()[0]->rect.size());
134
135 gfx::Point3F p1(100, 0, 0);
136 gfx::Point3F p2(0, 50, 0);
137 impl.quad_list()[0]->quadTransform().TransformPoint(&p1);
138 impl.quad_list()[0]->quadTransform().TransformPoint(&p2);
139 EXPECT_EQ(gfx::Point3F(100, 0, 0), p1);
140 EXPECT_EQ(gfx::Point3F(0, 50, 0), p2);
141 }
142 video_layer->SetLayerTreeHost(NULL);
enne (OOO) 2014/07/23 21:46:53 Why does this need to happen? Won't the VideoLayer
suderman 2014/07/23 23:27:01 In this case the LayerTreeHost is provided by impl
enne (OOO) 2014/07/23 23:39:26 The VideoLayer has a raw/weak pointer to the Layer
143 }
144
145 TEST(VideoLayerImplTest, Rotated90) {
146 gfx::Size layer_size(100, 50);
147 gfx::Size viewport_size(1000, 500);
148
149 LayerTestCommon::LayerImplTest impl;
150 DebugScopedSetImplThreadAndMainThreadBlocked thread(impl.proxy());
151
152 scoped_refptr<media::VideoFrame> video_frame =
153 media::VideoFrame::CreateFrame(media::VideoFrame::YV12,
154 gfx::Size(20, 10),
155 gfx::Rect(20, 10),
156 gfx::Size(20, 10),
157 base::TimeDelta());
158 FakeVideoFrameProvider provider;
159 provider.set_frame(video_frame);
160
161 scoped_refptr<VideoLayer> video_layer = VideoLayer::Create(&provider);
162 video_layer->SetLayerTreeHost(impl.host());
163 video_layer->draw_properties().content_bounds = layer_size;
164 video_layer->SetBounds(layer_size);
165 video_layer->set_video_rotation(media::VIDEO_ROTATION_90);
166
167 VideoLayerImpl* video_layer_impl =
168 impl.AddChildToRoot<VideoLayerImpl>(&provider);
169
170 video_layer->PushPropertiesTo(video_layer_impl);
171
172 {
173 SCOPED_TRACE("90 Degree Rotation");
174 impl.CalcDrawProps(viewport_size);
175 gfx::Rect occluded;
176 impl.AppendQuadsWithOcclusion(video_layer_impl, occluded);
177
178 EXPECT_EQ(1u, impl.quad_list().size());
179 EXPECT_EQ(gfx::Size(50, 100), impl.quad_list()[0]->rect.size());
180
181 gfx::Point3F p1(50, 0, 0);
182 gfx::Point3F p2(0, 100, 0);
183 impl.quad_list()[0]->quadTransform().TransformPoint(&p1);
184 impl.quad_list()[0]->quadTransform().TransformPoint(&p2);
185 EXPECT_EQ(gfx::Point3F(100, 50, 0), p1);
186 EXPECT_EQ(gfx::Point3F(0, 0, 0), p2);
187 }
188 video_layer->SetLayerTreeHost(NULL);
189 }
190
191 TEST(VideoLayerImplTest, Rotated180) {
192 gfx::Size layer_size(100, 50);
193 gfx::Size viewport_size(1000, 500);
194
195 LayerTestCommon::LayerImplTest impl;
196 DebugScopedSetImplThreadAndMainThreadBlocked thread(impl.proxy());
197
198 scoped_refptr<media::VideoFrame> video_frame =
199 media::VideoFrame::CreateFrame(media::VideoFrame::YV12,
200 gfx::Size(20, 10),
201 gfx::Rect(20, 10),
202 gfx::Size(20, 10),
203 base::TimeDelta());
204 FakeVideoFrameProvider provider;
205 provider.set_frame(video_frame);
206
207 scoped_refptr<VideoLayer> video_layer = VideoLayer::Create(&provider);
208 video_layer->SetLayerTreeHost(impl.host());
209 video_layer->draw_properties().content_bounds = layer_size;
210 video_layer->SetBounds(layer_size);
211 video_layer->set_video_rotation(media::VIDEO_ROTATION_180);
212
213 VideoLayerImpl* video_layer_impl =
214 impl.AddChildToRoot<VideoLayerImpl>(&provider);
215
216 video_layer->PushPropertiesTo(video_layer_impl);
217
218 {
219 SCOPED_TRACE("180 Degree Rotation");
220 impl.CalcDrawProps(viewport_size);
221 gfx::Rect occluded;
222 impl.AppendQuadsWithOcclusion(video_layer_impl, occluded);
223
224 EXPECT_EQ(1u, impl.quad_list().size());
225 EXPECT_EQ(gfx::Size(100, 50), impl.quad_list()[0]->rect.size());
226
227 gfx::Point3F p1(100, 0, 0);
228 gfx::Point3F p2(0, 50, 0);
229 impl.quad_list()[0]->quadTransform().TransformPoint(&p1);
230 impl.quad_list()[0]->quadTransform().TransformPoint(&p2);
231 EXPECT_EQ(gfx::Point3F(0, 50, 0), p1);
232 EXPECT_EQ(gfx::Point3F(100, 0, 0), p2);
233 }
234 video_layer->SetLayerTreeHost(NULL);
235 }
236
237 TEST(VideoLayerImplTest, Rotated270) {
238 gfx::Size layer_size(100, 50);
239 gfx::Size viewport_size(1000, 500);
240
241 LayerTestCommon::LayerImplTest impl;
242 DebugScopedSetImplThreadAndMainThreadBlocked thread(impl.proxy());
243
244 scoped_refptr<media::VideoFrame> video_frame =
245 media::VideoFrame::CreateFrame(media::VideoFrame::YV12,
246 gfx::Size(20, 10),
247 gfx::Rect(20, 10),
248 gfx::Size(20, 10),
249 base::TimeDelta());
250 FakeVideoFrameProvider provider;
251 provider.set_frame(video_frame);
252
253 scoped_refptr<VideoLayer> video_layer = VideoLayer::Create(&provider);
254 video_layer->SetLayerTreeHost(impl.host());
255 video_layer->draw_properties().content_bounds = layer_size;
256 video_layer->SetBounds(layer_size);
257 video_layer->set_video_rotation(media::VIDEO_ROTATION_270);
258
259 VideoLayerImpl* video_layer_impl =
260 impl.AddChildToRoot<VideoLayerImpl>(&provider);
261
262 video_layer->PushPropertiesTo(video_layer_impl);
263
264 {
265 SCOPED_TRACE("270 Degree Rotation");
266 impl.CalcDrawProps(viewport_size);
267 gfx::Rect occluded;
268 impl.AppendQuadsWithOcclusion(video_layer_impl, occluded);
269
270 EXPECT_EQ(1u, impl.quad_list().size());
271 EXPECT_EQ(gfx::Size(50, 100), impl.quad_list()[0]->rect.size());
272
273 gfx::Point3F p1(0, 100, 0);
274 gfx::Point3F p2(50, 0, 0);
275 impl.quad_list()[0]->quadTransform().TransformPoint(&p1);
276 impl.quad_list()[0]->quadTransform().TransformPoint(&p2);
277 EXPECT_EQ(gfx::Point3F(100, 50, 0), p1);
278 EXPECT_EQ(gfx::Point3F(0, 0, 0), p2);
279 }
280 video_layer->SetLayerTreeHost(NULL);
281 }
282
96 } // namespace 283 } // namespace
97 } // namespace cc 284 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698