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

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

Issue 2167713002: cc: Delete SurfaceDrawStatus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Scott's comments Created 4 years, 5 months 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/test/test_delegating_output_surface.h » ('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 "cc/surfaces/surface_factory.h" 5 #include "cc/surfaces/surface_factory.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <utility> 10 #include <utility>
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 CompositorFrame frame; 429 CompositorFrame frame;
430 frame.delegated_frame_data.reset(new DelegatedFrameData); 430 frame.delegated_frame_data.reset(new DelegatedFrameData);
431 431
432 factory_->SubmitCompositorFrame(surface_id, std::move(frame), 432 factory_->SubmitCompositorFrame(surface_id, std::move(frame),
433 SurfaceFactory::DrawCallback()); 433 SurfaceFactory::DrawCallback());
434 EXPECT_EQ(2, surface->frame_index()); 434 EXPECT_EQ(2, surface->frame_index());
435 factory_->Destroy(surface_id); 435 factory_->Destroy(surface_id);
436 } 436 }
437 437
438 void CreateSurfaceDrawCallback(SurfaceFactory* factory, 438 void CreateSurfaceDrawCallback(SurfaceFactory* factory,
439 uint32_t* execute_count, 439 uint32_t* execute_count) {
440 SurfaceDrawStatus* result,
441 SurfaceDrawStatus drawn) {
442 SurfaceId new_id(kArbitraryClientId, 7, 0); 440 SurfaceId new_id(kArbitraryClientId, 7, 0);
443 factory->Create(new_id); 441 factory->Create(new_id);
444 factory->Destroy(new_id); 442 factory->Destroy(new_id);
445 *execute_count += 1; 443 *execute_count += 1;
446 *result = drawn;
447 } 444 }
448 445
449 TEST_F(SurfaceFactoryTest, AddDuringDestroy) { 446 TEST_F(SurfaceFactoryTest, AddDuringDestroy) {
450 SurfaceId surface_id(kArbitraryClientId, 6, 0); 447 SurfaceId surface_id(kArbitraryClientId, 6, 0);
451 factory_->Create(surface_id); 448 factory_->Create(surface_id);
452 CompositorFrame frame; 449 CompositorFrame frame;
453 frame.delegated_frame_data.reset(new DelegatedFrameData); 450 frame.delegated_frame_data.reset(new DelegatedFrameData);
454 451
455 uint32_t execute_count = 0; 452 uint32_t execute_count = 0;
456 SurfaceDrawStatus drawn = SurfaceDrawStatus::DRAW_SKIPPED;
457 factory_->SubmitCompositorFrame( 453 factory_->SubmitCompositorFrame(
458 surface_id, std::move(frame), 454 surface_id, std::move(frame),
459 base::Bind(&CreateSurfaceDrawCallback, base::Unretained(factory_.get()), 455 base::Bind(&CreateSurfaceDrawCallback, base::Unretained(factory_.get()),
460 &execute_count, &drawn)); 456 &execute_count));
461 EXPECT_EQ(0u, execute_count); 457 EXPECT_EQ(0u, execute_count);
462 factory_->Destroy(surface_id); 458 factory_->Destroy(surface_id);
463 EXPECT_EQ(1u, execute_count); 459 EXPECT_EQ(1u, execute_count);
464 EXPECT_EQ(SurfaceDrawStatus::DRAW_SKIPPED, drawn);
465 } 460 }
466 461
467 void DrawCallback(uint32_t* execute_count, 462 void DrawCallback(uint32_t* execute_count) {
468 SurfaceDrawStatus* result,
469 SurfaceDrawStatus drawn) {
470 *execute_count += 1; 463 *execute_count += 1;
471 *result = drawn;
472 } 464 }
473 465
474 // Tests doing a DestroyAll before shutting down the factory; 466 // Tests doing a DestroyAll before shutting down the factory;
475 TEST_F(SurfaceFactoryTest, DestroyAll) { 467 TEST_F(SurfaceFactoryTest, DestroyAll) {
476 SurfaceId id(kArbitraryClientId, 7, 0); 468 SurfaceId id(kArbitraryClientId, 7, 0);
477 factory_->Create(id); 469 factory_->Create(id);
478 470
479 std::unique_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); 471 std::unique_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData);
480 TransferableResource resource; 472 TransferableResource resource;
481 resource.id = 1; 473 resource.id = 1;
482 resource.mailbox_holder.texture_target = GL_TEXTURE_2D; 474 resource.mailbox_holder.texture_target = GL_TEXTURE_2D;
483 frame_data->resource_list.push_back(resource); 475 frame_data->resource_list.push_back(resource);
484 CompositorFrame frame; 476 CompositorFrame frame;
485 frame.delegated_frame_data = std::move(frame_data); 477 frame.delegated_frame_data = std::move(frame_data);
486 uint32_t execute_count = 0; 478 uint32_t execute_count = 0;
487 SurfaceDrawStatus drawn = SurfaceDrawStatus::DRAW_SKIPPED; 479 factory_->SubmitCompositorFrame(id, std::move(frame),
488 480 base::Bind(&DrawCallback, &execute_count));
489 factory_->SubmitCompositorFrame(
490 id, std::move(frame), base::Bind(&DrawCallback, &execute_count, &drawn));
491 481
492 surface_id_ = SurfaceId(); 482 surface_id_ = SurfaceId();
493 factory_->DestroyAll(); 483 factory_->DestroyAll();
494 EXPECT_EQ(1u, execute_count); 484 EXPECT_EQ(1u, execute_count);
495 EXPECT_EQ(SurfaceDrawStatus::DRAW_SKIPPED, drawn);
496 } 485 }
497 486
498 TEST_F(SurfaceFactoryTest, DestroySequence) { 487 TEST_F(SurfaceFactoryTest, DestroySequence) {
499 SurfaceId id2(kArbitraryClientId, 5, 0); 488 SurfaceId id2(kArbitraryClientId, 5, 0);
500 factory_->Create(id2); 489 factory_->Create(id2);
501 490
502 manager_.RegisterSurfaceClientId(0); 491 manager_.RegisterSurfaceClientId(0);
503 492
504 // Check that waiting before the sequence is satisfied works. 493 // Check that waiting before the sequence is satisfied works.
505 manager_.GetSurfaceForId(id2) 494 manager_.GetSurfaceForId(id2)
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 638
650 factory_->Destroy(surface_id_); 639 factory_->Destroy(surface_id_);
651 surface_id_ = SurfaceId(); 640 surface_id_ = SurfaceId();
652 EXPECT_TRUE(called1); 641 EXPECT_TRUE(called1);
653 EXPECT_TRUE(called2); 642 EXPECT_TRUE(called2);
654 EXPECT_TRUE(called3); 643 EXPECT_TRUE(called3);
655 } 644 }
656 645
657 } // namespace 646 } // namespace
658 } // namespace cc 647 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface_factory.cc ('k') | cc/test/test_delegating_output_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698