| 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 28 matching lines...) Expand all Loading... |
| 39 layer_tree_host()->SetRootLayer(root); | 39 layer_tree_host()->SetRootLayer(root); |
| 40 layer_tree_host()->SetDeviceScaleFactor(2.f); | 40 layer_tree_host()->SetDeviceScaleFactor(2.f); |
| 41 LayerTreeHostVideoTest::SetupTree(); | 41 LayerTreeHostVideoTest::SetupTree(); |
| 42 } | 42 } |
| 43 | 43 |
| 44 virtual void BeginTest() OVERRIDE { | 44 virtual void BeginTest() OVERRIDE { |
| 45 num_draws_ = 0; | 45 num_draws_ = 0; |
| 46 PostSetNeedsCommitToMainThread(); | 46 PostSetNeedsCommitToMainThread(); |
| 47 } | 47 } |
| 48 | 48 |
| 49 virtual DrawSwapReadbackResult::DrawResult PrepareToDrawOnThread( | 49 virtual DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
| 50 LayerTreeHostImpl* host_impl, | 50 LayerTreeHostImpl::FrameData* frame, |
| 51 LayerTreeHostImpl::FrameData* frame, | 51 DrawResult draw_result) OVERRIDE { |
| 52 DrawSwapReadbackResult::DrawResult draw_result) OVERRIDE { | |
| 53 LayerImpl* root_layer = host_impl->active_tree()->root_layer(); | 52 LayerImpl* root_layer = host_impl->active_tree()->root_layer(); |
| 54 RenderSurfaceImpl* root_surface = root_layer->render_surface(); | 53 RenderSurfaceImpl* root_surface = root_layer->render_surface(); |
| 55 gfx::RectF damage_rect = | 54 gfx::RectF damage_rect = |
| 56 root_surface->damage_tracker()->current_damage_rect(); | 55 root_surface->damage_tracker()->current_damage_rect(); |
| 57 | 56 |
| 58 switch (num_draws_) { | 57 switch (num_draws_) { |
| 59 case 0: | 58 case 0: |
| 60 // First frame the whole viewport is damaged. | 59 // First frame the whole viewport is damaged. |
| 61 EXPECT_EQ(gfx::RectF(0.f, 0.f, 20.f, 20.f).ToString(), | 60 EXPECT_EQ(gfx::RectF(0.f, 0.f, 20.f, 20.f).ToString(), |
| 62 damage_rect.ToString()); | 61 damage_rect.ToString()); |
| 63 break; | 62 break; |
| 64 case 1: | 63 case 1: |
| 65 // Second frame the video layer is damaged. | 64 // Second frame the video layer is damaged. |
| 66 EXPECT_EQ(gfx::RectF(6.f, 6.f, 8.f, 8.f).ToString(), | 65 EXPECT_EQ(gfx::RectF(6.f, 6.f, 8.f, 8.f).ToString(), |
| 67 damage_rect.ToString()); | 66 damage_rect.ToString()); |
| 68 EndTest(); | 67 EndTest(); |
| 69 break; | 68 break; |
| 70 } | 69 } |
| 71 | 70 |
| 72 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, draw_result); | 71 EXPECT_EQ(DRAW_SUCCESS, draw_result); |
| 73 return draw_result; | 72 return draw_result; |
| 74 } | 73 } |
| 75 | 74 |
| 76 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 75 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 77 VideoLayerImpl* video = static_cast<VideoLayerImpl*>( | 76 VideoLayerImpl* video = static_cast<VideoLayerImpl*>( |
| 78 host_impl->active_tree()->root_layer()->children()[0]); | 77 host_impl->active_tree()->root_layer()->children()[0]); |
| 79 | 78 |
| 80 if (num_draws_ == 0) | 79 if (num_draws_ == 0) |
| 81 video->SetNeedsRedraw(); | 80 video->SetNeedsRedraw(); |
| 82 | 81 |
| 83 ++num_draws_; | 82 ++num_draws_; |
| 84 } | 83 } |
| 85 | 84 |
| 86 virtual void AfterTest() OVERRIDE { | 85 virtual void AfterTest() OVERRIDE { |
| 87 EXPECT_EQ(2, num_draws_); | 86 EXPECT_EQ(2, num_draws_); |
| 88 } | 87 } |
| 89 | 88 |
| 90 private: | 89 private: |
| 91 int num_draws_; | 90 int num_draws_; |
| 92 | 91 |
| 93 FakeVideoFrameProvider video_frame_provider_; | 92 FakeVideoFrameProvider video_frame_provider_; |
| 94 }; | 93 }; |
| 95 | 94 |
| 96 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostVideoTestSetNeedsDisplay); | 95 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostVideoTestSetNeedsDisplay); |
| 97 | 96 |
| 98 } // namespace | 97 } // namespace |
| 99 } // namespace cc | 98 } // namespace cc |
| OLD | NEW |