Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #include "cc/resources/resource_provider.h" | 5 #include "cc/resources/resource_provider.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 2630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2641 uint32 release_sync_point = 0; | 2641 uint32 release_sync_point = 0; |
| 2642 bool lost_resource = false; | 2642 bool lost_resource = false; |
| 2643 BlockingTaskRunner* main_thread_task_runner = NULL; | 2643 BlockingTaskRunner* main_thread_task_runner = NULL; |
| 2644 scoped_ptr<SingleReleaseCallbackImpl> callback = | 2644 scoped_ptr<SingleReleaseCallbackImpl> callback = |
| 2645 SingleReleaseCallbackImpl::Create(base::Bind(&ReleaseCallback, | 2645 SingleReleaseCallbackImpl::Create(base::Bind(&ReleaseCallback, |
| 2646 &release_sync_point, | 2646 &release_sync_point, |
| 2647 &lost_resource, | 2647 &lost_resource, |
| 2648 &main_thread_task_runner)); | 2648 &main_thread_task_runner)); |
| 2649 | 2649 |
| 2650 TextureMailbox mailbox(gpu_mailbox, target, sync_point); | 2650 TextureMailbox mailbox(gpu_mailbox, target, sync_point); |
| 2651 mailbox.set_nearest_neighbor(true); | |
| 2651 | 2652 |
| 2652 ResourceProvider::ResourceId id = | 2653 ResourceProvider::ResourceId id = |
| 2653 resource_provider->CreateResourceFromTextureMailbox( | 2654 resource_provider->CreateResourceFromTextureMailbox( |
| 2654 mailbox, callback.Pass()); | 2655 mailbox, callback.Pass()); |
| 2655 EXPECT_NE(0u, id); | 2656 EXPECT_NE(0u, id); |
| 2656 | 2657 |
| 2657 Mock::VerifyAndClearExpectations(context); | 2658 Mock::VerifyAndClearExpectations(context); |
| 2658 | 2659 |
| 2659 { | 2660 { |
| 2660 // Mailbox sync point WaitSyncPoint before using the texture. | 2661 // Mailbox sync point WaitSyncPoint before using the texture. |
| 2661 EXPECT_CALL(*context, waitSyncPoint(sync_point)); | 2662 EXPECT_CALL(*context, waitSyncPoint(sync_point)); |
| 2662 resource_provider->WaitSyncPointIfNeeded(id); | 2663 resource_provider->WaitSyncPointIfNeeded(id); |
| 2663 Mock::VerifyAndClearExpectations(context); | 2664 Mock::VerifyAndClearExpectations(context); |
| 2664 | 2665 |
| 2665 // Using the texture does a consume of the mailbox. | 2666 // Using the texture does a consume of the mailbox. |
| 2666 EXPECT_CALL(*context, bindTexture(target, texture_id)); | 2667 EXPECT_CALL(*context, bindTexture(target, texture_id)).Times(2); |
| 2667 EXPECT_CALL(*context, consumeTextureCHROMIUM(target, _)); | 2668 EXPECT_CALL(*context, consumeTextureCHROMIUM(target, _)); |
| 2668 | 2669 |
| 2669 EXPECT_CALL(*context, insertSyncPoint()).Times(0); | 2670 EXPECT_CALL(*context, insertSyncPoint()).Times(0); |
| 2670 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); | 2671 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); |
| 2671 | 2672 |
| 2672 ResourceProvider::ScopedReadLockGL lock(resource_provider.get(), id); | 2673 // The sampler will reset these because |nearest_neighbor| was set on the |
|
danakj
2014/11/17 17:39:41
It would be nice to test 2 TextureMailboxes, one w
jackhou1
2014/11/17 22:46:35
Refactored this test in a similar way to ResourceP
| |
| 2674 // mailbox. | |
| 2675 EXPECT_CALL(*context, | |
| 2676 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); | |
| 2677 EXPECT_CALL(*context, | |
| 2678 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); | |
| 2679 | |
| 2680 ResourceProvider::ScopedSamplerGL lock( | |
| 2681 resource_provider.get(), id, GL_LINEAR); | |
| 2673 Mock::VerifyAndClearExpectations(context); | 2682 Mock::VerifyAndClearExpectations(context); |
| 2674 | 2683 |
| 2675 // When done with it, a sync point should be inserted, but no produce is | 2684 // When done with it, a sync point should be inserted, but no produce is |
| 2676 // necessary. | 2685 // necessary. |
| 2677 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); | 2686 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); |
| 2678 EXPECT_CALL(*context, insertSyncPoint()); | 2687 EXPECT_CALL(*context, insertSyncPoint()); |
| 2679 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); | 2688 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); |
| 2680 | 2689 |
| 2681 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); | 2690 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); |
| 2682 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0); | 2691 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0); |
| (...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3639 resource_provider->AllocateForTesting(id); | 3648 resource_provider->AllocateForTesting(id); |
| 3640 Mock::VerifyAndClearExpectations(context); | 3649 Mock::VerifyAndClearExpectations(context); |
| 3641 | 3650 |
| 3642 DCHECK_EQ(10u, context->PeekTextureId()); | 3651 DCHECK_EQ(10u, context->PeekTextureId()); |
| 3643 resource_provider->DeleteResource(id); | 3652 resource_provider->DeleteResource(id); |
| 3644 } | 3653 } |
| 3645 } | 3654 } |
| 3646 | 3655 |
| 3647 } // namespace | 3656 } // namespace |
| 3648 } // namespace cc | 3657 } // namespace cc |
| OLD | NEW |