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

Unified 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: Formatting 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 side-by-side diff with in-line comments
Download patch
Index: cc/layers/video_layer_impl_unittest.cc
diff --git a/cc/layers/video_layer_impl_unittest.cc b/cc/layers/video_layer_impl_unittest.cc
index 7a17eefd09492186fcabce76b0b14b9790c1ffa3..8008310edf1d14138886a7968e74c542749b99f6 100644
--- a/cc/layers/video_layer_impl_unittest.cc
+++ b/cc/layers/video_layer_impl_unittest.cc
@@ -7,6 +7,7 @@
#include "cc/layers/video_frame_provider_client_impl.h"
#include "cc/output/context_provider.h"
#include "cc/output/output_surface.h"
+#include "cc/quads/draw_quad.h"
#include "cc/test/fake_video_frame_provider.h"
#include "cc/test/layer_test_common.h"
#include "cc/trees/single_thread_proxy.h"
@@ -93,5 +94,169 @@ TEST(VideoLayerImplTest, DidBecomeActiveShouldSetActiveVideoLayer) {
EXPECT_EQ(video_layer_impl, client->active_video_layer());
}
+TEST(VideoLayerImplTest, Rotated0) {
+ gfx::Size layer_size(100, 50);
+ gfx::Size viewport_size(1000, 500);
+
+ LayerTestCommon::LayerImplTest impl;
+ DebugScopedSetImplThreadAndMainThreadBlocked thread(impl.proxy());
+
+ scoped_refptr<media::VideoFrame> video_frame =
+ media::VideoFrame::CreateFrame(media::VideoFrame::YV12,
+ gfx::Size(20, 10),
+ gfx::Rect(20, 10),
+ gfx::Size(20, 10),
+ base::TimeDelta());
+ FakeVideoFrameProvider provider;
+ provider.set_frame(video_frame);
+
+ VideoLayerImpl* video_layer_impl =
+ impl.AddChildToRoot<VideoLayerImpl>(&provider);
+ video_layer_impl->SetBounds(layer_size);
+ video_layer_impl->SetContentBounds(layer_size);
+ video_layer_impl->SetDrawsContent(true);
+
+ {
+ SCOPED_TRACE("0 Degree Rotation");
+ video_layer_impl->set_video_rotation(media::VIDEO_ROTATION_0);
+ impl.CalcDrawProps(viewport_size);
+ gfx::Rect occluded;
+ impl.AppendQuadsWithOcclusion(video_layer_impl, occluded);
+
+ EXPECT_EQ(1u, impl.quad_list().size());
+ EXPECT_EQ(gfx::Size(100, 50), impl.quad_list()[0]->rect.size());
+
+ gfx::Point3F p1(0, 100, 0);
+ gfx::Point3F p2(50, 0, 0);
+ impl.quad_list()[0]->quadTransform().TransformPoint(&p1);
+ impl.quad_list()[0]->quadTransform().TransformPoint(&p2);
+ EXPECT_EQ(gfx::Point3F(0, 100, 0), p1);
+ EXPECT_EQ(gfx::Point3F(50, 0, 0), p2);
+ }
+}
+
+TEST(VideoLayerImplTest, Rotated90) {
+ gfx::Size layer_size(100, 50);
+ gfx::Size viewport_size(1000, 500);
+
+ LayerTestCommon::LayerImplTest impl;
+ DebugScopedSetImplThreadAndMainThreadBlocked thread(impl.proxy());
+
+ scoped_refptr<media::VideoFrame> video_frame =
+ media::VideoFrame::CreateFrame(media::VideoFrame::YV12,
+ gfx::Size(20, 10),
+ gfx::Rect(20, 10),
+ gfx::Size(20, 10),
+ base::TimeDelta());
+ FakeVideoFrameProvider provider;
+ provider.set_frame(video_frame);
+
+ VideoLayerImpl* video_layer_impl =
+ impl.AddChildToRoot<VideoLayerImpl>(&provider);
+ video_layer_impl->SetBounds(layer_size);
+ video_layer_impl->SetContentBounds(layer_size);
+ video_layer_impl->SetDrawsContent(true);
+
+ {
+ SCOPED_TRACE("90 Degree Rotation");
+ video_layer_impl->set_video_rotation(media::VIDEO_ROTATION_90);
+ impl.CalcDrawProps(viewport_size);
+ gfx::Rect occluded;
+ impl.AppendQuadsWithOcclusion(video_layer_impl, occluded);
+
+ EXPECT_EQ(1u, impl.quad_list().size());
+ EXPECT_EQ(gfx::Size(50, 100), impl.quad_list()[0]->rect.size());
+
+ gfx::Point3F p1(0, 100, 0);
+ gfx::Point3F p2(50, 0, 0);
+ impl.quad_list()[0]->quadTransform().TransformPoint(&p1);
+ impl.quad_list()[0]->quadTransform().TransformPoint(&p2);
+ EXPECT_EQ(gfx::Point3F(0, 0, 0), p1);
+ EXPECT_EQ(gfx::Point3F(100, 50, 0), p2);
+ }
+}
+
+TEST(VideoLayerImplTest, Rotated180) {
+ gfx::Size layer_size(100, 50);
+ gfx::Size viewport_size(1000, 500);
+
+ LayerTestCommon::LayerImplTest impl;
+ DebugScopedSetImplThreadAndMainThreadBlocked thread(impl.proxy());
+
+ scoped_refptr<media::VideoFrame> video_frame =
+ media::VideoFrame::CreateFrame(media::VideoFrame::YV12,
+ gfx::Size(20, 10),
+ gfx::Rect(20, 10),
+ gfx::Size(20, 10),
+ base::TimeDelta());
+ FakeVideoFrameProvider provider;
+ provider.set_frame(video_frame);
+
+ VideoLayerImpl* video_layer_impl =
+ impl.AddChildToRoot<VideoLayerImpl>(&provider);
+ video_layer_impl->SetBounds(layer_size);
+ video_layer_impl->SetContentBounds(layer_size);
+ video_layer_impl->SetDrawsContent(true);
+
+ {
+ SCOPED_TRACE("180 Degree Rotation");
+ video_layer_impl->set_video_rotation(media::VIDEO_ROTATION_180);
+ impl.CalcDrawProps(viewport_size);
+ gfx::Rect occluded;
+ impl.AppendQuadsWithOcclusion(video_layer_impl, occluded);
+
+ EXPECT_EQ(1u, impl.quad_list().size());
+ EXPECT_EQ(gfx::Size(100, 50), impl.quad_list()[0]->rect.size());
+
+ gfx::Point3F p1(0, 50, 0);
+ gfx::Point3F p2(100, 0, 0);
+ impl.quad_list()[0]->quadTransform().TransformPoint(&p1);
+ impl.quad_list()[0]->quadTransform().TransformPoint(&p2);
+ EXPECT_EQ(gfx::Point3F(100, 0, 0), p1);
+ EXPECT_EQ(gfx::Point3F(0, 50, 0), p2);
+ }
+}
+
+TEST(VideoLayerImplTest, Rotated270) {
+ gfx::Size layer_size(100, 50);
+ gfx::Size viewport_size(1000, 500);
+
+ LayerTestCommon::LayerImplTest impl;
+ DebugScopedSetImplThreadAndMainThreadBlocked thread(impl.proxy());
+
+ scoped_refptr<media::VideoFrame> video_frame =
+ media::VideoFrame::CreateFrame(media::VideoFrame::YV12,
+ gfx::Size(20, 10),
+ gfx::Rect(20, 10),
+ gfx::Size(20, 10),
+ base::TimeDelta());
+ FakeVideoFrameProvider provider;
+ provider.set_frame(video_frame);
+
+ VideoLayerImpl* video_layer_impl =
+ impl.AddChildToRoot<VideoLayerImpl>(&provider);
+ video_layer_impl->SetBounds(layer_size);
+ video_layer_impl->SetContentBounds(layer_size);
+ video_layer_impl->SetDrawsContent(true);
+
+ {
+ SCOPED_TRACE("270 Degree Rotation");
+ video_layer_impl->set_video_rotation(media::VIDEO_ROTATION_270);
+ impl.CalcDrawProps(viewport_size);
+ gfx::Rect occluded;
+ impl.AppendQuadsWithOcclusion(video_layer_impl, occluded);
+
+ EXPECT_EQ(1u, impl.quad_list().size());
+ EXPECT_EQ(gfx::Size(50, 100), impl.quad_list()[0]->rect.size());
+
+ gfx::Point3F p1(0, 100, 0);
+ gfx::Point3F p2(50, 0, 0);
+ impl.quad_list()[0]->quadTransform().TransformPoint(&p1);
+ impl.quad_list()[0]->quadTransform().TransformPoint(&p2);
+ EXPECT_EQ(gfx::Point3F(100, 50, 0), p1);
+ EXPECT_EQ(gfx::Point3F(0, 0, 0), p2);
+ }
+}
+
} // namespace
} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698