Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/trees/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "cc/layers/render_surface_impl.h" | 8 #include "cc/layers/render_surface_impl.h" |
| 9 #include "cc/layers/video_layer.h" | 9 #include "cc/layers/video_layer.h" |
| 10 #include "cc/layers/video_layer_impl.h" | 10 #include "cc/layers/video_layer_impl.h" |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 : public LayerTreeHostVideoTest { | 23 : public LayerTreeHostVideoTest { |
| 24 public: | 24 public: |
| 25 virtual void SetupTree() OVERRIDE { | 25 virtual void SetupTree() OVERRIDE { |
| 26 scoped_refptr<Layer> root = Layer::Create(); | 26 scoped_refptr<Layer> root = Layer::Create(); |
| 27 root->SetBounds(gfx::Size(10, 10)); | 27 root->SetBounds(gfx::Size(10, 10)); |
| 28 root->SetIsDrawable(true); | 28 root->SetIsDrawable(true); |
| 29 | 29 |
| 30 scoped_refptr<VideoLayer> video = VideoLayer::Create( | 30 scoped_refptr<VideoLayer> video = VideoLayer::Create( |
| 31 &video_frame_provider_); | 31 &video_frame_provider_); |
| 32 video->SetPosition(gfx::PointF(3.f, 3.f)); | 32 video->SetPosition(gfx::PointF(3.f, 3.f)); |
| 33 video->SetBounds(gfx::Size(4, 4)); | 33 video->SetBounds(gfx::Size(4, 3)); |
| 34 video->set_video_rotation(media::VIDEO_ROTATION_90); | |
| 34 video->SetIsDrawable(true); | 35 video->SetIsDrawable(true); |
| 35 root->AddChild(video); | 36 root->AddChild(video); |
| 36 | 37 |
| 37 layer_tree_host()->SetRootLayer(root); | 38 layer_tree_host()->SetRootLayer(root); |
| 38 layer_tree_host()->SetDeviceScaleFactor(2.f); | 39 layer_tree_host()->SetDeviceScaleFactor(2.f); |
| 39 LayerTreeHostVideoTest::SetupTree(); | 40 LayerTreeHostVideoTest::SetupTree(); |
| 40 } | 41 } |
| 41 | 42 |
| 42 virtual void BeginTest() OVERRIDE { | 43 virtual void BeginTest() OVERRIDE { |
| 43 num_draws_ = 0; | 44 num_draws_ = 0; |
| 44 PostSetNeedsCommitToMainThread(); | 45 PostSetNeedsCommitToMainThread(); |
| 45 } | 46 } |
| 46 | 47 |
| 47 virtual DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, | 48 virtual DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
| 48 LayerTreeHostImpl::FrameData* frame, | 49 LayerTreeHostImpl::FrameData* frame, |
| 49 DrawResult draw_result) OVERRIDE { | 50 DrawResult draw_result) OVERRIDE { |
| 50 LayerImpl* root_layer = host_impl->active_tree()->root_layer(); | 51 LayerImpl* root_layer = host_impl->active_tree()->root_layer(); |
| 51 RenderSurfaceImpl* root_surface = root_layer->render_surface(); | 52 RenderSurfaceImpl* root_surface = root_layer->render_surface(); |
| 52 gfx::RectF damage_rect = | 53 gfx::RectF damage_rect = |
| 53 root_surface->damage_tracker()->current_damage_rect(); | 54 root_surface->damage_tracker()->current_damage_rect(); |
| 54 | 55 |
| 55 switch (num_draws_) { | 56 switch (num_draws_) { |
| 56 case 0: | 57 case 0: |
| 57 // First frame the whole viewport is damaged. | 58 // First frame the whole viewport is damaged. |
| 58 EXPECT_EQ(gfx::RectF(0.f, 0.f, 20.f, 20.f).ToString(), | 59 EXPECT_EQ(gfx::RectF(0.f, 0.f, 20.f, 20.f).ToString(), |
| 59 damage_rect.ToString()); | 60 damage_rect.ToString()); |
| 60 break; | 61 break; |
| 61 case 1: | 62 case 1: |
| 62 // Second frame the video layer is damaged. | 63 // Second frame the video layer is damaged. |
| 63 EXPECT_EQ(gfx::RectF(6.f, 6.f, 8.f, 8.f).ToString(), | 64 EXPECT_EQ(gfx::RectF(8.f, 6.f, 6.f, 6.f).ToString(), |
|
enne (OOO)
2014/07/25 17:55:13
Does this actually pass? I wouldn't expect the dam
| |
| 64 damage_rect.ToString()); | 65 damage_rect.ToString()); |
| 65 EndTest(); | 66 EndTest(); |
| 66 break; | 67 break; |
| 67 } | 68 } |
| 68 | 69 |
| 69 EXPECT_EQ(DRAW_SUCCESS, draw_result); | 70 EXPECT_EQ(DRAW_SUCCESS, draw_result); |
| 70 return draw_result; | 71 return draw_result; |
| 71 } | 72 } |
| 72 | 73 |
| 73 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 74 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 87 private: | 88 private: |
| 88 int num_draws_; | 89 int num_draws_; |
| 89 | 90 |
| 90 FakeVideoFrameProvider video_frame_provider_; | 91 FakeVideoFrameProvider video_frame_provider_; |
| 91 }; | 92 }; |
| 92 | 93 |
| 93 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostVideoTestSetNeedsDisplay); | 94 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostVideoTestSetNeedsDisplay); |
| 94 | 95 |
| 95 } // namespace | 96 } // namespace |
| 96 } // namespace cc | 97 } // namespace cc |
| OLD | NEW |