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

Side by Side Diff: gpu/command_buffer/client/gles2_implementation_unittest.cc

Issue 2257533006: Free worker context resources on idle. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fix-cleanup2
Patch Set: fixes Created 4 years, 4 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // Tests for GLES2Implementation. 5 // Tests for GLES2Implementation.
6 6
7 #include "gpu/command_buffer/client/gles2_implementation.h" 7 #include "gpu/command_buffer/client/gles2_implementation.h"
8 8
9 #include <GLES2/gl2.h> 9 #include <GLES2/gl2.h>
10 #include <GLES2/gl2ext.h> 10 #include <GLES2/gl2ext.h>
11 #include <GLES2/gl2extchromium.h> 11 #include <GLES2/gl2extchromium.h>
12 #include <GLES3/gl3.h> 12 #include <GLES3/gl3.h>
13 13
14 #include <stddef.h> 14 #include <stddef.h>
15 #include <stdint.h> 15 #include <stdint.h>
16 16
17 #include <memory> 17 #include <memory>
18 18
19 #include "base/bind.h"
19 #include "base/compiler_specific.h" 20 #include "base/compiler_specific.h"
20 #include "base/memory/ptr_util.h" 21 #include "base/memory/ptr_util.h"
22 #include "base/test/test_mock_time_task_runner.h"
23 #include "base/threading/thread_task_runner_handle.h"
21 #include "gpu/command_buffer/client/client_test_helper.h" 24 #include "gpu/command_buffer/client/client_test_helper.h"
22 #include "gpu/command_buffer/client/gles2_cmd_helper.h" 25 #include "gpu/command_buffer/client/gles2_cmd_helper.h"
23 #include "gpu/command_buffer/client/program_info_manager.h" 26 #include "gpu/command_buffer/client/program_info_manager.h"
24 #include "gpu/command_buffer/client/query_tracker.h" 27 #include "gpu/command_buffer/client/query_tracker.h"
25 #include "gpu/command_buffer/client/ring_buffer.h" 28 #include "gpu/command_buffer/client/ring_buffer.h"
26 #include "gpu/command_buffer/client/shared_memory_limits.h" 29 #include "gpu/command_buffer/client/shared_memory_limits.h"
27 #include "gpu/command_buffer/client/transfer_buffer.h" 30 #include "gpu/command_buffer/client/transfer_buffer.h"
28 #include "gpu/command_buffer/common/command_buffer.h" 31 #include "gpu/command_buffer/common/command_buffer.h"
29 #include "gpu/command_buffer/common/sync_token.h" 32 #include "gpu/command_buffer/common/sync_token.h"
30 #include "testing/gmock/include/gmock/gmock.h" 33 #include "testing/gmock/include/gmock/gmock.h"
(...skipping 4589 matching lines...) Expand 10 before | Expand all | Expand 10 after
4620 auto visibility_0 = gl_->ClientBecameVisible(); 4623 auto visibility_0 = gl_->ClientBecameVisible();
4621 auto visibility_1 = gl_->ClientBecameVisible(); 4624 auto visibility_1 = gl_->ClientBecameVisible();
4622 EXPECT_TRUE(gl_->AnyClientsVisible()); 4625 EXPECT_TRUE(gl_->AnyClientsVisible());
4623 gl_->ClientBecameNotVisible(std::move(visibility_0)); 4626 gl_->ClientBecameNotVisible(std::move(visibility_0));
4624 EXPECT_TRUE(gl_->AnyClientsVisible()); 4627 EXPECT_TRUE(gl_->AnyClientsVisible());
4625 gl_->ClientBecameNotVisible(std::move(visibility_1)); 4628 gl_->ClientBecameNotVisible(std::move(visibility_1));
4626 EXPECT_FALSE(gl_->AnyClientsVisible()); 4629 EXPECT_FALSE(gl_->AnyClientsVisible());
4627 } 4630 }
4628 } 4631 }
4629 4632
4633 TEST_F(GLES2ImplementationTest, ClientBusyBasic) {
4634 auto runner = make_scoped_refptr(new base::TestMockTimeTaskRunner());
4635 base::ThreadTaskRunnerHandle handle(runner);
4636
4637 bool signaled = false;
4638 gl_->SetIdleCallback(
4639 base::Bind([](bool* signaled) { *signaled = true; }, &signaled), runner);
4640 auto busy = gl_->ClientBecameBusy();
4641 gl_->ClientBecameNotBusy(std::move(busy));
4642
4643 runner->FastForwardBy(base::TimeDelta::FromSeconds(5));
4644 EXPECT_TRUE(signaled);
4645 }
4646
4647 TEST_F(GLES2ImplementationTest, ClientBusyCancelled) {
4648 auto runner = make_scoped_refptr(new base::TestMockTimeTaskRunner());
4649 base::ThreadTaskRunnerHandle handle(runner);
4650
4651 bool signaled = false;
4652 gl_->SetIdleCallback(
4653 base::Bind([](bool* signaled) { *signaled = true; }, &signaled), runner);
4654 auto busy = gl_->ClientBecameBusy();
4655
4656 // This will trigger the idle callback to start counting down.
4657 gl_->ClientBecameNotBusy(std::move(busy));
4658
4659 // Immediately take another busy lock to stop the countdown.
4660 busy = gl_->ClientBecameBusy();
4661
4662 // Advance time and ensure that our callback was cancelled (does not run).
4663 runner->FastForwardBy(base::TimeDelta::FromSeconds(5));
4664 EXPECT_FALSE(signaled);
4665
4666 // Release our busy lock, and let the idle callback run.
4667 gl_->ClientBecameNotBusy(std::move(busy));
4668
4669 runner->FastForwardBy(base::TimeDelta::FromSeconds(5));
4670 EXPECT_TRUE(signaled);
4671 }
4672
4630 #include "base/macros.h" 4673 #include "base/macros.h"
4631 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" 4674 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h"
4632 4675
4633 } // namespace gles2 4676 } // namespace gles2
4634 } // namespace gpu 4677 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698