| 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 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 using testing::Mock; | 30 using testing::Mock; |
| 31 using testing::NiceMock; | 31 using testing::NiceMock; |
| 32 using testing::Return; | 32 using testing::Return; |
| 33 using testing::SetArgPointee; | 33 using testing::SetArgPointee; |
| 34 using testing::StrictMock; | 34 using testing::StrictMock; |
| 35 using testing::_; | 35 using testing::_; |
| 36 | 36 |
| 37 namespace cc { | 37 namespace cc { |
| 38 namespace { | 38 namespace { |
| 39 | 39 |
| 40 static void EmptyReleaseCallback(unsigned sync_point, bool lost_resource) {} | 40 static void EmptyReleaseCallback(uint32 sync_point, bool lost_resource) {} |
| 41 | 41 |
| 42 static void SharedMemoryReleaseCallback(scoped_ptr<base::SharedMemory> memory, | 42 static void SharedMemoryReleaseCallback(scoped_ptr<base::SharedMemory> memory, |
| 43 unsigned sync_point, | 43 uint32 sync_point, |
| 44 bool lost_resource) {} | 44 bool lost_resource) {} |
| 45 | 45 |
| 46 static void ReleaseTextureMailbox(unsigned* release_sync_point, | 46 static void ReleaseTextureMailbox(uint32* release_sync_point, |
| 47 bool* release_lost_resource, | 47 bool* release_lost_resource, |
| 48 unsigned sync_point, | 48 uint32 sync_point, |
| 49 bool lost_resource) { | 49 bool lost_resource) { |
| 50 *release_sync_point = sync_point; | 50 *release_sync_point = sync_point; |
| 51 *release_lost_resource = lost_resource; | 51 *release_lost_resource = lost_resource; |
| 52 } | 52 } |
| 53 | 53 |
| 54 static void ReleaseSharedMemoryCallback( | 54 static void ReleaseSharedMemoryCallback( |
| 55 scoped_ptr<base::SharedMemory> shared_memory, | 55 scoped_ptr<base::SharedMemory> shared_memory, |
| 56 bool* release_called, | 56 bool* release_called, |
| 57 unsigned* release_sync_point, | 57 uint32* release_sync_point, |
| 58 bool* lost_resource_result, | 58 bool* lost_resource_result, |
| 59 unsigned sync_point, | 59 uint32 sync_point, |
| 60 bool lost_resource) { | 60 bool lost_resource) { |
| 61 *release_called = true; | 61 *release_called = true; |
| 62 *release_sync_point = sync_point; | 62 *release_sync_point = sync_point; |
| 63 *lost_resource_result = lost_resource; | 63 *lost_resource_result = lost_resource; |
| 64 } | 64 } |
| 65 | 65 |
| 66 static scoped_ptr<base::SharedMemory> CreateAndFillSharedMemory( | 66 static scoped_ptr<base::SharedMemory> CreateAndFillSharedMemory( |
| 67 const gfx::Size& size, | 67 const gfx::Size& size, |
| 68 uint32_t value) { | 68 uint32_t value) { |
| 69 scoped_ptr<base::SharedMemory> shared_memory(new base::SharedMemory); | 69 scoped_ptr<base::SharedMemory> shared_memory(new base::SharedMemory); |
| 70 CHECK(shared_memory->CreateAndMapAnonymous(4 * size.GetArea())); | 70 CHECK(shared_memory->CreateAndMapAnonymous(4 * size.GetArea())); |
| 71 uint32_t* pixels = reinterpret_cast<uint32_t*>(shared_memory->memory()); | 71 uint32_t* pixels = reinterpret_cast<uint32_t*>(shared_memory->memory()); |
| 72 CHECK(pixels); | 72 CHECK(pixels); |
| 73 std::fill_n(pixels, size.GetArea(), value); | 73 std::fill_n(pixels, size.GetArea(), value); |
| 74 return shared_memory.Pass(); | 74 return shared_memory.Pass(); |
| 75 } | 75 } |
| 76 | 76 |
| 77 class TextureStateTrackingContext : public TestWebGraphicsContext3D { | 77 class TextureStateTrackingContext : public TestWebGraphicsContext3D { |
| 78 public: | 78 public: |
| 79 MOCK_METHOD2(bindTexture, void(GLenum target, GLuint texture)); | 79 MOCK_METHOD2(bindTexture, void(GLenum target, GLuint texture)); |
| 80 MOCK_METHOD3(texParameteri, void(GLenum target, GLenum pname, GLint param)); | 80 MOCK_METHOD3(texParameteri, void(GLenum target, GLenum pname, GLint param)); |
| 81 MOCK_METHOD1(waitSyncPoint, void(unsigned sync_point)); | 81 MOCK_METHOD1(waitSyncPoint, void(GLuint sync_point)); |
| 82 MOCK_METHOD0(insertSyncPoint, unsigned(void)); | 82 MOCK_METHOD0(insertSyncPoint, GLuint(void)); |
| 83 MOCK_METHOD2(produceTextureCHROMIUM, | 83 MOCK_METHOD2(produceTextureCHROMIUM, |
| 84 void(GLenum target, const GLbyte* mailbox)); | 84 void(GLenum target, const GLbyte* mailbox)); |
| 85 MOCK_METHOD2(consumeTextureCHROMIUM, | 85 MOCK_METHOD2(consumeTextureCHROMIUM, |
| 86 void(GLenum target, const GLbyte* mailbox)); | 86 void(GLenum target, const GLbyte* mailbox)); |
| 87 | 87 |
| 88 // Force all textures to be consecutive numbers starting at "1", | 88 // Force all textures to be consecutive numbers starting at "1", |
| 89 // so we easily can test for them. | 89 // so we easily can test for them. |
| 90 virtual GLuint NextTextureId() OVERRIDE { | 90 virtual GLuint NextTextureId() OVERRIDE { |
| 91 base::AutoLock lock(namespace_->lock); | 91 base::AutoLock lock(namespace_->lock); |
| 92 return namespace_->next_texture_id++; | 92 return namespace_->next_texture_id++; |
| 93 } | 93 } |
| 94 virtual void RetireTextureId(GLuint) OVERRIDE {} | 94 virtual void RetireTextureId(GLuint) OVERRIDE {} |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 // Shared data between multiple ResourceProviderContext. This contains mailbox | 97 // Shared data between multiple ResourceProviderContext. This contains mailbox |
| 98 // contents as well as information about sync points. | 98 // contents as well as information about sync points. |
| 99 class ContextSharedData { | 99 class ContextSharedData { |
| 100 public: | 100 public: |
| 101 static scoped_ptr<ContextSharedData> Create() { | 101 static scoped_ptr<ContextSharedData> Create() { |
| 102 return make_scoped_ptr(new ContextSharedData()); | 102 return make_scoped_ptr(new ContextSharedData()); |
| 103 } | 103 } |
| 104 | 104 |
| 105 unsigned InsertSyncPoint() { return next_sync_point_++; } | 105 uint32 InsertSyncPoint() { return next_sync_point_++; } |
| 106 | 106 |
| 107 void GenMailbox(GLbyte* mailbox) { | 107 void GenMailbox(GLbyte* mailbox) { |
| 108 memset(mailbox, 0, sizeof(GLbyte[64])); | 108 memset(mailbox, 0, sizeof(GLbyte[64])); |
| 109 memcpy(mailbox, &next_mailbox_, sizeof(next_mailbox_)); | 109 memcpy(mailbox, &next_mailbox_, sizeof(next_mailbox_)); |
| 110 ++next_mailbox_; | 110 ++next_mailbox_; |
| 111 } | 111 } |
| 112 | 112 |
| 113 void ProduceTexture(const GLbyte* mailbox_name, | 113 void ProduceTexture(const GLbyte* mailbox_name, |
| 114 unsigned sync_point, | 114 uint32 sync_point, |
| 115 scoped_refptr<TestTexture> texture) { | 115 scoped_refptr<TestTexture> texture) { |
| 116 unsigned mailbox = 0; | 116 unsigned mailbox = 0; |
| 117 memcpy(&mailbox, mailbox_name, sizeof(mailbox)); | 117 memcpy(&mailbox, mailbox_name, sizeof(mailbox)); |
| 118 ASSERT_TRUE(mailbox && mailbox < next_mailbox_); | 118 ASSERT_TRUE(mailbox && mailbox < next_mailbox_); |
| 119 textures_[mailbox] = texture; | 119 textures_[mailbox] = texture; |
| 120 ASSERT_LT(sync_point_for_mailbox_[mailbox], sync_point); | 120 ASSERT_LT(sync_point_for_mailbox_[mailbox], sync_point); |
| 121 sync_point_for_mailbox_[mailbox] = sync_point; | 121 sync_point_for_mailbox_[mailbox] = sync_point; |
| 122 } | 122 } |
| 123 | 123 |
| 124 scoped_refptr<TestTexture> ConsumeTexture(const GLbyte* mailbox_name, | 124 scoped_refptr<TestTexture> ConsumeTexture(const GLbyte* mailbox_name, |
| 125 unsigned sync_point) { | 125 uint32 sync_point) { |
| 126 unsigned mailbox = 0; | 126 unsigned mailbox = 0; |
| 127 memcpy(&mailbox, mailbox_name, sizeof(mailbox)); | 127 memcpy(&mailbox, mailbox_name, sizeof(mailbox)); |
| 128 DCHECK(mailbox && mailbox < next_mailbox_); | 128 DCHECK(mailbox && mailbox < next_mailbox_); |
| 129 | 129 |
| 130 // If the latest sync point the context has waited on is before the sync | 130 // If the latest sync point the context has waited on is before the sync |
| 131 // point for when the mailbox was set, pretend we never saw that | 131 // point for when the mailbox was set, pretend we never saw that |
| 132 // ProduceTexture. | 132 // ProduceTexture. |
| 133 if (sync_point_for_mailbox_[mailbox] > sync_point) { | 133 if (sync_point_for_mailbox_[mailbox] > sync_point) { |
| 134 NOTREACHED(); | 134 NOTREACHED(); |
| 135 return scoped_refptr<TestTexture>(); | 135 return scoped_refptr<TestTexture>(); |
| 136 } | 136 } |
| 137 return textures_[mailbox]; | 137 return textures_[mailbox]; |
| 138 } | 138 } |
| 139 | 139 |
| 140 private: | 140 private: |
| 141 ContextSharedData() : next_sync_point_(1), next_mailbox_(1) {} | 141 ContextSharedData() : next_sync_point_(1), next_mailbox_(1) {} |
| 142 | 142 |
| 143 unsigned next_sync_point_; | 143 uint32 next_sync_point_; |
| 144 unsigned next_mailbox_; | 144 unsigned next_mailbox_; |
| 145 typedef base::hash_map<unsigned, scoped_refptr<TestTexture> > TextureMap; | 145 typedef base::hash_map<unsigned, scoped_refptr<TestTexture> > TextureMap; |
| 146 TextureMap textures_; | 146 TextureMap textures_; |
| 147 base::hash_map<unsigned, unsigned> sync_point_for_mailbox_; | 147 base::hash_map<unsigned, uint32> sync_point_for_mailbox_; |
| 148 }; | 148 }; |
| 149 | 149 |
| 150 class ResourceProviderContext : public TestWebGraphicsContext3D { | 150 class ResourceProviderContext : public TestWebGraphicsContext3D { |
| 151 public: | 151 public: |
| 152 static scoped_ptr<ResourceProviderContext> Create( | 152 static scoped_ptr<ResourceProviderContext> Create( |
| 153 ContextSharedData* shared_data) { | 153 ContextSharedData* shared_data) { |
| 154 return make_scoped_ptr(new ResourceProviderContext(shared_data)); | 154 return make_scoped_ptr(new ResourceProviderContext(shared_data)); |
| 155 } | 155 } |
| 156 | 156 |
| 157 virtual unsigned insertSyncPoint() OVERRIDE { | 157 virtual GLuint insertSyncPoint() OVERRIDE { |
| 158 unsigned sync_point = shared_data_->InsertSyncPoint(); | 158 uint32 sync_point = shared_data_->InsertSyncPoint(); |
| 159 // Commit the produceTextureCHROMIUM calls at this point, so that | 159 // Commit the produceTextureCHROMIUM calls at this point, so that |
| 160 // they're associated with the sync point. | 160 // they're associated with the sync point. |
| 161 for (PendingProduceTextureList::iterator it = | 161 for (PendingProduceTextureList::iterator it = |
| 162 pending_produce_textures_.begin(); | 162 pending_produce_textures_.begin(); |
| 163 it != pending_produce_textures_.end(); | 163 it != pending_produce_textures_.end(); |
| 164 ++it) { | 164 ++it) { |
| 165 shared_data_->ProduceTexture( | 165 shared_data_->ProduceTexture( |
| 166 (*it)->mailbox, sync_point, (*it)->texture); | 166 (*it)->mailbox, sync_point, (*it)->texture); |
| 167 } | 167 } |
| 168 pending_produce_textures_.clear(); | 168 pending_produce_textures_.clear(); |
| 169 return sync_point; | 169 return sync_point; |
| 170 } | 170 } |
| 171 | 171 |
| 172 virtual void waitSyncPoint(unsigned sync_point) OVERRIDE { | 172 virtual void waitSyncPoint(GLuint sync_point) OVERRIDE { |
| 173 last_waited_sync_point_ = std::max(sync_point, last_waited_sync_point_); | 173 last_waited_sync_point_ = std::max(sync_point, last_waited_sync_point_); |
| 174 } | 174 } |
| 175 | 175 |
| 176 unsigned last_waited_sync_point() const { return last_waited_sync_point_; } | 176 unsigned last_waited_sync_point() const { return last_waited_sync_point_; } |
| 177 | 177 |
| 178 virtual void texStorage2DEXT(GLenum target, | 178 virtual void texStorage2DEXT(GLenum target, |
| 179 GLint levels, | 179 GLint levels, |
| 180 GLuint internalformat, | 180 GLuint internalformat, |
| 181 GLint width, | 181 GLint width, |
| 182 GLint height) OVERRIDE { | 182 GLint height) OVERRIDE { |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 src += in_pitch; | 320 src += in_pitch; |
| 321 } | 321 } |
| 322 } | 322 } |
| 323 | 323 |
| 324 struct PendingProduceTexture { | 324 struct PendingProduceTexture { |
| 325 GLbyte mailbox[64]; | 325 GLbyte mailbox[64]; |
| 326 scoped_refptr<TestTexture> texture; | 326 scoped_refptr<TestTexture> texture; |
| 327 }; | 327 }; |
| 328 typedef ScopedPtrDeque<PendingProduceTexture> PendingProduceTextureList; | 328 typedef ScopedPtrDeque<PendingProduceTexture> PendingProduceTextureList; |
| 329 ContextSharedData* shared_data_; | 329 ContextSharedData* shared_data_; |
| 330 unsigned last_waited_sync_point_; | 330 GLuint last_waited_sync_point_; |
| 331 PendingProduceTextureList pending_produce_textures_; | 331 PendingProduceTextureList pending_produce_textures_; |
| 332 }; | 332 }; |
| 333 | 333 |
| 334 void FreeSharedBitmap(SharedBitmap* shared_bitmap) { | 334 void FreeSharedBitmap(SharedBitmap* shared_bitmap) { |
| 335 delete shared_bitmap->memory(); | 335 delete shared_bitmap->memory(); |
| 336 } | 336 } |
| 337 | 337 |
| 338 void IgnoreSharedBitmap(SharedBitmap* shared_bitmap) {} | 338 void IgnoreSharedBitmap(SharedBitmap* shared_bitmap) {} |
| 339 | 339 |
| 340 class TestSharedBitmapManager : public SharedBitmapManager { | 340 class TestSharedBitmapManager : public SharedBitmapManager { |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 | 470 |
| 471 static void SetResourceFilter(ResourceProvider* resource_provider, | 471 static void SetResourceFilter(ResourceProvider* resource_provider, |
| 472 ResourceProvider::ResourceId id, | 472 ResourceProvider::ResourceId id, |
| 473 GLenum filter) { | 473 GLenum filter) { |
| 474 ResourceProvider::ScopedSamplerGL sampler( | 474 ResourceProvider::ScopedSamplerGL sampler( |
| 475 resource_provider, id, GL_TEXTURE_2D, filter); | 475 resource_provider, id, GL_TEXTURE_2D, filter); |
| 476 } | 476 } |
| 477 | 477 |
| 478 ResourceProviderContext* context() { return context3d_; } | 478 ResourceProviderContext* context() { return context3d_; } |
| 479 | 479 |
| 480 ResourceProvider::ResourceId CreateChildMailbox(unsigned* release_sync_point, | 480 ResourceProvider::ResourceId CreateChildMailbox(uint32* release_sync_point, |
| 481 bool* lost_resource, | 481 bool* lost_resource, |
| 482 bool* release_called, | 482 bool* release_called, |
| 483 unsigned* sync_point) { | 483 uint32* sync_point) { |
| 484 if (GetParam() == ResourceProvider::GLTexture) { | 484 if (GetParam() == ResourceProvider::GLTexture) { |
| 485 unsigned texture = child_context_->createTexture(); | 485 unsigned texture = child_context_->createTexture(); |
| 486 gpu::Mailbox gpu_mailbox; | 486 gpu::Mailbox gpu_mailbox; |
| 487 child_context_->bindTexture(GL_TEXTURE_2D, texture); | 487 child_context_->bindTexture(GL_TEXTURE_2D, texture); |
| 488 child_context_->genMailboxCHROMIUM(gpu_mailbox.name); | 488 child_context_->genMailboxCHROMIUM(gpu_mailbox.name); |
| 489 child_context_->produceTextureCHROMIUM(GL_TEXTURE_2D, gpu_mailbox.name); | 489 child_context_->produceTextureCHROMIUM(GL_TEXTURE_2D, gpu_mailbox.name); |
| 490 *sync_point = child_context_->insertSyncPoint(); | 490 *sync_point = child_context_->insertSyncPoint(); |
| 491 EXPECT_LT(0u, *sync_point); | 491 EXPECT_LT(0u, *sync_point); |
| 492 | 492 |
| 493 scoped_ptr<base::SharedMemory> shared_memory; | 493 scoped_ptr<base::SharedMemory> shared_memory; |
| 494 scoped_ptr<SingleReleaseCallback> callback = | 494 scoped_ptr<SingleReleaseCallback> callback = |
| 495 SingleReleaseCallback::Create(base::Bind(ReleaseSharedMemoryCallback, | 495 SingleReleaseCallback::Create(base::Bind(ReleaseSharedMemoryCallback, |
| 496 base::Passed(&shared_memory), | 496 base::Passed(&shared_memory), |
| 497 release_called, | 497 release_called, |
| 498 release_sync_point, | 498 release_sync_point, |
| 499 lost_resource)); | 499 lost_resource)); |
| 500 return child_resource_provider_->CreateResourceFromTextureMailbox( | 500 return child_resource_provider_->CreateResourceFromTextureMailbox( |
| 501 TextureMailbox(gpu_mailbox, *sync_point), callback.Pass()); | 501 TextureMailbox(gpu_mailbox, GL_TEXTURE_2D, *sync_point), |
| 502 callback.Pass()); |
| 502 } else { | 503 } else { |
| 503 gfx::Size size(64, 64); | 504 gfx::Size size(64, 64); |
| 504 scoped_ptr<base::SharedMemory> shared_memory( | 505 scoped_ptr<base::SharedMemory> shared_memory( |
| 505 CreateAndFillSharedMemory(size, 0)); | 506 CreateAndFillSharedMemory(size, 0)); |
| 506 | 507 |
| 507 base::SharedMemory* shared_memory_ptr = shared_memory.get(); | 508 base::SharedMemory* shared_memory_ptr = shared_memory.get(); |
| 508 scoped_ptr<SingleReleaseCallback> callback = | 509 scoped_ptr<SingleReleaseCallback> callback = |
| 509 SingleReleaseCallback::Create(base::Bind(ReleaseSharedMemoryCallback, | 510 SingleReleaseCallback::Create(base::Bind(ReleaseSharedMemoryCallback, |
| 510 base::Passed(&shared_memory), | 511 base::Passed(&shared_memory), |
| 511 release_called, | 512 release_called, |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 child_resource_provider_->MapImage(id3); | 658 child_resource_provider_->MapImage(id3); |
| 658 child_resource_provider_->UnmapImage(id3); | 659 child_resource_provider_->UnmapImage(id3); |
| 659 | 660 |
| 660 GLuint external_texture_id = child_context_->createExternalTexture(); | 661 GLuint external_texture_id = child_context_->createExternalTexture(); |
| 661 child_context_->bindTexture(GL_TEXTURE_EXTERNAL_OES, external_texture_id); | 662 child_context_->bindTexture(GL_TEXTURE_EXTERNAL_OES, external_texture_id); |
| 662 | 663 |
| 663 gpu::Mailbox external_mailbox; | 664 gpu::Mailbox external_mailbox; |
| 664 child_context_->genMailboxCHROMIUM(external_mailbox.name); | 665 child_context_->genMailboxCHROMIUM(external_mailbox.name); |
| 665 child_context_->produceTextureCHROMIUM(GL_TEXTURE_EXTERNAL_OES, | 666 child_context_->produceTextureCHROMIUM(GL_TEXTURE_EXTERNAL_OES, |
| 666 external_mailbox.name); | 667 external_mailbox.name); |
| 667 const unsigned external_sync_point = child_context_->insertSyncPoint(); | 668 const GLuint external_sync_point = child_context_->insertSyncPoint(); |
| 668 ResourceProvider::ResourceId id4 = | 669 ResourceProvider::ResourceId id4 = |
| 669 child_resource_provider_->CreateResourceFromTextureMailbox( | 670 child_resource_provider_->CreateResourceFromTextureMailbox( |
| 670 TextureMailbox( | 671 TextureMailbox( |
| 671 external_mailbox, GL_TEXTURE_EXTERNAL_OES, external_sync_point), | 672 external_mailbox, GL_TEXTURE_EXTERNAL_OES, external_sync_point), |
| 672 SingleReleaseCallback::Create(base::Bind(&EmptyReleaseCallback))); | 673 SingleReleaseCallback::Create(base::Bind(&EmptyReleaseCallback))); |
| 673 | 674 |
| 674 ReturnedResourceArray returned_to_child; | 675 ReturnedResourceArray returned_to_child; |
| 675 int child_id = | 676 int child_id = |
| 676 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); | 677 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); |
| 677 { | 678 { |
| 678 // Transfer some resources to the parent. | 679 // Transfer some resources to the parent. |
| 679 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 680 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
| 680 resource_ids_to_transfer.push_back(id1); | 681 resource_ids_to_transfer.push_back(id1); |
| 681 resource_ids_to_transfer.push_back(id2); | 682 resource_ids_to_transfer.push_back(id2); |
| 682 resource_ids_to_transfer.push_back(id3); | 683 resource_ids_to_transfer.push_back(id3); |
| 683 resource_ids_to_transfer.push_back(id4); | 684 resource_ids_to_transfer.push_back(id4); |
| 684 TransferableResourceArray list; | 685 TransferableResourceArray list; |
| 685 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, | 686 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, |
| 686 &list); | 687 &list); |
| 687 ASSERT_EQ(4u, list.size()); | 688 ASSERT_EQ(4u, list.size()); |
| 688 EXPECT_NE(0u, list[0].sync_point); | 689 EXPECT_NE(0u, list[0].mailbox_holder.sync_point); |
| 689 EXPECT_NE(0u, list[1].sync_point); | 690 EXPECT_NE(0u, list[1].mailbox_holder.sync_point); |
| 690 EXPECT_EQ(list[0].sync_point, list[1].sync_point); | 691 EXPECT_EQ(list[0].mailbox_holder.sync_point, |
| 691 EXPECT_NE(0u, list[2].sync_point); | 692 list[1].mailbox_holder.sync_point); |
| 692 EXPECT_EQ(list[0].sync_point, list[2].sync_point); | 693 EXPECT_NE(0u, list[2].mailbox_holder.sync_point); |
| 693 EXPECT_EQ(external_sync_point, list[3].sync_point); | 694 EXPECT_EQ(list[0].mailbox_holder.sync_point, |
| 694 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), list[0].target); | 695 list[2].mailbox_holder.sync_point); |
| 695 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), list[1].target); | 696 EXPECT_EQ(external_sync_point, list[3].mailbox_holder.sync_point); |
| 696 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), list[2].target); | 697 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), |
| 697 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_EXTERNAL_OES), list[3].target); | 698 list[0].mailbox_holder.texture_target); |
| 699 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), |
| 700 list[1].mailbox_holder.texture_target); |
| 701 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), |
| 702 list[2].mailbox_holder.texture_target); |
| 703 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_EXTERNAL_OES), |
| 704 list[3].mailbox_holder.texture_target); |
| 698 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); | 705 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); |
| 699 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); | 706 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); |
| 700 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id3)); | 707 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id3)); |
| 701 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id4)); | 708 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id4)); |
| 702 resource_provider_->ReceiveFromChild(child_id, list); | 709 resource_provider_->ReceiveFromChild(child_id, list); |
| 703 EXPECT_NE(list[0].sync_point, context3d_->last_waited_sync_point()); | 710 EXPECT_NE(list[0].mailbox_holder.sync_point, |
| 711 context3d_->last_waited_sync_point()); |
| 704 { | 712 { |
| 705 ResourceProvider::ScopedReadLockGL lock(resource_provider_.get(), | 713 ResourceProvider::ScopedReadLockGL lock(resource_provider_.get(), |
| 706 list[0].id); | 714 list[0].id); |
| 707 } | 715 } |
| 708 EXPECT_EQ(list[0].sync_point, context3d_->last_waited_sync_point()); | 716 EXPECT_EQ(list[0].mailbox_holder.sync_point, |
| 717 context3d_->last_waited_sync_point()); |
| 709 resource_provider_->DeclareUsedResourcesFromChild(child_id, | 718 resource_provider_->DeclareUsedResourcesFromChild(child_id, |
| 710 resource_ids_to_transfer); | 719 resource_ids_to_transfer); |
| 711 } | 720 } |
| 712 | 721 |
| 713 EXPECT_EQ(4u, resource_provider_->num_resources()); | 722 EXPECT_EQ(4u, resource_provider_->num_resources()); |
| 714 ResourceProvider::ResourceIdMap resource_map = | 723 ResourceProvider::ResourceIdMap resource_map = |
| 715 resource_provider_->GetChildToParentMap(child_id); | 724 resource_provider_->GetChildToParentMap(child_id); |
| 716 ResourceProvider::ResourceId mapped_id1 = resource_map[id1]; | 725 ResourceProvider::ResourceId mapped_id1 = resource_map[id1]; |
| 717 ResourceProvider::ResourceId mapped_id2 = resource_map[id2]; | 726 ResourceProvider::ResourceId mapped_id2 = resource_map[id2]; |
| 718 ResourceProvider::ResourceId mapped_id3 = resource_map[id3]; | 727 ResourceProvider::ResourceId mapped_id3 = resource_map[id3]; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 742 resource_ids_to_transfer.push_back(id1); | 751 resource_ids_to_transfer.push_back(id1); |
| 743 resource_ids_to_transfer.push_back(id2); | 752 resource_ids_to_transfer.push_back(id2); |
| 744 resource_ids_to_transfer.push_back(id3); | 753 resource_ids_to_transfer.push_back(id3); |
| 745 TransferableResourceArray list; | 754 TransferableResourceArray list; |
| 746 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, | 755 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, |
| 747 &list); | 756 &list); |
| 748 EXPECT_EQ(3u, list.size()); | 757 EXPECT_EQ(3u, list.size()); |
| 749 EXPECT_EQ(id1, list[0].id); | 758 EXPECT_EQ(id1, list[0].id); |
| 750 EXPECT_EQ(id2, list[1].id); | 759 EXPECT_EQ(id2, list[1].id); |
| 751 EXPECT_EQ(id3, list[2].id); | 760 EXPECT_EQ(id3, list[2].id); |
| 752 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), list[0].target); | 761 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), |
| 753 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), list[1].target); | 762 list[0].mailbox_holder.texture_target); |
| 754 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), list[2].target); | 763 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), |
| 764 list[1].mailbox_holder.texture_target); |
| 765 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), |
| 766 list[2].mailbox_holder.texture_target); |
| 755 ReturnedResourceArray returned; | 767 ReturnedResourceArray returned; |
| 756 TransferableResource::ReturnResources(list, &returned); | 768 TransferableResource::ReturnResources(list, &returned); |
| 757 child_resource_provider_->ReceiveReturnsFromParent(returned); | 769 child_resource_provider_->ReceiveReturnsFromParent(returned); |
| 758 // ids were exported twice, we returned them only once, they should still | 770 // ids were exported twice, we returned them only once, they should still |
| 759 // be in-use. | 771 // be in-use. |
| 760 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); | 772 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); |
| 761 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); | 773 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); |
| 762 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id3)); | 774 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id3)); |
| 763 } | 775 } |
| 764 { | 776 { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 816 resource_ids_to_transfer.push_back(id3); | 828 resource_ids_to_transfer.push_back(id3); |
| 817 resource_ids_to_transfer.push_back(id4); | 829 resource_ids_to_transfer.push_back(id4); |
| 818 TransferableResourceArray list; | 830 TransferableResourceArray list; |
| 819 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, | 831 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, |
| 820 &list); | 832 &list); |
| 821 ASSERT_EQ(4u, list.size()); | 833 ASSERT_EQ(4u, list.size()); |
| 822 EXPECT_EQ(id1, list[0].id); | 834 EXPECT_EQ(id1, list[0].id); |
| 823 EXPECT_EQ(id2, list[1].id); | 835 EXPECT_EQ(id2, list[1].id); |
| 824 EXPECT_EQ(id3, list[2].id); | 836 EXPECT_EQ(id3, list[2].id); |
| 825 EXPECT_EQ(id4, list[3].id); | 837 EXPECT_EQ(id4, list[3].id); |
| 826 EXPECT_NE(0u, list[0].sync_point); | 838 EXPECT_NE(0u, list[0].mailbox_holder.sync_point); |
| 827 EXPECT_NE(0u, list[1].sync_point); | 839 EXPECT_NE(0u, list[1].mailbox_holder.sync_point); |
| 828 EXPECT_NE(0u, list[2].sync_point); | 840 EXPECT_NE(0u, list[2].mailbox_holder.sync_point); |
| 829 EXPECT_NE(0u, list[3].sync_point); | 841 EXPECT_NE(0u, list[3].mailbox_holder.sync_point); |
| 830 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), list[0].target); | 842 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), |
| 831 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), list[1].target); | 843 list[0].mailbox_holder.texture_target); |
| 832 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), list[2].target); | 844 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), |
| 833 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_EXTERNAL_OES), list[3].target); | 845 list[1].mailbox_holder.texture_target); |
| 846 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), |
| 847 list[2].mailbox_holder.texture_target); |
| 848 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_EXTERNAL_OES), |
| 849 list[3].mailbox_holder.texture_target); |
| 834 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); | 850 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); |
| 835 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); | 851 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); |
| 836 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id3)); | 852 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id3)); |
| 837 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id4)); | 853 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id4)); |
| 838 resource_provider_->ReceiveFromChild(child_id, list); | 854 resource_provider_->ReceiveFromChild(child_id, list); |
| 839 resource_provider_->DeclareUsedResourcesFromChild(child_id, | 855 resource_provider_->DeclareUsedResourcesFromChild(child_id, |
| 840 resource_ids_to_transfer); | 856 resource_ids_to_transfer); |
| 841 } | 857 } |
| 842 | 858 |
| 843 EXPECT_EQ(0u, returned_to_child.size()); | 859 EXPECT_EQ(0u, returned_to_child.size()); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 901 // Transfer some resources to the parent. | 917 // Transfer some resources to the parent. |
| 902 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 918 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
| 903 resource_ids_to_transfer.push_back(id1); | 919 resource_ids_to_transfer.push_back(id1); |
| 904 resource_ids_to_transfer.push_back(id2); | 920 resource_ids_to_transfer.push_back(id2); |
| 905 resource_ids_to_transfer.push_back(id3); | 921 resource_ids_to_transfer.push_back(id3); |
| 906 resource_ids_to_transfer.push_back(id4); | 922 resource_ids_to_transfer.push_back(id4); |
| 907 TransferableResourceArray list; | 923 TransferableResourceArray list; |
| 908 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, | 924 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, |
| 909 &list); | 925 &list); |
| 910 ASSERT_EQ(4u, list.size()); | 926 ASSERT_EQ(4u, list.size()); |
| 911 EXPECT_EQ(0u, list[0].sync_point); | 927 EXPECT_EQ(0u, list[0].mailbox_holder.sync_point); |
| 912 EXPECT_EQ(0u, list[1].sync_point); | 928 EXPECT_EQ(0u, list[1].mailbox_holder.sync_point); |
| 913 EXPECT_EQ(0u, list[2].sync_point); | 929 EXPECT_EQ(0u, list[2].mailbox_holder.sync_point); |
| 914 EXPECT_EQ(0u, list[3].sync_point); | 930 EXPECT_EQ(0u, list[3].mailbox_holder.sync_point); |
| 915 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); | 931 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); |
| 916 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); | 932 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); |
| 917 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id3)); | 933 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id3)); |
| 918 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id4)); | 934 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id4)); |
| 919 resource_provider_->ReceiveFromChild(child_id, list); | 935 resource_provider_->ReceiveFromChild(child_id, list); |
| 920 resource_provider_->DeclareUsedResourcesFromChild(child_id, | 936 resource_provider_->DeclareUsedResourcesFromChild(child_id, |
| 921 resource_ids_to_transfer); | 937 resource_ids_to_transfer); |
| 922 } | 938 } |
| 923 | 939 |
| 924 EXPECT_EQ(4u, resource_provider_->num_resources()); | 940 EXPECT_EQ(4u, resource_provider_->num_resources()); |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1162 ReturnedResourceArray returned_to_child; | 1178 ReturnedResourceArray returned_to_child; |
| 1163 int child_id = | 1179 int child_id = |
| 1164 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); | 1180 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); |
| 1165 { | 1181 { |
| 1166 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 1182 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
| 1167 resource_ids_to_transfer.push_back(id1); | 1183 resource_ids_to_transfer.push_back(id1); |
| 1168 TransferableResourceArray list; | 1184 TransferableResourceArray list; |
| 1169 child_resource_provider->PrepareSendToParent(resource_ids_to_transfer, | 1185 child_resource_provider->PrepareSendToParent(resource_ids_to_transfer, |
| 1170 &list); | 1186 &list); |
| 1171 ASSERT_EQ(1u, list.size()); | 1187 ASSERT_EQ(1u, list.size()); |
| 1172 EXPECT_NE(0u, list[0].sync_point); | 1188 EXPECT_NE(0u, list[0].mailbox_holder.sync_point); |
| 1173 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), list[0].target); | 1189 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), |
| 1190 list[0].mailbox_holder.texture_target); |
| 1174 EXPECT_TRUE(child_resource_provider->InUseByConsumer(id1)); | 1191 EXPECT_TRUE(child_resource_provider->InUseByConsumer(id1)); |
| 1175 resource_provider_->ReceiveFromChild(child_id, list); | 1192 resource_provider_->ReceiveFromChild(child_id, list); |
| 1176 } | 1193 } |
| 1177 | 1194 |
| 1178 EXPECT_EQ(0u, resource_provider_->num_resources()); | 1195 EXPECT_EQ(0u, resource_provider_->num_resources()); |
| 1179 ASSERT_EQ(1u, returned_to_child.size()); | 1196 ASSERT_EQ(1u, returned_to_child.size()); |
| 1180 EXPECT_EQ(returned_to_child[0].id, id1); | 1197 EXPECT_EQ(returned_to_child[0].id, id1); |
| 1181 ResourceProvider::ResourceIdMap resource_map = | 1198 ResourceProvider::ResourceIdMap resource_map = |
| 1182 resource_provider_->GetChildToParentMap(child_id); | 1199 resource_provider_->GetChildToParentMap(child_id); |
| 1183 ResourceProvider::ResourceId mapped_id1 = resource_map[id1]; | 1200 ResourceProvider::ResourceId mapped_id1 = resource_map[id1]; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1209 int child_id = | 1226 int child_id = |
| 1210 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); | 1227 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); |
| 1211 { | 1228 { |
| 1212 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 1229 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
| 1213 resource_ids_to_transfer.push_back(id1); | 1230 resource_ids_to_transfer.push_back(id1); |
| 1214 TransferableResourceArray list; | 1231 TransferableResourceArray list; |
| 1215 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, | 1232 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, |
| 1216 &list); | 1233 &list); |
| 1217 ASSERT_EQ(1u, list.size()); | 1234 ASSERT_EQ(1u, list.size()); |
| 1218 // Make invalid. | 1235 // Make invalid. |
| 1219 list[0].mailbox.name[1] = 5; | 1236 list[0].mailbox_holder.mailbox.name[1] = 5; |
| 1220 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); | 1237 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); |
| 1221 resource_provider_->ReceiveFromChild(child_id, list); | 1238 resource_provider_->ReceiveFromChild(child_id, list); |
| 1222 } | 1239 } |
| 1223 | 1240 |
| 1224 EXPECT_EQ(0u, resource_provider_->num_resources()); | 1241 EXPECT_EQ(0u, resource_provider_->num_resources()); |
| 1225 ASSERT_EQ(1u, returned_to_child.size()); | 1242 ASSERT_EQ(1u, returned_to_child.size()); |
| 1226 EXPECT_EQ(returned_to_child[0].id, id1); | 1243 EXPECT_EQ(returned_to_child[0].id, id1); |
| 1227 ResourceProvider::ResourceIdMap resource_map = | 1244 ResourceProvider::ResourceIdMap resource_map = |
| 1228 resource_provider_->GetChildToParentMap(child_id); | 1245 resource_provider_->GetChildToParentMap(child_id); |
| 1229 ResourceProvider::ResourceId mapped_id1 = resource_map[id1]; | 1246 ResourceProvider::ResourceId mapped_id1 = resource_map[id1]; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1259 { | 1276 { |
| 1260 // Transfer some resources to the parent. | 1277 // Transfer some resources to the parent. |
| 1261 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 1278 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
| 1262 resource_ids_to_transfer.push_back(id1); | 1279 resource_ids_to_transfer.push_back(id1); |
| 1263 resource_ids_to_transfer.push_back(id2); | 1280 resource_ids_to_transfer.push_back(id2); |
| 1264 TransferableResourceArray list; | 1281 TransferableResourceArray list; |
| 1265 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, | 1282 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, |
| 1266 &list); | 1283 &list); |
| 1267 ASSERT_EQ(2u, list.size()); | 1284 ASSERT_EQ(2u, list.size()); |
| 1268 if (GetParam() == ResourceProvider::GLTexture) { | 1285 if (GetParam() == ResourceProvider::GLTexture) { |
| 1269 EXPECT_NE(0u, list[0].sync_point); | 1286 EXPECT_NE(0u, list[0].mailbox_holder.sync_point); |
| 1270 EXPECT_NE(0u, list[1].sync_point); | 1287 EXPECT_NE(0u, list[1].mailbox_holder.sync_point); |
| 1271 } | 1288 } |
| 1272 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); | 1289 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); |
| 1273 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); | 1290 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); |
| 1274 resource_provider_->ReceiveFromChild(child_id, list); | 1291 resource_provider_->ReceiveFromChild(child_id, list); |
| 1275 resource_provider_->DeclareUsedResourcesFromChild(child_id, | 1292 resource_provider_->DeclareUsedResourcesFromChild(child_id, |
| 1276 resource_ids_to_transfer); | 1293 resource_ids_to_transfer); |
| 1277 } | 1294 } |
| 1278 | 1295 |
| 1279 EXPECT_EQ(2u, resource_provider_->num_resources()); | 1296 EXPECT_EQ(2u, resource_provider_->num_resources()); |
| 1280 ResourceProvider::ResourceIdMap resource_map = | 1297 ResourceProvider::ResourceIdMap resource_map = |
| 1281 resource_provider_->GetChildToParentMap(child_id); | 1298 resource_provider_->GetChildToParentMap(child_id); |
| 1282 ResourceProvider::ResourceId mapped_id1 = resource_map[id1]; | 1299 ResourceProvider::ResourceId mapped_id1 = resource_map[id1]; |
| 1283 ResourceProvider::ResourceId mapped_id2 = resource_map[id2]; | 1300 ResourceProvider::ResourceId mapped_id2 = resource_map[id2]; |
| 1284 EXPECT_NE(0u, mapped_id1); | 1301 EXPECT_NE(0u, mapped_id1); |
| 1285 EXPECT_NE(0u, mapped_id2); | 1302 EXPECT_NE(0u, mapped_id2); |
| 1286 EXPECT_FALSE(resource_provider_->InUseByConsumer(id1)); | 1303 EXPECT_FALSE(resource_provider_->InUseByConsumer(id1)); |
| 1287 EXPECT_FALSE(resource_provider_->InUseByConsumer(id2)); | 1304 EXPECT_FALSE(resource_provider_->InUseByConsumer(id2)); |
| 1288 | 1305 |
| 1289 { | 1306 { |
| 1290 // The parent transfers the resources to the grandparent. | 1307 // The parent transfers the resources to the grandparent. |
| 1291 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 1308 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
| 1292 resource_ids_to_transfer.push_back(mapped_id1); | 1309 resource_ids_to_transfer.push_back(mapped_id1); |
| 1293 resource_ids_to_transfer.push_back(mapped_id2); | 1310 resource_ids_to_transfer.push_back(mapped_id2); |
| 1294 TransferableResourceArray list; | 1311 TransferableResourceArray list; |
| 1295 resource_provider_->PrepareSendToParent(resource_ids_to_transfer, &list); | 1312 resource_provider_->PrepareSendToParent(resource_ids_to_transfer, &list); |
| 1296 | 1313 |
| 1297 ASSERT_EQ(2u, list.size()); | 1314 ASSERT_EQ(2u, list.size()); |
| 1298 if (GetParam() == ResourceProvider::GLTexture) { | 1315 if (GetParam() == ResourceProvider::GLTexture) { |
| 1299 EXPECT_NE(0u, list[0].sync_point); | 1316 EXPECT_NE(0u, list[0].mailbox_holder.sync_point); |
| 1300 EXPECT_NE(0u, list[1].sync_point); | 1317 EXPECT_NE(0u, list[1].mailbox_holder.sync_point); |
| 1301 } | 1318 } |
| 1302 EXPECT_TRUE(resource_provider_->InUseByConsumer(id1)); | 1319 EXPECT_TRUE(resource_provider_->InUseByConsumer(id1)); |
| 1303 EXPECT_TRUE(resource_provider_->InUseByConsumer(id2)); | 1320 EXPECT_TRUE(resource_provider_->InUseByConsumer(id2)); |
| 1304 | 1321 |
| 1305 // Release the resource in the parent. Set no resources as being in use. The | 1322 // Release the resource in the parent. Set no resources as being in use. The |
| 1306 // resources are exported so that can't be transferred back yet. | 1323 // resources are exported so that can't be transferred back yet. |
| 1307 ResourceProvider::ResourceIdArray no_resources; | 1324 ResourceProvider::ResourceIdArray no_resources; |
| 1308 resource_provider_->DeclareUsedResourcesFromChild(child_id, no_resources); | 1325 resource_provider_->DeclareUsedResourcesFromChild(child_id, no_resources); |
| 1309 | 1326 |
| 1310 EXPECT_EQ(0u, returned_to_child.size()); | 1327 EXPECT_EQ(0u, returned_to_child.size()); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1353 { | 1370 { |
| 1354 // Transfer some resources to the parent. | 1371 // Transfer some resources to the parent. |
| 1355 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 1372 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
| 1356 resource_ids_to_transfer.push_back(id1); | 1373 resource_ids_to_transfer.push_back(id1); |
| 1357 resource_ids_to_transfer.push_back(id2); | 1374 resource_ids_to_transfer.push_back(id2); |
| 1358 TransferableResourceArray list; | 1375 TransferableResourceArray list; |
| 1359 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, | 1376 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, |
| 1360 &list); | 1377 &list); |
| 1361 ASSERT_EQ(2u, list.size()); | 1378 ASSERT_EQ(2u, list.size()); |
| 1362 if (GetParam() == ResourceProvider::GLTexture) { | 1379 if (GetParam() == ResourceProvider::GLTexture) { |
| 1363 EXPECT_NE(0u, list[0].sync_point); | 1380 EXPECT_NE(0u, list[0].mailbox_holder.sync_point); |
| 1364 EXPECT_NE(0u, list[1].sync_point); | 1381 EXPECT_NE(0u, list[1].mailbox_holder.sync_point); |
| 1365 } | 1382 } |
| 1366 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); | 1383 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); |
| 1367 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); | 1384 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); |
| 1368 resource_provider_->ReceiveFromChild(child_id, list); | 1385 resource_provider_->ReceiveFromChild(child_id, list); |
| 1369 resource_provider_->DeclareUsedResourcesFromChild(child_id, | 1386 resource_provider_->DeclareUsedResourcesFromChild(child_id, |
| 1370 resource_ids_to_transfer); | 1387 resource_ids_to_transfer); |
| 1371 } | 1388 } |
| 1372 | 1389 |
| 1373 EXPECT_EQ(2u, resource_provider_->num_resources()); | 1390 EXPECT_EQ(2u, resource_provider_->num_resources()); |
| 1374 ResourceProvider::ResourceIdMap resource_map = | 1391 ResourceProvider::ResourceIdMap resource_map = |
| 1375 resource_provider_->GetChildToParentMap(child_id); | 1392 resource_provider_->GetChildToParentMap(child_id); |
| 1376 ResourceProvider::ResourceId mapped_id1 = resource_map[id1]; | 1393 ResourceProvider::ResourceId mapped_id1 = resource_map[id1]; |
| 1377 ResourceProvider::ResourceId mapped_id2 = resource_map[id2]; | 1394 ResourceProvider::ResourceId mapped_id2 = resource_map[id2]; |
| 1378 EXPECT_NE(0u, mapped_id1); | 1395 EXPECT_NE(0u, mapped_id1); |
| 1379 EXPECT_NE(0u, mapped_id2); | 1396 EXPECT_NE(0u, mapped_id2); |
| 1380 EXPECT_FALSE(resource_provider_->InUseByConsumer(id1)); | 1397 EXPECT_FALSE(resource_provider_->InUseByConsumer(id1)); |
| 1381 EXPECT_FALSE(resource_provider_->InUseByConsumer(id2)); | 1398 EXPECT_FALSE(resource_provider_->InUseByConsumer(id2)); |
| 1382 | 1399 |
| 1383 { | 1400 { |
| 1384 // The parent transfers the resources to the grandparent. | 1401 // The parent transfers the resources to the grandparent. |
| 1385 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 1402 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
| 1386 resource_ids_to_transfer.push_back(mapped_id1); | 1403 resource_ids_to_transfer.push_back(mapped_id1); |
| 1387 resource_ids_to_transfer.push_back(mapped_id2); | 1404 resource_ids_to_transfer.push_back(mapped_id2); |
| 1388 TransferableResourceArray list; | 1405 TransferableResourceArray list; |
| 1389 resource_provider_->PrepareSendToParent(resource_ids_to_transfer, &list); | 1406 resource_provider_->PrepareSendToParent(resource_ids_to_transfer, &list); |
| 1390 | 1407 |
| 1391 ASSERT_EQ(2u, list.size()); | 1408 ASSERT_EQ(2u, list.size()); |
| 1392 if (GetParam() == ResourceProvider::GLTexture) { | 1409 if (GetParam() == ResourceProvider::GLTexture) { |
| 1393 EXPECT_NE(0u, list[0].sync_point); | 1410 EXPECT_NE(0u, list[0].mailbox_holder.sync_point); |
| 1394 EXPECT_NE(0u, list[1].sync_point); | 1411 EXPECT_NE(0u, list[1].mailbox_holder.sync_point); |
| 1395 } | 1412 } |
| 1396 EXPECT_TRUE(resource_provider_->InUseByConsumer(id1)); | 1413 EXPECT_TRUE(resource_provider_->InUseByConsumer(id1)); |
| 1397 EXPECT_TRUE(resource_provider_->InUseByConsumer(id2)); | 1414 EXPECT_TRUE(resource_provider_->InUseByConsumer(id2)); |
| 1398 | 1415 |
| 1399 // Release the resource in the parent. Set no resources as being in use. The | 1416 // Release the resource in the parent. Set no resources as being in use. The |
| 1400 // resources are exported so that can't be transferred back yet. | 1417 // resources are exported so that can't be transferred back yet. |
| 1401 ResourceProvider::ResourceIdArray no_resources; | 1418 ResourceProvider::ResourceIdArray no_resources; |
| 1402 resource_provider_->DeclareUsedResourcesFromChild(child_id, no_resources); | 1419 resource_provider_->DeclareUsedResourcesFromChild(child_id, no_resources); |
| 1403 | 1420 |
| 1404 // Destroy the child, the resources should not be returned yet. | 1421 // Destroy the child, the resources should not be returned yet. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1458 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); | 1475 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); |
| 1459 { | 1476 { |
| 1460 // Transfer some resource to the parent. | 1477 // Transfer some resource to the parent. |
| 1461 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 1478 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
| 1462 resource_ids_to_transfer.push_back(id); | 1479 resource_ids_to_transfer.push_back(id); |
| 1463 TransferableResourceArray list; | 1480 TransferableResourceArray list; |
| 1464 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, | 1481 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, |
| 1465 &list); | 1482 &list); |
| 1466 ASSERT_EQ(1u, list.size()); | 1483 ASSERT_EQ(1u, list.size()); |
| 1467 if (GetParam() == ResourceProvider::GLTexture) | 1484 if (GetParam() == ResourceProvider::GLTexture) |
| 1468 EXPECT_NE(0u, list[0].sync_point); | 1485 EXPECT_NE(0u, list[0].mailbox_holder.sync_point); |
| 1469 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id)); | 1486 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id)); |
| 1470 resource_provider_->ReceiveFromChild(child_id, list); | 1487 resource_provider_->ReceiveFromChild(child_id, list); |
| 1471 resource_provider_->DeclareUsedResourcesFromChild(child_id, | 1488 resource_provider_->DeclareUsedResourcesFromChild(child_id, |
| 1472 resource_ids_to_transfer); | 1489 resource_ids_to_transfer); |
| 1473 } | 1490 } |
| 1474 | 1491 |
| 1475 // Delete textures in the child, while they are transfered. | 1492 // Delete textures in the child, while they are transfered. |
| 1476 child_resource_provider_->DeleteResource(id); | 1493 child_resource_provider_->DeleteResource(id); |
| 1477 EXPECT_EQ(1u, child_resource_provider_->num_resources()); | 1494 EXPECT_EQ(1u, child_resource_provider_->num_resources()); |
| 1478 { | 1495 { |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1676 if (GetParam() != ResourceProvider::GLTexture) | 1693 if (GetParam() != ResourceProvider::GLTexture) |
| 1677 return; | 1694 return; |
| 1678 unsigned texture = context()->createTexture(); | 1695 unsigned texture = context()->createTexture(); |
| 1679 context()->bindTexture(GL_TEXTURE_2D, texture); | 1696 context()->bindTexture(GL_TEXTURE_2D, texture); |
| 1680 uint8_t data[4] = { 1, 2, 3, 4 }; | 1697 uint8_t data[4] = { 1, 2, 3, 4 }; |
| 1681 context()->texImage2D( | 1698 context()->texImage2D( |
| 1682 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &data); | 1699 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &data); |
| 1683 gpu::Mailbox mailbox; | 1700 gpu::Mailbox mailbox; |
| 1684 context()->genMailboxCHROMIUM(mailbox.name); | 1701 context()->genMailboxCHROMIUM(mailbox.name); |
| 1685 context()->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); | 1702 context()->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); |
| 1686 unsigned sync_point = context()->insertSyncPoint(); | 1703 uint32 sync_point = context()->insertSyncPoint(); |
| 1687 | 1704 |
| 1688 // All the logic below assumes that the sync points are all positive. | 1705 // All the logic below assumes that the sync points are all positive. |
| 1689 EXPECT_LT(0u, sync_point); | 1706 EXPECT_LT(0u, sync_point); |
| 1690 | 1707 |
| 1691 unsigned release_sync_point = 0; | 1708 uint32 release_sync_point = 0; |
| 1692 bool lost_resource = false; | 1709 bool lost_resource = false; |
| 1693 ReleaseCallback callback = | 1710 ReleaseCallback callback = |
| 1694 base::Bind(ReleaseTextureMailbox, &release_sync_point, &lost_resource); | 1711 base::Bind(ReleaseTextureMailbox, &release_sync_point, &lost_resource); |
| 1695 ResourceProvider::ResourceId resource = | 1712 ResourceProvider::ResourceId resource = |
| 1696 resource_provider_->CreateResourceFromTextureMailbox( | 1713 resource_provider_->CreateResourceFromTextureMailbox( |
| 1697 TextureMailbox(mailbox, sync_point), | 1714 TextureMailbox(mailbox, GL_TEXTURE_2D, sync_point), |
| 1698 SingleReleaseCallback::Create(callback)); | 1715 SingleReleaseCallback::Create(callback)); |
| 1699 EXPECT_EQ(1u, context()->NumTextures()); | 1716 EXPECT_EQ(1u, context()->NumTextures()); |
| 1700 EXPECT_EQ(0u, release_sync_point); | 1717 EXPECT_EQ(0u, release_sync_point); |
| 1701 { | 1718 { |
| 1702 // Transfer the resource, expect the sync points to be consistent. | 1719 // Transfer the resource, expect the sync points to be consistent. |
| 1703 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 1720 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
| 1704 resource_ids_to_transfer.push_back(resource); | 1721 resource_ids_to_transfer.push_back(resource); |
| 1705 TransferableResourceArray list; | 1722 TransferableResourceArray list; |
| 1706 resource_provider_->PrepareSendToParent(resource_ids_to_transfer, &list); | 1723 resource_provider_->PrepareSendToParent(resource_ids_to_transfer, &list); |
| 1707 ASSERT_EQ(1u, list.size()); | 1724 ASSERT_EQ(1u, list.size()); |
| 1708 EXPECT_LE(sync_point, list[0].sync_point); | 1725 EXPECT_LE(sync_point, list[0].mailbox_holder.sync_point); |
| 1709 EXPECT_EQ(0, | 1726 EXPECT_EQ(0, |
| 1710 memcmp(mailbox.name, list[0].mailbox.name, sizeof(mailbox.name))); | 1727 memcmp(mailbox.name, |
| 1728 list[0].mailbox_holder.mailbox.name, |
| 1729 sizeof(mailbox.name))); |
| 1711 EXPECT_EQ(0u, release_sync_point); | 1730 EXPECT_EQ(0u, release_sync_point); |
| 1712 | 1731 |
| 1713 context()->waitSyncPoint(list[0].sync_point); | 1732 context()->waitSyncPoint(list[0].mailbox_holder.sync_point); |
| 1714 unsigned other_texture = context()->createTexture(); | 1733 unsigned other_texture = context()->createTexture(); |
| 1715 context()->bindTexture(GL_TEXTURE_2D, other_texture); | 1734 context()->bindTexture(GL_TEXTURE_2D, other_texture); |
| 1716 context()->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); | 1735 context()->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); |
| 1717 uint8_t test_data[4] = { 0 }; | 1736 uint8_t test_data[4] = { 0 }; |
| 1718 context()->GetPixels( | 1737 context()->GetPixels( |
| 1719 gfx::Size(1, 1), RGBA_8888, test_data); | 1738 gfx::Size(1, 1), RGBA_8888, test_data); |
| 1720 EXPECT_EQ(0, memcmp(data, test_data, sizeof(data))); | 1739 EXPECT_EQ(0, memcmp(data, test_data, sizeof(data))); |
| 1721 context()->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); | 1740 context()->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); |
| 1722 context()->deleteTexture(other_texture); | 1741 context()->deleteTexture(other_texture); |
| 1723 list[0].sync_point = context()->insertSyncPoint(); | 1742 list[0].mailbox_holder.sync_point = context()->insertSyncPoint(); |
| 1724 EXPECT_LT(0u, list[0].sync_point); | 1743 EXPECT_LT(0u, list[0].mailbox_holder.sync_point); |
| 1725 | 1744 |
| 1726 // Receive the resource, then delete it, expect the sync points to be | 1745 // Receive the resource, then delete it, expect the sync points to be |
| 1727 // consistent. | 1746 // consistent. |
| 1728 ReturnedResourceArray returned; | 1747 ReturnedResourceArray returned; |
| 1729 TransferableResource::ReturnResources(list, &returned); | 1748 TransferableResource::ReturnResources(list, &returned); |
| 1730 resource_provider_->ReceiveReturnsFromParent(returned); | 1749 resource_provider_->ReceiveReturnsFromParent(returned); |
| 1731 EXPECT_EQ(1u, context()->NumTextures()); | 1750 EXPECT_EQ(1u, context()->NumTextures()); |
| 1732 EXPECT_EQ(0u, release_sync_point); | 1751 EXPECT_EQ(0u, release_sync_point); |
| 1733 | 1752 |
| 1734 resource_provider_->DeleteResource(resource); | 1753 resource_provider_->DeleteResource(resource); |
| 1735 EXPECT_LE(list[0].sync_point, release_sync_point); | 1754 EXPECT_LE(list[0].mailbox_holder.sync_point, release_sync_point); |
| 1736 EXPECT_FALSE(lost_resource); | 1755 EXPECT_FALSE(lost_resource); |
| 1737 } | 1756 } |
| 1738 | 1757 |
| 1739 // We're going to do the same thing as above, but testing the case where we | 1758 // We're going to do the same thing as above, but testing the case where we |
| 1740 // delete the resource before we receive it back. | 1759 // delete the resource before we receive it back. |
| 1741 sync_point = release_sync_point; | 1760 sync_point = release_sync_point; |
| 1742 EXPECT_LT(0u, sync_point); | 1761 EXPECT_LT(0u, sync_point); |
| 1743 release_sync_point = 0; | 1762 release_sync_point = 0; |
| 1744 resource = resource_provider_->CreateResourceFromTextureMailbox( | 1763 resource = resource_provider_->CreateResourceFromTextureMailbox( |
| 1745 TextureMailbox(mailbox, sync_point), | 1764 TextureMailbox(mailbox, GL_TEXTURE_2D, sync_point), |
| 1746 SingleReleaseCallback::Create(callback)); | 1765 SingleReleaseCallback::Create(callback)); |
| 1747 EXPECT_EQ(1u, context()->NumTextures()); | 1766 EXPECT_EQ(1u, context()->NumTextures()); |
| 1748 EXPECT_EQ(0u, release_sync_point); | 1767 EXPECT_EQ(0u, release_sync_point); |
| 1749 { | 1768 { |
| 1750 // Transfer the resource, expect the sync points to be consistent. | 1769 // Transfer the resource, expect the sync points to be consistent. |
| 1751 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 1770 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
| 1752 resource_ids_to_transfer.push_back(resource); | 1771 resource_ids_to_transfer.push_back(resource); |
| 1753 TransferableResourceArray list; | 1772 TransferableResourceArray list; |
| 1754 resource_provider_->PrepareSendToParent(resource_ids_to_transfer, &list); | 1773 resource_provider_->PrepareSendToParent(resource_ids_to_transfer, &list); |
| 1755 ASSERT_EQ(1u, list.size()); | 1774 ASSERT_EQ(1u, list.size()); |
| 1756 EXPECT_LE(sync_point, list[0].sync_point); | 1775 EXPECT_LE(sync_point, list[0].mailbox_holder.sync_point); |
| 1757 EXPECT_EQ(0, | 1776 EXPECT_EQ(0, |
| 1758 memcmp(mailbox.name, list[0].mailbox.name, sizeof(mailbox.name))); | 1777 memcmp(mailbox.name, |
| 1778 list[0].mailbox_holder.mailbox.name, |
| 1779 sizeof(mailbox.name))); |
| 1759 EXPECT_EQ(0u, release_sync_point); | 1780 EXPECT_EQ(0u, release_sync_point); |
| 1760 | 1781 |
| 1761 context()->waitSyncPoint(list[0].sync_point); | 1782 context()->waitSyncPoint(list[0].mailbox_holder.sync_point); |
| 1762 unsigned other_texture = context()->createTexture(); | 1783 unsigned other_texture = context()->createTexture(); |
| 1763 context()->bindTexture(GL_TEXTURE_2D, other_texture); | 1784 context()->bindTexture(GL_TEXTURE_2D, other_texture); |
| 1764 context()->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); | 1785 context()->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); |
| 1765 uint8_t test_data[4] = { 0 }; | 1786 uint8_t test_data[4] = { 0 }; |
| 1766 context()->GetPixels( | 1787 context()->GetPixels( |
| 1767 gfx::Size(1, 1), RGBA_8888, test_data); | 1788 gfx::Size(1, 1), RGBA_8888, test_data); |
| 1768 EXPECT_EQ(0, memcmp(data, test_data, sizeof(data))); | 1789 EXPECT_EQ(0, memcmp(data, test_data, sizeof(data))); |
| 1769 context()->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); | 1790 context()->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); |
| 1770 context()->deleteTexture(other_texture); | 1791 context()->deleteTexture(other_texture); |
| 1771 list[0].sync_point = context()->insertSyncPoint(); | 1792 list[0].mailbox_holder.sync_point = context()->insertSyncPoint(); |
| 1772 EXPECT_LT(0u, list[0].sync_point); | 1793 EXPECT_LT(0u, list[0].mailbox_holder.sync_point); |
| 1773 | 1794 |
| 1774 // Delete the resource, which shouldn't do anything. | 1795 // Delete the resource, which shouldn't do anything. |
| 1775 resource_provider_->DeleteResource(resource); | 1796 resource_provider_->DeleteResource(resource); |
| 1776 EXPECT_EQ(1u, context()->NumTextures()); | 1797 EXPECT_EQ(1u, context()->NumTextures()); |
| 1777 EXPECT_EQ(0u, release_sync_point); | 1798 EXPECT_EQ(0u, release_sync_point); |
| 1778 | 1799 |
| 1779 // Then receive the resource which should release the mailbox, expect the | 1800 // Then receive the resource which should release the mailbox, expect the |
| 1780 // sync points to be consistent. | 1801 // sync points to be consistent. |
| 1781 ReturnedResourceArray returned; | 1802 ReturnedResourceArray returned; |
| 1782 TransferableResource::ReturnResources(list, &returned); | 1803 TransferableResource::ReturnResources(list, &returned); |
| 1783 resource_provider_->ReceiveReturnsFromParent(returned); | 1804 resource_provider_->ReceiveReturnsFromParent(returned); |
| 1784 EXPECT_LE(list[0].sync_point, release_sync_point); | 1805 EXPECT_LE(list[0].mailbox_holder.sync_point, release_sync_point); |
| 1785 EXPECT_FALSE(lost_resource); | 1806 EXPECT_FALSE(lost_resource); |
| 1786 } | 1807 } |
| 1787 | 1808 |
| 1788 context()->waitSyncPoint(release_sync_point); | 1809 context()->waitSyncPoint(release_sync_point); |
| 1789 context()->bindTexture(GL_TEXTURE_2D, texture); | 1810 context()->bindTexture(GL_TEXTURE_2D, texture); |
| 1790 context()->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); | 1811 context()->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); |
| 1791 context()->deleteTexture(texture); | 1812 context()->deleteTexture(texture); |
| 1792 } | 1813 } |
| 1793 | 1814 |
| 1794 TEST_P(ResourceProviderTest, LostResourceInParent) { | 1815 TEST_P(ResourceProviderTest, LostResourceInParent) { |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1914 } | 1935 } |
| 1915 | 1936 |
| 1916 // The resource should be lost. | 1937 // The resource should be lost. |
| 1917 EXPECT_TRUE(child_resource_provider_->IsLost(resource)); | 1938 EXPECT_TRUE(child_resource_provider_->IsLost(resource)); |
| 1918 | 1939 |
| 1919 // Lost resources stay in use in the parent forever. | 1940 // Lost resources stay in use in the parent forever. |
| 1920 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(resource)); | 1941 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(resource)); |
| 1921 } | 1942 } |
| 1922 | 1943 |
| 1923 TEST_P(ResourceProviderTest, LostMailboxInParent) { | 1944 TEST_P(ResourceProviderTest, LostMailboxInParent) { |
| 1924 unsigned release_sync_point = 0; | 1945 uint32 release_sync_point = 0; |
| 1925 bool lost_resource = false; | 1946 bool lost_resource = false; |
| 1926 bool release_called = false; | 1947 bool release_called = false; |
| 1927 unsigned sync_point = 0; | 1948 uint32 sync_point = 0; |
| 1928 ResourceProvider::ResourceId resource = CreateChildMailbox( | 1949 ResourceProvider::ResourceId resource = CreateChildMailbox( |
| 1929 &release_sync_point, &lost_resource, &release_called, &sync_point); | 1950 &release_sync_point, &lost_resource, &release_called, &sync_point); |
| 1930 | 1951 |
| 1931 ReturnedResourceArray returned_to_child; | 1952 ReturnedResourceArray returned_to_child; |
| 1932 int child_id = | 1953 int child_id = |
| 1933 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); | 1954 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); |
| 1934 { | 1955 { |
| 1935 // Transfer the resource to the parent. | 1956 // Transfer the resource to the parent. |
| 1936 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 1957 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
| 1937 resource_ids_to_transfer.push_back(resource); | 1958 resource_ids_to_transfer.push_back(resource); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1964 returned_to_child.clear(); | 1985 returned_to_child.clear(); |
| 1965 } | 1986 } |
| 1966 | 1987 |
| 1967 // Delete the resource in the child. Expect the resource to be lost if it's | 1988 // Delete the resource in the child. Expect the resource to be lost if it's |
| 1968 // a GL texture. | 1989 // a GL texture. |
| 1969 child_resource_provider_->DeleteResource(resource); | 1990 child_resource_provider_->DeleteResource(resource); |
| 1970 EXPECT_EQ(lost_resource, GetParam() == ResourceProvider::GLTexture); | 1991 EXPECT_EQ(lost_resource, GetParam() == ResourceProvider::GLTexture); |
| 1971 } | 1992 } |
| 1972 | 1993 |
| 1973 TEST_P(ResourceProviderTest, LostMailboxInGrandParent) { | 1994 TEST_P(ResourceProviderTest, LostMailboxInGrandParent) { |
| 1974 unsigned release_sync_point = 0; | 1995 uint32 release_sync_point = 0; |
| 1975 bool lost_resource = false; | 1996 bool lost_resource = false; |
| 1976 bool release_called = false; | 1997 bool release_called = false; |
| 1977 unsigned sync_point = 0; | 1998 uint32 sync_point = 0; |
| 1978 ResourceProvider::ResourceId resource = CreateChildMailbox( | 1999 ResourceProvider::ResourceId resource = CreateChildMailbox( |
| 1979 &release_sync_point, &lost_resource, &release_called, &sync_point); | 2000 &release_sync_point, &lost_resource, &release_called, &sync_point); |
| 1980 | 2001 |
| 1981 ReturnedResourceArray returned_to_child; | 2002 ReturnedResourceArray returned_to_child; |
| 1982 int child_id = | 2003 int child_id = |
| 1983 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); | 2004 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); |
| 1984 { | 2005 { |
| 1985 // Transfer the resource to the parent. | 2006 // Transfer the resource to the parent. |
| 1986 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 2007 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
| 1987 resource_ids_to_transfer.push_back(resource); | 2008 resource_ids_to_transfer.push_back(resource); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2032 child_resource_provider_->ReceiveReturnsFromParent(returned_to_child); | 2053 child_resource_provider_->ReceiveReturnsFromParent(returned_to_child); |
| 2033 returned_to_child.clear(); | 2054 returned_to_child.clear(); |
| 2034 } | 2055 } |
| 2035 | 2056 |
| 2036 // Delete the resource in the child. Expect the resource to be lost. | 2057 // Delete the resource in the child. Expect the resource to be lost. |
| 2037 child_resource_provider_->DeleteResource(resource); | 2058 child_resource_provider_->DeleteResource(resource); |
| 2038 EXPECT_TRUE(lost_resource); | 2059 EXPECT_TRUE(lost_resource); |
| 2039 } | 2060 } |
| 2040 | 2061 |
| 2041 TEST_P(ResourceProviderTest, Shutdown) { | 2062 TEST_P(ResourceProviderTest, Shutdown) { |
| 2042 unsigned release_sync_point = 0; | 2063 uint32 release_sync_point = 0; |
| 2043 bool lost_resource = false; | 2064 bool lost_resource = false; |
| 2044 bool release_called = false; | 2065 bool release_called = false; |
| 2045 unsigned sync_point = 0; | 2066 uint32 sync_point = 0; |
| 2046 CreateChildMailbox( | 2067 CreateChildMailbox( |
| 2047 &release_sync_point, &lost_resource, &release_called, &sync_point); | 2068 &release_sync_point, &lost_resource, &release_called, &sync_point); |
| 2048 | 2069 |
| 2049 EXPECT_EQ(0u, release_sync_point); | 2070 EXPECT_EQ(0u, release_sync_point); |
| 2050 EXPECT_FALSE(lost_resource); | 2071 EXPECT_FALSE(lost_resource); |
| 2051 | 2072 |
| 2052 child_resource_provider_.reset(); | 2073 child_resource_provider_.reset(); |
| 2053 | 2074 |
| 2054 if (GetParam() == ResourceProvider::GLTexture) { | 2075 if (GetParam() == ResourceProvider::GLTexture) { |
| 2055 EXPECT_LE(sync_point, release_sync_point); | 2076 EXPECT_LE(sync_point, release_sync_point); |
| 2056 } | 2077 } |
| 2057 EXPECT_TRUE(release_called); | 2078 EXPECT_TRUE(release_called); |
| 2058 EXPECT_FALSE(lost_resource); | 2079 EXPECT_FALSE(lost_resource); |
| 2059 } | 2080 } |
| 2060 | 2081 |
| 2061 TEST_P(ResourceProviderTest, ShutdownWithExportedResource) { | 2082 TEST_P(ResourceProviderTest, ShutdownWithExportedResource) { |
| 2062 unsigned release_sync_point = 0; | 2083 uint32 release_sync_point = 0; |
| 2063 bool lost_resource = false; | 2084 bool lost_resource = false; |
| 2064 bool release_called = false; | 2085 bool release_called = false; |
| 2065 unsigned sync_point = 0; | 2086 uint32 sync_point = 0; |
| 2066 ResourceProvider::ResourceId resource = CreateChildMailbox( | 2087 ResourceProvider::ResourceId resource = CreateChildMailbox( |
| 2067 &release_sync_point, &lost_resource, &release_called, &sync_point); | 2088 &release_sync_point, &lost_resource, &release_called, &sync_point); |
| 2068 | 2089 |
| 2069 // Transfer the resource, so we can't release it properly on shutdown. | 2090 // Transfer the resource, so we can't release it properly on shutdown. |
| 2070 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 2091 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
| 2071 resource_ids_to_transfer.push_back(resource); | 2092 resource_ids_to_transfer.push_back(resource); |
| 2072 TransferableResourceArray list; | 2093 TransferableResourceArray list; |
| 2073 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, | 2094 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, |
| 2074 &list); | 2095 &list); |
| 2075 | 2096 |
| 2076 EXPECT_EQ(0u, release_sync_point); | 2097 EXPECT_EQ(0u, release_sync_point); |
| 2077 EXPECT_FALSE(lost_resource); | 2098 EXPECT_FALSE(lost_resource); |
| 2078 | 2099 |
| 2079 child_resource_provider_.reset(); | 2100 child_resource_provider_.reset(); |
| 2080 | 2101 |
| 2081 // Since the resource is in the parent, the child considers it lost. | 2102 // Since the resource is in the parent, the child considers it lost. |
| 2082 EXPECT_EQ(0u, release_sync_point); | 2103 EXPECT_EQ(0u, release_sync_point); |
| 2083 EXPECT_TRUE(lost_resource); | 2104 EXPECT_TRUE(lost_resource); |
| 2084 } | 2105 } |
| 2085 | 2106 |
| 2086 TEST_P(ResourceProviderTest, LostContext) { | 2107 TEST_P(ResourceProviderTest, LostContext) { |
| 2087 // TextureMailbox callbacks only exist for GL textures for now. | 2108 // TextureMailbox callbacks only exist for GL textures for now. |
| 2088 if (GetParam() != ResourceProvider::GLTexture) | 2109 if (GetParam() != ResourceProvider::GLTexture) |
| 2089 return; | 2110 return; |
| 2090 unsigned texture = context()->createTexture(); | 2111 unsigned texture = context()->createTexture(); |
| 2091 context()->bindTexture(GL_TEXTURE_2D, texture); | 2112 context()->bindTexture(GL_TEXTURE_2D, texture); |
| 2092 gpu::Mailbox mailbox; | 2113 gpu::Mailbox mailbox; |
| 2093 context()->genMailboxCHROMIUM(mailbox.name); | 2114 context()->genMailboxCHROMIUM(mailbox.name); |
| 2094 context()->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); | 2115 context()->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); |
| 2095 unsigned sync_point = context()->insertSyncPoint(); | 2116 uint32 sync_point = context()->insertSyncPoint(); |
| 2096 | 2117 |
| 2097 EXPECT_LT(0u, sync_point); | 2118 EXPECT_LT(0u, sync_point); |
| 2098 | 2119 |
| 2099 unsigned release_sync_point = 0; | 2120 uint32 release_sync_point = 0; |
| 2100 bool lost_resource = false; | 2121 bool lost_resource = false; |
| 2101 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( | 2122 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( |
| 2102 base::Bind(ReleaseTextureMailbox, &release_sync_point, &lost_resource)); | 2123 base::Bind(ReleaseTextureMailbox, &release_sync_point, &lost_resource)); |
| 2103 resource_provider_->CreateResourceFromTextureMailbox( | 2124 resource_provider_->CreateResourceFromTextureMailbox( |
| 2104 TextureMailbox(mailbox, sync_point), | 2125 TextureMailbox(mailbox, GL_TEXTURE_2D, sync_point), callback.Pass()); |
| 2105 callback.Pass()); | |
| 2106 | 2126 |
| 2107 EXPECT_EQ(0u, release_sync_point); | 2127 EXPECT_EQ(0u, release_sync_point); |
| 2108 EXPECT_FALSE(lost_resource); | 2128 EXPECT_FALSE(lost_resource); |
| 2109 | 2129 |
| 2110 resource_provider_->DidLoseOutputSurface(); | 2130 resource_provider_->DidLoseOutputSurface(); |
| 2111 resource_provider_.reset(); | 2131 resource_provider_.reset(); |
| 2112 | 2132 |
| 2113 EXPECT_LE(sync_point, release_sync_point); | 2133 EXPECT_LE(sync_point, release_sync_point); |
| 2114 EXPECT_TRUE(lost_resource); | 2134 EXPECT_TRUE(lost_resource); |
| 2115 } | 2135 } |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2344 | 2364 |
| 2345 FakeOutputSurfaceClient output_surface_client; | 2365 FakeOutputSurfaceClient output_surface_client; |
| 2346 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 2366 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 2347 context_owned.PassAs<TestWebGraphicsContext3D>())); | 2367 context_owned.PassAs<TestWebGraphicsContext3D>())); |
| 2348 CHECK(output_surface->BindToClient(&output_surface_client)); | 2368 CHECK(output_surface->BindToClient(&output_surface_client)); |
| 2349 | 2369 |
| 2350 scoped_ptr<ResourceProvider> resource_provider( | 2370 scoped_ptr<ResourceProvider> resource_provider( |
| 2351 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); | 2371 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); |
| 2352 | 2372 |
| 2353 unsigned texture_id = 1; | 2373 unsigned texture_id = 1; |
| 2354 unsigned sync_point = 30; | 2374 uint32 sync_point = 30; |
| 2355 unsigned target = GL_TEXTURE_2D; | 2375 unsigned target = GL_TEXTURE_2D; |
| 2356 | 2376 |
| 2357 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); | 2377 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); |
| 2358 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); | 2378 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); |
| 2359 EXPECT_CALL(*context, insertSyncPoint()).Times(0); | 2379 EXPECT_CALL(*context, insertSyncPoint()).Times(0); |
| 2360 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); | 2380 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); |
| 2361 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0); | 2381 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0); |
| 2362 | 2382 |
| 2363 gpu::Mailbox gpu_mailbox; | 2383 gpu::Mailbox gpu_mailbox; |
| 2364 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1); | 2384 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1); |
| 2365 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( | 2385 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( |
| 2366 base::Bind(&EmptyReleaseCallback)); | 2386 base::Bind(&EmptyReleaseCallback)); |
| 2367 | 2387 |
| 2368 TextureMailbox mailbox(gpu_mailbox, sync_point); | 2388 TextureMailbox mailbox(gpu_mailbox, target, sync_point); |
| 2369 | 2389 |
| 2370 ResourceProvider::ResourceId id = | 2390 ResourceProvider::ResourceId id = |
| 2371 resource_provider->CreateResourceFromTextureMailbox( | 2391 resource_provider->CreateResourceFromTextureMailbox( |
| 2372 mailbox, callback.Pass()); | 2392 mailbox, callback.Pass()); |
| 2373 EXPECT_NE(0u, id); | 2393 EXPECT_NE(0u, id); |
| 2374 | 2394 |
| 2375 Mock::VerifyAndClearExpectations(context); | 2395 Mock::VerifyAndClearExpectations(context); |
| 2376 | 2396 |
| 2377 { | 2397 { |
| 2378 // Using the texture does a consume of the mailbox. | 2398 // Using the texture does a consume of the mailbox. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2408 | 2428 |
| 2409 FakeOutputSurfaceClient output_surface_client; | 2429 FakeOutputSurfaceClient output_surface_client; |
| 2410 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 2430 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 2411 context_owned.PassAs<TestWebGraphicsContext3D>())); | 2431 context_owned.PassAs<TestWebGraphicsContext3D>())); |
| 2412 CHECK(output_surface->BindToClient(&output_surface_client)); | 2432 CHECK(output_surface->BindToClient(&output_surface_client)); |
| 2413 | 2433 |
| 2414 scoped_ptr<ResourceProvider> resource_provider( | 2434 scoped_ptr<ResourceProvider> resource_provider( |
| 2415 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); | 2435 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); |
| 2416 | 2436 |
| 2417 unsigned texture_id = 1; | 2437 unsigned texture_id = 1; |
| 2418 unsigned sync_point = 30; | 2438 uint32 sync_point = 30; |
| 2419 unsigned target = GL_TEXTURE_EXTERNAL_OES; | 2439 unsigned target = GL_TEXTURE_EXTERNAL_OES; |
| 2420 | 2440 |
| 2421 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); | 2441 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); |
| 2422 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); | 2442 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); |
| 2423 EXPECT_CALL(*context, insertSyncPoint()).Times(0); | 2443 EXPECT_CALL(*context, insertSyncPoint()).Times(0); |
| 2424 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); | 2444 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); |
| 2425 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0); | 2445 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0); |
| 2426 | 2446 |
| 2427 gpu::Mailbox gpu_mailbox; | 2447 gpu::Mailbox gpu_mailbox; |
| 2428 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1); | 2448 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1); |
| (...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3161 resource_provider->AllocateForTesting(id); | 3181 resource_provider->AllocateForTesting(id); |
| 3162 Mock::VerifyAndClearExpectations(context); | 3182 Mock::VerifyAndClearExpectations(context); |
| 3163 | 3183 |
| 3164 DCHECK_EQ(10u, context->PeekTextureId()); | 3184 DCHECK_EQ(10u, context->PeekTextureId()); |
| 3165 resource_provider->DeleteResource(id); | 3185 resource_provider->DeleteResource(id); |
| 3166 } | 3186 } |
| 3167 } | 3187 } |
| 3168 | 3188 |
| 3169 } // namespace | 3189 } // namespace |
| 3170 } // namespace cc | 3190 } // namespace cc |
| OLD | NEW |