OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/output/delegating_renderer.h" | 5 #include "cc/output/delegating_renderer.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "cc/test/fake_output_surface.h" | 9 #include "cc/test/fake_output_surface.h" |
10 #include "cc/test/layer_tree_test.h" | 10 #include "cc/test/layer_tree_test.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 DrawResult draw_result) override { | 44 DrawResult draw_result) override { |
45 EXPECT_EQ(0u, output_surface_->num_sent_frames()); | 45 EXPECT_EQ(0u, output_surface_->num_sent_frames()); |
46 | 46 |
47 const CompositorFrame* last_frame = output_surface_->last_sent_frame(); | 47 const CompositorFrame* last_frame = output_surface_->last_sent_frame(); |
48 EXPECT_EQ(nullptr, last_frame); | 48 EXPECT_EQ(nullptr, last_frame); |
49 return DRAW_SUCCESS; | 49 return DRAW_SUCCESS; |
50 } | 50 } |
51 | 51 |
52 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { | 52 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { |
53 EXPECT_EQ(0u, output_surface_->num_sent_frames()); | 53 EXPECT_EQ(0u, output_surface_->num_sent_frames()); |
| 54 drawn_viewport_ = host_impl->DeviceViewport(); |
54 } | 55 } |
55 | 56 |
56 void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) override { | 57 void SwapBuffersCompleteOnThread() override { |
57 EXPECT_TRUE(result); | |
58 EXPECT_EQ(1u, output_surface_->num_sent_frames()); | 58 EXPECT_EQ(1u, output_surface_->num_sent_frames()); |
59 | 59 |
60 const CompositorFrame* last_frame = output_surface_->last_sent_frame(); | 60 const CompositorFrame* last_frame = output_surface_->last_sent_frame(); |
61 DelegatedFrameData* last_frame_data = | 61 DelegatedFrameData* last_frame_data = |
62 last_frame->delegated_frame_data.get(); | 62 last_frame->delegated_frame_data.get(); |
63 ASSERT_TRUE(last_frame->delegated_frame_data); | 63 ASSERT_TRUE(last_frame->delegated_frame_data); |
64 EXPECT_FALSE(last_frame->gl_frame_data); | 64 EXPECT_FALSE(last_frame->gl_frame_data); |
65 EXPECT_EQ(host_impl->DeviceViewport().ToString(), | 65 EXPECT_EQ(drawn_viewport_, |
66 last_frame_data->render_pass_list.back()->output_rect.ToString()); | 66 last_frame_data->render_pass_list.back()->output_rect); |
67 EXPECT_EQ(0.5f, last_frame->metadata.min_page_scale_factor); | 67 EXPECT_EQ(0.5f, last_frame->metadata.min_page_scale_factor); |
68 EXPECT_EQ(4.f, last_frame->metadata.max_page_scale_factor); | 68 EXPECT_EQ(4.f, last_frame->metadata.max_page_scale_factor); |
69 | 69 |
70 EXPECT_EQ(0u, last_frame->delegated_frame_data->resource_list.size()); | 70 EXPECT_EQ(0u, last_frame->delegated_frame_data->resource_list.size()); |
71 EXPECT_EQ(1u, last_frame->delegated_frame_data->render_pass_list.size()); | 71 EXPECT_EQ(1u, last_frame->delegated_frame_data->render_pass_list.size()); |
72 | 72 |
73 EndTest(); | 73 EndTest(); |
74 } | 74 } |
| 75 |
| 76 gfx::Rect drawn_viewport_; |
75 }; | 77 }; |
76 | 78 |
77 SINGLE_AND_MULTI_THREAD_DELEGATING_RENDERER_TEST_F(DelegatingRendererTestDraw); | 79 SINGLE_AND_MULTI_THREAD_DELEGATING_RENDERER_TEST_F(DelegatingRendererTestDraw); |
78 | 80 |
79 class DelegatingRendererTestResources : public DelegatingRendererTest { | 81 class DelegatingRendererTestResources : public DelegatingRendererTest { |
80 public: | 82 public: |
81 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 83 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
82 | 84 |
83 void AfterTest() override {} | 85 void AfterTest() override {} |
84 | 86 |
(...skipping 13 matching lines...) Expand all Loading... |
98 gfx::Rect(3, 3, 10, 10), gfx::Transform()); | 100 gfx::Rect(3, 3, 10, 10), gfx::Transform()); |
99 AddOneOfEveryQuadType(pass, host_impl->resource_provider(), child_pass->id, | 101 AddOneOfEveryQuadType(pass, host_impl->resource_provider(), child_pass->id, |
100 &mailbox_sync_token); | 102 &mailbox_sync_token); |
101 return draw_result; | 103 return draw_result; |
102 } | 104 } |
103 | 105 |
104 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { | 106 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { |
105 EXPECT_EQ(0u, output_surface_->num_sent_frames()); | 107 EXPECT_EQ(0u, output_surface_->num_sent_frames()); |
106 } | 108 } |
107 | 109 |
108 void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) override { | 110 void SwapBuffersCompleteOnThread() override { |
109 EXPECT_TRUE(result); | |
110 EXPECT_EQ(1u, output_surface_->num_sent_frames()); | 111 EXPECT_EQ(1u, output_surface_->num_sent_frames()); |
111 | 112 |
112 const CompositorFrame* last_frame = output_surface_->last_sent_frame(); | 113 const CompositorFrame* last_frame = output_surface_->last_sent_frame(); |
113 ASSERT_TRUE(last_frame->delegated_frame_data); | 114 ASSERT_TRUE(last_frame->delegated_frame_data); |
114 | 115 |
115 EXPECT_EQ(2u, last_frame->delegated_frame_data->render_pass_list.size()); | 116 EXPECT_EQ(2u, last_frame->delegated_frame_data->render_pass_list.size()); |
116 // Each render pass has 10 resources in it. And the root render pass has a | 117 // Each render pass has 10 resources in it. And the root render pass has a |
117 // mask resource used when drawing the child render pass, as well as its | 118 // mask resource used when drawing the child render pass, as well as its |
118 // replica (it's added twice). The number 10 may change if | 119 // replica (it's added twice). The number 10 may change if |
119 // AppendOneOfEveryQuadType() is updated, and the value here should be | 120 // AppendOneOfEveryQuadType() is updated, and the value here should be |
120 // updated accordingly. | 121 // updated accordingly. |
121 EXPECT_EQ(22u, last_frame->delegated_frame_data->resource_list.size()); | 122 EXPECT_EQ(22u, last_frame->delegated_frame_data->resource_list.size()); |
122 | 123 |
123 EndTest(); | 124 EndTest(); |
124 } | 125 } |
125 }; | 126 }; |
126 | 127 |
127 SINGLE_AND_MULTI_THREAD_DELEGATING_RENDERER_TEST_F( | 128 SINGLE_AND_MULTI_THREAD_DELEGATING_RENDERER_TEST_F( |
128 DelegatingRendererTestResources); | 129 DelegatingRendererTestResources); |
129 | 130 |
130 } // namespace cc | 131 } // namespace cc |
OLD | NEW |