OLD | NEW |
---|---|
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) { |
20 gfx::Size layer_size(1000, 1000); | 21 gfx::Size layer_size(1000, 1000); |
21 gfx::Size viewport_size(1000, 1000); | 22 gfx::Size viewport_size(1000, 1000); |
22 | 23 |
23 LayerTestCommon::LayerImplTest impl; | 24 LayerTestCommon::LayerImplTest impl; |
24 DebugScopedSetImplThreadAndMainThreadBlocked thread(impl.proxy()); | 25 DebugScopedSetImplThreadAndMainThreadBlocked thread(impl.proxy()); |
25 | 26 |
26 scoped_refptr<media::VideoFrame> video_frame = | 27 scoped_refptr<media::VideoFrame> video_frame = |
27 media::VideoFrame::CreateFrame(media::VideoFrame::YV12, | 28 media::VideoFrame::CreateFrame(media::VideoFrame::YV12, |
28 gfx::Size(10, 10), | 29 gfx::Size(10, 10), |
29 gfx::Rect(10, 10), | 30 gfx::Rect(10, 10), |
30 gfx::Size(10, 10), | 31 gfx::Size(10, 10), |
31 base::TimeDelta()); | 32 base::TimeDelta()); |
32 FakeVideoFrameProvider provider; | 33 FakeVideoFrameProvider provider; |
33 provider.set_frame(video_frame); | 34 provider.set_frame(video_frame); |
34 | 35 |
35 VideoLayerImpl* video_layer_impl = | 36 VideoLayerImpl* video_layer_impl = |
36 impl.AddChildToRoot<VideoLayerImpl>(&provider); | 37 impl.AddChildToRoot<VideoLayerImpl>(&provider, media::VIDEO_ROTATION_0); |
37 video_layer_impl->SetBounds(layer_size); | 38 video_layer_impl->SetBounds(layer_size); |
38 video_layer_impl->SetContentBounds(layer_size); | 39 video_layer_impl->SetContentBounds(layer_size); |
39 video_layer_impl->SetDrawsContent(true); | 40 video_layer_impl->SetDrawsContent(true); |
40 | 41 |
41 impl.CalcDrawProps(viewport_size); | 42 impl.CalcDrawProps(viewport_size); |
42 | 43 |
43 { | 44 { |
44 SCOPED_TRACE("No occlusion"); | 45 SCOPED_TRACE("No occlusion"); |
45 gfx::Rect occluded; | 46 gfx::Rect occluded; |
46 impl.AppendQuadsWithOcclusion(video_layer_impl, occluded); | 47 impl.AppendQuadsWithOcclusion(video_layer_impl, occluded); |
(...skipping 28 matching lines...) Expand all Loading... | |
75 EXPECT_EQ(1u, partially_occluded_count); | 76 EXPECT_EQ(1u, partially_occluded_count); |
76 } | 77 } |
77 } | 78 } |
78 | 79 |
79 TEST(VideoLayerImplTest, DidBecomeActiveShouldSetActiveVideoLayer) { | 80 TEST(VideoLayerImplTest, DidBecomeActiveShouldSetActiveVideoLayer) { |
80 LayerTestCommon::LayerImplTest impl; | 81 LayerTestCommon::LayerImplTest impl; |
81 DebugScopedSetImplThreadAndMainThreadBlocked thread(impl.proxy()); | 82 DebugScopedSetImplThreadAndMainThreadBlocked thread(impl.proxy()); |
82 | 83 |
83 FakeVideoFrameProvider provider; | 84 FakeVideoFrameProvider provider; |
84 VideoLayerImpl* video_layer_impl = | 85 VideoLayerImpl* video_layer_impl = |
85 impl.AddChildToRoot<VideoLayerImpl>(&provider); | 86 impl.AddChildToRoot<VideoLayerImpl>(&provider, media::VIDEO_ROTATION_0); |
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, media::VIDEO_ROTATION_0); | |
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 impl.CalcDrawProps(viewport_size); | |
122 gfx::Rect occluded; | |
123 impl.AppendQuadsWithOcclusion(video_layer_impl, occluded); | |
124 | |
125 EXPECT_EQ(1u, impl.quad_list().size()); | |
126 | |
127 gfx::Point3F p1(0, impl.quad_list()[0]->rect.height(), 0); | |
128 gfx::Point3F p2(impl.quad_list()[0]->rect.width(), 0, 0); | |
129 impl.quad_list()[0]->quadTransform().TransformPoint(&p1); | |
130 impl.quad_list()[0]->quadTransform().TransformPoint(&p2); | |
131 EXPECT_EQ(gfx::Point3F(0, 50, 0), p1); | |
132 EXPECT_EQ(gfx::Point3F(100, 0, 0), p2); | |
133 } | |
134 } | |
135 | |
136 TEST(VideoLayerImplTest, Rotated90) { | |
137 gfx::Size layer_size(100, 50); | |
138 gfx::Size viewport_size(1000, 500); | |
139 | |
140 LayerTestCommon::LayerImplTest impl; | |
141 DebugScopedSetImplThreadAndMainThreadBlocked thread(impl.proxy()); | |
142 | |
143 scoped_refptr<media::VideoFrame> video_frame = | |
144 media::VideoFrame::CreateFrame(media::VideoFrame::YV12, | |
145 gfx::Size(20, 10), | |
146 gfx::Rect(20, 10), | |
147 gfx::Size(20, 10), | |
148 base::TimeDelta()); | |
149 FakeVideoFrameProvider provider; | |
150 provider.set_frame(video_frame); | |
151 | |
152 VideoLayerImpl* video_layer_impl = | |
153 impl.AddChildToRoot<VideoLayerImpl>(&provider, media::VIDEO_ROTATION_90); | |
154 video_layer_impl->SetBounds(layer_size); | |
155 video_layer_impl->SetContentBounds(layer_size); | |
156 video_layer_impl->SetDrawsContent(true); | |
157 | |
158 { | |
159 SCOPED_TRACE("90 Degree Rotation"); | |
160 impl.CalcDrawProps(viewport_size); | |
161 gfx::Rect occluded; | |
162 impl.AppendQuadsWithOcclusion(video_layer_impl, occluded); | |
163 | |
164 EXPECT_EQ(1u, impl.quad_list().size()); | |
165 | |
166 gfx::Point3F p1(0, impl.quad_list()[0]->rect.height(), 0); | |
167 gfx::Point3F p2(impl.quad_list()[0]->rect.width(), 0, 0); | |
168 impl.quad_list()[0]->quadTransform().TransformPoint(&p1); | |
169 impl.quad_list()[0]->quadTransform().TransformPoint(&p2); | |
170 EXPECT_EQ(gfx::Point3F(0, 0, 0), p1); | |
171 EXPECT_EQ(gfx::Point3F(100, 50, 0), p2); | |
172 } | |
173 } | |
174 | |
175 TEST(VideoLayerImplTest, Rotated180) { | |
176 gfx::Size layer_size(100, 50); | |
177 gfx::Size viewport_size(1000, 500); | |
178 | |
179 LayerTestCommon::LayerImplTest impl; | |
180 DebugScopedSetImplThreadAndMainThreadBlocked thread(impl.proxy()); | |
181 | |
182 scoped_refptr<media::VideoFrame> video_frame = | |
183 media::VideoFrame::CreateFrame(media::VideoFrame::YV12, | |
184 gfx::Size(20, 10), | |
185 gfx::Rect(20, 10), | |
186 gfx::Size(20, 10), | |
187 base::TimeDelta()); | |
188 FakeVideoFrameProvider provider; | |
189 provider.set_frame(video_frame); | |
190 | |
191 VideoLayerImpl* video_layer_impl = | |
192 impl.AddChildToRoot<VideoLayerImpl>(&provider, media::VIDEO_ROTATION_180); | |
193 video_layer_impl->SetBounds(layer_size); | |
194 video_layer_impl->SetContentBounds(layer_size); | |
195 video_layer_impl->SetDrawsContent(true); | |
196 | |
197 { | |
198 SCOPED_TRACE("180 Degree Rotation"); | |
danakj
2014/08/05 20:18:21
Since you broke these into separate test cases (th
| |
199 impl.CalcDrawProps(viewport_size); | |
200 gfx::Rect occluded; | |
201 impl.AppendQuadsWithOcclusion(video_layer_impl, occluded); | |
202 | |
203 EXPECT_EQ(1u, impl.quad_list().size()); | |
204 | |
205 gfx::Point3F p1(0, impl.quad_list()[0]->rect.height(), 0); | |
206 gfx::Point3F p2(impl.quad_list()[0]->rect.width(), 0, 0); | |
207 impl.quad_list()[0]->quadTransform().TransformPoint(&p1); | |
208 impl.quad_list()[0]->quadTransform().TransformPoint(&p2); | |
209 EXPECT_EQ(gfx::Point3F(100, 0, 0), p1); | |
210 EXPECT_EQ(gfx::Point3F(0, 50, 0), p2); | |
211 } | |
212 } | |
213 | |
214 TEST(VideoLayerImplTest, Rotated270) { | |
215 gfx::Size layer_size(100, 50); | |
216 gfx::Size viewport_size(1000, 500); | |
217 | |
218 LayerTestCommon::LayerImplTest impl; | |
219 DebugScopedSetImplThreadAndMainThreadBlocked thread(impl.proxy()); | |
220 | |
221 scoped_refptr<media::VideoFrame> video_frame = | |
222 media::VideoFrame::CreateFrame(media::VideoFrame::YV12, | |
223 gfx::Size(20, 10), | |
224 gfx::Rect(20, 10), | |
225 gfx::Size(20, 10), | |
226 base::TimeDelta()); | |
227 FakeVideoFrameProvider provider; | |
228 provider.set_frame(video_frame); | |
229 | |
230 VideoLayerImpl* video_layer_impl = | |
231 impl.AddChildToRoot<VideoLayerImpl>(&provider, media::VIDEO_ROTATION_270); | |
232 video_layer_impl->SetBounds(layer_size); | |
233 video_layer_impl->SetContentBounds(layer_size); | |
234 video_layer_impl->SetDrawsContent(true); | |
235 | |
236 { | |
237 SCOPED_TRACE("270 Degree Rotation"); | |
238 impl.CalcDrawProps(viewport_size); | |
239 gfx::Rect occluded; | |
240 impl.AppendQuadsWithOcclusion(video_layer_impl, occluded); | |
241 | |
242 EXPECT_EQ(1u, impl.quad_list().size()); | |
243 | |
244 gfx::Point3F p1(0, impl.quad_list()[0]->rect.height(), 0); | |
245 gfx::Point3F p2(impl.quad_list()[0]->rect.width(), 0, 0); | |
246 impl.quad_list()[0]->quadTransform().TransformPoint(&p1); | |
247 impl.quad_list()[0]->quadTransform().TransformPoint(&p2); | |
248 EXPECT_EQ(gfx::Point3F(100, 50, 0), p1); | |
249 EXPECT_EQ(gfx::Point3F(0, 0, 0), p2); | |
250 } | |
251 } | |
252 | |
96 } // namespace | 253 } // namespace |
97 } // namespace cc | 254 } // namespace cc |
OLD | NEW |