Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: cc/surfaces/surface_factory_unittest.cc

Issue 1455023002: cc: Replace Pass() with std::move() in some subdirs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pass-cc
Patch Set: pass-cc2: . Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/surfaces/surface_factory.cc ('k') | cc/surfaces/surface_hittest_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/bind.h" 5 #include "base/bind.h"
6 #include "cc/output/compositor_frame.h" 6 #include "cc/output/compositor_frame.h"
7 #include "cc/output/delegated_frame_data.h" 7 #include "cc/output/delegated_frame_data.h"
8 #include "cc/resources/resource_provider.h" 8 #include "cc/resources/resource_provider.h"
9 #include "cc/surfaces/surface.h" 9 #include "cc/surfaces/surface.h"
10 #include "cc/surfaces/surface_factory.h" 10 #include "cc/surfaces/surface_factory.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 void SubmitCompositorFrameWithResources(ResourceId* resource_ids, 62 void SubmitCompositorFrameWithResources(ResourceId* resource_ids,
63 size_t num_resource_ids) { 63 size_t num_resource_ids) {
64 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); 64 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData);
65 for (size_t i = 0u; i < num_resource_ids; ++i) { 65 for (size_t i = 0u; i < num_resource_ids; ++i) {
66 TransferableResource resource; 66 TransferableResource resource;
67 resource.id = resource_ids[i]; 67 resource.id = resource_ids[i];
68 resource.mailbox_holder.texture_target = GL_TEXTURE_2D; 68 resource.mailbox_holder.texture_target = GL_TEXTURE_2D;
69 frame_data->resource_list.push_back(resource); 69 frame_data->resource_list.push_back(resource);
70 } 70 }
71 scoped_ptr<CompositorFrame> frame(new CompositorFrame); 71 scoped_ptr<CompositorFrame> frame(new CompositorFrame);
72 frame->delegated_frame_data = frame_data.Pass(); 72 frame->delegated_frame_data = std::move(frame_data);
73 factory_->SubmitCompositorFrame(surface_id_, frame.Pass(), 73 factory_->SubmitCompositorFrame(surface_id_, std::move(frame),
74 SurfaceFactory::DrawCallback()); 74 SurfaceFactory::DrawCallback());
75 } 75 }
76 76
77 void UnrefResources(ResourceId* ids_to_unref, 77 void UnrefResources(ResourceId* ids_to_unref,
78 int* counts_to_unref, 78 int* counts_to_unref,
79 size_t num_ids_to_unref) { 79 size_t num_ids_to_unref) {
80 ReturnedResourceArray unref_array; 80 ReturnedResourceArray unref_array;
81 for (size_t i = 0; i < num_ids_to_unref; ++i) { 81 for (size_t i = 0; i < num_ids_to_unref; ++i) {
82 ReturnedResource resource; 82 ReturnedResource resource;
83 resource.id = ids_to_unref[i]; 83 resource.id = ids_to_unref[i];
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 382
383 TEST_F(SurfaceFactoryTest, BlankNoIndexIncrement) { 383 TEST_F(SurfaceFactoryTest, BlankNoIndexIncrement) {
384 SurfaceId surface_id(6); 384 SurfaceId surface_id(6);
385 factory_->Create(surface_id); 385 factory_->Create(surface_id);
386 Surface* surface = manager_.GetSurfaceForId(surface_id); 386 Surface* surface = manager_.GetSurfaceForId(surface_id);
387 ASSERT_NE(nullptr, surface); 387 ASSERT_NE(nullptr, surface);
388 EXPECT_EQ(2, surface->frame_index()); 388 EXPECT_EQ(2, surface->frame_index());
389 scoped_ptr<CompositorFrame> frame(new CompositorFrame); 389 scoped_ptr<CompositorFrame> frame(new CompositorFrame);
390 frame->delegated_frame_data.reset(new DelegatedFrameData); 390 frame->delegated_frame_data.reset(new DelegatedFrameData);
391 391
392 factory_->SubmitCompositorFrame(surface_id, frame.Pass(), 392 factory_->SubmitCompositorFrame(surface_id, std::move(frame),
393 SurfaceFactory::DrawCallback()); 393 SurfaceFactory::DrawCallback());
394 EXPECT_EQ(2, surface->frame_index()); 394 EXPECT_EQ(2, surface->frame_index());
395 factory_->Destroy(surface_id); 395 factory_->Destroy(surface_id);
396 } 396 }
397 397
398 void DrawCallback(uint32* execute_count, 398 void DrawCallback(uint32* execute_count,
399 SurfaceDrawStatus* result, 399 SurfaceDrawStatus* result,
400 SurfaceDrawStatus drawn) { 400 SurfaceDrawStatus drawn) {
401 *execute_count += 1; 401 *execute_count += 1;
402 *result = drawn; 402 *result = drawn;
403 } 403 }
404 404
405 // Tests doing a DestroyAll before shutting down the factory; 405 // Tests doing a DestroyAll before shutting down the factory;
406 TEST_F(SurfaceFactoryTest, DestroyAll) { 406 TEST_F(SurfaceFactoryTest, DestroyAll) {
407 SurfaceId id(7); 407 SurfaceId id(7);
408 factory_->Create(id); 408 factory_->Create(id);
409 409
410 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); 410 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData);
411 TransferableResource resource; 411 TransferableResource resource;
412 resource.id = 1; 412 resource.id = 1;
413 resource.mailbox_holder.texture_target = GL_TEXTURE_2D; 413 resource.mailbox_holder.texture_target = GL_TEXTURE_2D;
414 frame_data->resource_list.push_back(resource); 414 frame_data->resource_list.push_back(resource);
415 scoped_ptr<CompositorFrame> frame(new CompositorFrame); 415 scoped_ptr<CompositorFrame> frame(new CompositorFrame);
416 frame->delegated_frame_data = frame_data.Pass(); 416 frame->delegated_frame_data = std::move(frame_data);
417 uint32 execute_count = 0; 417 uint32 execute_count = 0;
418 SurfaceDrawStatus drawn = SurfaceDrawStatus::DRAW_SKIPPED; 418 SurfaceDrawStatus drawn = SurfaceDrawStatus::DRAW_SKIPPED;
419 419
420 factory_->SubmitCompositorFrame( 420 factory_->SubmitCompositorFrame(
421 id, frame.Pass(), base::Bind(&DrawCallback, &execute_count, &drawn)); 421 id, std::move(frame), base::Bind(&DrawCallback, &execute_count, &drawn));
422 422
423 surface_id_ = SurfaceId(); 423 surface_id_ = SurfaceId();
424 factory_->DestroyAll(); 424 factory_->DestroyAll();
425 EXPECT_EQ(1u, execute_count); 425 EXPECT_EQ(1u, execute_count);
426 EXPECT_EQ(SurfaceDrawStatus::DRAW_SKIPPED, drawn); 426 EXPECT_EQ(SurfaceDrawStatus::DRAW_SKIPPED, drawn);
427 } 427 }
428 428
429 TEST_F(SurfaceFactoryTest, DestroySequence) { 429 TEST_F(SurfaceFactoryTest, DestroySequence) {
430 SurfaceId id2(5); 430 SurfaceId id2(5);
431 factory_->Create(id2); 431 factory_->Create(id2);
432 432
433 manager_.RegisterSurfaceIdNamespace(0); 433 manager_.RegisterSurfaceIdNamespace(0);
434 434
435 // Check that waiting before the sequence is satisfied works. 435 // Check that waiting before the sequence is satisfied works.
436 manager_.GetSurfaceForId(id2) 436 manager_.GetSurfaceForId(id2)
437 ->AddDestructionDependency(SurfaceSequence(0, 4)); 437 ->AddDestructionDependency(SurfaceSequence(0, 4));
438 factory_->Destroy(id2); 438 factory_->Destroy(id2);
439 439
440 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); 440 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData);
441 scoped_ptr<CompositorFrame> frame(new CompositorFrame); 441 scoped_ptr<CompositorFrame> frame(new CompositorFrame);
442 frame->metadata.satisfies_sequences.push_back(6); 442 frame->metadata.satisfies_sequences.push_back(6);
443 frame->metadata.satisfies_sequences.push_back(4); 443 frame->metadata.satisfies_sequences.push_back(4);
444 frame->delegated_frame_data = frame_data.Pass(); 444 frame->delegated_frame_data = std::move(frame_data);
445 DCHECK(manager_.GetSurfaceForId(id2)); 445 DCHECK(manager_.GetSurfaceForId(id2));
446 factory_->SubmitCompositorFrame(surface_id_, frame.Pass(), 446 factory_->SubmitCompositorFrame(surface_id_, std::move(frame),
447 SurfaceFactory::DrawCallback()); 447 SurfaceFactory::DrawCallback());
448 DCHECK(!manager_.GetSurfaceForId(id2)); 448 DCHECK(!manager_.GetSurfaceForId(id2));
449 449
450 // Check that waiting after the sequence is satisfied works. 450 // Check that waiting after the sequence is satisfied works.
451 factory_->Create(id2); 451 factory_->Create(id2);
452 DCHECK(manager_.GetSurfaceForId(id2)); 452 DCHECK(manager_.GetSurfaceForId(id2));
453 manager_.GetSurfaceForId(id2) 453 manager_.GetSurfaceForId(id2)
454 ->AddDestructionDependency(SurfaceSequence(0, 6)); 454 ->AddDestructionDependency(SurfaceSequence(0, 6));
455 factory_->Destroy(id2); 455 factory_->Destroy(id2);
456 DCHECK(!manager_.GetSurfaceForId(id2)); 456 DCHECK(!manager_.GetSurfaceForId(id2));
(...skipping 28 matching lines...) Expand all
485 manager_.RegisterSurfaceIdNamespace(0); 485 manager_.RegisterSurfaceIdNamespace(0);
486 486
487 manager_.GetSurfaceForId(id2) 487 manager_.GetSurfaceForId(id2)
488 ->AddDestructionDependency(SurfaceSequence(0, 4)); 488 ->AddDestructionDependency(SurfaceSequence(0, 4));
489 489
490 // Give id2 a frame that references surface_id_. 490 // Give id2 a frame that references surface_id_.
491 { 491 {
492 scoped_ptr<RenderPass> render_pass(RenderPass::Create()); 492 scoped_ptr<RenderPass> render_pass(RenderPass::Create());
493 render_pass->referenced_surfaces.push_back(surface_id_); 493 render_pass->referenced_surfaces.push_back(surface_id_);
494 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); 494 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData);
495 frame_data->render_pass_list.push_back(render_pass.Pass()); 495 frame_data->render_pass_list.push_back(std::move(render_pass));
496 scoped_ptr<CompositorFrame> frame(new CompositorFrame); 496 scoped_ptr<CompositorFrame> frame(new CompositorFrame);
497 frame->delegated_frame_data = frame_data.Pass(); 497 frame->delegated_frame_data = std::move(frame_data);
498 factory_->SubmitCompositorFrame(id2, frame.Pass(), 498 factory_->SubmitCompositorFrame(id2, std::move(frame),
499 SurfaceFactory::DrawCallback()); 499 SurfaceFactory::DrawCallback());
500 } 500 }
501 factory_->Destroy(id2); 501 factory_->Destroy(id2);
502 502
503 // Give surface_id_ a frame that references id2. 503 // Give surface_id_ a frame that references id2.
504 { 504 {
505 scoped_ptr<RenderPass> render_pass(RenderPass::Create()); 505 scoped_ptr<RenderPass> render_pass(RenderPass::Create());
506 render_pass->referenced_surfaces.push_back(id2); 506 render_pass->referenced_surfaces.push_back(id2);
507 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); 507 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData);
508 frame_data->render_pass_list.push_back(render_pass.Pass()); 508 frame_data->render_pass_list.push_back(std::move(render_pass));
509 scoped_ptr<CompositorFrame> frame(new CompositorFrame); 509 scoped_ptr<CompositorFrame> frame(new CompositorFrame);
510 frame->delegated_frame_data = frame_data.Pass(); 510 frame->delegated_frame_data = std::move(frame_data);
511 factory_->SubmitCompositorFrame(surface_id_, frame.Pass(), 511 factory_->SubmitCompositorFrame(surface_id_, std::move(frame),
512 SurfaceFactory::DrawCallback()); 512 SurfaceFactory::DrawCallback());
513 } 513 }
514 factory_->Destroy(surface_id_); 514 factory_->Destroy(surface_id_);
515 EXPECT_TRUE(manager_.GetSurfaceForId(id2)); 515 EXPECT_TRUE(manager_.GetSurfaceForId(id2));
516 // surface_id_ should be retained by reference from id2. 516 // surface_id_ should be retained by reference from id2.
517 EXPECT_TRUE(manager_.GetSurfaceForId(surface_id_)); 517 EXPECT_TRUE(manager_.GetSurfaceForId(surface_id_));
518 518
519 // Satisfy last destruction dependency for id2. 519 // Satisfy last destruction dependency for id2.
520 std::vector<uint32_t> to_satisfy; 520 std::vector<uint32_t> to_satisfy;
521 to_satisfy.push_back(4); 521 to_satisfy.push_back(4);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 surface_id_ = SurfaceId(); 555 surface_id_ = SurfaceId();
556 factory_->DestroyAll(); 556 factory_->DestroyAll();
557 557
558 EXPECT_EQ(&bfs, client_.begin_frame_source()); 558 EXPECT_EQ(&bfs, client_.begin_frame_source());
559 factory_.reset(); 559 factory_.reset();
560 EXPECT_EQ(nullptr, client_.begin_frame_source()); 560 EXPECT_EQ(nullptr, client_.begin_frame_source());
561 } 561 }
562 562
563 } // namespace 563 } // namespace
564 } // namespace cc 564 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface_factory.cc ('k') | cc/surfaces/surface_hittest_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698