| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "base/test/null_task_runner.h" | 5 #include "base/test/null_task_runner.h" |
| 6 #include "cc/output/compositor_frame.h" | 6 #include "cc/output/compositor_frame.h" |
| 7 #include "cc/output/copy_output_result.h" | 7 #include "cc/output/copy_output_result.h" |
| 8 #include "cc/output/delegated_frame_data.h" | 8 #include "cc/output/delegated_frame_data.h" |
| 9 #include "cc/quads/render_pass.h" | 9 #include "cc/quads/render_pass.h" |
| 10 #include "cc/resources/shared_bitmap_manager.h" | 10 #include "cc/resources/shared_bitmap_manager.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 public: | 55 public: |
| 56 DisplayTest() | 56 DisplayTest() |
| 57 : factory_(&manager_, &surface_factory_client_), | 57 : factory_(&manager_, &surface_factory_client_), |
| 58 software_output_device_(nullptr), | 58 software_output_device_(nullptr), |
| 59 task_runner_(new base::NullTaskRunner) {} | 59 task_runner_(new base::NullTaskRunner) {} |
| 60 | 60 |
| 61 protected: | 61 protected: |
| 62 void SetUpContext(scoped_ptr<TestWebGraphicsContext3D> context) { | 62 void SetUpContext(scoped_ptr<TestWebGraphicsContext3D> context) { |
| 63 if (context) { | 63 if (context) { |
| 64 output_surface_ = FakeOutputSurface::Create3d( | 64 output_surface_ = FakeOutputSurface::Create3d( |
| 65 TestContextProvider::Create(context.Pass())); | 65 TestContextProvider::Create(std::move(context))); |
| 66 } else { | 66 } else { |
| 67 scoped_ptr<TestSoftwareOutputDevice> output_device( | 67 scoped_ptr<TestSoftwareOutputDevice> output_device( |
| 68 new TestSoftwareOutputDevice); | 68 new TestSoftwareOutputDevice); |
| 69 software_output_device_ = output_device.get(); | 69 software_output_device_ = output_device.get(); |
| 70 output_surface_ = FakeOutputSurface::CreateSoftware(output_device.Pass()); | 70 output_surface_ = |
| 71 FakeOutputSurface::CreateSoftware(std::move(output_device)); |
| 71 } | 72 } |
| 72 shared_bitmap_manager_.reset(new TestSharedBitmapManager); | 73 shared_bitmap_manager_.reset(new TestSharedBitmapManager); |
| 73 output_surface_ptr_ = output_surface_.get(); | 74 output_surface_ptr_ = output_surface_.get(); |
| 74 } | 75 } |
| 75 | 76 |
| 76 void SubmitCompositorFrame(RenderPassList* pass_list, SurfaceId surface_id) { | 77 void SubmitCompositorFrame(RenderPassList* pass_list, SurfaceId surface_id) { |
| 77 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); | 78 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); |
| 78 pass_list->swap(frame_data->render_pass_list); | 79 pass_list->swap(frame_data->render_pass_list); |
| 79 | 80 |
| 80 scoped_ptr<CompositorFrame> frame(new CompositorFrame); | 81 scoped_ptr<CompositorFrame> frame(new CompositorFrame); |
| 81 frame->delegated_frame_data = frame_data.Pass(); | 82 frame->delegated_frame_data = std::move(frame_data); |
| 82 | 83 |
| 83 factory_.SubmitCompositorFrame(surface_id, frame.Pass(), | 84 factory_.SubmitCompositorFrame(surface_id, std::move(frame), |
| 84 SurfaceFactory::DrawCallback()); | 85 SurfaceFactory::DrawCallback()); |
| 85 } | 86 } |
| 86 | 87 |
| 87 SurfaceManager manager_; | 88 SurfaceManager manager_; |
| 88 FakeSurfaceFactoryClient surface_factory_client_; | 89 FakeSurfaceFactoryClient surface_factory_client_; |
| 89 SurfaceFactory factory_; | 90 SurfaceFactory factory_; |
| 90 TestSoftwareOutputDevice* software_output_device_; | 91 TestSoftwareOutputDevice* software_output_device_; |
| 91 scoped_ptr<FakeOutputSurface> output_surface_; | 92 scoped_ptr<FakeOutputSurface> output_surface_; |
| 92 FakeOutputSurface* output_surface_ptr_; | 93 FakeOutputSurface* output_surface_ptr_; |
| 93 FakeBeginFrameSource fake_begin_frame_source_; | 94 FakeBeginFrameSource fake_begin_frame_source_; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 // Verify Display responds to SurfaceAggregatorClient methods properly. | 154 // Verify Display responds to SurfaceAggregatorClient methods properly. |
| 154 TEST_F(DisplayTest, DisplayAsSurfaceAggregatorClient) { | 155 TEST_F(DisplayTest, DisplayAsSurfaceAggregatorClient) { |
| 155 SetUpContext(nullptr); | 156 SetUpContext(nullptr); |
| 156 TestDisplayClient client; | 157 TestDisplayClient client; |
| 157 RendererSettings settings; | 158 RendererSettings settings; |
| 158 Display display(&client, &manager_, shared_bitmap_manager_.get(), nullptr, | 159 Display display(&client, &manager_, shared_bitmap_manager_.get(), nullptr, |
| 159 settings); | 160 settings); |
| 160 | 161 |
| 161 TestDisplayScheduler scheduler(&display, &fake_begin_frame_source_, | 162 TestDisplayScheduler scheduler(&display, &fake_begin_frame_source_, |
| 162 task_runner_.get()); | 163 task_runner_.get()); |
| 163 display.Initialize(output_surface_.Pass(), &scheduler); | 164 display.Initialize(std::move(output_surface_), &scheduler); |
| 164 | 165 |
| 165 SurfaceId surface_id(6); | 166 SurfaceId surface_id(6); |
| 166 factory_.Create(surface_id); | 167 factory_.Create(surface_id); |
| 167 Surface* surface = manager_.GetSurfaceForId(surface_id); | 168 Surface* surface = manager_.GetSurfaceForId(surface_id); |
| 168 | 169 |
| 169 EXPECT_EQ(nullptr, surface_factory_client_.begin_frame_source()); | 170 EXPECT_EQ(nullptr, surface_factory_client_.begin_frame_source()); |
| 170 display.AddSurface(surface); | 171 display.AddSurface(surface); |
| 171 EXPECT_NE(nullptr, surface_factory_client_.begin_frame_source()); | 172 EXPECT_NE(nullptr, surface_factory_client_.begin_frame_source()); |
| 172 display.RemoveSurface(surface); | 173 display.RemoveSurface(surface); |
| 173 EXPECT_EQ(nullptr, surface_factory_client_.begin_frame_source()); | 174 EXPECT_EQ(nullptr, surface_factory_client_.begin_frame_source()); |
| 174 } | 175 } |
| 175 | 176 |
| 176 // Check that frame is damaged and swapped only under correct conditions. | 177 // Check that frame is damaged and swapped only under correct conditions. |
| 177 TEST_F(DisplayTest, DisplayDamaged) { | 178 TEST_F(DisplayTest, DisplayDamaged) { |
| 178 SetUpContext(nullptr); | 179 SetUpContext(nullptr); |
| 179 TestDisplayClient client; | 180 TestDisplayClient client; |
| 180 RendererSettings settings; | 181 RendererSettings settings; |
| 181 settings.partial_swap_enabled = true; | 182 settings.partial_swap_enabled = true; |
| 182 settings.finish_rendering_on_resize = true; | 183 settings.finish_rendering_on_resize = true; |
| 183 Display display(&client, &manager_, shared_bitmap_manager_.get(), nullptr, | 184 Display display(&client, &manager_, shared_bitmap_manager_.get(), nullptr, |
| 184 settings); | 185 settings); |
| 185 | 186 |
| 186 TestDisplayScheduler scheduler(&display, &fake_begin_frame_source_, | 187 TestDisplayScheduler scheduler(&display, &fake_begin_frame_source_, |
| 187 task_runner_.get()); | 188 task_runner_.get()); |
| 188 display.Initialize(output_surface_.Pass(), &scheduler); | 189 display.Initialize(std::move(output_surface_), &scheduler); |
| 189 | 190 |
| 190 SurfaceId surface_id(7u); | 191 SurfaceId surface_id(7u); |
| 191 EXPECT_FALSE(scheduler.damaged); | 192 EXPECT_FALSE(scheduler.damaged); |
| 192 EXPECT_FALSE(scheduler.has_new_root_surface); | 193 EXPECT_FALSE(scheduler.has_new_root_surface); |
| 193 display.SetSurfaceId(surface_id, 1.f); | 194 display.SetSurfaceId(surface_id, 1.f); |
| 194 EXPECT_FALSE(scheduler.damaged); | 195 EXPECT_FALSE(scheduler.damaged); |
| 195 EXPECT_FALSE(scheduler.display_resized_); | 196 EXPECT_FALSE(scheduler.display_resized_); |
| 196 EXPECT_TRUE(scheduler.has_new_root_surface); | 197 EXPECT_TRUE(scheduler.has_new_root_surface); |
| 197 | 198 |
| 198 scheduler.ResetDamageForTest(); | 199 scheduler.ResetDamageForTest(); |
| 199 display.Resize(gfx::Size(100, 100)); | 200 display.Resize(gfx::Size(100, 100)); |
| 200 EXPECT_FALSE(scheduler.damaged); | 201 EXPECT_FALSE(scheduler.damaged); |
| 201 EXPECT_TRUE(scheduler.display_resized_); | 202 EXPECT_TRUE(scheduler.display_resized_); |
| 202 EXPECT_FALSE(scheduler.has_new_root_surface); | 203 EXPECT_FALSE(scheduler.has_new_root_surface); |
| 203 | 204 |
| 204 factory_.Create(surface_id); | 205 factory_.Create(surface_id); |
| 205 | 206 |
| 206 // First draw from surface should have full damage. | 207 // First draw from surface should have full damage. |
| 207 RenderPassList pass_list; | 208 RenderPassList pass_list; |
| 208 scoped_ptr<RenderPass> pass = RenderPass::Create(); | 209 scoped_ptr<RenderPass> pass = RenderPass::Create(); |
| 209 pass->output_rect = gfx::Rect(0, 0, 100, 100); | 210 pass->output_rect = gfx::Rect(0, 0, 100, 100); |
| 210 pass->damage_rect = gfx::Rect(10, 10, 1, 1); | 211 pass->damage_rect = gfx::Rect(10, 10, 1, 1); |
| 211 pass->id = RenderPassId(1, 1); | 212 pass->id = RenderPassId(1, 1); |
| 212 pass_list.push_back(pass.Pass()); | 213 pass_list.push_back(std::move(pass)); |
| 213 | 214 |
| 214 scheduler.ResetDamageForTest(); | 215 scheduler.ResetDamageForTest(); |
| 215 SubmitCompositorFrame(&pass_list, surface_id); | 216 SubmitCompositorFrame(&pass_list, surface_id); |
| 216 EXPECT_TRUE(scheduler.damaged); | 217 EXPECT_TRUE(scheduler.damaged); |
| 217 EXPECT_FALSE(scheduler.display_resized_); | 218 EXPECT_FALSE(scheduler.display_resized_); |
| 218 EXPECT_FALSE(scheduler.has_new_root_surface); | 219 EXPECT_FALSE(scheduler.has_new_root_surface); |
| 219 | 220 |
| 220 EXPECT_FALSE(scheduler.swapped); | 221 EXPECT_FALSE(scheduler.swapped); |
| 221 EXPECT_EQ(0u, output_surface_ptr_->num_sent_frames()); | 222 EXPECT_EQ(0u, output_surface_ptr_->num_sent_frames()); |
| 222 display.DrawAndSwap(); | 223 display.DrawAndSwap(); |
| 223 EXPECT_TRUE(scheduler.swapped); | 224 EXPECT_TRUE(scheduler.swapped); |
| 224 EXPECT_EQ(1u, output_surface_ptr_->num_sent_frames()); | 225 EXPECT_EQ(1u, output_surface_ptr_->num_sent_frames()); |
| 225 EXPECT_EQ(gfx::Size(100, 100), | 226 EXPECT_EQ(gfx::Size(100, 100), |
| 226 software_output_device_->viewport_pixel_size()); | 227 software_output_device_->viewport_pixel_size()); |
| 227 EXPECT_EQ(gfx::Rect(0, 0, 100, 100), software_output_device_->damage_rect()); | 228 EXPECT_EQ(gfx::Rect(0, 0, 100, 100), software_output_device_->damage_rect()); |
| 228 | 229 |
| 229 { | 230 { |
| 230 // Only damaged portion should be swapped. | 231 // Only damaged portion should be swapped. |
| 231 pass = RenderPass::Create(); | 232 pass = RenderPass::Create(); |
| 232 pass->output_rect = gfx::Rect(0, 0, 100, 100); | 233 pass->output_rect = gfx::Rect(0, 0, 100, 100); |
| 233 pass->damage_rect = gfx::Rect(10, 10, 1, 1); | 234 pass->damage_rect = gfx::Rect(10, 10, 1, 1); |
| 234 pass->id = RenderPassId(1, 1); | 235 pass->id = RenderPassId(1, 1); |
| 235 | 236 |
| 236 pass_list.push_back(pass.Pass()); | 237 pass_list.push_back(std::move(pass)); |
| 237 scheduler.ResetDamageForTest(); | 238 scheduler.ResetDamageForTest(); |
| 238 SubmitCompositorFrame(&pass_list, surface_id); | 239 SubmitCompositorFrame(&pass_list, surface_id); |
| 239 EXPECT_TRUE(scheduler.damaged); | 240 EXPECT_TRUE(scheduler.damaged); |
| 240 EXPECT_FALSE(scheduler.display_resized_); | 241 EXPECT_FALSE(scheduler.display_resized_); |
| 241 EXPECT_FALSE(scheduler.has_new_root_surface); | 242 EXPECT_FALSE(scheduler.has_new_root_surface); |
| 242 | 243 |
| 243 scheduler.swapped = false; | 244 scheduler.swapped = false; |
| 244 display.DrawAndSwap(); | 245 display.DrawAndSwap(); |
| 245 EXPECT_TRUE(scheduler.swapped); | 246 EXPECT_TRUE(scheduler.swapped); |
| 246 EXPECT_EQ(2u, output_surface_ptr_->num_sent_frames()); | 247 EXPECT_EQ(2u, output_surface_ptr_->num_sent_frames()); |
| 247 EXPECT_EQ(gfx::Size(100, 100), | 248 EXPECT_EQ(gfx::Size(100, 100), |
| 248 software_output_device_->viewport_pixel_size()); | 249 software_output_device_->viewport_pixel_size()); |
| 249 EXPECT_EQ(gfx::Rect(10, 10, 1, 1), software_output_device_->damage_rect()); | 250 EXPECT_EQ(gfx::Rect(10, 10, 1, 1), software_output_device_->damage_rect()); |
| 250 } | 251 } |
| 251 | 252 |
| 252 { | 253 { |
| 253 // Pass has no damage so shouldn't be swapped. | 254 // Pass has no damage so shouldn't be swapped. |
| 254 pass = RenderPass::Create(); | 255 pass = RenderPass::Create(); |
| 255 pass->output_rect = gfx::Rect(0, 0, 100, 100); | 256 pass->output_rect = gfx::Rect(0, 0, 100, 100); |
| 256 pass->damage_rect = gfx::Rect(10, 10, 0, 0); | 257 pass->damage_rect = gfx::Rect(10, 10, 0, 0); |
| 257 pass->id = RenderPassId(1, 1); | 258 pass->id = RenderPassId(1, 1); |
| 258 | 259 |
| 259 pass_list.push_back(pass.Pass()); | 260 pass_list.push_back(std::move(pass)); |
| 260 scheduler.ResetDamageForTest(); | 261 scheduler.ResetDamageForTest(); |
| 261 SubmitCompositorFrame(&pass_list, surface_id); | 262 SubmitCompositorFrame(&pass_list, surface_id); |
| 262 EXPECT_TRUE(scheduler.damaged); | 263 EXPECT_TRUE(scheduler.damaged); |
| 263 EXPECT_FALSE(scheduler.display_resized_); | 264 EXPECT_FALSE(scheduler.display_resized_); |
| 264 EXPECT_FALSE(scheduler.has_new_root_surface); | 265 EXPECT_FALSE(scheduler.has_new_root_surface); |
| 265 | 266 |
| 266 scheduler.swapped = false; | 267 scheduler.swapped = false; |
| 267 display.DrawAndSwap(); | 268 display.DrawAndSwap(); |
| 268 EXPECT_TRUE(scheduler.swapped); | 269 EXPECT_TRUE(scheduler.swapped); |
| 269 EXPECT_EQ(2u, output_surface_ptr_->num_sent_frames()); | 270 EXPECT_EQ(2u, output_surface_ptr_->num_sent_frames()); |
| 270 } | 271 } |
| 271 | 272 |
| 272 { | 273 { |
| 273 // Pass is wrong size so shouldn't be swapped. | 274 // Pass is wrong size so shouldn't be swapped. |
| 274 pass = RenderPass::Create(); | 275 pass = RenderPass::Create(); |
| 275 pass->output_rect = gfx::Rect(0, 0, 99, 99); | 276 pass->output_rect = gfx::Rect(0, 0, 99, 99); |
| 276 pass->damage_rect = gfx::Rect(10, 10, 10, 10); | 277 pass->damage_rect = gfx::Rect(10, 10, 10, 10); |
| 277 pass->id = RenderPassId(1, 1); | 278 pass->id = RenderPassId(1, 1); |
| 278 | 279 |
| 279 pass_list.push_back(pass.Pass()); | 280 pass_list.push_back(std::move(pass)); |
| 280 scheduler.ResetDamageForTest(); | 281 scheduler.ResetDamageForTest(); |
| 281 SubmitCompositorFrame(&pass_list, surface_id); | 282 SubmitCompositorFrame(&pass_list, surface_id); |
| 282 EXPECT_TRUE(scheduler.damaged); | 283 EXPECT_TRUE(scheduler.damaged); |
| 283 EXPECT_FALSE(scheduler.display_resized_); | 284 EXPECT_FALSE(scheduler.display_resized_); |
| 284 EXPECT_FALSE(scheduler.has_new_root_surface); | 285 EXPECT_FALSE(scheduler.has_new_root_surface); |
| 285 | 286 |
| 286 scheduler.swapped = false; | 287 scheduler.swapped = false; |
| 287 display.DrawAndSwap(); | 288 display.DrawAndSwap(); |
| 288 EXPECT_TRUE(scheduler.swapped); | 289 EXPECT_TRUE(scheduler.swapped); |
| 289 EXPECT_EQ(2u, output_surface_ptr_->num_sent_frames()); | 290 EXPECT_EQ(2u, output_surface_ptr_->num_sent_frames()); |
| 290 } | 291 } |
| 291 | 292 |
| 292 { | 293 { |
| 293 // Previous frame wasn't swapped, so next swap should have full damage. | 294 // Previous frame wasn't swapped, so next swap should have full damage. |
| 294 pass = RenderPass::Create(); | 295 pass = RenderPass::Create(); |
| 295 pass->output_rect = gfx::Rect(0, 0, 100, 100); | 296 pass->output_rect = gfx::Rect(0, 0, 100, 100); |
| 296 pass->damage_rect = gfx::Rect(10, 10, 0, 0); | 297 pass->damage_rect = gfx::Rect(10, 10, 0, 0); |
| 297 pass->id = RenderPassId(1, 1); | 298 pass->id = RenderPassId(1, 1); |
| 298 | 299 |
| 299 pass_list.push_back(pass.Pass()); | 300 pass_list.push_back(std::move(pass)); |
| 300 scheduler.ResetDamageForTest(); | 301 scheduler.ResetDamageForTest(); |
| 301 SubmitCompositorFrame(&pass_list, surface_id); | 302 SubmitCompositorFrame(&pass_list, surface_id); |
| 302 EXPECT_TRUE(scheduler.damaged); | 303 EXPECT_TRUE(scheduler.damaged); |
| 303 EXPECT_FALSE(scheduler.display_resized_); | 304 EXPECT_FALSE(scheduler.display_resized_); |
| 304 EXPECT_FALSE(scheduler.has_new_root_surface); | 305 EXPECT_FALSE(scheduler.has_new_root_surface); |
| 305 | 306 |
| 306 scheduler.swapped = false; | 307 scheduler.swapped = false; |
| 307 display.DrawAndSwap(); | 308 display.DrawAndSwap(); |
| 308 EXPECT_TRUE(scheduler.swapped); | 309 EXPECT_TRUE(scheduler.swapped); |
| 309 EXPECT_EQ(3u, output_surface_ptr_->num_sent_frames()); | 310 EXPECT_EQ(3u, output_surface_ptr_->num_sent_frames()); |
| 310 EXPECT_EQ(gfx::Rect(0, 0, 100, 100), | 311 EXPECT_EQ(gfx::Rect(0, 0, 100, 100), |
| 311 software_output_device_->damage_rect()); | 312 software_output_device_->damage_rect()); |
| 312 } | 313 } |
| 313 | 314 |
| 314 { | 315 { |
| 315 // Pass has copy output request so should be swapped. | 316 // Pass has copy output request so should be swapped. |
| 316 pass = RenderPass::Create(); | 317 pass = RenderPass::Create(); |
| 317 pass->output_rect = gfx::Rect(0, 0, 100, 100); | 318 pass->output_rect = gfx::Rect(0, 0, 100, 100); |
| 318 pass->damage_rect = gfx::Rect(10, 10, 0, 0); | 319 pass->damage_rect = gfx::Rect(10, 10, 0, 0); |
| 319 bool copy_called = false; | 320 bool copy_called = false; |
| 320 pass->copy_requests.push_back(CopyOutputRequest::CreateRequest( | 321 pass->copy_requests.push_back(CopyOutputRequest::CreateRequest( |
| 321 base::Bind(&CopyCallback, ©_called))); | 322 base::Bind(&CopyCallback, ©_called))); |
| 322 pass->id = RenderPassId(1, 1); | 323 pass->id = RenderPassId(1, 1); |
| 323 | 324 |
| 324 pass_list.push_back(pass.Pass()); | 325 pass_list.push_back(std::move(pass)); |
| 325 scheduler.ResetDamageForTest(); | 326 scheduler.ResetDamageForTest(); |
| 326 SubmitCompositorFrame(&pass_list, surface_id); | 327 SubmitCompositorFrame(&pass_list, surface_id); |
| 327 EXPECT_TRUE(scheduler.damaged); | 328 EXPECT_TRUE(scheduler.damaged); |
| 328 EXPECT_FALSE(scheduler.display_resized_); | 329 EXPECT_FALSE(scheduler.display_resized_); |
| 329 EXPECT_FALSE(scheduler.has_new_root_surface); | 330 EXPECT_FALSE(scheduler.has_new_root_surface); |
| 330 | 331 |
| 331 scheduler.swapped = false; | 332 scheduler.swapped = false; |
| 332 display.DrawAndSwap(); | 333 display.DrawAndSwap(); |
| 333 EXPECT_TRUE(scheduler.swapped); | 334 EXPECT_TRUE(scheduler.swapped); |
| 334 EXPECT_EQ(4u, output_surface_ptr_->num_sent_frames()); | 335 EXPECT_EQ(4u, output_surface_ptr_->num_sent_frames()); |
| 335 EXPECT_TRUE(copy_called); | 336 EXPECT_TRUE(copy_called); |
| 336 } | 337 } |
| 337 | 338 |
| 338 // Pass has latency info so should be swapped. | 339 // Pass has latency info so should be swapped. |
| 339 { | 340 { |
| 340 pass = RenderPass::Create(); | 341 pass = RenderPass::Create(); |
| 341 pass->output_rect = gfx::Rect(0, 0, 100, 100); | 342 pass->output_rect = gfx::Rect(0, 0, 100, 100); |
| 342 pass->damage_rect = gfx::Rect(10, 10, 0, 0); | 343 pass->damage_rect = gfx::Rect(10, 10, 0, 0); |
| 343 pass->id = RenderPassId(1, 1); | 344 pass->id = RenderPassId(1, 1); |
| 344 | 345 |
| 345 pass_list.push_back(pass.Pass()); | 346 pass_list.push_back(std::move(pass)); |
| 346 scheduler.ResetDamageForTest(); | 347 scheduler.ResetDamageForTest(); |
| 347 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); | 348 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); |
| 348 pass_list.swap(frame_data->render_pass_list); | 349 pass_list.swap(frame_data->render_pass_list); |
| 349 | 350 |
| 350 scoped_ptr<CompositorFrame> frame(new CompositorFrame); | 351 scoped_ptr<CompositorFrame> frame(new CompositorFrame); |
| 351 frame->delegated_frame_data = frame_data.Pass(); | 352 frame->delegated_frame_data = std::move(frame_data); |
| 352 frame->metadata.latency_info.push_back(ui::LatencyInfo()); | 353 frame->metadata.latency_info.push_back(ui::LatencyInfo()); |
| 353 | 354 |
| 354 factory_.SubmitCompositorFrame(surface_id, frame.Pass(), | 355 factory_.SubmitCompositorFrame(surface_id, std::move(frame), |
| 355 SurfaceFactory::DrawCallback()); | 356 SurfaceFactory::DrawCallback()); |
| 356 EXPECT_TRUE(scheduler.damaged); | 357 EXPECT_TRUE(scheduler.damaged); |
| 357 EXPECT_FALSE(scheduler.display_resized_); | 358 EXPECT_FALSE(scheduler.display_resized_); |
| 358 EXPECT_FALSE(scheduler.has_new_root_surface); | 359 EXPECT_FALSE(scheduler.has_new_root_surface); |
| 359 | 360 |
| 360 scheduler.swapped = false; | 361 scheduler.swapped = false; |
| 361 display.DrawAndSwap(); | 362 display.DrawAndSwap(); |
| 362 EXPECT_TRUE(scheduler.swapped); | 363 EXPECT_TRUE(scheduler.swapped); |
| 363 EXPECT_EQ(5u, output_surface_ptr_->num_sent_frames()); | 364 EXPECT_EQ(5u, output_surface_ptr_->num_sent_frames()); |
| 364 } | 365 } |
| 365 | 366 |
| 366 // Resize should cause a swap if no frame was swapped at the previous size. | 367 // Resize should cause a swap if no frame was swapped at the previous size. |
| 367 { | 368 { |
| 368 scheduler.swapped = false; | 369 scheduler.swapped = false; |
| 369 display.Resize(gfx::Size(200, 200)); | 370 display.Resize(gfx::Size(200, 200)); |
| 370 EXPECT_FALSE(scheduler.swapped); | 371 EXPECT_FALSE(scheduler.swapped); |
| 371 EXPECT_EQ(5u, output_surface_ptr_->num_sent_frames()); | 372 EXPECT_EQ(5u, output_surface_ptr_->num_sent_frames()); |
| 372 | 373 |
| 373 pass = RenderPass::Create(); | 374 pass = RenderPass::Create(); |
| 374 pass->output_rect = gfx::Rect(0, 0, 200, 200); | 375 pass->output_rect = gfx::Rect(0, 0, 200, 200); |
| 375 pass->damage_rect = gfx::Rect(10, 10, 10, 10); | 376 pass->damage_rect = gfx::Rect(10, 10, 10, 10); |
| 376 pass->id = RenderPassId(1, 1); | 377 pass->id = RenderPassId(1, 1); |
| 377 | 378 |
| 378 pass_list.push_back(pass.Pass()); | 379 pass_list.push_back(std::move(pass)); |
| 379 scheduler.ResetDamageForTest(); | 380 scheduler.ResetDamageForTest(); |
| 380 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); | 381 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); |
| 381 pass_list.swap(frame_data->render_pass_list); | 382 pass_list.swap(frame_data->render_pass_list); |
| 382 | 383 |
| 383 scoped_ptr<CompositorFrame> frame(new CompositorFrame); | 384 scoped_ptr<CompositorFrame> frame(new CompositorFrame); |
| 384 frame->delegated_frame_data = frame_data.Pass(); | 385 frame->delegated_frame_data = std::move(frame_data); |
| 385 | 386 |
| 386 factory_.SubmitCompositorFrame(surface_id, frame.Pass(), | 387 factory_.SubmitCompositorFrame(surface_id, std::move(frame), |
| 387 SurfaceFactory::DrawCallback()); | 388 SurfaceFactory::DrawCallback()); |
| 388 EXPECT_TRUE(scheduler.damaged); | 389 EXPECT_TRUE(scheduler.damaged); |
| 389 EXPECT_FALSE(scheduler.display_resized_); | 390 EXPECT_FALSE(scheduler.display_resized_); |
| 390 EXPECT_FALSE(scheduler.has_new_root_surface); | 391 EXPECT_FALSE(scheduler.has_new_root_surface); |
| 391 | 392 |
| 392 scheduler.swapped = false; | 393 scheduler.swapped = false; |
| 393 display.Resize(gfx::Size(100, 100)); | 394 display.Resize(gfx::Size(100, 100)); |
| 394 EXPECT_TRUE(scheduler.swapped); | 395 EXPECT_TRUE(scheduler.swapped); |
| 395 EXPECT_EQ(6u, output_surface_ptr_->num_sent_frames()); | 396 EXPECT_EQ(6u, output_surface_ptr_->num_sent_frames()); |
| 396 } | 397 } |
| 397 | 398 |
| 398 factory_.Destroy(surface_id); | 399 factory_.Destroy(surface_id); |
| 399 } | 400 } |
| 400 | 401 |
| 401 class MockedContext : public TestWebGraphicsContext3D { | 402 class MockedContext : public TestWebGraphicsContext3D { |
| 402 public: | 403 public: |
| 403 MOCK_METHOD0(shallowFinishCHROMIUM, void()); | 404 MOCK_METHOD0(shallowFinishCHROMIUM, void()); |
| 404 }; | 405 }; |
| 405 | 406 |
| 406 TEST_F(DisplayTest, Finish) { | 407 TEST_F(DisplayTest, Finish) { |
| 407 scoped_ptr<MockedContext> context(new MockedContext()); | 408 scoped_ptr<MockedContext> context(new MockedContext()); |
| 408 MockedContext* context_ptr = context.get(); | 409 MockedContext* context_ptr = context.get(); |
| 409 SetUpContext(context.Pass()); | 410 SetUpContext(std::move(context)); |
| 410 | 411 |
| 411 EXPECT_CALL(*context_ptr, shallowFinishCHROMIUM()).Times(0); | 412 EXPECT_CALL(*context_ptr, shallowFinishCHROMIUM()).Times(0); |
| 412 TestDisplayClient client; | 413 TestDisplayClient client; |
| 413 RendererSettings settings; | 414 RendererSettings settings; |
| 414 settings.partial_swap_enabled = true; | 415 settings.partial_swap_enabled = true; |
| 415 settings.finish_rendering_on_resize = true; | 416 settings.finish_rendering_on_resize = true; |
| 416 Display display(&client, &manager_, shared_bitmap_manager_.get(), nullptr, | 417 Display display(&client, &manager_, shared_bitmap_manager_.get(), nullptr, |
| 417 settings); | 418 settings); |
| 418 | 419 |
| 419 TestDisplayScheduler scheduler(&display, &fake_begin_frame_source_, | 420 TestDisplayScheduler scheduler(&display, &fake_begin_frame_source_, |
| 420 task_runner_.get()); | 421 task_runner_.get()); |
| 421 display.Initialize(output_surface_.Pass(), &scheduler); | 422 display.Initialize(std::move(output_surface_), &scheduler); |
| 422 | 423 |
| 423 SurfaceId surface_id(7u); | 424 SurfaceId surface_id(7u); |
| 424 display.SetSurfaceId(surface_id, 1.f); | 425 display.SetSurfaceId(surface_id, 1.f); |
| 425 | 426 |
| 426 display.Resize(gfx::Size(100, 100)); | 427 display.Resize(gfx::Size(100, 100)); |
| 427 factory_.Create(surface_id); | 428 factory_.Create(surface_id); |
| 428 | 429 |
| 429 { | 430 { |
| 430 RenderPassList pass_list; | 431 RenderPassList pass_list; |
| 431 scoped_ptr<RenderPass> pass = RenderPass::Create(); | 432 scoped_ptr<RenderPass> pass = RenderPass::Create(); |
| 432 pass->output_rect = gfx::Rect(0, 0, 100, 100); | 433 pass->output_rect = gfx::Rect(0, 0, 100, 100); |
| 433 pass->damage_rect = gfx::Rect(10, 10, 1, 1); | 434 pass->damage_rect = gfx::Rect(10, 10, 1, 1); |
| 434 pass->id = RenderPassId(1, 1); | 435 pass->id = RenderPassId(1, 1); |
| 435 pass_list.push_back(pass.Pass()); | 436 pass_list.push_back(std::move(pass)); |
| 436 | 437 |
| 437 SubmitCompositorFrame(&pass_list, surface_id); | 438 SubmitCompositorFrame(&pass_list, surface_id); |
| 438 } | 439 } |
| 439 | 440 |
| 440 display.DrawAndSwap(); | 441 display.DrawAndSwap(); |
| 441 | 442 |
| 442 // First resize and draw shouldn't finish. | 443 // First resize and draw shouldn't finish. |
| 443 testing::Mock::VerifyAndClearExpectations(context_ptr); | 444 testing::Mock::VerifyAndClearExpectations(context_ptr); |
| 444 | 445 |
| 445 EXPECT_CALL(*context_ptr, shallowFinishCHROMIUM()); | 446 EXPECT_CALL(*context_ptr, shallowFinishCHROMIUM()); |
| 446 display.Resize(gfx::Size(150, 150)); | 447 display.Resize(gfx::Size(150, 150)); |
| 447 testing::Mock::VerifyAndClearExpectations(context_ptr); | 448 testing::Mock::VerifyAndClearExpectations(context_ptr); |
| 448 | 449 |
| 449 // Another resize without a swap doesn't need to finish. | 450 // Another resize without a swap doesn't need to finish. |
| 450 EXPECT_CALL(*context_ptr, shallowFinishCHROMIUM()).Times(0); | 451 EXPECT_CALL(*context_ptr, shallowFinishCHROMIUM()).Times(0); |
| 451 display.Resize(gfx::Size(200, 200)); | 452 display.Resize(gfx::Size(200, 200)); |
| 452 testing::Mock::VerifyAndClearExpectations(context_ptr); | 453 testing::Mock::VerifyAndClearExpectations(context_ptr); |
| 453 | 454 |
| 454 EXPECT_CALL(*context_ptr, shallowFinishCHROMIUM()).Times(0); | 455 EXPECT_CALL(*context_ptr, shallowFinishCHROMIUM()).Times(0); |
| 455 { | 456 { |
| 456 RenderPassList pass_list; | 457 RenderPassList pass_list; |
| 457 scoped_ptr<RenderPass> pass = RenderPass::Create(); | 458 scoped_ptr<RenderPass> pass = RenderPass::Create(); |
| 458 pass->output_rect = gfx::Rect(0, 0, 200, 200); | 459 pass->output_rect = gfx::Rect(0, 0, 200, 200); |
| 459 pass->damage_rect = gfx::Rect(10, 10, 1, 1); | 460 pass->damage_rect = gfx::Rect(10, 10, 1, 1); |
| 460 pass->id = RenderPassId(1, 1); | 461 pass->id = RenderPassId(1, 1); |
| 461 pass_list.push_back(pass.Pass()); | 462 pass_list.push_back(std::move(pass)); |
| 462 | 463 |
| 463 SubmitCompositorFrame(&pass_list, surface_id); | 464 SubmitCompositorFrame(&pass_list, surface_id); |
| 464 } | 465 } |
| 465 | 466 |
| 466 display.DrawAndSwap(); | 467 display.DrawAndSwap(); |
| 467 | 468 |
| 468 testing::Mock::VerifyAndClearExpectations(context_ptr); | 469 testing::Mock::VerifyAndClearExpectations(context_ptr); |
| 469 | 470 |
| 470 EXPECT_CALL(*context_ptr, shallowFinishCHROMIUM()); | 471 EXPECT_CALL(*context_ptr, shallowFinishCHROMIUM()); |
| 471 display.Resize(gfx::Size(250, 250)); | 472 display.Resize(gfx::Size(250, 250)); |
| 472 testing::Mock::VerifyAndClearExpectations(context_ptr); | 473 testing::Mock::VerifyAndClearExpectations(context_ptr); |
| 473 | 474 |
| 474 factory_.Destroy(surface_id); | 475 factory_.Destroy(surface_id); |
| 475 } | 476 } |
| 476 | 477 |
| 477 } // namespace | 478 } // namespace |
| 478 } // namespace cc | 479 } // namespace cc |
| OLD | NEW |