| 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 "cc/surfaces/display.h" | 5 #include "cc/surfaces/display.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/test/null_task_runner.h" | 10 #include "base/test/null_task_runner.h" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 display_ = base::MakeUnique<Display>( | 133 display_ = base::MakeUnique<Display>( |
| 134 &shared_bitmap_manager_, nullptr /* gpu_memory_buffer_manager */, | 134 &shared_bitmap_manager_, nullptr /* gpu_memory_buffer_manager */, |
| 135 settings, kArbitraryFrameSinkId, begin_frame_source_.get(), | 135 settings, kArbitraryFrameSinkId, begin_frame_source_.get(), |
| 136 std::move(output_surface), std::move(scheduler), | 136 std::move(output_surface), std::move(scheduler), |
| 137 base::MakeUnique<TextureMailboxDeleter>(task_runner_.get())); | 137 base::MakeUnique<TextureMailboxDeleter>(task_runner_.get())); |
| 138 display_->SetVisible(true); | 138 display_->SetVisible(true); |
| 139 } | 139 } |
| 140 | 140 |
| 141 protected: | 141 protected: |
| 142 void SubmitCompositorFrame(RenderPassList* pass_list, | 142 void SubmitCompositorFrame(RenderPassList* pass_list, |
| 143 const LocalFrameId& local_frame_id) { | 143 const LocalSurfaceId& local_surface_id) { |
| 144 CompositorFrame frame; | 144 CompositorFrame frame; |
| 145 pass_list->swap(frame.render_pass_list); | 145 pass_list->swap(frame.render_pass_list); |
| 146 | 146 |
| 147 factory_.SubmitCompositorFrame(local_frame_id, std::move(frame), | 147 factory_.SubmitCompositorFrame(local_surface_id, std::move(frame), |
| 148 SurfaceFactory::DrawCallback()); | 148 SurfaceFactory::DrawCallback()); |
| 149 } | 149 } |
| 150 | 150 |
| 151 SurfaceManager manager_; | 151 SurfaceManager manager_; |
| 152 FakeSurfaceFactoryClient surface_factory_client_; | 152 FakeSurfaceFactoryClient surface_factory_client_; |
| 153 SurfaceFactory factory_; | 153 SurfaceFactory factory_; |
| 154 SurfaceIdAllocator id_allocator_; | 154 SurfaceIdAllocator id_allocator_; |
| 155 scoped_refptr<base::NullTaskRunner> task_runner_; | 155 scoped_refptr<base::NullTaskRunner> task_runner_; |
| 156 TestSharedBitmapManager shared_bitmap_manager_; | 156 TestSharedBitmapManager shared_bitmap_manager_; |
| 157 std::unique_ptr<BeginFrameSource> begin_frame_source_; | 157 std::unique_ptr<BeginFrameSource> begin_frame_source_; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 176 // Check that frame is damaged and swapped only under correct conditions. | 176 // Check that frame is damaged and swapped only under correct conditions. |
| 177 TEST_F(DisplayTest, DisplayDamaged) { | 177 TEST_F(DisplayTest, DisplayDamaged) { |
| 178 RendererSettings settings; | 178 RendererSettings settings; |
| 179 settings.partial_swap_enabled = true; | 179 settings.partial_swap_enabled = true; |
| 180 settings.finish_rendering_on_resize = true; | 180 settings.finish_rendering_on_resize = true; |
| 181 SetUpDisplay(settings, nullptr); | 181 SetUpDisplay(settings, nullptr); |
| 182 | 182 |
| 183 StubDisplayClient client; | 183 StubDisplayClient client; |
| 184 display_->Initialize(&client, &manager_); | 184 display_->Initialize(&client, &manager_); |
| 185 | 185 |
| 186 LocalFrameId local_frame_id(id_allocator_.GenerateId()); | 186 LocalSurfaceId local_surface_id(id_allocator_.GenerateId()); |
| 187 EXPECT_FALSE(scheduler_->damaged); | 187 EXPECT_FALSE(scheduler_->damaged); |
| 188 EXPECT_FALSE(scheduler_->has_new_root_surface); | 188 EXPECT_FALSE(scheduler_->has_new_root_surface); |
| 189 display_->SetLocalFrameId(local_frame_id, 1.f); | 189 display_->SetLocalSurfaceId(local_surface_id, 1.f); |
| 190 EXPECT_FALSE(scheduler_->damaged); | 190 EXPECT_FALSE(scheduler_->damaged); |
| 191 EXPECT_FALSE(scheduler_->display_resized_); | 191 EXPECT_FALSE(scheduler_->display_resized_); |
| 192 EXPECT_TRUE(scheduler_->has_new_root_surface); | 192 EXPECT_TRUE(scheduler_->has_new_root_surface); |
| 193 | 193 |
| 194 scheduler_->ResetDamageForTest(); | 194 scheduler_->ResetDamageForTest(); |
| 195 display_->Resize(gfx::Size(100, 100)); | 195 display_->Resize(gfx::Size(100, 100)); |
| 196 EXPECT_FALSE(scheduler_->damaged); | 196 EXPECT_FALSE(scheduler_->damaged); |
| 197 EXPECT_TRUE(scheduler_->display_resized_); | 197 EXPECT_TRUE(scheduler_->display_resized_); |
| 198 EXPECT_FALSE(scheduler_->has_new_root_surface); | 198 EXPECT_FALSE(scheduler_->has_new_root_surface); |
| 199 | 199 |
| 200 // First draw from surface should have full damage. | 200 // First draw from surface should have full damage. |
| 201 RenderPassList pass_list; | 201 RenderPassList pass_list; |
| 202 std::unique_ptr<RenderPass> pass = RenderPass::Create(); | 202 std::unique_ptr<RenderPass> pass = RenderPass::Create(); |
| 203 pass->output_rect = gfx::Rect(0, 0, 100, 100); | 203 pass->output_rect = gfx::Rect(0, 0, 100, 100); |
| 204 pass->damage_rect = gfx::Rect(10, 10, 1, 1); | 204 pass->damage_rect = gfx::Rect(10, 10, 1, 1); |
| 205 pass->id = 1; | 205 pass->id = 1; |
| 206 pass_list.push_back(std::move(pass)); | 206 pass_list.push_back(std::move(pass)); |
| 207 | 207 |
| 208 scheduler_->ResetDamageForTest(); | 208 scheduler_->ResetDamageForTest(); |
| 209 SubmitCompositorFrame(&pass_list, local_frame_id); | 209 SubmitCompositorFrame(&pass_list, local_surface_id); |
| 210 EXPECT_TRUE(scheduler_->damaged); | 210 EXPECT_TRUE(scheduler_->damaged); |
| 211 EXPECT_FALSE(scheduler_->display_resized_); | 211 EXPECT_FALSE(scheduler_->display_resized_); |
| 212 EXPECT_FALSE(scheduler_->has_new_root_surface); | 212 EXPECT_FALSE(scheduler_->has_new_root_surface); |
| 213 | 213 |
| 214 EXPECT_FALSE(scheduler_->swapped); | 214 EXPECT_FALSE(scheduler_->swapped); |
| 215 EXPECT_EQ(0u, output_surface_->num_sent_frames()); | 215 EXPECT_EQ(0u, output_surface_->num_sent_frames()); |
| 216 display_->DrawAndSwap(); | 216 display_->DrawAndSwap(); |
| 217 EXPECT_TRUE(scheduler_->swapped); | 217 EXPECT_TRUE(scheduler_->swapped); |
| 218 EXPECT_EQ(1u, output_surface_->num_sent_frames()); | 218 EXPECT_EQ(1u, output_surface_->num_sent_frames()); |
| 219 EXPECT_EQ(gfx::Size(100, 100), | 219 EXPECT_EQ(gfx::Size(100, 100), |
| 220 software_output_device_->viewport_pixel_size()); | 220 software_output_device_->viewport_pixel_size()); |
| 221 EXPECT_EQ(gfx::Rect(0, 0, 100, 100), software_output_device_->damage_rect()); | 221 EXPECT_EQ(gfx::Rect(0, 0, 100, 100), software_output_device_->damage_rect()); |
| 222 | 222 |
| 223 { | 223 { |
| 224 // Only damaged portion should be swapped. | 224 // Only damaged portion should be swapped. |
| 225 pass = RenderPass::Create(); | 225 pass = RenderPass::Create(); |
| 226 pass->output_rect = gfx::Rect(0, 0, 100, 100); | 226 pass->output_rect = gfx::Rect(0, 0, 100, 100); |
| 227 pass->damage_rect = gfx::Rect(10, 10, 1, 1); | 227 pass->damage_rect = gfx::Rect(10, 10, 1, 1); |
| 228 pass->id = 1; | 228 pass->id = 1; |
| 229 | 229 |
| 230 pass_list.push_back(std::move(pass)); | 230 pass_list.push_back(std::move(pass)); |
| 231 scheduler_->ResetDamageForTest(); | 231 scheduler_->ResetDamageForTest(); |
| 232 SubmitCompositorFrame(&pass_list, local_frame_id); | 232 SubmitCompositorFrame(&pass_list, local_surface_id); |
| 233 EXPECT_TRUE(scheduler_->damaged); | 233 EXPECT_TRUE(scheduler_->damaged); |
| 234 EXPECT_FALSE(scheduler_->display_resized_); | 234 EXPECT_FALSE(scheduler_->display_resized_); |
| 235 EXPECT_FALSE(scheduler_->has_new_root_surface); | 235 EXPECT_FALSE(scheduler_->has_new_root_surface); |
| 236 | 236 |
| 237 scheduler_->swapped = false; | 237 scheduler_->swapped = false; |
| 238 display_->DrawAndSwap(); | 238 display_->DrawAndSwap(); |
| 239 EXPECT_TRUE(scheduler_->swapped); | 239 EXPECT_TRUE(scheduler_->swapped); |
| 240 EXPECT_EQ(2u, output_surface_->num_sent_frames()); | 240 EXPECT_EQ(2u, output_surface_->num_sent_frames()); |
| 241 EXPECT_EQ(gfx::Size(100, 100), | 241 EXPECT_EQ(gfx::Size(100, 100), |
| 242 software_output_device_->viewport_pixel_size()); | 242 software_output_device_->viewport_pixel_size()); |
| 243 EXPECT_EQ(gfx::Rect(10, 10, 1, 1), software_output_device_->damage_rect()); | 243 EXPECT_EQ(gfx::Rect(10, 10, 1, 1), software_output_device_->damage_rect()); |
| 244 } | 244 } |
| 245 | 245 |
| 246 { | 246 { |
| 247 // Pass has no damage so shouldn't be swapped. | 247 // Pass has no damage so shouldn't be swapped. |
| 248 pass = RenderPass::Create(); | 248 pass = RenderPass::Create(); |
| 249 pass->output_rect = gfx::Rect(0, 0, 100, 100); | 249 pass->output_rect = gfx::Rect(0, 0, 100, 100); |
| 250 pass->damage_rect = gfx::Rect(10, 10, 0, 0); | 250 pass->damage_rect = gfx::Rect(10, 10, 0, 0); |
| 251 pass->id = 1; | 251 pass->id = 1; |
| 252 | 252 |
| 253 pass_list.push_back(std::move(pass)); | 253 pass_list.push_back(std::move(pass)); |
| 254 scheduler_->ResetDamageForTest(); | 254 scheduler_->ResetDamageForTest(); |
| 255 SubmitCompositorFrame(&pass_list, local_frame_id); | 255 SubmitCompositorFrame(&pass_list, local_surface_id); |
| 256 EXPECT_TRUE(scheduler_->damaged); | 256 EXPECT_TRUE(scheduler_->damaged); |
| 257 EXPECT_FALSE(scheduler_->display_resized_); | 257 EXPECT_FALSE(scheduler_->display_resized_); |
| 258 EXPECT_FALSE(scheduler_->has_new_root_surface); | 258 EXPECT_FALSE(scheduler_->has_new_root_surface); |
| 259 | 259 |
| 260 scheduler_->swapped = false; | 260 scheduler_->swapped = false; |
| 261 display_->DrawAndSwap(); | 261 display_->DrawAndSwap(); |
| 262 EXPECT_TRUE(scheduler_->swapped); | 262 EXPECT_TRUE(scheduler_->swapped); |
| 263 EXPECT_EQ(2u, output_surface_->num_sent_frames()); | 263 EXPECT_EQ(2u, output_surface_->num_sent_frames()); |
| 264 } | 264 } |
| 265 | 265 |
| 266 { | 266 { |
| 267 // Pass is wrong size so shouldn't be swapped. | 267 // Pass is wrong size so shouldn't be swapped. |
| 268 pass = RenderPass::Create(); | 268 pass = RenderPass::Create(); |
| 269 pass->output_rect = gfx::Rect(0, 0, 99, 99); | 269 pass->output_rect = gfx::Rect(0, 0, 99, 99); |
| 270 pass->damage_rect = gfx::Rect(10, 10, 10, 10); | 270 pass->damage_rect = gfx::Rect(10, 10, 10, 10); |
| 271 pass->id = 1; | 271 pass->id = 1; |
| 272 | 272 |
| 273 pass_list.push_back(std::move(pass)); | 273 pass_list.push_back(std::move(pass)); |
| 274 scheduler_->ResetDamageForTest(); | 274 scheduler_->ResetDamageForTest(); |
| 275 SubmitCompositorFrame(&pass_list, local_frame_id); | 275 SubmitCompositorFrame(&pass_list, local_surface_id); |
| 276 EXPECT_TRUE(scheduler_->damaged); | 276 EXPECT_TRUE(scheduler_->damaged); |
| 277 EXPECT_FALSE(scheduler_->display_resized_); | 277 EXPECT_FALSE(scheduler_->display_resized_); |
| 278 EXPECT_FALSE(scheduler_->has_new_root_surface); | 278 EXPECT_FALSE(scheduler_->has_new_root_surface); |
| 279 | 279 |
| 280 scheduler_->swapped = false; | 280 scheduler_->swapped = false; |
| 281 display_->DrawAndSwap(); | 281 display_->DrawAndSwap(); |
| 282 EXPECT_TRUE(scheduler_->swapped); | 282 EXPECT_TRUE(scheduler_->swapped); |
| 283 EXPECT_EQ(2u, output_surface_->num_sent_frames()); | 283 EXPECT_EQ(2u, output_surface_->num_sent_frames()); |
| 284 } | 284 } |
| 285 | 285 |
| 286 { | 286 { |
| 287 // Previous frame wasn't swapped, so next swap should have full damage. | 287 // Previous frame wasn't swapped, so next swap should have full damage. |
| 288 pass = RenderPass::Create(); | 288 pass = RenderPass::Create(); |
| 289 pass->output_rect = gfx::Rect(0, 0, 100, 100); | 289 pass->output_rect = gfx::Rect(0, 0, 100, 100); |
| 290 pass->damage_rect = gfx::Rect(10, 10, 0, 0); | 290 pass->damage_rect = gfx::Rect(10, 10, 0, 0); |
| 291 pass->id = 1; | 291 pass->id = 1; |
| 292 | 292 |
| 293 pass_list.push_back(std::move(pass)); | 293 pass_list.push_back(std::move(pass)); |
| 294 scheduler_->ResetDamageForTest(); | 294 scheduler_->ResetDamageForTest(); |
| 295 SubmitCompositorFrame(&pass_list, local_frame_id); | 295 SubmitCompositorFrame(&pass_list, local_surface_id); |
| 296 EXPECT_TRUE(scheduler_->damaged); | 296 EXPECT_TRUE(scheduler_->damaged); |
| 297 EXPECT_FALSE(scheduler_->display_resized_); | 297 EXPECT_FALSE(scheduler_->display_resized_); |
| 298 EXPECT_FALSE(scheduler_->has_new_root_surface); | 298 EXPECT_FALSE(scheduler_->has_new_root_surface); |
| 299 | 299 |
| 300 scheduler_->swapped = false; | 300 scheduler_->swapped = false; |
| 301 display_->DrawAndSwap(); | 301 display_->DrawAndSwap(); |
| 302 EXPECT_TRUE(scheduler_->swapped); | 302 EXPECT_TRUE(scheduler_->swapped); |
| 303 EXPECT_EQ(3u, output_surface_->num_sent_frames()); | 303 EXPECT_EQ(3u, output_surface_->num_sent_frames()); |
| 304 EXPECT_EQ(gfx::Rect(0, 0, 100, 100), | 304 EXPECT_EQ(gfx::Rect(0, 0, 100, 100), |
| 305 software_output_device_->damage_rect()); | 305 software_output_device_->damage_rect()); |
| 306 } | 306 } |
| 307 | 307 |
| 308 { | 308 { |
| 309 // Pass has copy output request so should be swapped. | 309 // Pass has copy output request so should be swapped. |
| 310 pass = RenderPass::Create(); | 310 pass = RenderPass::Create(); |
| 311 pass->output_rect = gfx::Rect(0, 0, 100, 100); | 311 pass->output_rect = gfx::Rect(0, 0, 100, 100); |
| 312 pass->damage_rect = gfx::Rect(10, 10, 0, 0); | 312 pass->damage_rect = gfx::Rect(10, 10, 0, 0); |
| 313 bool copy_called = false; | 313 bool copy_called = false; |
| 314 pass->copy_requests.push_back(CopyOutputRequest::CreateRequest( | 314 pass->copy_requests.push_back(CopyOutputRequest::CreateRequest( |
| 315 base::Bind(&CopyCallback, ©_called))); | 315 base::Bind(&CopyCallback, ©_called))); |
| 316 pass->id = 1; | 316 pass->id = 1; |
| 317 | 317 |
| 318 pass_list.push_back(std::move(pass)); | 318 pass_list.push_back(std::move(pass)); |
| 319 scheduler_->ResetDamageForTest(); | 319 scheduler_->ResetDamageForTest(); |
| 320 SubmitCompositorFrame(&pass_list, local_frame_id); | 320 SubmitCompositorFrame(&pass_list, local_surface_id); |
| 321 EXPECT_TRUE(scheduler_->damaged); | 321 EXPECT_TRUE(scheduler_->damaged); |
| 322 EXPECT_FALSE(scheduler_->display_resized_); | 322 EXPECT_FALSE(scheduler_->display_resized_); |
| 323 EXPECT_FALSE(scheduler_->has_new_root_surface); | 323 EXPECT_FALSE(scheduler_->has_new_root_surface); |
| 324 | 324 |
| 325 scheduler_->swapped = false; | 325 scheduler_->swapped = false; |
| 326 display_->DrawAndSwap(); | 326 display_->DrawAndSwap(); |
| 327 EXPECT_TRUE(scheduler_->swapped); | 327 EXPECT_TRUE(scheduler_->swapped); |
| 328 EXPECT_EQ(4u, output_surface_->num_sent_frames()); | 328 EXPECT_EQ(4u, output_surface_->num_sent_frames()); |
| 329 EXPECT_TRUE(copy_called); | 329 EXPECT_TRUE(copy_called); |
| 330 } | 330 } |
| 331 | 331 |
| 332 // Pass has no damage, so shouldn't be swapped, but latency info should be | 332 // Pass has no damage, so shouldn't be swapped, but latency info should be |
| 333 // saved for next swap. | 333 // saved for next swap. |
| 334 { | 334 { |
| 335 pass = RenderPass::Create(); | 335 pass = RenderPass::Create(); |
| 336 pass->output_rect = gfx::Rect(0, 0, 100, 100); | 336 pass->output_rect = gfx::Rect(0, 0, 100, 100); |
| 337 pass->damage_rect = gfx::Rect(10, 10, 0, 0); | 337 pass->damage_rect = gfx::Rect(10, 10, 0, 0); |
| 338 pass->id = 1; | 338 pass->id = 1; |
| 339 | 339 |
| 340 pass_list.push_back(std::move(pass)); | 340 pass_list.push_back(std::move(pass)); |
| 341 scheduler_->ResetDamageForTest(); | 341 scheduler_->ResetDamageForTest(); |
| 342 | 342 |
| 343 CompositorFrame frame; | 343 CompositorFrame frame; |
| 344 pass_list.swap(frame.render_pass_list); | 344 pass_list.swap(frame.render_pass_list); |
| 345 frame.metadata.latency_info.push_back(ui::LatencyInfo()); | 345 frame.metadata.latency_info.push_back(ui::LatencyInfo()); |
| 346 | 346 |
| 347 factory_.SubmitCompositorFrame(local_frame_id, std::move(frame), | 347 factory_.SubmitCompositorFrame(local_surface_id, std::move(frame), |
| 348 SurfaceFactory::DrawCallback()); | 348 SurfaceFactory::DrawCallback()); |
| 349 EXPECT_TRUE(scheduler_->damaged); | 349 EXPECT_TRUE(scheduler_->damaged); |
| 350 EXPECT_FALSE(scheduler_->display_resized_); | 350 EXPECT_FALSE(scheduler_->display_resized_); |
| 351 EXPECT_FALSE(scheduler_->has_new_root_surface); | 351 EXPECT_FALSE(scheduler_->has_new_root_surface); |
| 352 | 352 |
| 353 scheduler_->swapped = false; | 353 scheduler_->swapped = false; |
| 354 display_->DrawAndSwap(); | 354 display_->DrawAndSwap(); |
| 355 EXPECT_TRUE(scheduler_->swapped); | 355 EXPECT_TRUE(scheduler_->swapped); |
| 356 EXPECT_EQ(4u, output_surface_->num_sent_frames()); | 356 EXPECT_EQ(4u, output_surface_->num_sent_frames()); |
| 357 } | 357 } |
| 358 | 358 |
| 359 // Resize should cause a swap if no frame was swapped at the previous size. | 359 // Resize should cause a swap if no frame was swapped at the previous size. |
| 360 { | 360 { |
| 361 scheduler_->swapped = false; | 361 scheduler_->swapped = false; |
| 362 display_->Resize(gfx::Size(200, 200)); | 362 display_->Resize(gfx::Size(200, 200)); |
| 363 EXPECT_FALSE(scheduler_->swapped); | 363 EXPECT_FALSE(scheduler_->swapped); |
| 364 EXPECT_EQ(4u, output_surface_->num_sent_frames()); | 364 EXPECT_EQ(4u, output_surface_->num_sent_frames()); |
| 365 | 365 |
| 366 pass = RenderPass::Create(); | 366 pass = RenderPass::Create(); |
| 367 pass->output_rect = gfx::Rect(0, 0, 200, 200); | 367 pass->output_rect = gfx::Rect(0, 0, 200, 200); |
| 368 pass->damage_rect = gfx::Rect(10, 10, 10, 10); | 368 pass->damage_rect = gfx::Rect(10, 10, 10, 10); |
| 369 pass->id = 1; | 369 pass->id = 1; |
| 370 | 370 |
| 371 pass_list.push_back(std::move(pass)); | 371 pass_list.push_back(std::move(pass)); |
| 372 scheduler_->ResetDamageForTest(); | 372 scheduler_->ResetDamageForTest(); |
| 373 | 373 |
| 374 CompositorFrame frame; | 374 CompositorFrame frame; |
| 375 pass_list.swap(frame.render_pass_list); | 375 pass_list.swap(frame.render_pass_list); |
| 376 | 376 |
| 377 factory_.SubmitCompositorFrame(local_frame_id, std::move(frame), | 377 factory_.SubmitCompositorFrame(local_surface_id, std::move(frame), |
| 378 SurfaceFactory::DrawCallback()); | 378 SurfaceFactory::DrawCallback()); |
| 379 EXPECT_TRUE(scheduler_->damaged); | 379 EXPECT_TRUE(scheduler_->damaged); |
| 380 EXPECT_FALSE(scheduler_->display_resized_); | 380 EXPECT_FALSE(scheduler_->display_resized_); |
| 381 EXPECT_FALSE(scheduler_->has_new_root_surface); | 381 EXPECT_FALSE(scheduler_->has_new_root_surface); |
| 382 | 382 |
| 383 scheduler_->swapped = false; | 383 scheduler_->swapped = false; |
| 384 display_->Resize(gfx::Size(100, 100)); | 384 display_->Resize(gfx::Size(100, 100)); |
| 385 EXPECT_TRUE(scheduler_->swapped); | 385 EXPECT_TRUE(scheduler_->swapped); |
| 386 EXPECT_EQ(5u, output_surface_->num_sent_frames()); | 386 EXPECT_EQ(5u, output_surface_->num_sent_frames()); |
| 387 | 387 |
| 388 // Latency info from previous frame should be sent now. | 388 // Latency info from previous frame should be sent now. |
| 389 EXPECT_EQ(1u, output_surface_->last_sent_frame()->latency_info.size()); | 389 EXPECT_EQ(1u, output_surface_->last_sent_frame()->latency_info.size()); |
| 390 } | 390 } |
| 391 | 391 |
| 392 { | 392 { |
| 393 // Surface that's damaged completely should be resized and swapped. | 393 // Surface that's damaged completely should be resized and swapped. |
| 394 pass = RenderPass::Create(); | 394 pass = RenderPass::Create(); |
| 395 pass->output_rect = gfx::Rect(0, 0, 99, 99); | 395 pass->output_rect = gfx::Rect(0, 0, 99, 99); |
| 396 pass->damage_rect = gfx::Rect(0, 0, 99, 99); | 396 pass->damage_rect = gfx::Rect(0, 0, 99, 99); |
| 397 pass->id = 1; | 397 pass->id = 1; |
| 398 | 398 |
| 399 pass_list.push_back(std::move(pass)); | 399 pass_list.push_back(std::move(pass)); |
| 400 scheduler_->ResetDamageForTest(); | 400 scheduler_->ResetDamageForTest(); |
| 401 SubmitCompositorFrame(&pass_list, local_frame_id); | 401 SubmitCompositorFrame(&pass_list, local_surface_id); |
| 402 EXPECT_TRUE(scheduler_->damaged); | 402 EXPECT_TRUE(scheduler_->damaged); |
| 403 EXPECT_FALSE(scheduler_->display_resized_); | 403 EXPECT_FALSE(scheduler_->display_resized_); |
| 404 EXPECT_FALSE(scheduler_->has_new_root_surface); | 404 EXPECT_FALSE(scheduler_->has_new_root_surface); |
| 405 | 405 |
| 406 scheduler_->swapped = false; | 406 scheduler_->swapped = false; |
| 407 display_->DrawAndSwap(); | 407 display_->DrawAndSwap(); |
| 408 EXPECT_TRUE(scheduler_->swapped); | 408 EXPECT_TRUE(scheduler_->swapped); |
| 409 EXPECT_EQ(6u, output_surface_->num_sent_frames()); | 409 EXPECT_EQ(6u, output_surface_->num_sent_frames()); |
| 410 EXPECT_EQ(gfx::Size(100, 100), | 410 EXPECT_EQ(gfx::Size(100, 100), |
| 411 software_output_device_->viewport_pixel_size()); | 411 software_output_device_->viewport_pixel_size()); |
| 412 EXPECT_EQ(gfx::Rect(0, 0, 100, 100), | 412 EXPECT_EQ(gfx::Rect(0, 0, 100, 100), |
| 413 software_output_device_->damage_rect()); | 413 software_output_device_->damage_rect()); |
| 414 EXPECT_EQ(0u, output_surface_->last_sent_frame()->latency_info.size()); | 414 EXPECT_EQ(0u, output_surface_->last_sent_frame()->latency_info.size()); |
| 415 } | 415 } |
| 416 } | 416 } |
| 417 | 417 |
| 418 class MockedContext : public TestWebGraphicsContext3D { | 418 class MockedContext : public TestWebGraphicsContext3D { |
| 419 public: | 419 public: |
| 420 MOCK_METHOD0(shallowFinishCHROMIUM, void()); | 420 MOCK_METHOD0(shallowFinishCHROMIUM, void()); |
| 421 }; | 421 }; |
| 422 | 422 |
| 423 TEST_F(DisplayTest, Finish) { | 423 TEST_F(DisplayTest, Finish) { |
| 424 LocalFrameId local_frame_id(id_allocator_.GenerateId()); | 424 LocalSurfaceId local_surface_id(id_allocator_.GenerateId()); |
| 425 | 425 |
| 426 RendererSettings settings; | 426 RendererSettings settings; |
| 427 settings.partial_swap_enabled = true; | 427 settings.partial_swap_enabled = true; |
| 428 settings.finish_rendering_on_resize = true; | 428 settings.finish_rendering_on_resize = true; |
| 429 | 429 |
| 430 std::unique_ptr<MockedContext> context(new MockedContext()); | 430 std::unique_ptr<MockedContext> context(new MockedContext()); |
| 431 MockedContext* context_ptr = context.get(); | 431 MockedContext* context_ptr = context.get(); |
| 432 EXPECT_CALL(*context_ptr, shallowFinishCHROMIUM()).Times(0); | 432 EXPECT_CALL(*context_ptr, shallowFinishCHROMIUM()).Times(0); |
| 433 | 433 |
| 434 SetUpDisplay(settings, std::move(context)); | 434 SetUpDisplay(settings, std::move(context)); |
| 435 | 435 |
| 436 StubDisplayClient client; | 436 StubDisplayClient client; |
| 437 display_->Initialize(&client, &manager_); | 437 display_->Initialize(&client, &manager_); |
| 438 | 438 |
| 439 display_->SetLocalFrameId(local_frame_id, 1.f); | 439 display_->SetLocalSurfaceId(local_surface_id, 1.f); |
| 440 | 440 |
| 441 display_->Resize(gfx::Size(100, 100)); | 441 display_->Resize(gfx::Size(100, 100)); |
| 442 | 442 |
| 443 { | 443 { |
| 444 RenderPassList pass_list; | 444 RenderPassList pass_list; |
| 445 std::unique_ptr<RenderPass> pass = RenderPass::Create(); | 445 std::unique_ptr<RenderPass> pass = RenderPass::Create(); |
| 446 pass->output_rect = gfx::Rect(0, 0, 100, 100); | 446 pass->output_rect = gfx::Rect(0, 0, 100, 100); |
| 447 pass->damage_rect = gfx::Rect(10, 10, 1, 1); | 447 pass->damage_rect = gfx::Rect(10, 10, 1, 1); |
| 448 pass->id = 1; | 448 pass->id = 1; |
| 449 pass_list.push_back(std::move(pass)); | 449 pass_list.push_back(std::move(pass)); |
| 450 | 450 |
| 451 SubmitCompositorFrame(&pass_list, local_frame_id); | 451 SubmitCompositorFrame(&pass_list, local_surface_id); |
| 452 } | 452 } |
| 453 | 453 |
| 454 display_->DrawAndSwap(); | 454 display_->DrawAndSwap(); |
| 455 | 455 |
| 456 // First resize and draw shouldn't finish. | 456 // First resize and draw shouldn't finish. |
| 457 testing::Mock::VerifyAndClearExpectations(context_ptr); | 457 testing::Mock::VerifyAndClearExpectations(context_ptr); |
| 458 | 458 |
| 459 EXPECT_CALL(*context_ptr, shallowFinishCHROMIUM()); | 459 EXPECT_CALL(*context_ptr, shallowFinishCHROMIUM()); |
| 460 display_->Resize(gfx::Size(150, 150)); | 460 display_->Resize(gfx::Size(150, 150)); |
| 461 testing::Mock::VerifyAndClearExpectations(context_ptr); | 461 testing::Mock::VerifyAndClearExpectations(context_ptr); |
| 462 | 462 |
| 463 // Another resize without a swap doesn't need to finish. | 463 // Another resize without a swap doesn't need to finish. |
| 464 EXPECT_CALL(*context_ptr, shallowFinishCHROMIUM()).Times(0); | 464 EXPECT_CALL(*context_ptr, shallowFinishCHROMIUM()).Times(0); |
| 465 display_->Resize(gfx::Size(200, 200)); | 465 display_->Resize(gfx::Size(200, 200)); |
| 466 testing::Mock::VerifyAndClearExpectations(context_ptr); | 466 testing::Mock::VerifyAndClearExpectations(context_ptr); |
| 467 | 467 |
| 468 EXPECT_CALL(*context_ptr, shallowFinishCHROMIUM()).Times(0); | 468 EXPECT_CALL(*context_ptr, shallowFinishCHROMIUM()).Times(0); |
| 469 { | 469 { |
| 470 RenderPassList pass_list; | 470 RenderPassList pass_list; |
| 471 std::unique_ptr<RenderPass> pass = RenderPass::Create(); | 471 std::unique_ptr<RenderPass> pass = RenderPass::Create(); |
| 472 pass->output_rect = gfx::Rect(0, 0, 200, 200); | 472 pass->output_rect = gfx::Rect(0, 0, 200, 200); |
| 473 pass->damage_rect = gfx::Rect(10, 10, 1, 1); | 473 pass->damage_rect = gfx::Rect(10, 10, 1, 1); |
| 474 pass->id = 1; | 474 pass->id = 1; |
| 475 pass_list.push_back(std::move(pass)); | 475 pass_list.push_back(std::move(pass)); |
| 476 | 476 |
| 477 SubmitCompositorFrame(&pass_list, local_frame_id); | 477 SubmitCompositorFrame(&pass_list, local_surface_id); |
| 478 } | 478 } |
| 479 | 479 |
| 480 display_->DrawAndSwap(); | 480 display_->DrawAndSwap(); |
| 481 | 481 |
| 482 testing::Mock::VerifyAndClearExpectations(context_ptr); | 482 testing::Mock::VerifyAndClearExpectations(context_ptr); |
| 483 | 483 |
| 484 EXPECT_CALL(*context_ptr, shallowFinishCHROMIUM()); | 484 EXPECT_CALL(*context_ptr, shallowFinishCHROMIUM()); |
| 485 display_->Resize(gfx::Size(250, 250)); | 485 display_->Resize(gfx::Size(250, 250)); |
| 486 testing::Mock::VerifyAndClearExpectations(context_ptr); | 486 testing::Mock::VerifyAndClearExpectations(context_ptr); |
| 487 } | 487 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 507 // Verify DidLoseOutputSurface callback is hooked up correctly. | 507 // Verify DidLoseOutputSurface callback is hooked up correctly. |
| 508 EXPECT_EQ(0, client.loss_count()); | 508 EXPECT_EQ(0, client.loss_count()); |
| 509 output_surface_->context_provider()->ContextGL()->LoseContextCHROMIUM( | 509 output_surface_->context_provider()->ContextGL()->LoseContextCHROMIUM( |
| 510 GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB); | 510 GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB); |
| 511 output_surface_->context_provider()->ContextGL()->Flush(); | 511 output_surface_->context_provider()->ContextGL()->Flush(); |
| 512 EXPECT_EQ(1, client.loss_count()); | 512 EXPECT_EQ(1, client.loss_count()); |
| 513 } | 513 } |
| 514 | 514 |
| 515 } // namespace | 515 } // namespace |
| 516 } // namespace cc | 516 } // namespace cc |
| OLD | NEW |