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

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

Issue 105743004: Add gpu::MailboxHolder to hold state for a gpu::Mailbox (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: c301e01d Rebase. Created 6 years, 11 months 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 | Annotate | Revision Log
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 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 19 matching lines...) Expand all
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 GLuint InsertSyncPoint() { return next_sync_point_++; }
danakj 2014/01/06 20:13:42 I think for consistency, things that aren't part o
sheu 2014/01/06 22:44:44 Sure.
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 GLuint 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 GLuint 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 GLuint 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, GLuint> 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 GLuint 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
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
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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 uint8_t data2[4] = { 5, 5, 5, 5 }; 648 uint8_t data2[4] = { 5, 5, 5, 5 };
648 child_resource_provider_->SetPixels(id2, data2, rect, rect, gfx::Vector2d()); 649 child_resource_provider_->SetPixels(id2, data2, rect, rect, gfx::Vector2d());
649 650
650 GLuint external_texture_id = child_context_->createExternalTexture(); 651 GLuint external_texture_id = child_context_->createExternalTexture();
651 child_context_->bindTexture(GL_TEXTURE_EXTERNAL_OES, external_texture_id); 652 child_context_->bindTexture(GL_TEXTURE_EXTERNAL_OES, external_texture_id);
652 653
653 gpu::Mailbox external_mailbox; 654 gpu::Mailbox external_mailbox;
654 child_context_->genMailboxCHROMIUM(external_mailbox.name); 655 child_context_->genMailboxCHROMIUM(external_mailbox.name);
655 child_context_->produceTextureCHROMIUM(GL_TEXTURE_EXTERNAL_OES, 656 child_context_->produceTextureCHROMIUM(GL_TEXTURE_EXTERNAL_OES,
656 external_mailbox.name); 657 external_mailbox.name);
657 const unsigned external_sync_point = child_context_->insertSyncPoint(); 658 const GLuint external_sync_point = child_context_->insertSyncPoint();
658 ResourceProvider::ResourceId id3 = 659 ResourceProvider::ResourceId id3 =
659 child_resource_provider_->CreateResourceFromTextureMailbox( 660 child_resource_provider_->CreateResourceFromTextureMailbox(
660 TextureMailbox( 661 TextureMailbox(
661 external_mailbox, GL_TEXTURE_EXTERNAL_OES, external_sync_point), 662 external_mailbox, GL_TEXTURE_EXTERNAL_OES, external_sync_point),
662 SingleReleaseCallback::Create(base::Bind(&EmptyReleaseCallback))); 663 SingleReleaseCallback::Create(base::Bind(&EmptyReleaseCallback)));
663 664
664 ReturnedResourceArray returned_to_child; 665 ReturnedResourceArray returned_to_child;
665 int child_id = 666 int child_id =
666 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); 667 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child));
667 { 668 {
668 // Transfer some resources to the parent. 669 // Transfer some resources to the parent.
669 ResourceProvider::ResourceIdArray resource_ids_to_transfer; 670 ResourceProvider::ResourceIdArray resource_ids_to_transfer;
670 resource_ids_to_transfer.push_back(id1); 671 resource_ids_to_transfer.push_back(id1);
671 resource_ids_to_transfer.push_back(id2); 672 resource_ids_to_transfer.push_back(id2);
672 resource_ids_to_transfer.push_back(id3); 673 resource_ids_to_transfer.push_back(id3);
673 TransferableResourceArray list; 674 TransferableResourceArray list;
674 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, 675 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer,
675 &list); 676 &list);
676 ASSERT_EQ(3u, list.size()); 677 ASSERT_EQ(3u, list.size());
677 EXPECT_NE(0u, list[0].sync_point); 678 EXPECT_NE(0u, list[0].mailbox_holder.sync_point);
678 EXPECT_NE(0u, list[1].sync_point); 679 EXPECT_NE(0u, list[1].mailbox_holder.sync_point);
679 EXPECT_EQ(external_sync_point, list[2].sync_point); 680 EXPECT_EQ(external_sync_point, list[2].mailbox_holder.sync_point);
680 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), list[0].target); 681 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D),
681 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), list[1].target); 682 list[0].mailbox_holder.texture_target);
682 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_EXTERNAL_OES), list[2].target); 683 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D),
684 list[1].mailbox_holder.texture_target);
685 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_EXTERNAL_OES),
686 list[2].mailbox_holder.texture_target);
683 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); 687 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1));
684 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); 688 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2));
685 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id3)); 689 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id3));
686 resource_provider_->ReceiveFromChild(child_id, list); 690 resource_provider_->ReceiveFromChild(child_id, list);
687 resource_provider_->DeclareUsedResourcesFromChild(child_id, 691 resource_provider_->DeclareUsedResourcesFromChild(child_id,
688 resource_ids_to_transfer); 692 resource_ids_to_transfer);
689 } 693 }
690 694
691 EXPECT_EQ(3u, resource_provider_->num_resources()); 695 EXPECT_EQ(3u, resource_provider_->num_resources());
692 ResourceProvider::ResourceIdMap resource_map = 696 ResourceProvider::ResourceIdMap resource_map =
(...skipping 20 matching lines...) Expand all
713 { 717 {
714 // Check that transfering again the same resource from the child to the 718 // Check that transfering again the same resource from the child to the
715 // parent works. 719 // parent works.
716 ResourceProvider::ResourceIdArray resource_ids_to_transfer; 720 ResourceProvider::ResourceIdArray resource_ids_to_transfer;
717 resource_ids_to_transfer.push_back(id1); 721 resource_ids_to_transfer.push_back(id1);
718 TransferableResourceArray list; 722 TransferableResourceArray list;
719 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, 723 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer,
720 &list); 724 &list);
721 EXPECT_EQ(1u, list.size()); 725 EXPECT_EQ(1u, list.size());
722 EXPECT_EQ(id1, list[0].id); 726 EXPECT_EQ(id1, list[0].id);
723 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), list[0].target); 727 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D),
728 list[0].mailbox_holder.texture_target);
724 ReturnedResourceArray returned; 729 ReturnedResourceArray returned;
725 TransferableResource::ReturnResources(list, &returned); 730 TransferableResource::ReturnResources(list, &returned);
726 child_resource_provider_->ReceiveReturnsFromParent(returned); 731 child_resource_provider_->ReceiveReturnsFromParent(returned);
727 // id1 was exported twice, we returned it only once, it should still be 732 // id1 was exported twice, we returned it only once, it should still be
728 // in-use. 733 // in-use.
729 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); 734 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1));
730 } 735 }
731 { 736 {
732 EXPECT_EQ(0u, returned_to_child.size()); 737 EXPECT_EQ(0u, returned_to_child.size());
733 738
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 resource_ids_to_transfer.push_back(id1); 777 resource_ids_to_transfer.push_back(id1);
773 resource_ids_to_transfer.push_back(id2); 778 resource_ids_to_transfer.push_back(id2);
774 resource_ids_to_transfer.push_back(id3); 779 resource_ids_to_transfer.push_back(id3);
775 TransferableResourceArray list; 780 TransferableResourceArray list;
776 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, 781 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer,
777 &list); 782 &list);
778 ASSERT_EQ(3u, list.size()); 783 ASSERT_EQ(3u, list.size());
779 EXPECT_EQ(id1, list[0].id); 784 EXPECT_EQ(id1, list[0].id);
780 EXPECT_EQ(id2, list[1].id); 785 EXPECT_EQ(id2, list[1].id);
781 EXPECT_EQ(id3, list[2].id); 786 EXPECT_EQ(id3, list[2].id);
782 EXPECT_NE(0u, list[0].sync_point); 787 EXPECT_NE(0u, list[0].mailbox_holder.sync_point);
783 EXPECT_NE(0u, list[1].sync_point); 788 EXPECT_NE(0u, list[1].mailbox_holder.sync_point);
784 EXPECT_NE(0u, list[2].sync_point); 789 EXPECT_NE(0u, list[2].mailbox_holder.sync_point);
785 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), list[0].target); 790 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D),
786 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), list[1].target); 791 list[0].mailbox_holder.texture_target);
787 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_EXTERNAL_OES), list[2].target); 792 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D),
793 list[1].mailbox_holder.texture_target);
794 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_EXTERNAL_OES),
795 list[2].mailbox_holder.texture_target);
788 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); 796 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1));
789 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); 797 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2));
790 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id3)); 798 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id3));
791 resource_provider_->ReceiveFromChild(child_id, list); 799 resource_provider_->ReceiveFromChild(child_id, list);
792 resource_provider_->DeclareUsedResourcesFromChild(child_id, 800 resource_provider_->DeclareUsedResourcesFromChild(child_id,
793 resource_ids_to_transfer); 801 resource_ids_to_transfer);
794 } 802 }
795 803
796 EXPECT_EQ(0u, returned_to_child.size()); 804 EXPECT_EQ(0u, returned_to_child.size());
797 805
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 { 851 {
844 // Transfer some resources to the parent. 852 // Transfer some resources to the parent.
845 ResourceProvider::ResourceIdArray resource_ids_to_transfer; 853 ResourceProvider::ResourceIdArray resource_ids_to_transfer;
846 resource_ids_to_transfer.push_back(id1); 854 resource_ids_to_transfer.push_back(id1);
847 resource_ids_to_transfer.push_back(id2); 855 resource_ids_to_transfer.push_back(id2);
848 resource_ids_to_transfer.push_back(id3); 856 resource_ids_to_transfer.push_back(id3);
849 TransferableResourceArray list; 857 TransferableResourceArray list;
850 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, 858 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer,
851 &list); 859 &list);
852 ASSERT_EQ(3u, list.size()); 860 ASSERT_EQ(3u, list.size());
853 EXPECT_EQ(0u, list[0].sync_point); 861 EXPECT_EQ(0u, list[0].mailbox_holder.sync_point);
854 EXPECT_EQ(0u, list[1].sync_point); 862 EXPECT_EQ(0u, list[1].mailbox_holder.sync_point);
855 EXPECT_EQ(0u, list[2].sync_point); 863 EXPECT_EQ(0u, list[2].mailbox_holder.sync_point);
856 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); 864 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1));
857 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); 865 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2));
858 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id3)); 866 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id3));
859 resource_provider_->ReceiveFromChild(child_id, list); 867 resource_provider_->ReceiveFromChild(child_id, list);
860 resource_provider_->DeclareUsedResourcesFromChild(child_id, 868 resource_provider_->DeclareUsedResourcesFromChild(child_id,
861 resource_ids_to_transfer); 869 resource_ids_to_transfer);
862 } 870 }
863 871
864 EXPECT_EQ(3u, resource_provider_->num_resources()); 872 EXPECT_EQ(3u, resource_provider_->num_resources());
865 ResourceProvider::ResourceIdMap resource_map = 873 ResourceProvider::ResourceIdMap resource_map =
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 ReturnedResourceArray returned_to_child; 1079 ReturnedResourceArray returned_to_child;
1072 int child_id = 1080 int child_id =
1073 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); 1081 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child));
1074 { 1082 {
1075 ResourceProvider::ResourceIdArray resource_ids_to_transfer; 1083 ResourceProvider::ResourceIdArray resource_ids_to_transfer;
1076 resource_ids_to_transfer.push_back(id1); 1084 resource_ids_to_transfer.push_back(id1);
1077 TransferableResourceArray list; 1085 TransferableResourceArray list;
1078 child_resource_provider->PrepareSendToParent(resource_ids_to_transfer, 1086 child_resource_provider->PrepareSendToParent(resource_ids_to_transfer,
1079 &list); 1087 &list);
1080 ASSERT_EQ(1u, list.size()); 1088 ASSERT_EQ(1u, list.size());
1081 EXPECT_NE(0u, list[0].sync_point); 1089 EXPECT_NE(0u, list[0].mailbox_holder.sync_point);
1082 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), list[0].target); 1090 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D),
1091 list[0].mailbox_holder.texture_target);
1083 EXPECT_TRUE(child_resource_provider->InUseByConsumer(id1)); 1092 EXPECT_TRUE(child_resource_provider->InUseByConsumer(id1));
1084 resource_provider_->ReceiveFromChild(child_id, list); 1093 resource_provider_->ReceiveFromChild(child_id, list);
1085 } 1094 }
1086 1095
1087 EXPECT_EQ(0u, resource_provider_->num_resources()); 1096 EXPECT_EQ(0u, resource_provider_->num_resources());
1088 ASSERT_EQ(1u, returned_to_child.size()); 1097 ASSERT_EQ(1u, returned_to_child.size());
1089 EXPECT_EQ(returned_to_child[0].id, id1); 1098 EXPECT_EQ(returned_to_child[0].id, id1);
1090 ResourceProvider::ResourceIdMap resource_map = 1099 ResourceProvider::ResourceIdMap resource_map =
1091 resource_provider_->GetChildToParentMap(child_id); 1100 resource_provider_->GetChildToParentMap(child_id);
1092 ResourceProvider::ResourceId mapped_id1 = resource_map[id1]; 1101 ResourceProvider::ResourceId mapped_id1 = resource_map[id1];
(...skipping 25 matching lines...) Expand all
1118 int child_id = 1127 int child_id =
1119 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); 1128 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child));
1120 { 1129 {
1121 ResourceProvider::ResourceIdArray resource_ids_to_transfer; 1130 ResourceProvider::ResourceIdArray resource_ids_to_transfer;
1122 resource_ids_to_transfer.push_back(id1); 1131 resource_ids_to_transfer.push_back(id1);
1123 TransferableResourceArray list; 1132 TransferableResourceArray list;
1124 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, 1133 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer,
1125 &list); 1134 &list);
1126 ASSERT_EQ(1u, list.size()); 1135 ASSERT_EQ(1u, list.size());
1127 // Make invalid. 1136 // Make invalid.
1128 list[0].mailbox.name[1] = 5; 1137 list[0].mailbox_holder.mailbox.name[1] = 5;
1129 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); 1138 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1));
1130 resource_provider_->ReceiveFromChild(child_id, list); 1139 resource_provider_->ReceiveFromChild(child_id, list);
1131 } 1140 }
1132 1141
1133 EXPECT_EQ(0u, resource_provider_->num_resources()); 1142 EXPECT_EQ(0u, resource_provider_->num_resources());
1134 ASSERT_EQ(1u, returned_to_child.size()); 1143 ASSERT_EQ(1u, returned_to_child.size());
1135 EXPECT_EQ(returned_to_child[0].id, id1); 1144 EXPECT_EQ(returned_to_child[0].id, id1);
1136 ResourceProvider::ResourceIdMap resource_map = 1145 ResourceProvider::ResourceIdMap resource_map =
1137 resource_provider_->GetChildToParentMap(child_id); 1146 resource_provider_->GetChildToParentMap(child_id);
1138 ResourceProvider::ResourceId mapped_id1 = resource_map[id1]; 1147 ResourceProvider::ResourceId mapped_id1 = resource_map[id1];
(...skipping 29 matching lines...) Expand all
1168 { 1177 {
1169 // Transfer some resources to the parent. 1178 // Transfer some resources to the parent.
1170 ResourceProvider::ResourceIdArray resource_ids_to_transfer; 1179 ResourceProvider::ResourceIdArray resource_ids_to_transfer;
1171 resource_ids_to_transfer.push_back(id1); 1180 resource_ids_to_transfer.push_back(id1);
1172 resource_ids_to_transfer.push_back(id2); 1181 resource_ids_to_transfer.push_back(id2);
1173 TransferableResourceArray list; 1182 TransferableResourceArray list;
1174 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, 1183 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer,
1175 &list); 1184 &list);
1176 ASSERT_EQ(2u, list.size()); 1185 ASSERT_EQ(2u, list.size());
1177 if (GetParam() == ResourceProvider::GLTexture) { 1186 if (GetParam() == ResourceProvider::GLTexture) {
1178 EXPECT_NE(0u, list[0].sync_point); 1187 EXPECT_NE(0u, list[0].mailbox_holder.sync_point);
1179 EXPECT_NE(0u, list[1].sync_point); 1188 EXPECT_NE(0u, list[1].mailbox_holder.sync_point);
1180 } 1189 }
1181 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); 1190 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1));
1182 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); 1191 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2));
1183 resource_provider_->ReceiveFromChild(child_id, list); 1192 resource_provider_->ReceiveFromChild(child_id, list);
1184 resource_provider_->DeclareUsedResourcesFromChild(child_id, 1193 resource_provider_->DeclareUsedResourcesFromChild(child_id,
1185 resource_ids_to_transfer); 1194 resource_ids_to_transfer);
1186 } 1195 }
1187 1196
1188 EXPECT_EQ(2u, resource_provider_->num_resources()); 1197 EXPECT_EQ(2u, resource_provider_->num_resources());
1189 ResourceProvider::ResourceIdMap resource_map = 1198 ResourceProvider::ResourceIdMap resource_map =
1190 resource_provider_->GetChildToParentMap(child_id); 1199 resource_provider_->GetChildToParentMap(child_id);
1191 ResourceProvider::ResourceId mapped_id1 = resource_map[id1]; 1200 ResourceProvider::ResourceId mapped_id1 = resource_map[id1];
1192 ResourceProvider::ResourceId mapped_id2 = resource_map[id2]; 1201 ResourceProvider::ResourceId mapped_id2 = resource_map[id2];
1193 EXPECT_NE(0u, mapped_id1); 1202 EXPECT_NE(0u, mapped_id1);
1194 EXPECT_NE(0u, mapped_id2); 1203 EXPECT_NE(0u, mapped_id2);
1195 EXPECT_FALSE(resource_provider_->InUseByConsumer(id1)); 1204 EXPECT_FALSE(resource_provider_->InUseByConsumer(id1));
1196 EXPECT_FALSE(resource_provider_->InUseByConsumer(id2)); 1205 EXPECT_FALSE(resource_provider_->InUseByConsumer(id2));
1197 1206
1198 { 1207 {
1199 // The parent transfers the resources to the grandparent. 1208 // The parent transfers the resources to the grandparent.
1200 ResourceProvider::ResourceIdArray resource_ids_to_transfer; 1209 ResourceProvider::ResourceIdArray resource_ids_to_transfer;
1201 resource_ids_to_transfer.push_back(mapped_id1); 1210 resource_ids_to_transfer.push_back(mapped_id1);
1202 resource_ids_to_transfer.push_back(mapped_id2); 1211 resource_ids_to_transfer.push_back(mapped_id2);
1203 TransferableResourceArray list; 1212 TransferableResourceArray list;
1204 resource_provider_->PrepareSendToParent(resource_ids_to_transfer, &list); 1213 resource_provider_->PrepareSendToParent(resource_ids_to_transfer, &list);
1205 1214
1206 ASSERT_EQ(2u, list.size()); 1215 ASSERT_EQ(2u, list.size());
1207 if (GetParam() == ResourceProvider::GLTexture) { 1216 if (GetParam() == ResourceProvider::GLTexture) {
1208 EXPECT_NE(0u, list[0].sync_point); 1217 EXPECT_NE(0u, list[0].mailbox_holder.sync_point);
1209 EXPECT_NE(0u, list[1].sync_point); 1218 EXPECT_NE(0u, list[1].mailbox_holder.sync_point);
1210 } 1219 }
1211 EXPECT_TRUE(resource_provider_->InUseByConsumer(id1)); 1220 EXPECT_TRUE(resource_provider_->InUseByConsumer(id1));
1212 EXPECT_TRUE(resource_provider_->InUseByConsumer(id2)); 1221 EXPECT_TRUE(resource_provider_->InUseByConsumer(id2));
1213 1222
1214 // Release the resource in the parent. Set no resources as being in use. The 1223 // Release the resource in the parent. Set no resources as being in use. The
1215 // resources are exported so that can't be transferred back yet. 1224 // resources are exported so that can't be transferred back yet.
1216 ResourceProvider::ResourceIdArray no_resources; 1225 ResourceProvider::ResourceIdArray no_resources;
1217 resource_provider_->DeclareUsedResourcesFromChild(child_id, no_resources); 1226 resource_provider_->DeclareUsedResourcesFromChild(child_id, no_resources);
1218 1227
1219 EXPECT_EQ(0u, returned_to_child.size()); 1228 EXPECT_EQ(0u, returned_to_child.size());
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1262 { 1271 {
1263 // Transfer some resources to the parent. 1272 // Transfer some resources to the parent.
1264 ResourceProvider::ResourceIdArray resource_ids_to_transfer; 1273 ResourceProvider::ResourceIdArray resource_ids_to_transfer;
1265 resource_ids_to_transfer.push_back(id1); 1274 resource_ids_to_transfer.push_back(id1);
1266 resource_ids_to_transfer.push_back(id2); 1275 resource_ids_to_transfer.push_back(id2);
1267 TransferableResourceArray list; 1276 TransferableResourceArray list;
1268 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, 1277 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer,
1269 &list); 1278 &list);
1270 ASSERT_EQ(2u, list.size()); 1279 ASSERT_EQ(2u, list.size());
1271 if (GetParam() == ResourceProvider::GLTexture) { 1280 if (GetParam() == ResourceProvider::GLTexture) {
1272 EXPECT_NE(0u, list[0].sync_point); 1281 EXPECT_NE(0u, list[0].mailbox_holder.sync_point);
1273 EXPECT_NE(0u, list[1].sync_point); 1282 EXPECT_NE(0u, list[1].mailbox_holder.sync_point);
1274 } 1283 }
1275 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); 1284 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1));
1276 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); 1285 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2));
1277 resource_provider_->ReceiveFromChild(child_id, list); 1286 resource_provider_->ReceiveFromChild(child_id, list);
1278 resource_provider_->DeclareUsedResourcesFromChild(child_id, 1287 resource_provider_->DeclareUsedResourcesFromChild(child_id,
1279 resource_ids_to_transfer); 1288 resource_ids_to_transfer);
1280 } 1289 }
1281 1290
1282 EXPECT_EQ(2u, resource_provider_->num_resources()); 1291 EXPECT_EQ(2u, resource_provider_->num_resources());
1283 ResourceProvider::ResourceIdMap resource_map = 1292 ResourceProvider::ResourceIdMap resource_map =
1284 resource_provider_->GetChildToParentMap(child_id); 1293 resource_provider_->GetChildToParentMap(child_id);
1285 ResourceProvider::ResourceId mapped_id1 = resource_map[id1]; 1294 ResourceProvider::ResourceId mapped_id1 = resource_map[id1];
1286 ResourceProvider::ResourceId mapped_id2 = resource_map[id2]; 1295 ResourceProvider::ResourceId mapped_id2 = resource_map[id2];
1287 EXPECT_NE(0u, mapped_id1); 1296 EXPECT_NE(0u, mapped_id1);
1288 EXPECT_NE(0u, mapped_id2); 1297 EXPECT_NE(0u, mapped_id2);
1289 EXPECT_FALSE(resource_provider_->InUseByConsumer(id1)); 1298 EXPECT_FALSE(resource_provider_->InUseByConsumer(id1));
1290 EXPECT_FALSE(resource_provider_->InUseByConsumer(id2)); 1299 EXPECT_FALSE(resource_provider_->InUseByConsumer(id2));
1291 1300
1292 { 1301 {
1293 // The parent transfers the resources to the grandparent. 1302 // The parent transfers the resources to the grandparent.
1294 ResourceProvider::ResourceIdArray resource_ids_to_transfer; 1303 ResourceProvider::ResourceIdArray resource_ids_to_transfer;
1295 resource_ids_to_transfer.push_back(mapped_id1); 1304 resource_ids_to_transfer.push_back(mapped_id1);
1296 resource_ids_to_transfer.push_back(mapped_id2); 1305 resource_ids_to_transfer.push_back(mapped_id2);
1297 TransferableResourceArray list; 1306 TransferableResourceArray list;
1298 resource_provider_->PrepareSendToParent(resource_ids_to_transfer, &list); 1307 resource_provider_->PrepareSendToParent(resource_ids_to_transfer, &list);
1299 1308
1300 ASSERT_EQ(2u, list.size()); 1309 ASSERT_EQ(2u, list.size());
1301 if (GetParam() == ResourceProvider::GLTexture) { 1310 if (GetParam() == ResourceProvider::GLTexture) {
1302 EXPECT_NE(0u, list[0].sync_point); 1311 EXPECT_NE(0u, list[0].mailbox_holder.sync_point);
1303 EXPECT_NE(0u, list[1].sync_point); 1312 EXPECT_NE(0u, list[1].mailbox_holder.sync_point);
1304 } 1313 }
1305 EXPECT_TRUE(resource_provider_->InUseByConsumer(id1)); 1314 EXPECT_TRUE(resource_provider_->InUseByConsumer(id1));
1306 EXPECT_TRUE(resource_provider_->InUseByConsumer(id2)); 1315 EXPECT_TRUE(resource_provider_->InUseByConsumer(id2));
1307 1316
1308 // Release the resource in the parent. Set no resources as being in use. The 1317 // Release the resource in the parent. Set no resources as being in use. The
1309 // resources are exported so that can't be transferred back yet. 1318 // resources are exported so that can't be transferred back yet.
1310 ResourceProvider::ResourceIdArray no_resources; 1319 ResourceProvider::ResourceIdArray no_resources;
1311 resource_provider_->DeclareUsedResourcesFromChild(child_id, no_resources); 1320 resource_provider_->DeclareUsedResourcesFromChild(child_id, no_resources);
1312 1321
1313 // Destroy the child, the resources should not be returned yet. 1322 // Destroy the child, the resources should not be returned yet.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1367 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); 1376 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child));
1368 { 1377 {
1369 // Transfer some resource to the parent. 1378 // Transfer some resource to the parent.
1370 ResourceProvider::ResourceIdArray resource_ids_to_transfer; 1379 ResourceProvider::ResourceIdArray resource_ids_to_transfer;
1371 resource_ids_to_transfer.push_back(id); 1380 resource_ids_to_transfer.push_back(id);
1372 TransferableResourceArray list; 1381 TransferableResourceArray list;
1373 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, 1382 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer,
1374 &list); 1383 &list);
1375 ASSERT_EQ(1u, list.size()); 1384 ASSERT_EQ(1u, list.size());
1376 if (GetParam() == ResourceProvider::GLTexture) 1385 if (GetParam() == ResourceProvider::GLTexture)
1377 EXPECT_NE(0u, list[0].sync_point); 1386 EXPECT_NE(0u, list[0].mailbox_holder.sync_point);
1378 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id)); 1387 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id));
1379 resource_provider_->ReceiveFromChild(child_id, list); 1388 resource_provider_->ReceiveFromChild(child_id, list);
1380 resource_provider_->DeclareUsedResourcesFromChild(child_id, 1389 resource_provider_->DeclareUsedResourcesFromChild(child_id,
1381 resource_ids_to_transfer); 1390 resource_ids_to_transfer);
1382 } 1391 }
1383 1392
1384 // Delete textures in the child, while they are transfered. 1393 // Delete textures in the child, while they are transfered.
1385 child_resource_provider_->DeleteResource(id); 1394 child_resource_provider_->DeleteResource(id);
1386 EXPECT_EQ(1u, child_resource_provider_->num_resources()); 1395 EXPECT_EQ(1u, child_resource_provider_->num_resources());
1387 { 1396 {
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1581 if (GetParam() != ResourceProvider::GLTexture) 1590 if (GetParam() != ResourceProvider::GLTexture)
1582 return; 1591 return;
1583 unsigned texture = context()->createTexture(); 1592 unsigned texture = context()->createTexture();
1584 context()->bindTexture(GL_TEXTURE_2D, texture); 1593 context()->bindTexture(GL_TEXTURE_2D, texture);
1585 uint8_t data[4] = { 1, 2, 3, 4 }; 1594 uint8_t data[4] = { 1, 2, 3, 4 };
1586 context()->texImage2D( 1595 context()->texImage2D(
1587 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &data); 1596 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &data);
1588 gpu::Mailbox mailbox; 1597 gpu::Mailbox mailbox;
1589 context()->genMailboxCHROMIUM(mailbox.name); 1598 context()->genMailboxCHROMIUM(mailbox.name);
1590 context()->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); 1599 context()->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name);
1591 unsigned sync_point = context()->insertSyncPoint(); 1600 uint32 sync_point = context()->insertSyncPoint();
1592 1601
1593 // All the logic below assumes that the sync points are all positive. 1602 // All the logic below assumes that the sync points are all positive.
1594 EXPECT_LT(0u, sync_point); 1603 EXPECT_LT(0u, sync_point);
1595 1604
1596 unsigned release_sync_point = 0; 1605 uint32 release_sync_point = 0;
1597 bool lost_resource = false; 1606 bool lost_resource = false;
1598 ReleaseCallback callback = 1607 ReleaseCallback callback =
1599 base::Bind(ReleaseTextureMailbox, &release_sync_point, &lost_resource); 1608 base::Bind(ReleaseTextureMailbox, &release_sync_point, &lost_resource);
1600 ResourceProvider::ResourceId resource = 1609 ResourceProvider::ResourceId resource =
1601 resource_provider_->CreateResourceFromTextureMailbox( 1610 resource_provider_->CreateResourceFromTextureMailbox(
1602 TextureMailbox(mailbox, sync_point), 1611 TextureMailbox(mailbox, GL_TEXTURE_2D, sync_point),
1603 SingleReleaseCallback::Create(callback)); 1612 SingleReleaseCallback::Create(callback));
1604 EXPECT_EQ(1u, context()->NumTextures()); 1613 EXPECT_EQ(1u, context()->NumTextures());
1605 EXPECT_EQ(0u, release_sync_point); 1614 EXPECT_EQ(0u, release_sync_point);
1606 { 1615 {
1607 // Transfer the resource, expect the sync points to be consistent. 1616 // Transfer the resource, expect the sync points to be consistent.
1608 ResourceProvider::ResourceIdArray resource_ids_to_transfer; 1617 ResourceProvider::ResourceIdArray resource_ids_to_transfer;
1609 resource_ids_to_transfer.push_back(resource); 1618 resource_ids_to_transfer.push_back(resource);
1610 TransferableResourceArray list; 1619 TransferableResourceArray list;
1611 resource_provider_->PrepareSendToParent(resource_ids_to_transfer, &list); 1620 resource_provider_->PrepareSendToParent(resource_ids_to_transfer, &list);
1612 ASSERT_EQ(1u, list.size()); 1621 ASSERT_EQ(1u, list.size());
1613 EXPECT_LE(sync_point, list[0].sync_point); 1622 EXPECT_LE(sync_point, list[0].mailbox_holder.sync_point);
1614 EXPECT_EQ(0, 1623 EXPECT_EQ(0,
1615 memcmp(mailbox.name, list[0].mailbox.name, sizeof(mailbox.name))); 1624 memcmp(mailbox.name,
1625 list[0].mailbox_holder.mailbox.name,
1626 sizeof(mailbox.name)));
1616 EXPECT_EQ(0u, release_sync_point); 1627 EXPECT_EQ(0u, release_sync_point);
1617 1628
1618 context()->waitSyncPoint(list[0].sync_point); 1629 context()->waitSyncPoint(list[0].mailbox_holder.sync_point);
1619 unsigned other_texture = context()->createTexture(); 1630 unsigned other_texture = context()->createTexture();
1620 context()->bindTexture(GL_TEXTURE_2D, other_texture); 1631 context()->bindTexture(GL_TEXTURE_2D, other_texture);
1621 context()->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); 1632 context()->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name);
1622 uint8_t test_data[4] = { 0 }; 1633 uint8_t test_data[4] = { 0 };
1623 context()->GetPixels( 1634 context()->GetPixels(
1624 gfx::Size(1, 1), RGBA_8888, test_data); 1635 gfx::Size(1, 1), RGBA_8888, test_data);
1625 EXPECT_EQ(0, memcmp(data, test_data, sizeof(data))); 1636 EXPECT_EQ(0, memcmp(data, test_data, sizeof(data)));
1626 context()->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); 1637 context()->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name);
1627 context()->deleteTexture(other_texture); 1638 context()->deleteTexture(other_texture);
1628 list[0].sync_point = context()->insertSyncPoint(); 1639 list[0].mailbox_holder.sync_point = context()->insertSyncPoint();
1629 EXPECT_LT(0u, list[0].sync_point); 1640 EXPECT_LT(0u, list[0].mailbox_holder.sync_point);
1630 1641
1631 // Receive the resource, then delete it, expect the sync points to be 1642 // Receive the resource, then delete it, expect the sync points to be
1632 // consistent. 1643 // consistent.
1633 ReturnedResourceArray returned; 1644 ReturnedResourceArray returned;
1634 TransferableResource::ReturnResources(list, &returned); 1645 TransferableResource::ReturnResources(list, &returned);
1635 resource_provider_->ReceiveReturnsFromParent(returned); 1646 resource_provider_->ReceiveReturnsFromParent(returned);
1636 EXPECT_EQ(1u, context()->NumTextures()); 1647 EXPECT_EQ(1u, context()->NumTextures());
1637 EXPECT_EQ(0u, release_sync_point); 1648 EXPECT_EQ(0u, release_sync_point);
1638 1649
1639 resource_provider_->DeleteResource(resource); 1650 resource_provider_->DeleteResource(resource);
1640 EXPECT_LE(list[0].sync_point, release_sync_point); 1651 EXPECT_LE(list[0].mailbox_holder.sync_point, release_sync_point);
1641 EXPECT_FALSE(lost_resource); 1652 EXPECT_FALSE(lost_resource);
1642 } 1653 }
1643 1654
1644 // We're going to do the same thing as above, but testing the case where we 1655 // We're going to do the same thing as above, but testing the case where we
1645 // delete the resource before we receive it back. 1656 // delete the resource before we receive it back.
1646 sync_point = release_sync_point; 1657 sync_point = release_sync_point;
1647 EXPECT_LT(0u, sync_point); 1658 EXPECT_LT(0u, sync_point);
1648 release_sync_point = 0; 1659 release_sync_point = 0;
1649 resource = resource_provider_->CreateResourceFromTextureMailbox( 1660 resource = resource_provider_->CreateResourceFromTextureMailbox(
1650 TextureMailbox(mailbox, sync_point), 1661 TextureMailbox(mailbox, GL_TEXTURE_2D, sync_point),
1651 SingleReleaseCallback::Create(callback)); 1662 SingleReleaseCallback::Create(callback));
1652 EXPECT_EQ(1u, context()->NumTextures()); 1663 EXPECT_EQ(1u, context()->NumTextures());
1653 EXPECT_EQ(0u, release_sync_point); 1664 EXPECT_EQ(0u, release_sync_point);
1654 { 1665 {
1655 // Transfer the resource, expect the sync points to be consistent. 1666 // Transfer the resource, expect the sync points to be consistent.
1656 ResourceProvider::ResourceIdArray resource_ids_to_transfer; 1667 ResourceProvider::ResourceIdArray resource_ids_to_transfer;
1657 resource_ids_to_transfer.push_back(resource); 1668 resource_ids_to_transfer.push_back(resource);
1658 TransferableResourceArray list; 1669 TransferableResourceArray list;
1659 resource_provider_->PrepareSendToParent(resource_ids_to_transfer, &list); 1670 resource_provider_->PrepareSendToParent(resource_ids_to_transfer, &list);
1660 ASSERT_EQ(1u, list.size()); 1671 ASSERT_EQ(1u, list.size());
1661 EXPECT_LE(sync_point, list[0].sync_point); 1672 EXPECT_LE(sync_point, list[0].mailbox_holder.sync_point);
1662 EXPECT_EQ(0, 1673 EXPECT_EQ(0,
1663 memcmp(mailbox.name, list[0].mailbox.name, sizeof(mailbox.name))); 1674 memcmp(mailbox.name,
1675 list[0].mailbox_holder.mailbox.name,
1676 sizeof(mailbox.name)));
1664 EXPECT_EQ(0u, release_sync_point); 1677 EXPECT_EQ(0u, release_sync_point);
1665 1678
1666 context()->waitSyncPoint(list[0].sync_point); 1679 context()->waitSyncPoint(list[0].mailbox_holder.sync_point);
1667 unsigned other_texture = context()->createTexture(); 1680 unsigned other_texture = context()->createTexture();
1668 context()->bindTexture(GL_TEXTURE_2D, other_texture); 1681 context()->bindTexture(GL_TEXTURE_2D, other_texture);
1669 context()->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); 1682 context()->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name);
1670 uint8_t test_data[4] = { 0 }; 1683 uint8_t test_data[4] = { 0 };
1671 context()->GetPixels( 1684 context()->GetPixels(
1672 gfx::Size(1, 1), RGBA_8888, test_data); 1685 gfx::Size(1, 1), RGBA_8888, test_data);
1673 EXPECT_EQ(0, memcmp(data, test_data, sizeof(data))); 1686 EXPECT_EQ(0, memcmp(data, test_data, sizeof(data)));
1674 context()->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); 1687 context()->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name);
1675 context()->deleteTexture(other_texture); 1688 context()->deleteTexture(other_texture);
1676 list[0].sync_point = context()->insertSyncPoint(); 1689 list[0].mailbox_holder.sync_point = context()->insertSyncPoint();
1677 EXPECT_LT(0u, list[0].sync_point); 1690 EXPECT_LT(0u, list[0].mailbox_holder.sync_point);
1678 1691
1679 // Delete the resource, which shouldn't do anything. 1692 // Delete the resource, which shouldn't do anything.
1680 resource_provider_->DeleteResource(resource); 1693 resource_provider_->DeleteResource(resource);
1681 EXPECT_EQ(1u, context()->NumTextures()); 1694 EXPECT_EQ(1u, context()->NumTextures());
1682 EXPECT_EQ(0u, release_sync_point); 1695 EXPECT_EQ(0u, release_sync_point);
1683 1696
1684 // Then receive the resource which should release the mailbox, expect the 1697 // Then receive the resource which should release the mailbox, expect the
1685 // sync points to be consistent. 1698 // sync points to be consistent.
1686 ReturnedResourceArray returned; 1699 ReturnedResourceArray returned;
1687 TransferableResource::ReturnResources(list, &returned); 1700 TransferableResource::ReturnResources(list, &returned);
1688 resource_provider_->ReceiveReturnsFromParent(returned); 1701 resource_provider_->ReceiveReturnsFromParent(returned);
1689 EXPECT_LE(list[0].sync_point, release_sync_point); 1702 EXPECT_LE(list[0].mailbox_holder.sync_point, release_sync_point);
1690 EXPECT_FALSE(lost_resource); 1703 EXPECT_FALSE(lost_resource);
1691 } 1704 }
1692 1705
1693 context()->waitSyncPoint(release_sync_point); 1706 context()->waitSyncPoint(release_sync_point);
1694 context()->bindTexture(GL_TEXTURE_2D, texture); 1707 context()->bindTexture(GL_TEXTURE_2D, texture);
1695 context()->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); 1708 context()->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name);
1696 context()->deleteTexture(texture); 1709 context()->deleteTexture(texture);
1697 } 1710 }
1698 1711
1699 TEST_P(ResourceProviderTest, LostResourceInParent) { 1712 TEST_P(ResourceProviderTest, LostResourceInParent) {
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1819 } 1832 }
1820 1833
1821 // The resource should be lost. 1834 // The resource should be lost.
1822 EXPECT_TRUE(child_resource_provider_->IsLost(resource)); 1835 EXPECT_TRUE(child_resource_provider_->IsLost(resource));
1823 1836
1824 // Lost resources stay in use in the parent forever. 1837 // Lost resources stay in use in the parent forever.
1825 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(resource)); 1838 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(resource));
1826 } 1839 }
1827 1840
1828 TEST_P(ResourceProviderTest, LostMailboxInParent) { 1841 TEST_P(ResourceProviderTest, LostMailboxInParent) {
1829 unsigned release_sync_point = 0; 1842 uint32 release_sync_point = 0;
1830 bool lost_resource = false; 1843 bool lost_resource = false;
1831 bool release_called = false; 1844 bool release_called = false;
1832 unsigned sync_point = 0; 1845 uint32 sync_point = 0;
1833 ResourceProvider::ResourceId resource = CreateChildMailbox( 1846 ResourceProvider::ResourceId resource = CreateChildMailbox(
1834 &release_sync_point, &lost_resource, &release_called, &sync_point); 1847 &release_sync_point, &lost_resource, &release_called, &sync_point);
1835 1848
1836 ReturnedResourceArray returned_to_child; 1849 ReturnedResourceArray returned_to_child;
1837 int child_id = 1850 int child_id =
1838 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); 1851 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child));
1839 { 1852 {
1840 // Transfer the resource to the parent. 1853 // Transfer the resource to the parent.
1841 ResourceProvider::ResourceIdArray resource_ids_to_transfer; 1854 ResourceProvider::ResourceIdArray resource_ids_to_transfer;
1842 resource_ids_to_transfer.push_back(resource); 1855 resource_ids_to_transfer.push_back(resource);
(...skipping 26 matching lines...) Expand all
1869 returned_to_child.clear(); 1882 returned_to_child.clear();
1870 } 1883 }
1871 1884
1872 // Delete the resource in the child. Expect the resource to be lost if it's 1885 // Delete the resource in the child. Expect the resource to be lost if it's
1873 // a GL texture. 1886 // a GL texture.
1874 child_resource_provider_->DeleteResource(resource); 1887 child_resource_provider_->DeleteResource(resource);
1875 EXPECT_EQ(lost_resource, GetParam() == ResourceProvider::GLTexture); 1888 EXPECT_EQ(lost_resource, GetParam() == ResourceProvider::GLTexture);
1876 } 1889 }
1877 1890
1878 TEST_P(ResourceProviderTest, LostMailboxInGrandParent) { 1891 TEST_P(ResourceProviderTest, LostMailboxInGrandParent) {
1879 unsigned release_sync_point = 0; 1892 uint32 release_sync_point = 0;
1880 bool lost_resource = false; 1893 bool lost_resource = false;
1881 bool release_called = false; 1894 bool release_called = false;
1882 unsigned sync_point = 0; 1895 uint32 sync_point = 0;
1883 ResourceProvider::ResourceId resource = CreateChildMailbox( 1896 ResourceProvider::ResourceId resource = CreateChildMailbox(
1884 &release_sync_point, &lost_resource, &release_called, &sync_point); 1897 &release_sync_point, &lost_resource, &release_called, &sync_point);
1885 1898
1886 ReturnedResourceArray returned_to_child; 1899 ReturnedResourceArray returned_to_child;
1887 int child_id = 1900 int child_id =
1888 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); 1901 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child));
1889 { 1902 {
1890 // Transfer the resource to the parent. 1903 // Transfer the resource to the parent.
1891 ResourceProvider::ResourceIdArray resource_ids_to_transfer; 1904 ResourceProvider::ResourceIdArray resource_ids_to_transfer;
1892 resource_ids_to_transfer.push_back(resource); 1905 resource_ids_to_transfer.push_back(resource);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1937 child_resource_provider_->ReceiveReturnsFromParent(returned_to_child); 1950 child_resource_provider_->ReceiveReturnsFromParent(returned_to_child);
1938 returned_to_child.clear(); 1951 returned_to_child.clear();
1939 } 1952 }
1940 1953
1941 // Delete the resource in the child. Expect the resource to be lost. 1954 // Delete the resource in the child. Expect the resource to be lost.
1942 child_resource_provider_->DeleteResource(resource); 1955 child_resource_provider_->DeleteResource(resource);
1943 EXPECT_TRUE(lost_resource); 1956 EXPECT_TRUE(lost_resource);
1944 } 1957 }
1945 1958
1946 TEST_P(ResourceProviderTest, Shutdown) { 1959 TEST_P(ResourceProviderTest, Shutdown) {
1947 unsigned release_sync_point = 0; 1960 uint32 release_sync_point = 0;
1948 bool lost_resource = false; 1961 bool lost_resource = false;
1949 bool release_called = false; 1962 bool release_called = false;
1950 unsigned sync_point = 0; 1963 uint32 sync_point = 0;
1951 CreateChildMailbox( 1964 CreateChildMailbox(
1952 &release_sync_point, &lost_resource, &release_called, &sync_point); 1965 &release_sync_point, &lost_resource, &release_called, &sync_point);
1953 1966
1954 EXPECT_EQ(0u, release_sync_point); 1967 EXPECT_EQ(0u, release_sync_point);
1955 EXPECT_FALSE(lost_resource); 1968 EXPECT_FALSE(lost_resource);
1956 1969
1957 child_resource_provider_.reset(); 1970 child_resource_provider_.reset();
1958 1971
1959 if (GetParam() == ResourceProvider::GLTexture) { 1972 if (GetParam() == ResourceProvider::GLTexture) {
1960 EXPECT_LE(sync_point, release_sync_point); 1973 EXPECT_LE(sync_point, release_sync_point);
1961 } 1974 }
1962 EXPECT_TRUE(release_called); 1975 EXPECT_TRUE(release_called);
1963 EXPECT_FALSE(lost_resource); 1976 EXPECT_FALSE(lost_resource);
1964 } 1977 }
1965 1978
1966 TEST_P(ResourceProviderTest, ShutdownWithExportedResource) { 1979 TEST_P(ResourceProviderTest, ShutdownWithExportedResource) {
1967 unsigned release_sync_point = 0; 1980 uint32 release_sync_point = 0;
1968 bool lost_resource = false; 1981 bool lost_resource = false;
1969 bool release_called = false; 1982 bool release_called = false;
1970 unsigned sync_point = 0; 1983 uint32 sync_point = 0;
1971 ResourceProvider::ResourceId resource = CreateChildMailbox( 1984 ResourceProvider::ResourceId resource = CreateChildMailbox(
1972 &release_sync_point, &lost_resource, &release_called, &sync_point); 1985 &release_sync_point, &lost_resource, &release_called, &sync_point);
1973 1986
1974 // Transfer the resource, so we can't release it properly on shutdown. 1987 // Transfer the resource, so we can't release it properly on shutdown.
1975 ResourceProvider::ResourceIdArray resource_ids_to_transfer; 1988 ResourceProvider::ResourceIdArray resource_ids_to_transfer;
1976 resource_ids_to_transfer.push_back(resource); 1989 resource_ids_to_transfer.push_back(resource);
1977 TransferableResourceArray list; 1990 TransferableResourceArray list;
1978 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, 1991 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer,
1979 &list); 1992 &list);
1980 1993
1981 EXPECT_EQ(0u, release_sync_point); 1994 EXPECT_EQ(0u, release_sync_point);
1982 EXPECT_FALSE(lost_resource); 1995 EXPECT_FALSE(lost_resource);
1983 1996
1984 child_resource_provider_.reset(); 1997 child_resource_provider_.reset();
1985 1998
1986 // Since the resource is in the parent, the child considers it lost. 1999 // Since the resource is in the parent, the child considers it lost.
1987 EXPECT_EQ(0u, release_sync_point); 2000 EXPECT_EQ(0u, release_sync_point);
1988 EXPECT_TRUE(lost_resource); 2001 EXPECT_TRUE(lost_resource);
1989 } 2002 }
1990 2003
1991 TEST_P(ResourceProviderTest, LostContext) { 2004 TEST_P(ResourceProviderTest, LostContext) {
1992 // TextureMailbox callbacks only exist for GL textures for now. 2005 // TextureMailbox callbacks only exist for GL textures for now.
1993 if (GetParam() != ResourceProvider::GLTexture) 2006 if (GetParam() != ResourceProvider::GLTexture)
1994 return; 2007 return;
1995 unsigned texture = context()->createTexture(); 2008 unsigned texture = context()->createTexture();
1996 context()->bindTexture(GL_TEXTURE_2D, texture); 2009 context()->bindTexture(GL_TEXTURE_2D, texture);
1997 gpu::Mailbox mailbox; 2010 gpu::Mailbox mailbox;
1998 context()->genMailboxCHROMIUM(mailbox.name); 2011 context()->genMailboxCHROMIUM(mailbox.name);
1999 context()->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); 2012 context()->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name);
2000 unsigned sync_point = context()->insertSyncPoint(); 2013 uint32 sync_point = context()->insertSyncPoint();
2001 2014
2002 EXPECT_LT(0u, sync_point); 2015 EXPECT_LT(0u, sync_point);
2003 2016
2004 unsigned release_sync_point = 0; 2017 uint32 release_sync_point = 0;
2005 bool lost_resource = false; 2018 bool lost_resource = false;
2006 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( 2019 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create(
2007 base::Bind(ReleaseTextureMailbox, &release_sync_point, &lost_resource)); 2020 base::Bind(ReleaseTextureMailbox, &release_sync_point, &lost_resource));
2008 resource_provider_->CreateResourceFromTextureMailbox( 2021 resource_provider_->CreateResourceFromTextureMailbox(
2009 TextureMailbox(mailbox, sync_point), 2022 TextureMailbox(mailbox, GL_TEXTURE_2D, sync_point), callback.Pass());
2010 callback.Pass());
2011 2023
2012 EXPECT_EQ(0u, release_sync_point); 2024 EXPECT_EQ(0u, release_sync_point);
2013 EXPECT_FALSE(lost_resource); 2025 EXPECT_FALSE(lost_resource);
2014 2026
2015 resource_provider_->DidLoseOutputSurface(); 2027 resource_provider_->DidLoseOutputSurface();
2016 resource_provider_.reset(); 2028 resource_provider_.reset();
2017 2029
2018 EXPECT_LE(sync_point, release_sync_point); 2030 EXPECT_LE(sync_point, release_sync_point);
2019 EXPECT_TRUE(lost_resource); 2031 EXPECT_TRUE(lost_resource);
2020 } 2032 }
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
2249 2261
2250 FakeOutputSurfaceClient output_surface_client; 2262 FakeOutputSurfaceClient output_surface_client;
2251 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( 2263 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
2252 context_owned.PassAs<TestWebGraphicsContext3D>())); 2264 context_owned.PassAs<TestWebGraphicsContext3D>()));
2253 CHECK(output_surface->BindToClient(&output_surface_client)); 2265 CHECK(output_surface->BindToClient(&output_surface_client));
2254 2266
2255 scoped_ptr<ResourceProvider> resource_provider( 2267 scoped_ptr<ResourceProvider> resource_provider(
2256 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); 2268 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1));
2257 2269
2258 unsigned texture_id = 1; 2270 unsigned texture_id = 1;
2259 unsigned sync_point = 30; 2271 uint32 sync_point = 30;
2260 unsigned target = GL_TEXTURE_2D; 2272 unsigned target = GL_TEXTURE_2D;
2261 2273
2262 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); 2274 EXPECT_CALL(*context, bindTexture(_, _)).Times(0);
2263 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); 2275 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0);
2264 EXPECT_CALL(*context, insertSyncPoint()).Times(0); 2276 EXPECT_CALL(*context, insertSyncPoint()).Times(0);
2265 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); 2277 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0);
2266 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0); 2278 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0);
2267 2279
2268 gpu::Mailbox gpu_mailbox; 2280 gpu::Mailbox gpu_mailbox;
2269 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1); 2281 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1);
2270 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( 2282 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create(
2271 base::Bind(&EmptyReleaseCallback)); 2283 base::Bind(&EmptyReleaseCallback));
2272 2284
2273 TextureMailbox mailbox(gpu_mailbox, sync_point); 2285 TextureMailbox mailbox(gpu_mailbox, target, sync_point);
2274 2286
2275 ResourceProvider::ResourceId id = 2287 ResourceProvider::ResourceId id =
2276 resource_provider->CreateResourceFromTextureMailbox( 2288 resource_provider->CreateResourceFromTextureMailbox(
2277 mailbox, callback.Pass()); 2289 mailbox, callback.Pass());
2278 EXPECT_NE(0u, id); 2290 EXPECT_NE(0u, id);
2279 2291
2280 Mock::VerifyAndClearExpectations(context); 2292 Mock::VerifyAndClearExpectations(context);
2281 2293
2282 { 2294 {
2283 // Using the texture does a consume of the mailbox. 2295 // Using the texture does a consume of the mailbox.
(...skipping 29 matching lines...) Expand all
2313 2325
2314 FakeOutputSurfaceClient output_surface_client; 2326 FakeOutputSurfaceClient output_surface_client;
2315 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( 2327 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
2316 context_owned.PassAs<TestWebGraphicsContext3D>())); 2328 context_owned.PassAs<TestWebGraphicsContext3D>()));
2317 CHECK(output_surface->BindToClient(&output_surface_client)); 2329 CHECK(output_surface->BindToClient(&output_surface_client));
2318 2330
2319 scoped_ptr<ResourceProvider> resource_provider( 2331 scoped_ptr<ResourceProvider> resource_provider(
2320 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); 2332 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1));
2321 2333
2322 unsigned texture_id = 1; 2334 unsigned texture_id = 1;
2323 unsigned sync_point = 30; 2335 uint32 sync_point = 30;
2324 unsigned target = GL_TEXTURE_EXTERNAL_OES; 2336 unsigned target = GL_TEXTURE_EXTERNAL_OES;
2325 2337
2326 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); 2338 EXPECT_CALL(*context, bindTexture(_, _)).Times(0);
2327 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); 2339 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0);
2328 EXPECT_CALL(*context, insertSyncPoint()).Times(0); 2340 EXPECT_CALL(*context, insertSyncPoint()).Times(0);
2329 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); 2341 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0);
2330 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0); 2342 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0);
2331 2343
2332 gpu::Mailbox gpu_mailbox; 2344 gpu::Mailbox gpu_mailbox;
2333 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1); 2345 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1);
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after
3066 resource_provider->AllocateForTesting(id); 3078 resource_provider->AllocateForTesting(id);
3067 Mock::VerifyAndClearExpectations(context); 3079 Mock::VerifyAndClearExpectations(context);
3068 3080
3069 DCHECK_EQ(10u, context->PeekTextureId()); 3081 DCHECK_EQ(10u, context->PeekTextureId());
3070 resource_provider->DeleteResource(id); 3082 resource_provider->DeleteResource(id);
3071 } 3083 }
3072 } 3084 }
3073 3085
3074 } // namespace 3086 } // namespace
3075 } // namespace cc 3087 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698