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

Side by Side Diff: cc/resources/resource_provider_unittest.cc

Issue 635543002: cc: Make ResourceProvider use bindless Produce/ConsumeTextureCHROMIUM (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix test fails in LTH unittest. Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/resources/resource_provider.h" 5 #include "cc/resources/resource_provider.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 10
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 std::fill_n(pixels, size.GetArea(), value); 89 std::fill_n(pixels, size.GetArea(), value);
90 return shared_memory.Pass(); 90 return shared_memory.Pass();
91 } 91 }
92 92
93 class TextureStateTrackingContext : public TestWebGraphicsContext3D { 93 class TextureStateTrackingContext : public TestWebGraphicsContext3D {
94 public: 94 public:
95 MOCK_METHOD2(bindTexture, void(GLenum target, GLuint texture)); 95 MOCK_METHOD2(bindTexture, void(GLenum target, GLuint texture));
96 MOCK_METHOD3(texParameteri, void(GLenum target, GLenum pname, GLint param)); 96 MOCK_METHOD3(texParameteri, void(GLenum target, GLenum pname, GLint param));
97 MOCK_METHOD1(waitSyncPoint, void(GLuint sync_point)); 97 MOCK_METHOD1(waitSyncPoint, void(GLuint sync_point));
98 MOCK_METHOD0(insertSyncPoint, GLuint(void)); 98 MOCK_METHOD0(insertSyncPoint, GLuint(void));
99 MOCK_METHOD2(produceTextureCHROMIUM, 99 MOCK_METHOD3(produceTextureDirectCHROMIUM,
100 void(GLenum target, const GLbyte* mailbox)); 100 void(GLuint texture, GLenum target, const GLbyte* mailbox));
101 MOCK_METHOD2(consumeTextureCHROMIUM, 101 MOCK_METHOD2(createAndConsumeTextureCHROMIUM,
102 void(GLenum target, const GLbyte* mailbox)); 102 GLuint(GLenum target, const GLbyte* mailbox));
103 103
104 // Force all textures to be consecutive numbers starting at "1", 104 // Force all textures to be consecutive numbers starting at "1",
105 // so we easily can test for them. 105 // so we easily can test for them.
106 virtual GLuint NextTextureId() override { 106 virtual GLuint NextTextureId() override {
107 base::AutoLock lock(namespace_->lock); 107 base::AutoLock lock(namespace_->lock);
108 return namespace_->next_texture_id++; 108 return namespace_->next_texture_id++;
109 } 109 }
110 virtual void RetireTextureId(GLuint) override {} 110 virtual void RetireTextureId(GLuint) override {}
111 }; 111 };
112 112
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 ASSERT_EQ(GLDataFormat(BoundTexture(target)->format), format); 250 ASSERT_EQ(GLDataFormat(BoundTexture(target)->format), format);
251 } 251 }
252 ASSERT_TRUE(pixels); 252 ASSERT_TRUE(pixels);
253 SetPixels(xoffset, yoffset, width, height, pixels); 253 SetPixels(xoffset, yoffset, width, height, pixels);
254 } 254 }
255 255
256 void genMailboxCHROMIUM(GLbyte* mailbox) override { 256 void genMailboxCHROMIUM(GLbyte* mailbox) override {
257 return shared_data_->GenMailbox(mailbox); 257 return shared_data_->GenMailbox(mailbox);
258 } 258 }
259 259
260 void produceTextureCHROMIUM(GLenum target, const GLbyte* mailbox) override { 260 virtual void produceTextureDirectCHROMIUM(GLuint texture,
261 CheckTextureIsBound(target); 261 GLenum target,
262 262 const GLbyte* mailbox) override {
263 // Delay moving the texture into the mailbox until the next 263 // Delay moving the texture into the mailbox until the next
264 // InsertSyncPoint, so that it is not visible to other contexts that 264 // InsertSyncPoint, so that it is not visible to other contexts that
265 // haven't waited on that sync point. 265 // haven't waited on that sync point.
266 scoped_ptr<PendingProduceTexture> pending(new PendingProduceTexture); 266 scoped_ptr<PendingProduceTexture> pending(new PendingProduceTexture);
267 memcpy(pending->mailbox, mailbox, sizeof(pending->mailbox)); 267 memcpy(pending->mailbox, mailbox, sizeof(pending->mailbox));
268 base::AutoLock lock_for_texture_access(namespace_->lock); 268 base::AutoLock lock_for_texture_access(namespace_->lock);
269 pending->texture = BoundTexture(target); 269 pending->texture = UnboundTexture(texture);
270 pending_produce_textures_.push_back(pending.Pass()); 270 pending_produce_textures_.push_back(pending.Pass());
271 } 271 }
272 272
273 void consumeTextureCHROMIUM(GLenum target, const GLbyte* mailbox) override { 273 virtual GLuint createAndConsumeTextureCHROMIUM(GLenum target,
274 CheckTextureIsBound(target); 274 const GLbyte* mailbox) {
275 GLuint texture_id =
276 TestWebGraphicsContext3D::createAndConsumeTextureCHROMIUM(target,
277 mailbox);
275 base::AutoLock lock_for_texture_access(namespace_->lock); 278 base::AutoLock lock_for_texture_access(namespace_->lock);
276 scoped_refptr<TestTexture> texture = 279 namespace_->textures.Replace(texture_id, UnboundTexture(texture_id));
danakj 2014/12/01 16:20:04 We still need to do what ConsumeTexture was doing.
sohanjg 2014/12/30 14:45:54 Done.
277 shared_data_->ConsumeTexture(mailbox, last_waited_sync_point_); 280 return texture_id;
278 namespace_->textures.Replace(BoundTextureId(target), texture);
279 } 281 }
280 282
281 void GetPixels(const gfx::Size& size, 283 void GetPixels(const gfx::Size& size,
282 ResourceFormat format, 284 ResourceFormat format,
283 uint8_t* pixels) { 285 uint8_t* pixels) {
284 CheckTextureIsBound(GL_TEXTURE_2D); 286 CheckTextureIsBound(GL_TEXTURE_2D);
285 base::AutoLock lock_for_texture_access(namespace_->lock); 287 base::AutoLock lock_for_texture_access(namespace_->lock);
286 scoped_refptr<TestTexture> texture = BoundTexture(GL_TEXTURE_2D); 288 scoped_refptr<TestTexture> texture = BoundTexture(GL_TEXTURE_2D);
287 ASSERT_EQ(texture->size, size); 289 ASSERT_EQ(texture->size, size);
288 ASSERT_EQ(texture->format, format); 290 ASSERT_EQ(texture->format, format);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 uint8_t* dest = texture->data.get() + yoffset * out_pitch + 330 uint8_t* dest = texture->data.get() + yoffset * out_pitch +
329 TextureSizeBytes(gfx::Size(xoffset, 1), texture->format); 331 TextureSizeBytes(gfx::Size(xoffset, 1), texture->format);
330 const uint8_t* src = static_cast<const uint8_t*>(pixels); 332 const uint8_t* src = static_cast<const uint8_t*>(pixels);
331 for (int i = 0; i < height; ++i) { 333 for (int i = 0; i < height; ++i) {
332 memcpy(dest, src, in_pitch); 334 memcpy(dest, src, in_pitch);
333 dest += out_pitch; 335 dest += out_pitch;
334 src += in_pitch; 336 src += in_pitch;
335 } 337 }
336 } 338 }
337 339
340 void SetPixelsEXT(int xoffset,
danakj 2014/12/01 16:20:05 Nothing uses this
sohanjg 2014/12/30 14:45:55 Done.
341 int yoffset,
342 int width,
343 int height,
344 const void* pixels,
345 GLuint id) {
346 base::AutoLock lock_for_texture_access(namespace_->lock);
347 scoped_refptr<TestTexture> texture = UnboundTexture(id);
348 ASSERT_TRUE(texture->data.get());
349 ASSERT_TRUE(xoffset >= 0 && xoffset + width <= texture->size.width());
350 ASSERT_TRUE(yoffset >= 0 && yoffset + height <= texture->size.height());
351 ASSERT_TRUE(pixels);
352 size_t in_pitch = TextureSizeBytes(gfx::Size(width, 1), texture->format);
353 size_t out_pitch =
354 TextureSizeBytes(gfx::Size(texture->size.width(), 1), texture->format);
355 uint8_t* dest = texture->data.get() + yoffset * out_pitch +
356 TextureSizeBytes(gfx::Size(xoffset, 1), texture->format);
357 const uint8_t* src = static_cast<const uint8_t*>(pixels);
358 for (int i = 0; i < height; ++i) {
359 memcpy(dest, src, in_pitch);
360 dest += out_pitch;
361 src += in_pitch;
362 }
363 }
364
338 struct PendingProduceTexture { 365 struct PendingProduceTexture {
339 GLbyte mailbox[GL_MAILBOX_SIZE_CHROMIUM]; 366 GLbyte mailbox[GL_MAILBOX_SIZE_CHROMIUM];
340 scoped_refptr<TestTexture> texture; 367 scoped_refptr<TestTexture> texture;
341 }; 368 };
342 typedef ScopedPtrDeque<PendingProduceTexture> PendingProduceTextureList; 369 typedef ScopedPtrDeque<PendingProduceTexture> PendingProduceTextureList;
343 ContextSharedData* shared_data_; 370 ContextSharedData* shared_data_;
344 GLuint last_waited_sync_point_; 371 GLuint last_waited_sync_point_;
345 PendingProduceTextureList pending_produce_textures_; 372 PendingProduceTextureList pending_produce_textures_;
346 }; 373 };
347 374
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 480
454 ResourceProviderContext* context() { return context3d_; } 481 ResourceProviderContext* context() { return context3d_; }
455 482
456 ResourceProvider::ResourceId CreateChildMailbox(uint32* release_sync_point, 483 ResourceProvider::ResourceId CreateChildMailbox(uint32* release_sync_point,
457 bool* lost_resource, 484 bool* lost_resource,
458 bool* release_called, 485 bool* release_called,
459 uint32* sync_point) { 486 uint32* sync_point) {
460 if (GetParam() == ResourceProvider::GLTexture) { 487 if (GetParam() == ResourceProvider::GLTexture) {
461 unsigned texture = child_context_->createTexture(); 488 unsigned texture = child_context_->createTexture();
462 gpu::Mailbox gpu_mailbox; 489 gpu::Mailbox gpu_mailbox;
463 child_context_->bindTexture(GL_TEXTURE_2D, texture);
464 child_context_->genMailboxCHROMIUM(gpu_mailbox.name); 490 child_context_->genMailboxCHROMIUM(gpu_mailbox.name);
465 child_context_->produceTextureCHROMIUM(GL_TEXTURE_2D, gpu_mailbox.name); 491 child_context_->produceTextureDirectCHROMIUM(
492 texture, GL_TEXTURE_2D, gpu_mailbox.name);
466 *sync_point = child_context_->insertSyncPoint(); 493 *sync_point = child_context_->insertSyncPoint();
467 EXPECT_LT(0u, *sync_point); 494 EXPECT_LT(0u, *sync_point);
468 495
469 scoped_ptr<base::SharedMemory> shared_memory; 496 scoped_ptr<base::SharedMemory> shared_memory;
470 scoped_ptr<SingleReleaseCallbackImpl> callback = 497 scoped_ptr<SingleReleaseCallbackImpl> callback =
471 SingleReleaseCallbackImpl::Create( 498 SingleReleaseCallbackImpl::Create(
472 base::Bind(ReleaseSharedMemoryCallback, 499 base::Bind(ReleaseSharedMemoryCallback,
473 base::Passed(&shared_memory), 500 base::Passed(&shared_memory),
474 release_called, 501 release_called,
475 release_sync_point, 502 release_sync_point,
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 661
635 ResourceProvider::ResourceId id3 = child_resource_provider_->CreateResource( 662 ResourceProvider::ResourceId id3 = child_resource_provider_->CreateResource(
636 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); 663 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
637 { 664 {
638 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock( 665 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock(
639 child_resource_provider_.get(), id3); 666 child_resource_provider_.get(), id3);
640 EXPECT_TRUE(!!lock.GetGpuMemoryBuffer()); 667 EXPECT_TRUE(!!lock.GetGpuMemoryBuffer());
641 } 668 }
642 669
643 GLuint external_texture_id = child_context_->createExternalTexture(); 670 GLuint external_texture_id = child_context_->createExternalTexture();
644 child_context_->bindTexture(GL_TEXTURE_EXTERNAL_OES, external_texture_id);
645 671
646 gpu::Mailbox external_mailbox; 672 gpu::Mailbox external_mailbox;
647 child_context_->genMailboxCHROMIUM(external_mailbox.name); 673 child_context_->genMailboxCHROMIUM(external_mailbox.name);
648 child_context_->produceTextureCHROMIUM(GL_TEXTURE_EXTERNAL_OES, 674 child_context_->produceTextureDirectCHROMIUM(
649 external_mailbox.name); 675 external_texture_id, GL_TEXTURE_EXTERNAL_OES, external_mailbox.name);
650 const GLuint external_sync_point = child_context_->insertSyncPoint(); 676 const GLuint external_sync_point = child_context_->insertSyncPoint();
651 ResourceProvider::ResourceId id4 = 677 ResourceProvider::ResourceId id4 =
652 child_resource_provider_->CreateResourceFromTextureMailbox( 678 child_resource_provider_->CreateResourceFromTextureMailbox(
653 TextureMailbox( 679 TextureMailbox(
654 external_mailbox, GL_TEXTURE_EXTERNAL_OES, external_sync_point), 680 external_mailbox, GL_TEXTURE_EXTERNAL_OES, external_sync_point),
655 SingleReleaseCallbackImpl::Create(base::Bind(&EmptyReleaseCallback))); 681 SingleReleaseCallbackImpl::Create(base::Bind(&EmptyReleaseCallback)));
656 682
657 ReturnedResourceArray returned_to_child; 683 ReturnedResourceArray returned_to_child;
658 int child_id = 684 int child_id =
659 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); 685 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child));
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 EXPECT_NE(0u, mapped_id1); 738 EXPECT_NE(0u, mapped_id1);
713 EXPECT_NE(0u, mapped_id2); 739 EXPECT_NE(0u, mapped_id2);
714 EXPECT_NE(0u, mapped_id3); 740 EXPECT_NE(0u, mapped_id3);
715 EXPECT_NE(0u, mapped_id4); 741 EXPECT_NE(0u, mapped_id4);
716 EXPECT_FALSE(resource_provider_->InUseByConsumer(id1)); 742 EXPECT_FALSE(resource_provider_->InUseByConsumer(id1));
717 EXPECT_FALSE(resource_provider_->InUseByConsumer(id2)); 743 EXPECT_FALSE(resource_provider_->InUseByConsumer(id2));
718 EXPECT_FALSE(resource_provider_->InUseByConsumer(id3)); 744 EXPECT_FALSE(resource_provider_->InUseByConsumer(id3));
719 EXPECT_FALSE(resource_provider_->InUseByConsumer(id4)); 745 EXPECT_FALSE(resource_provider_->InUseByConsumer(id4));
720 746
721 uint8_t result[4] = { 0 }; 747 uint8_t result[4] = { 0 };
722 GetResourcePixels(
danakj 2014/12/01 16:20:05 We should not remove test expectations
sohanjg 2014/12/30 14:45:55 Done.
723 resource_provider_.get(), context(), mapped_id1, size, format, result);
724 EXPECT_EQ(0, memcmp(data1, result, pixel_size));
725
726 GetResourcePixels(
727 resource_provider_.get(), context(), mapped_id2, size, format, result);
728 EXPECT_EQ(0, memcmp(data2, result, pixel_size));
729 748
730 { 749 {
731 // Check that transfering again the same resource from the child to the 750 // Check that transfering again the same resource from the child to the
732 // parent works. 751 // parent works.
733 ResourceProvider::ResourceIdArray resource_ids_to_transfer; 752 ResourceProvider::ResourceIdArray resource_ids_to_transfer;
734 resource_ids_to_transfer.push_back(id1); 753 resource_ids_to_transfer.push_back(id1);
735 resource_ids_to_transfer.push_back(id2); 754 resource_ids_to_transfer.push_back(id2);
736 resource_ids_to_transfer.push_back(id3); 755 resource_ids_to_transfer.push_back(id3);
737 TransferableResourceArray list; 756 TransferableResourceArray list;
738 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, 757 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer,
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, 901 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer,
883 &list); 902 &list);
884 ASSERT_EQ(1u, list.size()); 903 ASSERT_EQ(1u, list.size());
885 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); 904 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1));
886 905
887 resource_provider_->ReceiveFromChild(child_id, list); 906 resource_provider_->ReceiveFromChild(child_id, list);
888 907
889 resource_provider_->WaitSyncPointIfNeeded(list[0].id); 908 resource_provider_->WaitSyncPointIfNeeded(list[0].id);
890 ResourceProvider::ScopedReadLockGL lock(resource_provider_.get(), 909 ResourceProvider::ScopedReadLockGL lock(resource_provider_.get(),
891 list[0].id); 910 list[0].id);
892
893 resource_provider_->DeclareUsedResourcesFromChild( 911 resource_provider_->DeclareUsedResourcesFromChild(
894 child_id, ResourceProvider::ResourceIdArray()); 912 child_id, ResourceProvider::ResourceIdArray());
895 EXPECT_EQ(0u, returned_to_child.size()); 913 EXPECT_EQ(0u, returned_to_child.size());
896 } 914 }
897 915
898 EXPECT_EQ(1u, returned_to_child.size()); 916 EXPECT_EQ(1u, returned_to_child.size());
899 child_resource_provider_->ReceiveReturnsFromParent(returned_to_child); 917 child_resource_provider_->ReceiveReturnsFromParent(returned_to_child);
900 918
901 { 919 {
902 child_resource_provider_->WaitSyncPointIfNeeded(id1); 920 child_resource_provider_->WaitSyncPointIfNeeded(id1);
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after
1721 1739
1722 ReturnedResourceArray returned_to_child; 1740 ReturnedResourceArray returned_to_child;
1723 int child_id = parent_resource_provider->CreateChild( 1741 int child_id = parent_resource_provider->CreateChild(
1724 GetReturnCallback(&returned_to_child)); 1742 GetReturnCallback(&returned_to_child));
1725 { 1743 {
1726 // Transfer some resource to the parent. 1744 // Transfer some resource to the parent.
1727 ResourceProvider::ResourceIdArray resource_ids_to_transfer; 1745 ResourceProvider::ResourceIdArray resource_ids_to_transfer;
1728 resource_ids_to_transfer.push_back(id); 1746 resource_ids_to_transfer.push_back(id);
1729 TransferableResourceArray list; 1747 TransferableResourceArray list;
1730 1748
1731 EXPECT_CALL(*child_context, bindTexture(GL_TEXTURE_2D, child_texture_id));
1732 EXPECT_CALL(*child_context, 1749 EXPECT_CALL(*child_context,
1733 produceTextureCHROMIUM(GL_TEXTURE_2D, _)); 1750 produceTextureDirectCHROMIUM(_, GL_TEXTURE_2D, _));
1734 EXPECT_CALL(*child_context, insertSyncPoint()); 1751 EXPECT_CALL(*child_context, insertSyncPoint());
1735 child_resource_provider->PrepareSendToParent(resource_ids_to_transfer, 1752 child_resource_provider->PrepareSendToParent(resource_ids_to_transfer,
1736 &list); 1753 &list);
1737 Mock::VerifyAndClearExpectations(child_context); 1754 Mock::VerifyAndClearExpectations(child_context);
1738 1755
1739 ASSERT_EQ(1u, list.size()); 1756 ASSERT_EQ(1u, list.size());
1740 EXPECT_EQ(static_cast<unsigned>(child_filter), list[0].filter); 1757 EXPECT_EQ(static_cast<unsigned>(child_filter), list[0].filter);
1741 1758
1742 EXPECT_CALL(*parent_context, 1759 EXPECT_CALL(*parent_context,
1743 bindTexture(GL_TEXTURE_2D, parent_texture_id)); 1760 createAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, _)).Times(0);
1744 EXPECT_CALL(*parent_context, consumeTextureCHROMIUM(GL_TEXTURE_2D, _));
1745 parent_resource_provider->ReceiveFromChild(child_id, list); 1761 parent_resource_provider->ReceiveFromChild(child_id, list);
1746 { 1762 {
1747 parent_resource_provider->WaitSyncPointIfNeeded(list[0].id); 1763 parent_resource_provider->WaitSyncPointIfNeeded(list[0].id);
1748 ResourceProvider::ScopedReadLockGL lock(parent_resource_provider.get(), 1764 ResourceProvider::ScopedReadLockGL lock(parent_resource_provider.get(),
1749 list[0].id); 1765 list[0].id);
1750 } 1766 }
1751 Mock::VerifyAndClearExpectations(parent_context); 1767 Mock::VerifyAndClearExpectations(parent_context);
1752 1768
1753 parent_resource_provider->DeclareUsedResourcesFromChild( 1769 parent_resource_provider->DeclareUsedResourcesFromChild(
1754 child_id, resource_ids_to_transfer); 1770 child_id, resource_ids_to_transfer);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1818 // Other mailbox transfers tested elsewhere. 1834 // Other mailbox transfers tested elsewhere.
1819 if (GetParam() != ResourceProvider::GLTexture) 1835 if (GetParam() != ResourceProvider::GLTexture)
1820 return; 1836 return;
1821 unsigned texture = context()->createTexture(); 1837 unsigned texture = context()->createTexture();
1822 context()->bindTexture(GL_TEXTURE_2D, texture); 1838 context()->bindTexture(GL_TEXTURE_2D, texture);
1823 uint8_t data[4] = { 1, 2, 3, 4 }; 1839 uint8_t data[4] = { 1, 2, 3, 4 };
1824 context()->texImage2D( 1840 context()->texImage2D(
1825 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &data); 1841 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &data);
1826 gpu::Mailbox mailbox; 1842 gpu::Mailbox mailbox;
1827 context()->genMailboxCHROMIUM(mailbox.name); 1843 context()->genMailboxCHROMIUM(mailbox.name);
1828 context()->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); 1844 context()->produceTextureDirectCHROMIUM(texture, GL_TEXTURE_2D, mailbox.name);
1829 uint32 sync_point = context()->insertSyncPoint(); 1845 uint32 sync_point = context()->insertSyncPoint();
1830 1846
1831 // All the logic below assumes that the sync points are all positive. 1847 // All the logic below assumes that the sync points are all positive.
1832 EXPECT_LT(0u, sync_point); 1848 EXPECT_LT(0u, sync_point);
1833 1849
1834 uint32 release_sync_point = 0; 1850 uint32 release_sync_point = 0;
1835 bool lost_resource = false; 1851 bool lost_resource = false;
1836 BlockingTaskRunner* main_thread_task_runner = NULL; 1852 BlockingTaskRunner* main_thread_task_runner = NULL;
1837 ReleaseCallbackImpl callback = base::Bind(ReleaseCallback, 1853 ReleaseCallbackImpl callback = base::Bind(ReleaseCallback,
1838 &release_sync_point, 1854 &release_sync_point,
(...skipping 13 matching lines...) Expand all
1852 resource_provider_->PrepareSendToParent(resource_ids_to_transfer, &list); 1868 resource_provider_->PrepareSendToParent(resource_ids_to_transfer, &list);
1853 ASSERT_EQ(1u, list.size()); 1869 ASSERT_EQ(1u, list.size());
1854 EXPECT_LE(sync_point, list[0].mailbox_holder.sync_point); 1870 EXPECT_LE(sync_point, list[0].mailbox_holder.sync_point);
1855 EXPECT_EQ(0, 1871 EXPECT_EQ(0,
1856 memcmp(mailbox.name, 1872 memcmp(mailbox.name,
1857 list[0].mailbox_holder.mailbox.name, 1873 list[0].mailbox_holder.mailbox.name,
1858 sizeof(mailbox.name))); 1874 sizeof(mailbox.name)));
1859 EXPECT_EQ(0u, release_sync_point); 1875 EXPECT_EQ(0u, release_sync_point);
1860 1876
1861 context()->waitSyncPoint(list[0].mailbox_holder.sync_point); 1877 context()->waitSyncPoint(list[0].mailbox_holder.sync_point);
1862 unsigned other_texture = context()->createTexture(); 1878 unsigned other_texture =
1863 context()->bindTexture(GL_TEXTURE_2D, other_texture); 1879 context()->createAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name);
1864 context()->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); 1880
1865 uint8_t test_data[4] = { 0 }; 1881 context()->produceTextureDirectCHROMIUM(
1866 context()->GetPixels( 1882 other_texture, GL_TEXTURE_2D, mailbox.name);
danakj 2014/12/01 16:20:04 We should not remove test expectations.
sohanjg 2014/12/30 14:45:54 Done.
1867 gfx::Size(1, 1), RGBA_8888, test_data);
1868 EXPECT_EQ(0, memcmp(data, test_data, sizeof(data)));
1869 context()->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name);
1870 context()->deleteTexture(other_texture); 1883 context()->deleteTexture(other_texture);
1871 list[0].mailbox_holder.sync_point = context()->insertSyncPoint(); 1884 list[0].mailbox_holder.sync_point = context()->insertSyncPoint();
1872 EXPECT_LT(0u, list[0].mailbox_holder.sync_point); 1885 EXPECT_LT(0u, list[0].mailbox_holder.sync_point);
1873 1886
1874 // Receive the resource, then delete it, expect the sync points to be 1887 // Receive the resource, then delete it, expect the sync points to be
1875 // consistent. 1888 // consistent.
1876 ReturnedResourceArray returned; 1889 ReturnedResourceArray returned;
1877 TransferableResource::ReturnResources(list, &returned); 1890 TransferableResource::ReturnResources(list, &returned);
1878 resource_provider_->ReceiveReturnsFromParent(returned); 1891 resource_provider_->ReceiveReturnsFromParent(returned);
1879 EXPECT_EQ(1u, context()->NumTextures()); 1892 EXPECT_EQ(1u, context()->NumTextures());
(...skipping 23 matching lines...) Expand all
1903 resource_provider_->PrepareSendToParent(resource_ids_to_transfer, &list); 1916 resource_provider_->PrepareSendToParent(resource_ids_to_transfer, &list);
1904 ASSERT_EQ(1u, list.size()); 1917 ASSERT_EQ(1u, list.size());
1905 EXPECT_LE(sync_point, list[0].mailbox_holder.sync_point); 1918 EXPECT_LE(sync_point, list[0].mailbox_holder.sync_point);
1906 EXPECT_EQ(0, 1919 EXPECT_EQ(0,
1907 memcmp(mailbox.name, 1920 memcmp(mailbox.name,
1908 list[0].mailbox_holder.mailbox.name, 1921 list[0].mailbox_holder.mailbox.name,
1909 sizeof(mailbox.name))); 1922 sizeof(mailbox.name)));
1910 EXPECT_EQ(0u, release_sync_point); 1923 EXPECT_EQ(0u, release_sync_point);
1911 1924
1912 context()->waitSyncPoint(list[0].mailbox_holder.sync_point); 1925 context()->waitSyncPoint(list[0].mailbox_holder.sync_point);
1913 unsigned other_texture = context()->createTexture(); 1926 unsigned other_texture =
1914 context()->bindTexture(GL_TEXTURE_2D, other_texture); 1927 context()->createAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name);
1915 context()->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); 1928
1916 uint8_t test_data[4] = { 0 }; 1929 context()->produceTextureDirectCHROMIUM(
1917 context()->GetPixels( 1930 other_texture, GL_TEXTURE_2D, mailbox.name);
danakj 2014/12/01 16:20:05 ditto...
sohanjg 2014/12/30 14:45:55 Done.
1918 gfx::Size(1, 1), RGBA_8888, test_data);
1919 EXPECT_EQ(0, memcmp(data, test_data, sizeof(data)));
1920 context()->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name);
1921 context()->deleteTexture(other_texture); 1931 context()->deleteTexture(other_texture);
1922 list[0].mailbox_holder.sync_point = context()->insertSyncPoint(); 1932 list[0].mailbox_holder.sync_point = context()->insertSyncPoint();
1923 EXPECT_LT(0u, list[0].mailbox_holder.sync_point); 1933 EXPECT_LT(0u, list[0].mailbox_holder.sync_point);
1924 1934
1925 // Delete the resource, which shouldn't do anything. 1935 // Delete the resource, which shouldn't do anything.
1926 resource_provider_->DeleteResource(resource); 1936 resource_provider_->DeleteResource(resource);
1927 EXPECT_EQ(1u, context()->NumTextures()); 1937 EXPECT_EQ(1u, context()->NumTextures());
1928 EXPECT_EQ(0u, release_sync_point); 1938 EXPECT_EQ(0u, release_sync_point);
1929 1939
1930 // Then receive the resource which should release the mailbox, expect the 1940 // Then receive the resource which should release the mailbox, expect the
1931 // sync points to be consistent. 1941 // sync points to be consistent.
1932 ReturnedResourceArray returned; 1942 ReturnedResourceArray returned;
1933 TransferableResource::ReturnResources(list, &returned); 1943 TransferableResource::ReturnResources(list, &returned);
1934 resource_provider_->ReceiveReturnsFromParent(returned); 1944 resource_provider_->ReceiveReturnsFromParent(returned);
1935 EXPECT_LE(list[0].mailbox_holder.sync_point, release_sync_point); 1945 EXPECT_LE(list[0].mailbox_holder.sync_point, release_sync_point);
1936 EXPECT_FALSE(lost_resource); 1946 EXPECT_FALSE(lost_resource);
1937 EXPECT_EQ(main_thread_task_runner_.get(), main_thread_task_runner); 1947 EXPECT_EQ(main_thread_task_runner_.get(), main_thread_task_runner);
1938 } 1948 }
1939 1949
1940 context()->waitSyncPoint(release_sync_point); 1950 context()->waitSyncPoint(release_sync_point);
1941 context()->bindTexture(GL_TEXTURE_2D, texture); 1951 texture =
1942 context()->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); 1952 context()->createAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name);
1943 context()->deleteTexture(texture); 1953 context()->deleteTexture(texture);
1944 } 1954 }
1945 1955
1946 TEST_P(ResourceProviderTest, LostResourceInParent) { 1956 TEST_P(ResourceProviderTest, LostResourceInParent) {
1947 gfx::Size size(1, 1); 1957 gfx::Size size(1, 1);
1948 ResourceFormat format = RGBA_8888; 1958 ResourceFormat format = RGBA_8888;
1949 ResourceProvider::ResourceId resource = 1959 ResourceProvider::ResourceId resource =
1950 child_resource_provider_->CreateResource( 1960 child_resource_provider_->CreateResource(
1951 size, 1961 size,
1952 GL_CLAMP_TO_EDGE, 1962 GL_CLAMP_TO_EDGE,
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
2242 } 2252 }
2243 2253
2244 TEST_P(ResourceProviderTest, LostContext) { 2254 TEST_P(ResourceProviderTest, LostContext) {
2245 // TextureMailbox callbacks only exist for GL textures for now. 2255 // TextureMailbox callbacks only exist for GL textures for now.
2246 if (GetParam() != ResourceProvider::GLTexture) 2256 if (GetParam() != ResourceProvider::GLTexture)
2247 return; 2257 return;
2248 unsigned texture = context()->createTexture(); 2258 unsigned texture = context()->createTexture();
2249 context()->bindTexture(GL_TEXTURE_2D, texture); 2259 context()->bindTexture(GL_TEXTURE_2D, texture);
2250 gpu::Mailbox mailbox; 2260 gpu::Mailbox mailbox;
2251 context()->genMailboxCHROMIUM(mailbox.name); 2261 context()->genMailboxCHROMIUM(mailbox.name);
2252 context()->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); 2262 context()->produceTextureDirectCHROMIUM(texture, GL_TEXTURE_2D, mailbox.name);
2253 uint32 sync_point = context()->insertSyncPoint(); 2263 uint32 sync_point = context()->insertSyncPoint();
2254 2264
2255 EXPECT_LT(0u, sync_point); 2265 EXPECT_LT(0u, sync_point);
2256 2266
2257 uint32 release_sync_point = 0; 2267 uint32 release_sync_point = 0;
2258 bool lost_resource = false; 2268 bool lost_resource = false;
2259 BlockingTaskRunner* main_thread_task_runner = NULL; 2269 BlockingTaskRunner* main_thread_task_runner = NULL;
2260 scoped_ptr<SingleReleaseCallbackImpl> callback = 2270 scoped_ptr<SingleReleaseCallbackImpl> callback =
2261 SingleReleaseCallbackImpl::Create(base::Bind(ReleaseCallback, 2271 SingleReleaseCallbackImpl::Create(base::Bind(ReleaseCallback,
2262 &release_sync_point, 2272 &release_sync_point,
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
2619 2629
2620 scoped_ptr<ResourceProvider> resource_provider( 2630 scoped_ptr<ResourceProvider> resource_provider(
2621 ResourceProvider::Create(output_surface.get(), 2631 ResourceProvider::Create(output_surface.get(),
2622 shared_bitmap_manager_.get(), 2632 shared_bitmap_manager_.get(),
2623 gpu_memory_buffer_manager_.get(), 2633 gpu_memory_buffer_manager_.get(),
2624 main_thread_task_runner_.get(), 2634 main_thread_task_runner_.get(),
2625 0, 2635 0,
2626 false, 2636 false,
2627 1)); 2637 1));
2628 2638
2629 unsigned texture_id = 1;
2630 uint32 sync_point = 30; 2639 uint32 sync_point = 30;
2631 unsigned target = GL_TEXTURE_2D; 2640 unsigned target = GL_TEXTURE_2D;
2632 2641
2633 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); 2642 EXPECT_CALL(*context, bindTexture(_, _)).Times(0);
2634 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); 2643 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0);
2635 EXPECT_CALL(*context, insertSyncPoint()).Times(0); 2644 EXPECT_CALL(*context, insertSyncPoint()).Times(0);
2636 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); 2645 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0);
2637 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0); 2646 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0);
2638 2647
2639 gpu::Mailbox gpu_mailbox; 2648 gpu::Mailbox gpu_mailbox;
2640 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1); 2649 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1);
2641 uint32 release_sync_point = 0; 2650 uint32 release_sync_point = 0;
2642 bool lost_resource = false; 2651 bool lost_resource = false;
2643 BlockingTaskRunner* main_thread_task_runner = NULL; 2652 BlockingTaskRunner* main_thread_task_runner = NULL;
2644 scoped_ptr<SingleReleaseCallbackImpl> callback = 2653 scoped_ptr<SingleReleaseCallbackImpl> callback =
2645 SingleReleaseCallbackImpl::Create(base::Bind(&ReleaseCallback, 2654 SingleReleaseCallbackImpl::Create(base::Bind(&ReleaseCallback,
2646 &release_sync_point, 2655 &release_sync_point,
2647 &lost_resource, 2656 &lost_resource,
2648 &main_thread_task_runner)); 2657 &main_thread_task_runner));
2649 2658
2650 TextureMailbox mailbox(gpu_mailbox, target, sync_point); 2659 TextureMailbox mailbox(gpu_mailbox, target, sync_point);
2651 2660
2652 ResourceProvider::ResourceId id = 2661 ResourceProvider::ResourceId id =
2653 resource_provider->CreateResourceFromTextureMailbox( 2662 resource_provider->CreateResourceFromTextureMailbox(
2654 mailbox, callback.Pass()); 2663 mailbox, callback.Pass());
2655 EXPECT_NE(0u, id); 2664 EXPECT_NE(0u, id);
2656 2665
2657 Mock::VerifyAndClearExpectations(context); 2666 Mock::VerifyAndClearExpectations(context);
2658 2667
2659 { 2668 {
2660 // Mailbox sync point WaitSyncPoint before using the texture. 2669 // Mailbox sync point WaitSyncPoint before using the texture.
2661 EXPECT_CALL(*context, waitSyncPoint(sync_point)); 2670 EXPECT_CALL(*context, waitSyncPoint(sync_point));
2662 resource_provider->WaitSyncPointIfNeeded(id); 2671 resource_provider->WaitSyncPointIfNeeded(id);
2663 Mock::VerifyAndClearExpectations(context); 2672 Mock::VerifyAndClearExpectations(context);
2664 2673
2665 // Using the texture does a consume of the mailbox. 2674 // Using the texture does a consume of the mailbox.
2666 EXPECT_CALL(*context, bindTexture(target, texture_id)); 2675 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(target, _)).Times(0);
2667 EXPECT_CALL(*context, consumeTextureCHROMIUM(target, _));
2668 2676
2669 EXPECT_CALL(*context, insertSyncPoint()).Times(0); 2677 EXPECT_CALL(*context, insertSyncPoint()).Times(0);
2670 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); 2678 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0);
2671 2679
2672 ResourceProvider::ScopedReadLockGL lock(resource_provider.get(), id); 2680 ResourceProvider::ScopedReadLockGL lock(resource_provider.get(), id);
2673 Mock::VerifyAndClearExpectations(context); 2681 Mock::VerifyAndClearExpectations(context);
2674 2682
2675 // When done with it, a sync point should be inserted, but no produce is 2683 // When done with it, a sync point should be inserted, but no produce is
2676 // necessary. 2684 // necessary.
2677 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); 2685 EXPECT_CALL(*context, bindTexture(_, _)).Times(0);
2678 EXPECT_CALL(*context, insertSyncPoint()); 2686 EXPECT_CALL(*context, insertSyncPoint());
2679 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); 2687 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0);
2680 2688
2681 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); 2689 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0);
2682 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0); 2690 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0);
2683 } 2691 }
2684 2692
2685 resource_provider->DeleteResource(id); 2693 resource_provider->DeleteResource(id);
2686 EXPECT_EQ(0u, release_sync_point); 2694 EXPECT_EQ(0u, release_sync_point);
2687 EXPECT_FALSE(lost_resource); 2695 EXPECT_FALSE(lost_resource);
2688 EXPECT_EQ(main_thread_task_runner_.get(), main_thread_task_runner); 2696 EXPECT_EQ(main_thread_task_runner_.get(), main_thread_task_runner);
2689 } 2697 }
2690 2698
2691 TEST_P(ResourceProviderTest, TextureMailbox_GLTextureExternalOES) { 2699 TEST_P(ResourceProviderTest, TextureMailbox_GLTextureExternalOES) {
2692 // Mailboxing is only supported for GL textures. 2700 // Mailboxing is only supported for GL textures.
(...skipping 11 matching lines...) Expand all
2704 2712
2705 scoped_ptr<ResourceProvider> resource_provider( 2713 scoped_ptr<ResourceProvider> resource_provider(
2706 ResourceProvider::Create(output_surface.get(), 2714 ResourceProvider::Create(output_surface.get(),
2707 shared_bitmap_manager_.get(), 2715 shared_bitmap_manager_.get(),
2708 gpu_memory_buffer_manager_.get(), 2716 gpu_memory_buffer_manager_.get(),
2709 NULL, 2717 NULL,
2710 0, 2718 0,
2711 false, 2719 false,
2712 1)); 2720 1));
2713 2721
2714 unsigned texture_id = 1;
2715 uint32 sync_point = 30; 2722 uint32 sync_point = 30;
2716 unsigned target = GL_TEXTURE_EXTERNAL_OES; 2723 unsigned target = GL_TEXTURE_EXTERNAL_OES;
2717 2724
2718 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); 2725 EXPECT_CALL(*context, bindTexture(_, _)).Times(0);
2719 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); 2726 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0);
2720 EXPECT_CALL(*context, insertSyncPoint()).Times(0); 2727 EXPECT_CALL(*context, insertSyncPoint()).Times(0);
2721 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); 2728 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0);
2722 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0); 2729 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0);
2723 2730
2724 gpu::Mailbox gpu_mailbox; 2731 gpu::Mailbox gpu_mailbox;
2725 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1); 2732 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1);
2726 scoped_ptr<SingleReleaseCallbackImpl> callback = 2733 scoped_ptr<SingleReleaseCallbackImpl> callback =
2727 SingleReleaseCallbackImpl::Create(base::Bind(&EmptyReleaseCallback)); 2734 SingleReleaseCallbackImpl::Create(base::Bind(&EmptyReleaseCallback));
2728 2735
2729 TextureMailbox mailbox(gpu_mailbox, target, sync_point); 2736 TextureMailbox mailbox(gpu_mailbox, target, sync_point);
2730 2737
2731 ResourceProvider::ResourceId id = 2738 ResourceProvider::ResourceId id =
2732 resource_provider->CreateResourceFromTextureMailbox( 2739 resource_provider->CreateResourceFromTextureMailbox(
2733 mailbox, callback.Pass()); 2740 mailbox, callback.Pass());
2734 EXPECT_NE(0u, id); 2741 EXPECT_NE(0u, id);
2735 2742
2736 Mock::VerifyAndClearExpectations(context); 2743 Mock::VerifyAndClearExpectations(context);
2737 2744
2738 { 2745 {
2739 // Mailbox sync point WaitSyncPoint before using the texture. 2746 // Mailbox sync point WaitSyncPoint before using the texture.
2740 EXPECT_CALL(*context, waitSyncPoint(sync_point)); 2747 EXPECT_CALL(*context, waitSyncPoint(sync_point));
2741 resource_provider->WaitSyncPointIfNeeded(id); 2748 resource_provider->WaitSyncPointIfNeeded(id);
2742 Mock::VerifyAndClearExpectations(context); 2749 Mock::VerifyAndClearExpectations(context);
2743 2750
2744 // Using the texture does a consume of the mailbox. 2751 // Using the texture does a consume of the mailbox.
2745 EXPECT_CALL(*context, bindTexture(target, texture_id)); 2752 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(target, _)).Times(0);
2746 EXPECT_CALL(*context, consumeTextureCHROMIUM(target, _));
2747 2753
2748 EXPECT_CALL(*context, insertSyncPoint()).Times(0); 2754 EXPECT_CALL(*context, insertSyncPoint()).Times(0);
2749 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); 2755 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0);
2750 2756
2751 ResourceProvider::ScopedReadLockGL lock(resource_provider.get(), id); 2757 ResourceProvider::ScopedReadLockGL lock(resource_provider.get(), id);
2752 Mock::VerifyAndClearExpectations(context); 2758 Mock::VerifyAndClearExpectations(context);
2753 2759
2754 // When done with it, a sync point should be inserted, but no produce is 2760 // When done with it, a sync point should be inserted, but no produce is
2755 // necessary. 2761 // necessary.
2756 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); 2762 EXPECT_CALL(*context, bindTexture(_, _)).Times(0);
2757 EXPECT_CALL(*context, insertSyncPoint()); 2763 EXPECT_CALL(*context, insertSyncPoint());
2758 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); 2764 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0);
2759 2765
2760 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); 2766 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0);
2761 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0); 2767 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0);
2762 } 2768 }
2763 } 2769 }
2764 2770
2765 TEST_P(ResourceProviderTest, 2771 TEST_P(ResourceProviderTest,
2766 TextureMailbox_WaitSyncPointIfNeeded_WithSyncPoint) { 2772 TextureMailbox_WaitSyncPointIfNeeded_WithSyncPoint) {
2767 // Mailboxing is only supported for GL textures. 2773 // Mailboxing is only supported for GL textures.
2768 if (GetParam() != ResourceProvider::GLTexture) 2774 if (GetParam() != ResourceProvider::GLTexture)
2769 return; 2775 return;
2770 2776
2771 scoped_ptr<TextureStateTrackingContext> context_owned( 2777 scoped_ptr<TextureStateTrackingContext> context_owned(
(...skipping 13 matching lines...) Expand all
2785 0, 2791 0,
2786 false, 2792 false,
2787 1)); 2793 1));
2788 2794
2789 uint32 sync_point = 30; 2795 uint32 sync_point = 30;
2790 unsigned target = GL_TEXTURE_2D; 2796 unsigned target = GL_TEXTURE_2D;
2791 2797
2792 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); 2798 EXPECT_CALL(*context, bindTexture(_, _)).Times(0);
2793 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); 2799 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0);
2794 EXPECT_CALL(*context, insertSyncPoint()).Times(0); 2800 EXPECT_CALL(*context, insertSyncPoint()).Times(0);
2795 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); 2801 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0);
2796 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0); 2802 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0);
2797 2803
2798 gpu::Mailbox gpu_mailbox; 2804 gpu::Mailbox gpu_mailbox;
2799 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1); 2805 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1);
2800 scoped_ptr<SingleReleaseCallbackImpl> callback = 2806 scoped_ptr<SingleReleaseCallbackImpl> callback =
2801 SingleReleaseCallbackImpl::Create(base::Bind(&EmptyReleaseCallback)); 2807 SingleReleaseCallbackImpl::Create(base::Bind(&EmptyReleaseCallback));
2802 2808
2803 TextureMailbox mailbox(gpu_mailbox, target, sync_point); 2809 TextureMailbox mailbox(gpu_mailbox, target, sync_point);
2804 2810
2805 ResourceProvider::ResourceId id = 2811 ResourceProvider::ResourceId id =
2806 resource_provider->CreateResourceFromTextureMailbox(mailbox, 2812 resource_provider->CreateResourceFromTextureMailbox(mailbox,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2844 0, 2850 0,
2845 false, 2851 false,
2846 1)); 2852 1));
2847 2853
2848 uint32 sync_point = 0; 2854 uint32 sync_point = 0;
2849 unsigned target = GL_TEXTURE_2D; 2855 unsigned target = GL_TEXTURE_2D;
2850 2856
2851 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); 2857 EXPECT_CALL(*context, bindTexture(_, _)).Times(0);
2852 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); 2858 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0);
2853 EXPECT_CALL(*context, insertSyncPoint()).Times(0); 2859 EXPECT_CALL(*context, insertSyncPoint()).Times(0);
2854 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); 2860 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0);
2855 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0); 2861 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0);
2856 2862
2857 gpu::Mailbox gpu_mailbox; 2863 gpu::Mailbox gpu_mailbox;
2858 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1); 2864 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1);
2859 scoped_ptr<SingleReleaseCallbackImpl> callback = 2865 scoped_ptr<SingleReleaseCallbackImpl> callback =
2860 SingleReleaseCallbackImpl::Create(base::Bind(&EmptyReleaseCallback)); 2866 SingleReleaseCallbackImpl::Create(base::Bind(&EmptyReleaseCallback));
2861 2867
2862 TextureMailbox mailbox(gpu_mailbox, target, sync_point); 2868 TextureMailbox mailbox(gpu_mailbox, target, sync_point);
2863 2869
2864 ResourceProvider::ResourceId id = 2870 ResourceProvider::ResourceId id =
2865 resource_provider->CreateResourceFromTextureMailbox(mailbox, 2871 resource_provider->CreateResourceFromTextureMailbox(mailbox,
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
3639 resource_provider->AllocateForTesting(id); 3645 resource_provider->AllocateForTesting(id);
3640 Mock::VerifyAndClearExpectations(context); 3646 Mock::VerifyAndClearExpectations(context);
3641 3647
3642 DCHECK_EQ(10u, context->PeekTextureId()); 3648 DCHECK_EQ(10u, context->PeekTextureId());
3643 resource_provider->DeleteResource(id); 3649 resource_provider->DeleteResource(id);
3644 } 3650 }
3645 } 3651 }
3646 3652
3647 } // namespace 3653 } // namespace
3648 } // namespace cc 3654 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698