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 gfx::Size size, | 67 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 virtual void texStorage2DEXT(GLenum target, | 176 virtual void texStorage2DEXT(GLenum target, |
177 GLint levels, | 177 GLint levels, |
178 GLuint internalformat, | 178 GLuint internalformat, |
179 GLint width, | 179 GLint width, |
180 GLint height) OVERRIDE { | 180 GLint height) OVERRIDE { |
181 CheckTextureIsBound(target); | 181 CheckTextureIsBound(target); |
182 ASSERT_EQ(static_cast<unsigned>(GL_TEXTURE_2D), target); | 182 ASSERT_EQ(static_cast<unsigned>(GL_TEXTURE_2D), target); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 src += in_pitch; | 316 src += in_pitch; |
317 } | 317 } |
318 } | 318 } |
319 | 319 |
320 struct PendingProduceTexture { | 320 struct PendingProduceTexture { |
321 GLbyte mailbox[64]; | 321 GLbyte mailbox[64]; |
322 scoped_refptr<TestTexture> texture; | 322 scoped_refptr<TestTexture> texture; |
323 }; | 323 }; |
324 typedef ScopedPtrDeque<PendingProduceTexture> PendingProduceTextureList; | 324 typedef ScopedPtrDeque<PendingProduceTexture> PendingProduceTextureList; |
325 ContextSharedData* shared_data_; | 325 ContextSharedData* shared_data_; |
326 unsigned last_waited_sync_point_; | 326 GLuint last_waited_sync_point_; |
327 PendingProduceTextureList pending_produce_textures_; | 327 PendingProduceTextureList pending_produce_textures_; |
328 }; | 328 }; |
329 | 329 |
330 void FreeSharedBitmap(SharedBitmap* shared_bitmap) { | 330 void FreeSharedBitmap(SharedBitmap* shared_bitmap) { |
331 delete shared_bitmap->memory(); | 331 delete shared_bitmap->memory(); |
332 } | 332 } |
333 | 333 |
334 void IgnoreSharedBitmap(SharedBitmap* shared_bitmap) {} | 334 void IgnoreSharedBitmap(SharedBitmap* shared_bitmap) {} |
335 | 335 |
336 class TestSharedBitmapManager : public SharedBitmapManager { | 336 class TestSharedBitmapManager : public SharedBitmapManager { |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 | 466 |
467 static void SetResourceFilter(ResourceProvider* resource_provider, | 467 static void SetResourceFilter(ResourceProvider* resource_provider, |
468 ResourceProvider::ResourceId id, | 468 ResourceProvider::ResourceId id, |
469 GLenum filter) { | 469 GLenum filter) { |
470 ResourceProvider::ScopedSamplerGL sampler( | 470 ResourceProvider::ScopedSamplerGL sampler( |
471 resource_provider, id, GL_TEXTURE_2D, filter); | 471 resource_provider, id, GL_TEXTURE_2D, filter); |
472 } | 472 } |
473 | 473 |
474 ResourceProviderContext* context() { return context3d_; } | 474 ResourceProviderContext* context() { return context3d_; } |
475 | 475 |
476 ResourceProvider::ResourceId CreateChildMailbox(unsigned* release_sync_point, | 476 ResourceProvider::ResourceId CreateChildMailbox(uint32* release_sync_point, |
477 bool* lost_resource, | 477 bool* lost_resource, |
478 bool* release_called, | 478 bool* release_called, |
479 unsigned* sync_point) { | 479 uint32* sync_point) { |
480 if (GetParam() == ResourceProvider::GLTexture) { | 480 if (GetParam() == ResourceProvider::GLTexture) { |
481 unsigned texture = child_context_->createTexture(); | 481 unsigned texture = child_context_->createTexture(); |
482 gpu::Mailbox gpu_mailbox; | 482 gpu::Mailbox gpu_mailbox; |
483 child_context_->bindTexture(GL_TEXTURE_2D, texture); | 483 child_context_->bindTexture(GL_TEXTURE_2D, texture); |
484 child_context_->genMailboxCHROMIUM(gpu_mailbox.name); | 484 child_context_->genMailboxCHROMIUM(gpu_mailbox.name); |
485 child_context_->produceTextureCHROMIUM(GL_TEXTURE_2D, gpu_mailbox.name); | 485 child_context_->produceTextureCHROMIUM(GL_TEXTURE_2D, gpu_mailbox.name); |
486 *sync_point = child_context_->insertSyncPoint(); | 486 *sync_point = child_context_->insertSyncPoint(); |
487 EXPECT_LT(0u, *sync_point); | 487 EXPECT_LT(0u, *sync_point); |
488 | 488 |
489 scoped_ptr<base::SharedMemory> shared_memory; | 489 scoped_ptr<base::SharedMemory> shared_memory; |
490 scoped_ptr<SingleReleaseCallback> callback = | 490 scoped_ptr<SingleReleaseCallback> callback = |
491 SingleReleaseCallback::Create(base::Bind(ReleaseSharedMemoryCallback, | 491 SingleReleaseCallback::Create(base::Bind(ReleaseSharedMemoryCallback, |
492 base::Passed(&shared_memory), | 492 base::Passed(&shared_memory), |
493 release_called, | 493 release_called, |
494 release_sync_point, | 494 release_sync_point, |
495 lost_resource)); | 495 lost_resource)); |
496 return child_resource_provider_->CreateResourceFromTextureMailbox( | 496 return child_resource_provider_->CreateResourceFromTextureMailbox( |
497 TextureMailbox(gpu_mailbox, *sync_point), callback.Pass()); | 497 TextureMailbox(gpu_mailbox, GL_TEXTURE_2D, *sync_point), |
| 498 callback.Pass()); |
498 } else { | 499 } else { |
499 gfx::Size size(64, 64); | 500 gfx::Size size(64, 64); |
500 scoped_ptr<base::SharedMemory> shared_memory( | 501 scoped_ptr<base::SharedMemory> shared_memory( |
501 CreateAndFillSharedMemory(size, 0)); | 502 CreateAndFillSharedMemory(size, 0)); |
502 | 503 |
503 base::SharedMemory* shared_memory_ptr = shared_memory.get(); | 504 base::SharedMemory* shared_memory_ptr = shared_memory.get(); |
504 scoped_ptr<SingleReleaseCallback> callback = | 505 scoped_ptr<SingleReleaseCallback> callback = |
505 SingleReleaseCallback::Create(base::Bind(ReleaseSharedMemoryCallback, | 506 SingleReleaseCallback::Create(base::Bind(ReleaseSharedMemoryCallback, |
506 base::Passed(&shared_memory), | 507 base::Passed(&shared_memory), |
507 release_called, | 508 release_called, |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 child_resource_provider_->MapImage(id3); | 654 child_resource_provider_->MapImage(id3); |
654 child_resource_provider_->UnmapImage(id3); | 655 child_resource_provider_->UnmapImage(id3); |
655 | 656 |
656 GLuint external_texture_id = child_context_->createExternalTexture(); | 657 GLuint external_texture_id = child_context_->createExternalTexture(); |
657 child_context_->bindTexture(GL_TEXTURE_EXTERNAL_OES, external_texture_id); | 658 child_context_->bindTexture(GL_TEXTURE_EXTERNAL_OES, external_texture_id); |
658 | 659 |
659 gpu::Mailbox external_mailbox; | 660 gpu::Mailbox external_mailbox; |
660 child_context_->genMailboxCHROMIUM(external_mailbox.name); | 661 child_context_->genMailboxCHROMIUM(external_mailbox.name); |
661 child_context_->produceTextureCHROMIUM(GL_TEXTURE_EXTERNAL_OES, | 662 child_context_->produceTextureCHROMIUM(GL_TEXTURE_EXTERNAL_OES, |
662 external_mailbox.name); | 663 external_mailbox.name); |
663 const unsigned external_sync_point = child_context_->insertSyncPoint(); | 664 const GLuint external_sync_point = child_context_->insertSyncPoint(); |
664 ResourceProvider::ResourceId id4 = | 665 ResourceProvider::ResourceId id4 = |
665 child_resource_provider_->CreateResourceFromTextureMailbox( | 666 child_resource_provider_->CreateResourceFromTextureMailbox( |
666 TextureMailbox( | 667 TextureMailbox( |
667 external_mailbox, GL_TEXTURE_EXTERNAL_OES, external_sync_point), | 668 external_mailbox, GL_TEXTURE_EXTERNAL_OES, external_sync_point), |
668 SingleReleaseCallback::Create(base::Bind(&EmptyReleaseCallback))); | 669 SingleReleaseCallback::Create(base::Bind(&EmptyReleaseCallback))); |
669 | 670 |
670 ReturnedResourceArray returned_to_child; | 671 ReturnedResourceArray returned_to_child; |
671 int child_id = | 672 int child_id = |
672 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); | 673 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); |
673 { | 674 { |
674 // Transfer some resources to the parent. | 675 // Transfer some resources to the parent. |
675 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 676 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
676 resource_ids_to_transfer.push_back(id1); | 677 resource_ids_to_transfer.push_back(id1); |
677 resource_ids_to_transfer.push_back(id2); | 678 resource_ids_to_transfer.push_back(id2); |
678 resource_ids_to_transfer.push_back(id3); | 679 resource_ids_to_transfer.push_back(id3); |
679 resource_ids_to_transfer.push_back(id4); | 680 resource_ids_to_transfer.push_back(id4); |
680 TransferableResourceArray list; | 681 TransferableResourceArray list; |
681 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, | 682 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, |
682 &list); | 683 &list); |
683 ASSERT_EQ(4u, list.size()); | 684 ASSERT_EQ(4u, list.size()); |
684 EXPECT_NE(0u, list[0].sync_point); | 685 EXPECT_NE(0u, list[0].mailbox_holder.sync_point); |
685 EXPECT_NE(0u, list[1].sync_point); | 686 EXPECT_NE(0u, list[1].mailbox_holder.sync_point); |
686 EXPECT_NE(0u, list[2].sync_point); | 687 EXPECT_NE(0u, list[2].mailbox_holder.sync_point); |
687 EXPECT_EQ(external_sync_point, list[3].sync_point); | 688 EXPECT_EQ(external_sync_point, list[3].mailbox_holder.sync_point); |
688 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), list[0].target); | 689 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), |
689 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), list[1].target); | 690 list[0].mailbox_holder.texture_target); |
690 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), list[2].target); | 691 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), |
691 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_EXTERNAL_OES), list[3].target); | 692 list[1].mailbox_holder.texture_target); |
| 693 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), |
| 694 list[2].mailbox_holder.texture_target); |
| 695 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_EXTERNAL_OES), |
| 696 list[3].mailbox_holder.texture_target); |
692 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); | 697 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); |
693 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); | 698 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); |
694 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id3)); | 699 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id3)); |
695 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id4)); | 700 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id4)); |
696 resource_provider_->ReceiveFromChild(child_id, list); | 701 resource_provider_->ReceiveFromChild(child_id, list); |
697 resource_provider_->DeclareUsedResourcesFromChild(child_id, | 702 resource_provider_->DeclareUsedResourcesFromChild(child_id, |
698 resource_ids_to_transfer); | 703 resource_ids_to_transfer); |
699 } | 704 } |
700 | 705 |
701 EXPECT_EQ(4u, resource_provider_->num_resources()); | 706 EXPECT_EQ(4u, resource_provider_->num_resources()); |
(...skipping 28 matching lines...) Expand all Loading... |
730 resource_ids_to_transfer.push_back(id1); | 735 resource_ids_to_transfer.push_back(id1); |
731 resource_ids_to_transfer.push_back(id2); | 736 resource_ids_to_transfer.push_back(id2); |
732 resource_ids_to_transfer.push_back(id3); | 737 resource_ids_to_transfer.push_back(id3); |
733 TransferableResourceArray list; | 738 TransferableResourceArray list; |
734 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, | 739 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, |
735 &list); | 740 &list); |
736 EXPECT_EQ(3u, list.size()); | 741 EXPECT_EQ(3u, list.size()); |
737 EXPECT_EQ(id1, list[0].id); | 742 EXPECT_EQ(id1, list[0].id); |
738 EXPECT_EQ(id2, list[1].id); | 743 EXPECT_EQ(id2, list[1].id); |
739 EXPECT_EQ(id3, list[2].id); | 744 EXPECT_EQ(id3, list[2].id); |
740 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), list[0].target); | 745 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), |
741 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), list[1].target); | 746 list[0].mailbox_holder.texture_target); |
742 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), list[2].target); | 747 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), |
| 748 list[1].mailbox_holder.texture_target); |
| 749 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), |
| 750 list[2].mailbox_holder.texture_target); |
743 ReturnedResourceArray returned; | 751 ReturnedResourceArray returned; |
744 TransferableResource::ReturnResources(list, &returned); | 752 TransferableResource::ReturnResources(list, &returned); |
745 child_resource_provider_->ReceiveReturnsFromParent(returned); | 753 child_resource_provider_->ReceiveReturnsFromParent(returned); |
746 // ids were exported twice, we returned them only once, they should still | 754 // ids were exported twice, we returned them only once, they should still |
747 // be in-use. | 755 // be in-use. |
748 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); | 756 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); |
749 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); | 757 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); |
750 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id3)); | 758 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id3)); |
751 } | 759 } |
752 { | 760 { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 resource_ids_to_transfer.push_back(id3); | 812 resource_ids_to_transfer.push_back(id3); |
805 resource_ids_to_transfer.push_back(id4); | 813 resource_ids_to_transfer.push_back(id4); |
806 TransferableResourceArray list; | 814 TransferableResourceArray list; |
807 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, | 815 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, |
808 &list); | 816 &list); |
809 ASSERT_EQ(4u, list.size()); | 817 ASSERT_EQ(4u, list.size()); |
810 EXPECT_EQ(id1, list[0].id); | 818 EXPECT_EQ(id1, list[0].id); |
811 EXPECT_EQ(id2, list[1].id); | 819 EXPECT_EQ(id2, list[1].id); |
812 EXPECT_EQ(id3, list[2].id); | 820 EXPECT_EQ(id3, list[2].id); |
813 EXPECT_EQ(id4, list[3].id); | 821 EXPECT_EQ(id4, list[3].id); |
814 EXPECT_NE(0u, list[0].sync_point); | 822 EXPECT_NE(0u, list[0].mailbox_holder.sync_point); |
815 EXPECT_NE(0u, list[1].sync_point); | 823 EXPECT_NE(0u, list[1].mailbox_holder.sync_point); |
816 EXPECT_NE(0u, list[2].sync_point); | 824 EXPECT_NE(0u, list[2].mailbox_holder.sync_point); |
817 EXPECT_NE(0u, list[3].sync_point); | 825 EXPECT_NE(0u, list[3].mailbox_holder.sync_point); |
818 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), list[0].target); | 826 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), |
819 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), list[1].target); | 827 list[0].mailbox_holder.texture_target); |
820 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), list[2].target); | 828 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), |
821 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_EXTERNAL_OES), list[3].target); | 829 list[1].mailbox_holder.texture_target); |
| 830 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), |
| 831 list[2].mailbox_holder.texture_target); |
| 832 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_EXTERNAL_OES), |
| 833 list[3].mailbox_holder.texture_target); |
822 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); | 834 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); |
823 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); | 835 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); |
824 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id3)); | 836 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id3)); |
825 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id4)); | 837 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id4)); |
826 resource_provider_->ReceiveFromChild(child_id, list); | 838 resource_provider_->ReceiveFromChild(child_id, list); |
827 resource_provider_->DeclareUsedResourcesFromChild(child_id, | 839 resource_provider_->DeclareUsedResourcesFromChild(child_id, |
828 resource_ids_to_transfer); | 840 resource_ids_to_transfer); |
829 } | 841 } |
830 | 842 |
831 EXPECT_EQ(0u, returned_to_child.size()); | 843 EXPECT_EQ(0u, returned_to_child.size()); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
889 // Transfer some resources to the parent. | 901 // Transfer some resources to the parent. |
890 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 902 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
891 resource_ids_to_transfer.push_back(id1); | 903 resource_ids_to_transfer.push_back(id1); |
892 resource_ids_to_transfer.push_back(id2); | 904 resource_ids_to_transfer.push_back(id2); |
893 resource_ids_to_transfer.push_back(id3); | 905 resource_ids_to_transfer.push_back(id3); |
894 resource_ids_to_transfer.push_back(id4); | 906 resource_ids_to_transfer.push_back(id4); |
895 TransferableResourceArray list; | 907 TransferableResourceArray list; |
896 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, | 908 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, |
897 &list); | 909 &list); |
898 ASSERT_EQ(4u, list.size()); | 910 ASSERT_EQ(4u, list.size()); |
899 EXPECT_EQ(0u, list[0].sync_point); | 911 EXPECT_EQ(0u, list[0].mailbox_holder.sync_point); |
900 EXPECT_EQ(0u, list[1].sync_point); | 912 EXPECT_EQ(0u, list[1].mailbox_holder.sync_point); |
901 EXPECT_EQ(0u, list[2].sync_point); | 913 EXPECT_EQ(0u, list[2].mailbox_holder.sync_point); |
902 EXPECT_EQ(0u, list[3].sync_point); | 914 EXPECT_EQ(0u, list[3].mailbox_holder.sync_point); |
903 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); | 915 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); |
904 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); | 916 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); |
905 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id3)); | 917 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id3)); |
906 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id4)); | 918 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id4)); |
907 resource_provider_->ReceiveFromChild(child_id, list); | 919 resource_provider_->ReceiveFromChild(child_id, list); |
908 resource_provider_->DeclareUsedResourcesFromChild(child_id, | 920 resource_provider_->DeclareUsedResourcesFromChild(child_id, |
909 resource_ids_to_transfer); | 921 resource_ids_to_transfer); |
910 } | 922 } |
911 | 923 |
912 EXPECT_EQ(4u, resource_provider_->num_resources()); | 924 EXPECT_EQ(4u, resource_provider_->num_resources()); |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1150 ReturnedResourceArray returned_to_child; | 1162 ReturnedResourceArray returned_to_child; |
1151 int child_id = | 1163 int child_id = |
1152 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); | 1164 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); |
1153 { | 1165 { |
1154 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 1166 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
1155 resource_ids_to_transfer.push_back(id1); | 1167 resource_ids_to_transfer.push_back(id1); |
1156 TransferableResourceArray list; | 1168 TransferableResourceArray list; |
1157 child_resource_provider->PrepareSendToParent(resource_ids_to_transfer, | 1169 child_resource_provider->PrepareSendToParent(resource_ids_to_transfer, |
1158 &list); | 1170 &list); |
1159 ASSERT_EQ(1u, list.size()); | 1171 ASSERT_EQ(1u, list.size()); |
1160 EXPECT_NE(0u, list[0].sync_point); | 1172 EXPECT_NE(0u, list[0].mailbox_holder.sync_point); |
1161 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), list[0].target); | 1173 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), |
| 1174 list[0].mailbox_holder.texture_target); |
1162 EXPECT_TRUE(child_resource_provider->InUseByConsumer(id1)); | 1175 EXPECT_TRUE(child_resource_provider->InUseByConsumer(id1)); |
1163 resource_provider_->ReceiveFromChild(child_id, list); | 1176 resource_provider_->ReceiveFromChild(child_id, list); |
1164 } | 1177 } |
1165 | 1178 |
1166 EXPECT_EQ(0u, resource_provider_->num_resources()); | 1179 EXPECT_EQ(0u, resource_provider_->num_resources()); |
1167 ASSERT_EQ(1u, returned_to_child.size()); | 1180 ASSERT_EQ(1u, returned_to_child.size()); |
1168 EXPECT_EQ(returned_to_child[0].id, id1); | 1181 EXPECT_EQ(returned_to_child[0].id, id1); |
1169 ResourceProvider::ResourceIdMap resource_map = | 1182 ResourceProvider::ResourceIdMap resource_map = |
1170 resource_provider_->GetChildToParentMap(child_id); | 1183 resource_provider_->GetChildToParentMap(child_id); |
1171 ResourceProvider::ResourceId mapped_id1 = resource_map[id1]; | 1184 ResourceProvider::ResourceId mapped_id1 = resource_map[id1]; |
(...skipping 25 matching lines...) Expand all Loading... |
1197 int child_id = | 1210 int child_id = |
1198 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); | 1211 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); |
1199 { | 1212 { |
1200 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 1213 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
1201 resource_ids_to_transfer.push_back(id1); | 1214 resource_ids_to_transfer.push_back(id1); |
1202 TransferableResourceArray list; | 1215 TransferableResourceArray list; |
1203 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, | 1216 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, |
1204 &list); | 1217 &list); |
1205 ASSERT_EQ(1u, list.size()); | 1218 ASSERT_EQ(1u, list.size()); |
1206 // Make invalid. | 1219 // Make invalid. |
1207 list[0].mailbox.name[1] = 5; | 1220 list[0].mailbox_holder.mailbox.name[1] = 5; |
1208 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); | 1221 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); |
1209 resource_provider_->ReceiveFromChild(child_id, list); | 1222 resource_provider_->ReceiveFromChild(child_id, list); |
1210 } | 1223 } |
1211 | 1224 |
1212 EXPECT_EQ(0u, resource_provider_->num_resources()); | 1225 EXPECT_EQ(0u, resource_provider_->num_resources()); |
1213 ASSERT_EQ(1u, returned_to_child.size()); | 1226 ASSERT_EQ(1u, returned_to_child.size()); |
1214 EXPECT_EQ(returned_to_child[0].id, id1); | 1227 EXPECT_EQ(returned_to_child[0].id, id1); |
1215 ResourceProvider::ResourceIdMap resource_map = | 1228 ResourceProvider::ResourceIdMap resource_map = |
1216 resource_provider_->GetChildToParentMap(child_id); | 1229 resource_provider_->GetChildToParentMap(child_id); |
1217 ResourceProvider::ResourceId mapped_id1 = resource_map[id1]; | 1230 ResourceProvider::ResourceId mapped_id1 = resource_map[id1]; |
(...skipping 29 matching lines...) Expand all Loading... |
1247 { | 1260 { |
1248 // Transfer some resources to the parent. | 1261 // Transfer some resources to the parent. |
1249 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 1262 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
1250 resource_ids_to_transfer.push_back(id1); | 1263 resource_ids_to_transfer.push_back(id1); |
1251 resource_ids_to_transfer.push_back(id2); | 1264 resource_ids_to_transfer.push_back(id2); |
1252 TransferableResourceArray list; | 1265 TransferableResourceArray list; |
1253 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, | 1266 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, |
1254 &list); | 1267 &list); |
1255 ASSERT_EQ(2u, list.size()); | 1268 ASSERT_EQ(2u, list.size()); |
1256 if (GetParam() == ResourceProvider::GLTexture) { | 1269 if (GetParam() == ResourceProvider::GLTexture) { |
1257 EXPECT_NE(0u, list[0].sync_point); | 1270 EXPECT_NE(0u, list[0].mailbox_holder.sync_point); |
1258 EXPECT_NE(0u, list[1].sync_point); | 1271 EXPECT_NE(0u, list[1].mailbox_holder.sync_point); |
1259 } | 1272 } |
1260 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); | 1273 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); |
1261 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); | 1274 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); |
1262 resource_provider_->ReceiveFromChild(child_id, list); | 1275 resource_provider_->ReceiveFromChild(child_id, list); |
1263 resource_provider_->DeclareUsedResourcesFromChild(child_id, | 1276 resource_provider_->DeclareUsedResourcesFromChild(child_id, |
1264 resource_ids_to_transfer); | 1277 resource_ids_to_transfer); |
1265 } | 1278 } |
1266 | 1279 |
1267 EXPECT_EQ(2u, resource_provider_->num_resources()); | 1280 EXPECT_EQ(2u, resource_provider_->num_resources()); |
1268 ResourceProvider::ResourceIdMap resource_map = | 1281 ResourceProvider::ResourceIdMap resource_map = |
1269 resource_provider_->GetChildToParentMap(child_id); | 1282 resource_provider_->GetChildToParentMap(child_id); |
1270 ResourceProvider::ResourceId mapped_id1 = resource_map[id1]; | 1283 ResourceProvider::ResourceId mapped_id1 = resource_map[id1]; |
1271 ResourceProvider::ResourceId mapped_id2 = resource_map[id2]; | 1284 ResourceProvider::ResourceId mapped_id2 = resource_map[id2]; |
1272 EXPECT_NE(0u, mapped_id1); | 1285 EXPECT_NE(0u, mapped_id1); |
1273 EXPECT_NE(0u, mapped_id2); | 1286 EXPECT_NE(0u, mapped_id2); |
1274 EXPECT_FALSE(resource_provider_->InUseByConsumer(id1)); | 1287 EXPECT_FALSE(resource_provider_->InUseByConsumer(id1)); |
1275 EXPECT_FALSE(resource_provider_->InUseByConsumer(id2)); | 1288 EXPECT_FALSE(resource_provider_->InUseByConsumer(id2)); |
1276 | 1289 |
1277 { | 1290 { |
1278 // The parent transfers the resources to the grandparent. | 1291 // The parent transfers the resources to the grandparent. |
1279 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 1292 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
1280 resource_ids_to_transfer.push_back(mapped_id1); | 1293 resource_ids_to_transfer.push_back(mapped_id1); |
1281 resource_ids_to_transfer.push_back(mapped_id2); | 1294 resource_ids_to_transfer.push_back(mapped_id2); |
1282 TransferableResourceArray list; | 1295 TransferableResourceArray list; |
1283 resource_provider_->PrepareSendToParent(resource_ids_to_transfer, &list); | 1296 resource_provider_->PrepareSendToParent(resource_ids_to_transfer, &list); |
1284 | 1297 |
1285 ASSERT_EQ(2u, list.size()); | 1298 ASSERT_EQ(2u, list.size()); |
1286 if (GetParam() == ResourceProvider::GLTexture) { | 1299 if (GetParam() == ResourceProvider::GLTexture) { |
1287 EXPECT_NE(0u, list[0].sync_point); | 1300 EXPECT_NE(0u, list[0].mailbox_holder.sync_point); |
1288 EXPECT_NE(0u, list[1].sync_point); | 1301 EXPECT_NE(0u, list[1].mailbox_holder.sync_point); |
1289 } | 1302 } |
1290 EXPECT_TRUE(resource_provider_->InUseByConsumer(id1)); | 1303 EXPECT_TRUE(resource_provider_->InUseByConsumer(id1)); |
1291 EXPECT_TRUE(resource_provider_->InUseByConsumer(id2)); | 1304 EXPECT_TRUE(resource_provider_->InUseByConsumer(id2)); |
1292 | 1305 |
1293 // Release the resource in the parent. Set no resources as being in use. The | 1306 // Release the resource in the parent. Set no resources as being in use. The |
1294 // resources are exported so that can't be transferred back yet. | 1307 // resources are exported so that can't be transferred back yet. |
1295 ResourceProvider::ResourceIdArray no_resources; | 1308 ResourceProvider::ResourceIdArray no_resources; |
1296 resource_provider_->DeclareUsedResourcesFromChild(child_id, no_resources); | 1309 resource_provider_->DeclareUsedResourcesFromChild(child_id, no_resources); |
1297 | 1310 |
1298 EXPECT_EQ(0u, returned_to_child.size()); | 1311 EXPECT_EQ(0u, returned_to_child.size()); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1341 { | 1354 { |
1342 // Transfer some resources to the parent. | 1355 // Transfer some resources to the parent. |
1343 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 1356 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
1344 resource_ids_to_transfer.push_back(id1); | 1357 resource_ids_to_transfer.push_back(id1); |
1345 resource_ids_to_transfer.push_back(id2); | 1358 resource_ids_to_transfer.push_back(id2); |
1346 TransferableResourceArray list; | 1359 TransferableResourceArray list; |
1347 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, | 1360 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, |
1348 &list); | 1361 &list); |
1349 ASSERT_EQ(2u, list.size()); | 1362 ASSERT_EQ(2u, list.size()); |
1350 if (GetParam() == ResourceProvider::GLTexture) { | 1363 if (GetParam() == ResourceProvider::GLTexture) { |
1351 EXPECT_NE(0u, list[0].sync_point); | 1364 EXPECT_NE(0u, list[0].mailbox_holder.sync_point); |
1352 EXPECT_NE(0u, list[1].sync_point); | 1365 EXPECT_NE(0u, list[1].mailbox_holder.sync_point); |
1353 } | 1366 } |
1354 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); | 1367 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); |
1355 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); | 1368 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); |
1356 resource_provider_->ReceiveFromChild(child_id, list); | 1369 resource_provider_->ReceiveFromChild(child_id, list); |
1357 resource_provider_->DeclareUsedResourcesFromChild(child_id, | 1370 resource_provider_->DeclareUsedResourcesFromChild(child_id, |
1358 resource_ids_to_transfer); | 1371 resource_ids_to_transfer); |
1359 } | 1372 } |
1360 | 1373 |
1361 EXPECT_EQ(2u, resource_provider_->num_resources()); | 1374 EXPECT_EQ(2u, resource_provider_->num_resources()); |
1362 ResourceProvider::ResourceIdMap resource_map = | 1375 ResourceProvider::ResourceIdMap resource_map = |
1363 resource_provider_->GetChildToParentMap(child_id); | 1376 resource_provider_->GetChildToParentMap(child_id); |
1364 ResourceProvider::ResourceId mapped_id1 = resource_map[id1]; | 1377 ResourceProvider::ResourceId mapped_id1 = resource_map[id1]; |
1365 ResourceProvider::ResourceId mapped_id2 = resource_map[id2]; | 1378 ResourceProvider::ResourceId mapped_id2 = resource_map[id2]; |
1366 EXPECT_NE(0u, mapped_id1); | 1379 EXPECT_NE(0u, mapped_id1); |
1367 EXPECT_NE(0u, mapped_id2); | 1380 EXPECT_NE(0u, mapped_id2); |
1368 EXPECT_FALSE(resource_provider_->InUseByConsumer(id1)); | 1381 EXPECT_FALSE(resource_provider_->InUseByConsumer(id1)); |
1369 EXPECT_FALSE(resource_provider_->InUseByConsumer(id2)); | 1382 EXPECT_FALSE(resource_provider_->InUseByConsumer(id2)); |
1370 | 1383 |
1371 { | 1384 { |
1372 // The parent transfers the resources to the grandparent. | 1385 // The parent transfers the resources to the grandparent. |
1373 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 1386 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
1374 resource_ids_to_transfer.push_back(mapped_id1); | 1387 resource_ids_to_transfer.push_back(mapped_id1); |
1375 resource_ids_to_transfer.push_back(mapped_id2); | 1388 resource_ids_to_transfer.push_back(mapped_id2); |
1376 TransferableResourceArray list; | 1389 TransferableResourceArray list; |
1377 resource_provider_->PrepareSendToParent(resource_ids_to_transfer, &list); | 1390 resource_provider_->PrepareSendToParent(resource_ids_to_transfer, &list); |
1378 | 1391 |
1379 ASSERT_EQ(2u, list.size()); | 1392 ASSERT_EQ(2u, list.size()); |
1380 if (GetParam() == ResourceProvider::GLTexture) { | 1393 if (GetParam() == ResourceProvider::GLTexture) { |
1381 EXPECT_NE(0u, list[0].sync_point); | 1394 EXPECT_NE(0u, list[0].mailbox_holder.sync_point); |
1382 EXPECT_NE(0u, list[1].sync_point); | 1395 EXPECT_NE(0u, list[1].mailbox_holder.sync_point); |
1383 } | 1396 } |
1384 EXPECT_TRUE(resource_provider_->InUseByConsumer(id1)); | 1397 EXPECT_TRUE(resource_provider_->InUseByConsumer(id1)); |
1385 EXPECT_TRUE(resource_provider_->InUseByConsumer(id2)); | 1398 EXPECT_TRUE(resource_provider_->InUseByConsumer(id2)); |
1386 | 1399 |
1387 // Release the resource in the parent. Set no resources as being in use. The | 1400 // Release the resource in the parent. Set no resources as being in use. The |
1388 // resources are exported so that can't be transferred back yet. | 1401 // resources are exported so that can't be transferred back yet. |
1389 ResourceProvider::ResourceIdArray no_resources; | 1402 ResourceProvider::ResourceIdArray no_resources; |
1390 resource_provider_->DeclareUsedResourcesFromChild(child_id, no_resources); | 1403 resource_provider_->DeclareUsedResourcesFromChild(child_id, no_resources); |
1391 | 1404 |
1392 // Destroy the child, the resources should not be returned yet. | 1405 // Destroy the child, the resources should not be returned yet. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1446 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); | 1459 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); |
1447 { | 1460 { |
1448 // Transfer some resource to the parent. | 1461 // Transfer some resource to the parent. |
1449 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 1462 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
1450 resource_ids_to_transfer.push_back(id); | 1463 resource_ids_to_transfer.push_back(id); |
1451 TransferableResourceArray list; | 1464 TransferableResourceArray list; |
1452 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, | 1465 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, |
1453 &list); | 1466 &list); |
1454 ASSERT_EQ(1u, list.size()); | 1467 ASSERT_EQ(1u, list.size()); |
1455 if (GetParam() == ResourceProvider::GLTexture) | 1468 if (GetParam() == ResourceProvider::GLTexture) |
1456 EXPECT_NE(0u, list[0].sync_point); | 1469 EXPECT_NE(0u, list[0].mailbox_holder.sync_point); |
1457 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id)); | 1470 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id)); |
1458 resource_provider_->ReceiveFromChild(child_id, list); | 1471 resource_provider_->ReceiveFromChild(child_id, list); |
1459 resource_provider_->DeclareUsedResourcesFromChild(child_id, | 1472 resource_provider_->DeclareUsedResourcesFromChild(child_id, |
1460 resource_ids_to_transfer); | 1473 resource_ids_to_transfer); |
1461 } | 1474 } |
1462 | 1475 |
1463 // Delete textures in the child, while they are transfered. | 1476 // Delete textures in the child, while they are transfered. |
1464 child_resource_provider_->DeleteResource(id); | 1477 child_resource_provider_->DeleteResource(id); |
1465 EXPECT_EQ(1u, child_resource_provider_->num_resources()); | 1478 EXPECT_EQ(1u, child_resource_provider_->num_resources()); |
1466 { | 1479 { |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1660 if (GetParam() != ResourceProvider::GLTexture) | 1673 if (GetParam() != ResourceProvider::GLTexture) |
1661 return; | 1674 return; |
1662 unsigned texture = context()->createTexture(); | 1675 unsigned texture = context()->createTexture(); |
1663 context()->bindTexture(GL_TEXTURE_2D, texture); | 1676 context()->bindTexture(GL_TEXTURE_2D, texture); |
1664 uint8_t data[4] = { 1, 2, 3, 4 }; | 1677 uint8_t data[4] = { 1, 2, 3, 4 }; |
1665 context()->texImage2D( | 1678 context()->texImage2D( |
1666 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &data); | 1679 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &data); |
1667 gpu::Mailbox mailbox; | 1680 gpu::Mailbox mailbox; |
1668 context()->genMailboxCHROMIUM(mailbox.name); | 1681 context()->genMailboxCHROMIUM(mailbox.name); |
1669 context()->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); | 1682 context()->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); |
1670 unsigned sync_point = context()->insertSyncPoint(); | 1683 uint32 sync_point = context()->insertSyncPoint(); |
1671 | 1684 |
1672 // All the logic below assumes that the sync points are all positive. | 1685 // All the logic below assumes that the sync points are all positive. |
1673 EXPECT_LT(0u, sync_point); | 1686 EXPECT_LT(0u, sync_point); |
1674 | 1687 |
1675 unsigned release_sync_point = 0; | 1688 uint32 release_sync_point = 0; |
1676 bool lost_resource = false; | 1689 bool lost_resource = false; |
1677 ReleaseCallback callback = | 1690 ReleaseCallback callback = |
1678 base::Bind(ReleaseTextureMailbox, &release_sync_point, &lost_resource); | 1691 base::Bind(ReleaseTextureMailbox, &release_sync_point, &lost_resource); |
1679 ResourceProvider::ResourceId resource = | 1692 ResourceProvider::ResourceId resource = |
1680 resource_provider_->CreateResourceFromTextureMailbox( | 1693 resource_provider_->CreateResourceFromTextureMailbox( |
1681 TextureMailbox(mailbox, sync_point), | 1694 TextureMailbox(mailbox, GL_TEXTURE_2D, sync_point), |
1682 SingleReleaseCallback::Create(callback)); | 1695 SingleReleaseCallback::Create(callback)); |
1683 EXPECT_EQ(1u, context()->NumTextures()); | 1696 EXPECT_EQ(1u, context()->NumTextures()); |
1684 EXPECT_EQ(0u, release_sync_point); | 1697 EXPECT_EQ(0u, release_sync_point); |
1685 { | 1698 { |
1686 // Transfer the resource, expect the sync points to be consistent. | 1699 // Transfer the resource, expect the sync points to be consistent. |
1687 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 1700 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
1688 resource_ids_to_transfer.push_back(resource); | 1701 resource_ids_to_transfer.push_back(resource); |
1689 TransferableResourceArray list; | 1702 TransferableResourceArray list; |
1690 resource_provider_->PrepareSendToParent(resource_ids_to_transfer, &list); | 1703 resource_provider_->PrepareSendToParent(resource_ids_to_transfer, &list); |
1691 ASSERT_EQ(1u, list.size()); | 1704 ASSERT_EQ(1u, list.size()); |
1692 EXPECT_LE(sync_point, list[0].sync_point); | 1705 EXPECT_LE(sync_point, list[0].mailbox_holder.sync_point); |
1693 EXPECT_EQ(0, | 1706 EXPECT_EQ(0, |
1694 memcmp(mailbox.name, list[0].mailbox.name, sizeof(mailbox.name))); | 1707 memcmp(mailbox.name, |
| 1708 list[0].mailbox_holder.mailbox.name, |
| 1709 sizeof(mailbox.name))); |
1695 EXPECT_EQ(0u, release_sync_point); | 1710 EXPECT_EQ(0u, release_sync_point); |
1696 | 1711 |
1697 context()->waitSyncPoint(list[0].sync_point); | 1712 context()->waitSyncPoint(list[0].mailbox_holder.sync_point); |
1698 unsigned other_texture = context()->createTexture(); | 1713 unsigned other_texture = context()->createTexture(); |
1699 context()->bindTexture(GL_TEXTURE_2D, other_texture); | 1714 context()->bindTexture(GL_TEXTURE_2D, other_texture); |
1700 context()->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); | 1715 context()->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); |
1701 uint8_t test_data[4] = { 0 }; | 1716 uint8_t test_data[4] = { 0 }; |
1702 context()->GetPixels( | 1717 context()->GetPixels( |
1703 gfx::Size(1, 1), RGBA_8888, test_data); | 1718 gfx::Size(1, 1), RGBA_8888, test_data); |
1704 EXPECT_EQ(0, memcmp(data, test_data, sizeof(data))); | 1719 EXPECT_EQ(0, memcmp(data, test_data, sizeof(data))); |
1705 context()->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); | 1720 context()->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); |
1706 context()->deleteTexture(other_texture); | 1721 context()->deleteTexture(other_texture); |
1707 list[0].sync_point = context()->insertSyncPoint(); | 1722 list[0].mailbox_holder.sync_point = context()->insertSyncPoint(); |
1708 EXPECT_LT(0u, list[0].sync_point); | 1723 EXPECT_LT(0u, list[0].mailbox_holder.sync_point); |
1709 | 1724 |
1710 // Receive the resource, then delete it, expect the sync points to be | 1725 // Receive the resource, then delete it, expect the sync points to be |
1711 // consistent. | 1726 // consistent. |
1712 ReturnedResourceArray returned; | 1727 ReturnedResourceArray returned; |
1713 TransferableResource::ReturnResources(list, &returned); | 1728 TransferableResource::ReturnResources(list, &returned); |
1714 resource_provider_->ReceiveReturnsFromParent(returned); | 1729 resource_provider_->ReceiveReturnsFromParent(returned); |
1715 EXPECT_EQ(1u, context()->NumTextures()); | 1730 EXPECT_EQ(1u, context()->NumTextures()); |
1716 EXPECT_EQ(0u, release_sync_point); | 1731 EXPECT_EQ(0u, release_sync_point); |
1717 | 1732 |
1718 resource_provider_->DeleteResource(resource); | 1733 resource_provider_->DeleteResource(resource); |
1719 EXPECT_LE(list[0].sync_point, release_sync_point); | 1734 EXPECT_LE(list[0].mailbox_holder.sync_point, release_sync_point); |
1720 EXPECT_FALSE(lost_resource); | 1735 EXPECT_FALSE(lost_resource); |
1721 } | 1736 } |
1722 | 1737 |
1723 // We're going to do the same thing as above, but testing the case where we | 1738 // We're going to do the same thing as above, but testing the case where we |
1724 // delete the resource before we receive it back. | 1739 // delete the resource before we receive it back. |
1725 sync_point = release_sync_point; | 1740 sync_point = release_sync_point; |
1726 EXPECT_LT(0u, sync_point); | 1741 EXPECT_LT(0u, sync_point); |
1727 release_sync_point = 0; | 1742 release_sync_point = 0; |
1728 resource = resource_provider_->CreateResourceFromTextureMailbox( | 1743 resource = resource_provider_->CreateResourceFromTextureMailbox( |
1729 TextureMailbox(mailbox, sync_point), | 1744 TextureMailbox(mailbox, GL_TEXTURE_2D, sync_point), |
1730 SingleReleaseCallback::Create(callback)); | 1745 SingleReleaseCallback::Create(callback)); |
1731 EXPECT_EQ(1u, context()->NumTextures()); | 1746 EXPECT_EQ(1u, context()->NumTextures()); |
1732 EXPECT_EQ(0u, release_sync_point); | 1747 EXPECT_EQ(0u, release_sync_point); |
1733 { | 1748 { |
1734 // Transfer the resource, expect the sync points to be consistent. | 1749 // Transfer the resource, expect the sync points to be consistent. |
1735 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 1750 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
1736 resource_ids_to_transfer.push_back(resource); | 1751 resource_ids_to_transfer.push_back(resource); |
1737 TransferableResourceArray list; | 1752 TransferableResourceArray list; |
1738 resource_provider_->PrepareSendToParent(resource_ids_to_transfer, &list); | 1753 resource_provider_->PrepareSendToParent(resource_ids_to_transfer, &list); |
1739 ASSERT_EQ(1u, list.size()); | 1754 ASSERT_EQ(1u, list.size()); |
1740 EXPECT_LE(sync_point, list[0].sync_point); | 1755 EXPECT_LE(sync_point, list[0].mailbox_holder.sync_point); |
1741 EXPECT_EQ(0, | 1756 EXPECT_EQ(0, |
1742 memcmp(mailbox.name, list[0].mailbox.name, sizeof(mailbox.name))); | 1757 memcmp(mailbox.name, |
| 1758 list[0].mailbox_holder.mailbox.name, |
| 1759 sizeof(mailbox.name))); |
1743 EXPECT_EQ(0u, release_sync_point); | 1760 EXPECT_EQ(0u, release_sync_point); |
1744 | 1761 |
1745 context()->waitSyncPoint(list[0].sync_point); | 1762 context()->waitSyncPoint(list[0].mailbox_holder.sync_point); |
1746 unsigned other_texture = context()->createTexture(); | 1763 unsigned other_texture = context()->createTexture(); |
1747 context()->bindTexture(GL_TEXTURE_2D, other_texture); | 1764 context()->bindTexture(GL_TEXTURE_2D, other_texture); |
1748 context()->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); | 1765 context()->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); |
1749 uint8_t test_data[4] = { 0 }; | 1766 uint8_t test_data[4] = { 0 }; |
1750 context()->GetPixels( | 1767 context()->GetPixels( |
1751 gfx::Size(1, 1), RGBA_8888, test_data); | 1768 gfx::Size(1, 1), RGBA_8888, test_data); |
1752 EXPECT_EQ(0, memcmp(data, test_data, sizeof(data))); | 1769 EXPECT_EQ(0, memcmp(data, test_data, sizeof(data))); |
1753 context()->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); | 1770 context()->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); |
1754 context()->deleteTexture(other_texture); | 1771 context()->deleteTexture(other_texture); |
1755 list[0].sync_point = context()->insertSyncPoint(); | 1772 list[0].mailbox_holder.sync_point = context()->insertSyncPoint(); |
1756 EXPECT_LT(0u, list[0].sync_point); | 1773 EXPECT_LT(0u, list[0].mailbox_holder.sync_point); |
1757 | 1774 |
1758 // Delete the resource, which shouldn't do anything. | 1775 // Delete the resource, which shouldn't do anything. |
1759 resource_provider_->DeleteResource(resource); | 1776 resource_provider_->DeleteResource(resource); |
1760 EXPECT_EQ(1u, context()->NumTextures()); | 1777 EXPECT_EQ(1u, context()->NumTextures()); |
1761 EXPECT_EQ(0u, release_sync_point); | 1778 EXPECT_EQ(0u, release_sync_point); |
1762 | 1779 |
1763 // Then receive the resource which should release the mailbox, expect the | 1780 // Then receive the resource which should release the mailbox, expect the |
1764 // sync points to be consistent. | 1781 // sync points to be consistent. |
1765 ReturnedResourceArray returned; | 1782 ReturnedResourceArray returned; |
1766 TransferableResource::ReturnResources(list, &returned); | 1783 TransferableResource::ReturnResources(list, &returned); |
1767 resource_provider_->ReceiveReturnsFromParent(returned); | 1784 resource_provider_->ReceiveReturnsFromParent(returned); |
1768 EXPECT_LE(list[0].sync_point, release_sync_point); | 1785 EXPECT_LE(list[0].mailbox_holder.sync_point, release_sync_point); |
1769 EXPECT_FALSE(lost_resource); | 1786 EXPECT_FALSE(lost_resource); |
1770 } | 1787 } |
1771 | 1788 |
1772 context()->waitSyncPoint(release_sync_point); | 1789 context()->waitSyncPoint(release_sync_point); |
1773 context()->bindTexture(GL_TEXTURE_2D, texture); | 1790 context()->bindTexture(GL_TEXTURE_2D, texture); |
1774 context()->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); | 1791 context()->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); |
1775 context()->deleteTexture(texture); | 1792 context()->deleteTexture(texture); |
1776 } | 1793 } |
1777 | 1794 |
1778 TEST_P(ResourceProviderTest, LostResourceInParent) { | 1795 TEST_P(ResourceProviderTest, LostResourceInParent) { |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1898 } | 1915 } |
1899 | 1916 |
1900 // The resource should be lost. | 1917 // The resource should be lost. |
1901 EXPECT_TRUE(child_resource_provider_->IsLost(resource)); | 1918 EXPECT_TRUE(child_resource_provider_->IsLost(resource)); |
1902 | 1919 |
1903 // Lost resources stay in use in the parent forever. | 1920 // Lost resources stay in use in the parent forever. |
1904 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(resource)); | 1921 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(resource)); |
1905 } | 1922 } |
1906 | 1923 |
1907 TEST_P(ResourceProviderTest, LostMailboxInParent) { | 1924 TEST_P(ResourceProviderTest, LostMailboxInParent) { |
1908 unsigned release_sync_point = 0; | 1925 uint32 release_sync_point = 0; |
1909 bool lost_resource = false; | 1926 bool lost_resource = false; |
1910 bool release_called = false; | 1927 bool release_called = false; |
1911 unsigned sync_point = 0; | 1928 uint32 sync_point = 0; |
1912 ResourceProvider::ResourceId resource = CreateChildMailbox( | 1929 ResourceProvider::ResourceId resource = CreateChildMailbox( |
1913 &release_sync_point, &lost_resource, &release_called, &sync_point); | 1930 &release_sync_point, &lost_resource, &release_called, &sync_point); |
1914 | 1931 |
1915 ReturnedResourceArray returned_to_child; | 1932 ReturnedResourceArray returned_to_child; |
1916 int child_id = | 1933 int child_id = |
1917 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); | 1934 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); |
1918 { | 1935 { |
1919 // Transfer the resource to the parent. | 1936 // Transfer the resource to the parent. |
1920 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 1937 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
1921 resource_ids_to_transfer.push_back(resource); | 1938 resource_ids_to_transfer.push_back(resource); |
(...skipping 26 matching lines...) Expand all Loading... |
1948 returned_to_child.clear(); | 1965 returned_to_child.clear(); |
1949 } | 1966 } |
1950 | 1967 |
1951 // Delete the resource in the child. Expect the resource to be lost if it's | 1968 // Delete the resource in the child. Expect the resource to be lost if it's |
1952 // a GL texture. | 1969 // a GL texture. |
1953 child_resource_provider_->DeleteResource(resource); | 1970 child_resource_provider_->DeleteResource(resource); |
1954 EXPECT_EQ(lost_resource, GetParam() == ResourceProvider::GLTexture); | 1971 EXPECT_EQ(lost_resource, GetParam() == ResourceProvider::GLTexture); |
1955 } | 1972 } |
1956 | 1973 |
1957 TEST_P(ResourceProviderTest, LostMailboxInGrandParent) { | 1974 TEST_P(ResourceProviderTest, LostMailboxInGrandParent) { |
1958 unsigned release_sync_point = 0; | 1975 uint32 release_sync_point = 0; |
1959 bool lost_resource = false; | 1976 bool lost_resource = false; |
1960 bool release_called = false; | 1977 bool release_called = false; |
1961 unsigned sync_point = 0; | 1978 uint32 sync_point = 0; |
1962 ResourceProvider::ResourceId resource = CreateChildMailbox( | 1979 ResourceProvider::ResourceId resource = CreateChildMailbox( |
1963 &release_sync_point, &lost_resource, &release_called, &sync_point); | 1980 &release_sync_point, &lost_resource, &release_called, &sync_point); |
1964 | 1981 |
1965 ReturnedResourceArray returned_to_child; | 1982 ReturnedResourceArray returned_to_child; |
1966 int child_id = | 1983 int child_id = |
1967 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); | 1984 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); |
1968 { | 1985 { |
1969 // Transfer the resource to the parent. | 1986 // Transfer the resource to the parent. |
1970 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 1987 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
1971 resource_ids_to_transfer.push_back(resource); | 1988 resource_ids_to_transfer.push_back(resource); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2016 child_resource_provider_->ReceiveReturnsFromParent(returned_to_child); | 2033 child_resource_provider_->ReceiveReturnsFromParent(returned_to_child); |
2017 returned_to_child.clear(); | 2034 returned_to_child.clear(); |
2018 } | 2035 } |
2019 | 2036 |
2020 // Delete the resource in the child. Expect the resource to be lost. | 2037 // Delete the resource in the child. Expect the resource to be lost. |
2021 child_resource_provider_->DeleteResource(resource); | 2038 child_resource_provider_->DeleteResource(resource); |
2022 EXPECT_TRUE(lost_resource); | 2039 EXPECT_TRUE(lost_resource); |
2023 } | 2040 } |
2024 | 2041 |
2025 TEST_P(ResourceProviderTest, Shutdown) { | 2042 TEST_P(ResourceProviderTest, Shutdown) { |
2026 unsigned release_sync_point = 0; | 2043 uint32 release_sync_point = 0; |
2027 bool lost_resource = false; | 2044 bool lost_resource = false; |
2028 bool release_called = false; | 2045 bool release_called = false; |
2029 unsigned sync_point = 0; | 2046 uint32 sync_point = 0; |
2030 CreateChildMailbox( | 2047 CreateChildMailbox( |
2031 &release_sync_point, &lost_resource, &release_called, &sync_point); | 2048 &release_sync_point, &lost_resource, &release_called, &sync_point); |
2032 | 2049 |
2033 EXPECT_EQ(0u, release_sync_point); | 2050 EXPECT_EQ(0u, release_sync_point); |
2034 EXPECT_FALSE(lost_resource); | 2051 EXPECT_FALSE(lost_resource); |
2035 | 2052 |
2036 child_resource_provider_.reset(); | 2053 child_resource_provider_.reset(); |
2037 | 2054 |
2038 if (GetParam() == ResourceProvider::GLTexture) { | 2055 if (GetParam() == ResourceProvider::GLTexture) { |
2039 EXPECT_LE(sync_point, release_sync_point); | 2056 EXPECT_LE(sync_point, release_sync_point); |
2040 } | 2057 } |
2041 EXPECT_TRUE(release_called); | 2058 EXPECT_TRUE(release_called); |
2042 EXPECT_FALSE(lost_resource); | 2059 EXPECT_FALSE(lost_resource); |
2043 } | 2060 } |
2044 | 2061 |
2045 TEST_P(ResourceProviderTest, ShutdownWithExportedResource) { | 2062 TEST_P(ResourceProviderTest, ShutdownWithExportedResource) { |
2046 unsigned release_sync_point = 0; | 2063 uint32 release_sync_point = 0; |
2047 bool lost_resource = false; | 2064 bool lost_resource = false; |
2048 bool release_called = false; | 2065 bool release_called = false; |
2049 unsigned sync_point = 0; | 2066 uint32 sync_point = 0; |
2050 ResourceProvider::ResourceId resource = CreateChildMailbox( | 2067 ResourceProvider::ResourceId resource = CreateChildMailbox( |
2051 &release_sync_point, &lost_resource, &release_called, &sync_point); | 2068 &release_sync_point, &lost_resource, &release_called, &sync_point); |
2052 | 2069 |
2053 // Transfer the resource, so we can't release it properly on shutdown. | 2070 // Transfer the resource, so we can't release it properly on shutdown. |
2054 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 2071 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
2055 resource_ids_to_transfer.push_back(resource); | 2072 resource_ids_to_transfer.push_back(resource); |
2056 TransferableResourceArray list; | 2073 TransferableResourceArray list; |
2057 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, | 2074 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, |
2058 &list); | 2075 &list); |
2059 | 2076 |
2060 EXPECT_EQ(0u, release_sync_point); | 2077 EXPECT_EQ(0u, release_sync_point); |
2061 EXPECT_FALSE(lost_resource); | 2078 EXPECT_FALSE(lost_resource); |
2062 | 2079 |
2063 child_resource_provider_.reset(); | 2080 child_resource_provider_.reset(); |
2064 | 2081 |
2065 // Since the resource is in the parent, the child considers it lost. | 2082 // Since the resource is in the parent, the child considers it lost. |
2066 EXPECT_EQ(0u, release_sync_point); | 2083 EXPECT_EQ(0u, release_sync_point); |
2067 EXPECT_TRUE(lost_resource); | 2084 EXPECT_TRUE(lost_resource); |
2068 } | 2085 } |
2069 | 2086 |
2070 TEST_P(ResourceProviderTest, LostContext) { | 2087 TEST_P(ResourceProviderTest, LostContext) { |
2071 // TextureMailbox callbacks only exist for GL textures for now. | 2088 // TextureMailbox callbacks only exist for GL textures for now. |
2072 if (GetParam() != ResourceProvider::GLTexture) | 2089 if (GetParam() != ResourceProvider::GLTexture) |
2073 return; | 2090 return; |
2074 unsigned texture = context()->createTexture(); | 2091 unsigned texture = context()->createTexture(); |
2075 context()->bindTexture(GL_TEXTURE_2D, texture); | 2092 context()->bindTexture(GL_TEXTURE_2D, texture); |
2076 gpu::Mailbox mailbox; | 2093 gpu::Mailbox mailbox; |
2077 context()->genMailboxCHROMIUM(mailbox.name); | 2094 context()->genMailboxCHROMIUM(mailbox.name); |
2078 context()->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); | 2095 context()->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); |
2079 unsigned sync_point = context()->insertSyncPoint(); | 2096 uint32 sync_point = context()->insertSyncPoint(); |
2080 | 2097 |
2081 EXPECT_LT(0u, sync_point); | 2098 EXPECT_LT(0u, sync_point); |
2082 | 2099 |
2083 unsigned release_sync_point = 0; | 2100 uint32 release_sync_point = 0; |
2084 bool lost_resource = false; | 2101 bool lost_resource = false; |
2085 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( | 2102 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( |
2086 base::Bind(ReleaseTextureMailbox, &release_sync_point, &lost_resource)); | 2103 base::Bind(ReleaseTextureMailbox, &release_sync_point, &lost_resource)); |
2087 resource_provider_->CreateResourceFromTextureMailbox( | 2104 resource_provider_->CreateResourceFromTextureMailbox( |
2088 TextureMailbox(mailbox, sync_point), | 2105 TextureMailbox(mailbox, GL_TEXTURE_2D, sync_point), callback.Pass()); |
2089 callback.Pass()); | |
2090 | 2106 |
2091 EXPECT_EQ(0u, release_sync_point); | 2107 EXPECT_EQ(0u, release_sync_point); |
2092 EXPECT_FALSE(lost_resource); | 2108 EXPECT_FALSE(lost_resource); |
2093 | 2109 |
2094 resource_provider_->DidLoseOutputSurface(); | 2110 resource_provider_->DidLoseOutputSurface(); |
2095 resource_provider_.reset(); | 2111 resource_provider_.reset(); |
2096 | 2112 |
2097 EXPECT_LE(sync_point, release_sync_point); | 2113 EXPECT_LE(sync_point, release_sync_point); |
2098 EXPECT_TRUE(lost_resource); | 2114 EXPECT_TRUE(lost_resource); |
2099 } | 2115 } |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2328 | 2344 |
2329 FakeOutputSurfaceClient output_surface_client; | 2345 FakeOutputSurfaceClient output_surface_client; |
2330 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 2346 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
2331 context_owned.PassAs<TestWebGraphicsContext3D>())); | 2347 context_owned.PassAs<TestWebGraphicsContext3D>())); |
2332 CHECK(output_surface->BindToClient(&output_surface_client)); | 2348 CHECK(output_surface->BindToClient(&output_surface_client)); |
2333 | 2349 |
2334 scoped_ptr<ResourceProvider> resource_provider( | 2350 scoped_ptr<ResourceProvider> resource_provider( |
2335 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); | 2351 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); |
2336 | 2352 |
2337 unsigned texture_id = 1; | 2353 unsigned texture_id = 1; |
2338 unsigned sync_point = 30; | 2354 uint32 sync_point = 30; |
2339 unsigned target = GL_TEXTURE_2D; | 2355 unsigned target = GL_TEXTURE_2D; |
2340 | 2356 |
2341 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); | 2357 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); |
2342 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); | 2358 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); |
2343 EXPECT_CALL(*context, insertSyncPoint()).Times(0); | 2359 EXPECT_CALL(*context, insertSyncPoint()).Times(0); |
2344 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); | 2360 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); |
2345 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0); | 2361 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0); |
2346 | 2362 |
2347 gpu::Mailbox gpu_mailbox; | 2363 gpu::Mailbox gpu_mailbox; |
2348 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1); | 2364 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1); |
2349 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( | 2365 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( |
2350 base::Bind(&EmptyReleaseCallback)); | 2366 base::Bind(&EmptyReleaseCallback)); |
2351 | 2367 |
2352 TextureMailbox mailbox(gpu_mailbox, sync_point); | 2368 TextureMailbox mailbox(gpu_mailbox, target, sync_point); |
2353 | 2369 |
2354 ResourceProvider::ResourceId id = | 2370 ResourceProvider::ResourceId id = |
2355 resource_provider->CreateResourceFromTextureMailbox( | 2371 resource_provider->CreateResourceFromTextureMailbox( |
2356 mailbox, callback.Pass()); | 2372 mailbox, callback.Pass()); |
2357 EXPECT_NE(0u, id); | 2373 EXPECT_NE(0u, id); |
2358 | 2374 |
2359 Mock::VerifyAndClearExpectations(context); | 2375 Mock::VerifyAndClearExpectations(context); |
2360 | 2376 |
2361 { | 2377 { |
2362 // Using the texture does a consume of the mailbox. | 2378 // Using the texture does a consume of the mailbox. |
(...skipping 29 matching lines...) Expand all Loading... |
2392 | 2408 |
2393 FakeOutputSurfaceClient output_surface_client; | 2409 FakeOutputSurfaceClient output_surface_client; |
2394 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 2410 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
2395 context_owned.PassAs<TestWebGraphicsContext3D>())); | 2411 context_owned.PassAs<TestWebGraphicsContext3D>())); |
2396 CHECK(output_surface->BindToClient(&output_surface_client)); | 2412 CHECK(output_surface->BindToClient(&output_surface_client)); |
2397 | 2413 |
2398 scoped_ptr<ResourceProvider> resource_provider( | 2414 scoped_ptr<ResourceProvider> resource_provider( |
2399 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); | 2415 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); |
2400 | 2416 |
2401 unsigned texture_id = 1; | 2417 unsigned texture_id = 1; |
2402 unsigned sync_point = 30; | 2418 uint32 sync_point = 30; |
2403 unsigned target = GL_TEXTURE_EXTERNAL_OES; | 2419 unsigned target = GL_TEXTURE_EXTERNAL_OES; |
2404 | 2420 |
2405 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); | 2421 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); |
2406 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); | 2422 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); |
2407 EXPECT_CALL(*context, insertSyncPoint()).Times(0); | 2423 EXPECT_CALL(*context, insertSyncPoint()).Times(0); |
2408 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); | 2424 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); |
2409 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0); | 2425 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0); |
2410 | 2426 |
2411 gpu::Mailbox gpu_mailbox; | 2427 gpu::Mailbox gpu_mailbox; |
2412 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1); | 2428 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1); |
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3145 resource_provider->AllocateForTesting(id); | 3161 resource_provider->AllocateForTesting(id); |
3146 Mock::VerifyAndClearExpectations(context); | 3162 Mock::VerifyAndClearExpectations(context); |
3147 | 3163 |
3148 DCHECK_EQ(10u, context->PeekTextureId()); | 3164 DCHECK_EQ(10u, context->PeekTextureId()); |
3149 resource_provider->DeleteResource(id); | 3165 resource_provider->DeleteResource(id); |
3150 } | 3166 } |
3151 } | 3167 } |
3152 | 3168 |
3153 } // namespace | 3169 } // namespace |
3154 } // namespace cc | 3170 } // namespace cc |
OLD | NEW |