OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/output/texture_mailbox_deleter.h" | 5 #include "cc/output/texture_mailbox_deleter.h" |
6 | 6 |
7 #include "base/single_thread_task_runner.h" | 7 #include "base/single_thread_task_runner.h" |
8 #include "base/thread_task_runner_handle.h" | 8 #include "base/thread_task_runner_handle.h" |
9 #include "cc/resources/single_release_callback.h" | 9 #include "cc/resources/single_release_callback.h" |
10 #include "cc/test/test_context_provider.h" | 10 #include "cc/test/test_context_provider.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures()); | 34 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures()); |
35 | 35 |
36 // When the deleter is destroyed, it immediately drops its ref on the | 36 // When the deleter is destroyed, it immediately drops its ref on the |
37 // ContextProvider, and deletes the texture. | 37 // ContextProvider, and deletes the texture. |
38 deleter = nullptr; | 38 deleter = nullptr; |
39 EXPECT_TRUE(context_provider->HasOneRef()); | 39 EXPECT_TRUE(context_provider->HasOneRef()); |
40 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures()); | 40 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures()); |
41 | 41 |
42 // Run the scoped release callback before destroying it, but it won't do | 42 // Run the scoped release callback before destroying it, but it won't do |
43 // anything. | 43 // anything. |
44 cb->Run(0, false); | 44 cb->Run(gpu::SyncToken(), false); |
45 } | 45 } |
46 | 46 |
47 TEST(TextureMailboxDeleterTest, NullTaskRunner) { | 47 TEST(TextureMailboxDeleterTest, NullTaskRunner) { |
48 scoped_ptr<TextureMailboxDeleter> deleter(new TextureMailboxDeleter(nullptr)); | 48 scoped_ptr<TextureMailboxDeleter> deleter(new TextureMailboxDeleter(nullptr)); |
49 | 49 |
50 scoped_refptr<TestContextProvider> context_provider = | 50 scoped_refptr<TestContextProvider> context_provider = |
51 TestContextProvider::Create(); | 51 TestContextProvider::Create(); |
52 context_provider->BindToCurrentThread(); | 52 context_provider->BindToCurrentThread(); |
53 | 53 |
54 GLuint texture_id = 0u; | 54 GLuint texture_id = 0u; |
55 context_provider->ContextGL()->GenTextures(1, &texture_id); | 55 context_provider->ContextGL()->GenTextures(1, &texture_id); |
56 | 56 |
57 EXPECT_TRUE(context_provider->HasOneRef()); | 57 EXPECT_TRUE(context_provider->HasOneRef()); |
58 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures()); | 58 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures()); |
59 | 59 |
60 scoped_ptr<SingleReleaseCallback> cb = | 60 scoped_ptr<SingleReleaseCallback> cb = |
61 deleter->GetReleaseCallback(context_provider, texture_id); | 61 deleter->GetReleaseCallback(context_provider, texture_id); |
62 EXPECT_FALSE(context_provider->HasOneRef()); | 62 EXPECT_FALSE(context_provider->HasOneRef()); |
63 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures()); | 63 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures()); |
64 | 64 |
65 cb->Run(0, false); | 65 cb->Run(gpu::SyncToken(), false); |
66 | 66 |
67 // With no task runner the callback will immediately drops its ref on the | 67 // With no task runner the callback will immediately drops its ref on the |
68 // ContextProvider and delete the texture. | 68 // ContextProvider and delete the texture. |
69 EXPECT_TRUE(context_provider->HasOneRef()); | 69 EXPECT_TRUE(context_provider->HasOneRef()); |
70 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures()); | 70 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures()); |
71 } | 71 } |
72 | 72 |
73 } // namespace | 73 } // namespace |
74 } // namespace cc | 74 } // namespace cc |
OLD | NEW |