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