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 26 matching lines...) Expand all Loading... |
37 PostSetNeedsCommitToMainThread(); | 37 PostSetNeedsCommitToMainThread(); |
38 } | 38 } |
39 | 39 |
40 void AfterTest() override {} | 40 void AfterTest() override {} |
41 | 41 |
42 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, | 42 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
43 LayerTreeHostImpl::FrameData* frame, | 43 LayerTreeHostImpl::FrameData* frame, |
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_FALSE(last_frame.delegated_frame_data); | 48 EXPECT_FALSE(last_frame); |
49 EXPECT_FALSE(last_frame.gl_frame_data); | |
50 EXPECT_EQ(0.f, last_frame.metadata.min_page_scale_factor); | |
51 EXPECT_EQ(0.f, last_frame.metadata.max_page_scale_factor); | |
52 return DRAW_SUCCESS; | 49 return DRAW_SUCCESS; |
53 } | 50 } |
54 | 51 |
55 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { | 52 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { |
56 EXPECT_EQ(0u, output_surface_->num_sent_frames()); | 53 EXPECT_EQ(0u, output_surface_->num_sent_frames()); |
57 } | 54 } |
58 | 55 |
59 void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) override { | 56 void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) override { |
60 EXPECT_TRUE(result); | 57 EXPECT_TRUE(result); |
61 EXPECT_EQ(1u, output_surface_->num_sent_frames()); | 58 EXPECT_EQ(1u, output_surface_->num_sent_frames()); |
62 | 59 |
63 const CompositorFrame& last_frame = output_surface_->last_sent_frame(); | 60 const CompositorFrame* last_frame = output_surface_->last_sent_frame(); |
64 DelegatedFrameData* last_frame_data = last_frame.delegated_frame_data.get(); | 61 DelegatedFrameData* last_frame_data = |
65 ASSERT_TRUE(last_frame.delegated_frame_data); | 62 last_frame->delegated_frame_data.get(); |
66 EXPECT_FALSE(last_frame.gl_frame_data); | 63 ASSERT_TRUE(last_frame->delegated_frame_data); |
| 64 EXPECT_FALSE(last_frame->gl_frame_data); |
67 EXPECT_EQ(host_impl->DeviceViewport().ToString(), | 65 EXPECT_EQ(host_impl->DeviceViewport().ToString(), |
68 last_frame_data->render_pass_list.back()->output_rect.ToString()); | 66 last_frame_data->render_pass_list.back()->output_rect.ToString()); |
69 EXPECT_EQ(0.5f, last_frame.metadata.min_page_scale_factor); | 67 EXPECT_EQ(0.5f, last_frame->metadata.min_page_scale_factor); |
70 EXPECT_EQ(4.f, last_frame.metadata.max_page_scale_factor); | 68 EXPECT_EQ(4.f, last_frame->metadata.max_page_scale_factor); |
71 | 69 |
72 EXPECT_EQ( | 70 EXPECT_EQ(0u, last_frame->delegated_frame_data->resource_list.size()); |
73 0u, last_frame.delegated_frame_data->resource_list.size()); | 71 EXPECT_EQ(1u, last_frame->delegated_frame_data->render_pass_list.size()); |
74 EXPECT_EQ(1u, last_frame.delegated_frame_data->render_pass_list.size()); | |
75 | 72 |
76 EndTest(); | 73 EndTest(); |
77 } | 74 } |
78 }; | 75 }; |
79 | 76 |
80 SINGLE_AND_MULTI_THREAD_DELEGATING_RENDERER_TEST_F(DelegatingRendererTestDraw); | 77 SINGLE_AND_MULTI_THREAD_DELEGATING_RENDERER_TEST_F(DelegatingRendererTestDraw); |
81 | 78 |
82 class DelegatingRendererTestResources : public DelegatingRendererTest { | 79 class DelegatingRendererTestResources : public DelegatingRendererTest { |
83 public: | 80 public: |
84 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 81 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
(...skipping 20 matching lines...) Expand all Loading... |
105 } | 102 } |
106 | 103 |
107 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { | 104 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { |
108 EXPECT_EQ(0u, output_surface_->num_sent_frames()); | 105 EXPECT_EQ(0u, output_surface_->num_sent_frames()); |
109 } | 106 } |
110 | 107 |
111 void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) override { | 108 void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) override { |
112 EXPECT_TRUE(result); | 109 EXPECT_TRUE(result); |
113 EXPECT_EQ(1u, output_surface_->num_sent_frames()); | 110 EXPECT_EQ(1u, output_surface_->num_sent_frames()); |
114 | 111 |
115 const CompositorFrame& last_frame = output_surface_->last_sent_frame(); | 112 const CompositorFrame* last_frame = output_surface_->last_sent_frame(); |
116 ASSERT_TRUE(last_frame.delegated_frame_data); | 113 ASSERT_TRUE(last_frame->delegated_frame_data); |
117 | 114 |
118 EXPECT_EQ(2u, last_frame.delegated_frame_data->render_pass_list.size()); | 115 EXPECT_EQ(2u, last_frame->delegated_frame_data->render_pass_list.size()); |
119 // Each render pass has 10 resources in it. And the root render pass has a | 116 // Each render pass has 10 resources in it. And the root render pass has a |
120 // mask resource used when drawing the child render pass, as well as its | 117 // mask resource used when drawing the child render pass, as well as its |
121 // replica (it's added twice). The number 10 may change if | 118 // replica (it's added twice). The number 10 may change if |
122 // AppendOneOfEveryQuadType() is updated, and the value here should be | 119 // AppendOneOfEveryQuadType() is updated, and the value here should be |
123 // updated accordingly. | 120 // updated accordingly. |
124 EXPECT_EQ(22u, last_frame.delegated_frame_data->resource_list.size()); | 121 EXPECT_EQ(22u, last_frame->delegated_frame_data->resource_list.size()); |
125 | 122 |
126 EndTest(); | 123 EndTest(); |
127 } | 124 } |
128 }; | 125 }; |
129 | 126 |
130 SINGLE_AND_MULTI_THREAD_DELEGATING_RENDERER_TEST_F( | 127 SINGLE_AND_MULTI_THREAD_DELEGATING_RENDERER_TEST_F( |
131 DelegatingRendererTestResources); | 128 DelegatingRendererTestResources); |
132 | 129 |
133 } // namespace cc | 130 } // namespace cc |
OLD | NEW |