OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/resources/resource_provider.h" | 5 #include "cc/resources/resource_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 25 matching lines...) Expand all Loading... |
36 using testing::Mock; | 36 using testing::Mock; |
37 using testing::NiceMock; | 37 using testing::NiceMock; |
38 using testing::Return; | 38 using testing::Return; |
39 using testing::SetArgPointee; | 39 using testing::SetArgPointee; |
40 using testing::StrictMock; | 40 using testing::StrictMock; |
41 using testing::_; | 41 using testing::_; |
42 | 42 |
43 namespace cc { | 43 namespace cc { |
44 namespace { | 44 namespace { |
45 | 45 |
46 static void EmptyReleaseCallback(uint32 sync_point, | 46 static void EmptyReleaseCallback(const gpu::SyncToken& sync_token, |
47 bool lost_resource, | 47 bool lost_resource, |
48 BlockingTaskRunner* main_thread_task_runner) { | 48 BlockingTaskRunner* main_thread_task_runner) {} |
49 } | |
50 | 49 |
51 static void ReleaseCallback( | 50 static void ReleaseCallback( |
52 uint32* release_sync_point, | 51 gpu::SyncToken* release_sync_token, |
53 bool* release_lost_resource, | 52 bool* release_lost_resource, |
54 BlockingTaskRunner** release_main_thread_task_runner, | 53 BlockingTaskRunner** release_main_thread_task_runner, |
55 uint32 sync_point, | 54 const gpu::SyncToken& sync_token, |
56 bool lost_resource, | 55 bool lost_resource, |
57 BlockingTaskRunner* main_thread_task_runner) { | 56 BlockingTaskRunner* main_thread_task_runner) { |
58 *release_sync_point = sync_point; | 57 *release_sync_token = sync_token; |
59 *release_lost_resource = lost_resource; | 58 *release_lost_resource = lost_resource; |
60 *release_main_thread_task_runner = main_thread_task_runner; | 59 *release_main_thread_task_runner = main_thread_task_runner; |
61 } | 60 } |
62 | 61 |
63 static void SharedBitmapReleaseCallback( | 62 static void SharedBitmapReleaseCallback( |
64 scoped_ptr<SharedBitmap> bitmap, | 63 scoped_ptr<SharedBitmap> bitmap, |
65 uint32 sync_point, | 64 const gpu::SyncToken& sync_token, |
66 bool lost_resource, | 65 bool lost_resource, |
67 BlockingTaskRunner* main_thread_task_runner) { | 66 BlockingTaskRunner* main_thread_task_runner) {} |
68 } | |
69 | 67 |
70 static void ReleaseSharedBitmapCallback( | 68 static void ReleaseSharedBitmapCallback( |
71 scoped_ptr<SharedBitmap> shared_bitmap, | 69 scoped_ptr<SharedBitmap> shared_bitmap, |
72 bool* release_called, | 70 bool* release_called, |
73 uint32* release_sync_point, | 71 gpu::SyncToken* release_sync_token, |
74 bool* lost_resource_result, | 72 bool* lost_resource_result, |
75 uint32 sync_point, | 73 const gpu::SyncToken& sync_token, |
76 bool lost_resource, | 74 bool lost_resource, |
77 BlockingTaskRunner* main_thread_task_runner) { | 75 BlockingTaskRunner* main_thread_task_runner) { |
78 *release_called = true; | 76 *release_called = true; |
79 *release_sync_point = sync_point; | 77 *release_sync_token = sync_token; |
80 *lost_resource_result = lost_resource; | 78 *lost_resource_result = lost_resource; |
81 } | 79 } |
82 | 80 |
83 static scoped_ptr<SharedBitmap> CreateAndFillSharedBitmap( | 81 static scoped_ptr<SharedBitmap> CreateAndFillSharedBitmap( |
84 SharedBitmapManager* manager, | 82 SharedBitmapManager* manager, |
85 const gfx::Size& size, | 83 const gfx::Size& size, |
86 uint32_t value) { | 84 uint32_t value) { |
87 scoped_ptr<SharedBitmap> shared_bitmap = manager->AllocateSharedBitmap(size); | 85 scoped_ptr<SharedBitmap> shared_bitmap = manager->AllocateSharedBitmap(size); |
88 CHECK(shared_bitmap); | 86 CHECK(shared_bitmap); |
89 uint32_t* pixels = reinterpret_cast<uint32_t*>(shared_bitmap->pixels()); | 87 uint32_t* pixels = reinterpret_cast<uint32_t*>(shared_bitmap->pixels()); |
90 CHECK(pixels); | 88 CHECK(pixels); |
91 std::fill_n(pixels, size.GetArea(), value); | 89 std::fill_n(pixels, size.GetArea(), value); |
92 return shared_bitmap.Pass(); | 90 return shared_bitmap.Pass(); |
93 } | 91 } |
94 | 92 |
95 class TextureStateTrackingContext : public TestWebGraphicsContext3D { | 93 class TextureStateTrackingContext : public TestWebGraphicsContext3D { |
96 public: | 94 public: |
97 MOCK_METHOD2(bindTexture, void(GLenum target, GLuint texture)); | 95 MOCK_METHOD2(bindTexture, void(GLenum target, GLuint texture)); |
98 MOCK_METHOD3(texParameteri, void(GLenum target, GLenum pname, GLint param)); | 96 MOCK_METHOD3(texParameteri, void(GLenum target, GLenum pname, GLint param)); |
99 MOCK_METHOD1(waitSyncPoint, void(GLuint sync_point)); | 97 MOCK_METHOD1(waitSyncToken, void(const GLbyte* sync_token)); |
100 MOCK_METHOD0(insertSyncPoint, GLuint(void)); | 98 MOCK_METHOD0(insertSyncPoint, GLuint(void)); |
101 MOCK_METHOD3(produceTextureDirectCHROMIUM, | 99 MOCK_METHOD3(produceTextureDirectCHROMIUM, |
102 void(GLuint texture, GLenum target, const GLbyte* mailbox)); | 100 void(GLuint texture, GLenum target, const GLbyte* mailbox)); |
103 MOCK_METHOD2(createAndConsumeTextureCHROMIUM, | 101 MOCK_METHOD2(createAndConsumeTextureCHROMIUM, |
104 unsigned(GLenum target, const GLbyte* mailbox)); | 102 unsigned(GLenum target, const GLbyte* mailbox)); |
105 | 103 |
106 // Force all textures to be consecutive numbers starting at "1", | 104 // Force all textures to be consecutive numbers starting at "1", |
107 // so we easily can test for them. | 105 // so we easily can test for them. |
108 GLuint NextTextureId() override { | 106 GLuint NextTextureId() override { |
109 base::AutoLock lock(namespace_->lock); | 107 base::AutoLock lock(namespace_->lock); |
(...skipping 12 matching lines...) Expand all Loading... |
122 | 120 |
123 uint32 InsertSyncPoint() { return next_sync_point_++; } | 121 uint32 InsertSyncPoint() { return next_sync_point_++; } |
124 | 122 |
125 void GenMailbox(GLbyte* mailbox) { | 123 void GenMailbox(GLbyte* mailbox) { |
126 memset(mailbox, 0, GL_MAILBOX_SIZE_CHROMIUM); | 124 memset(mailbox, 0, GL_MAILBOX_SIZE_CHROMIUM); |
127 memcpy(mailbox, &next_mailbox_, sizeof(next_mailbox_)); | 125 memcpy(mailbox, &next_mailbox_, sizeof(next_mailbox_)); |
128 ++next_mailbox_; | 126 ++next_mailbox_; |
129 } | 127 } |
130 | 128 |
131 void ProduceTexture(const GLbyte* mailbox_name, | 129 void ProduceTexture(const GLbyte* mailbox_name, |
132 uint32 sync_point, | 130 const gpu::SyncToken& sync_token, |
133 scoped_refptr<TestTexture> texture) { | 131 scoped_refptr<TestTexture> texture) { |
| 132 DCHECK(sync_token.namespace_id() == |
| 133 gpu::CommandBufferNamespace::OLD_SYNC_POINTS); |
| 134 uint32_t sync_point = static_cast<uint32_t>(sync_token.release_count()); |
| 135 |
134 unsigned mailbox = 0; | 136 unsigned mailbox = 0; |
135 memcpy(&mailbox, mailbox_name, sizeof(mailbox)); | 137 memcpy(&mailbox, mailbox_name, sizeof(mailbox)); |
136 ASSERT_TRUE(mailbox && mailbox < next_mailbox_); | 138 ASSERT_TRUE(mailbox && mailbox < next_mailbox_); |
137 textures_[mailbox] = texture; | 139 textures_[mailbox] = texture; |
138 ASSERT_LT(sync_point_for_mailbox_[mailbox], sync_point); | 140 ASSERT_LT(sync_point_for_mailbox_[mailbox], sync_point); |
139 sync_point_for_mailbox_[mailbox] = sync_point; | 141 sync_point_for_mailbox_[mailbox] = sync_point; |
140 } | 142 } |
141 | 143 |
142 scoped_refptr<TestTexture> ConsumeTexture(const GLbyte* mailbox_name, | 144 scoped_refptr<TestTexture> ConsumeTexture(const GLbyte* mailbox_name, |
143 uint32 sync_point) { | 145 const gpu::SyncToken& sync_token) { |
144 unsigned mailbox = 0; | 146 unsigned mailbox = 0; |
145 memcpy(&mailbox, mailbox_name, sizeof(mailbox)); | 147 memcpy(&mailbox, mailbox_name, sizeof(mailbox)); |
146 DCHECK(mailbox && mailbox < next_mailbox_); | 148 DCHECK(mailbox && mailbox < next_mailbox_); |
147 | 149 |
148 // If the latest sync point the context has waited on is before the sync | 150 // If the latest sync point the context has waited on is before the sync |
149 // point for when the mailbox was set, pretend we never saw that | 151 // point for when the mailbox was set, pretend we never saw that |
150 // ProduceTexture. | 152 // ProduceTexture. |
151 if (sync_point_for_mailbox_[mailbox] > sync_point) { | 153 if (sync_point_for_mailbox_[mailbox] > sync_token.release_count()) { |
152 NOTREACHED(); | 154 NOTREACHED(); |
153 return scoped_refptr<TestTexture>(); | 155 return scoped_refptr<TestTexture>(); |
154 } | 156 } |
155 return textures_[mailbox]; | 157 return textures_[mailbox]; |
156 } | 158 } |
157 | 159 |
158 private: | 160 private: |
159 ContextSharedData() : next_sync_point_(1), next_mailbox_(1) {} | 161 ContextSharedData() : next_sync_point_(1), next_mailbox_(1) {} |
160 | 162 |
161 uint32 next_sync_point_; | 163 uint32 next_sync_point_; |
(...skipping 11 matching lines...) Expand all Loading... |
173 } | 175 } |
174 | 176 |
175 GLuint insertSyncPoint() override { | 177 GLuint insertSyncPoint() override { |
176 uint32 sync_point = shared_data_->InsertSyncPoint(); | 178 uint32 sync_point = shared_data_->InsertSyncPoint(); |
177 // Commit the produceTextureCHROMIUM calls at this point, so that | 179 // Commit the produceTextureCHROMIUM calls at this point, so that |
178 // they're associated with the sync point. | 180 // they're associated with the sync point. |
179 for (PendingProduceTextureList::iterator it = | 181 for (PendingProduceTextureList::iterator it = |
180 pending_produce_textures_.begin(); | 182 pending_produce_textures_.begin(); |
181 it != pending_produce_textures_.end(); | 183 it != pending_produce_textures_.end(); |
182 ++it) { | 184 ++it) { |
183 shared_data_->ProduceTexture( | 185 shared_data_->ProduceTexture((*it)->mailbox, gpu::SyncToken(sync_point), |
184 (*it)->mailbox, sync_point, (*it)->texture); | 186 (*it)->texture); |
185 } | 187 } |
186 pending_produce_textures_.clear(); | 188 pending_produce_textures_.clear(); |
187 return sync_point; | 189 return sync_point; |
188 } | 190 } |
189 | 191 |
190 void waitSyncPoint(GLuint sync_point) override { | 192 void waitSyncToken(const GLbyte* sync_token) override { |
191 last_waited_sync_point_ = std::max(sync_point, last_waited_sync_point_); | 193 gpu::SyncToken sync_token_data; |
| 194 if (sync_token) |
| 195 memcpy(&sync_token_data, sync_token, sizeof(sync_token_data)); |
| 196 |
| 197 if (last_waited_sync_token_.release_count() > |
| 198 sync_token_data.release_count()) { |
| 199 last_waited_sync_token_ = sync_token_data; |
| 200 } |
192 } | 201 } |
193 | 202 |
194 unsigned last_waited_sync_point() const { return last_waited_sync_point_; } | 203 const gpu::SyncToken& last_waited_sync_token() const { |
| 204 return last_waited_sync_token_; |
| 205 } |
195 | 206 |
196 void texStorage2DEXT(GLenum target, | 207 void texStorage2DEXT(GLenum target, |
197 GLint levels, | 208 GLint levels, |
198 GLuint internalformat, | 209 GLuint internalformat, |
199 GLint width, | 210 GLint width, |
200 GLint height) override { | 211 GLint height) override { |
201 CheckTextureIsBound(target); | 212 CheckTextureIsBound(target); |
202 ASSERT_EQ(static_cast<unsigned>(GL_TEXTURE_2D), target); | 213 ASSERT_EQ(static_cast<unsigned>(GL_TEXTURE_2D), target); |
203 ASSERT_EQ(1, levels); | 214 ASSERT_EQ(1, levels); |
204 GLenum format = GL_RGBA; | 215 GLenum format = GL_RGBA; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 base::AutoLock lock_for_texture_access(namespace_->lock); | 281 base::AutoLock lock_for_texture_access(namespace_->lock); |
271 pending->texture = UnboundTexture(texture); | 282 pending->texture = UnboundTexture(texture); |
272 pending_produce_textures_.push_back(pending.Pass()); | 283 pending_produce_textures_.push_back(pending.Pass()); |
273 } | 284 } |
274 | 285 |
275 GLuint createAndConsumeTextureCHROMIUM(GLenum target, | 286 GLuint createAndConsumeTextureCHROMIUM(GLenum target, |
276 const GLbyte* mailbox) override { | 287 const GLbyte* mailbox) override { |
277 GLuint texture_id = createTexture(); | 288 GLuint texture_id = createTexture(); |
278 base::AutoLock lock_for_texture_access(namespace_->lock); | 289 base::AutoLock lock_for_texture_access(namespace_->lock); |
279 scoped_refptr<TestTexture> texture = | 290 scoped_refptr<TestTexture> texture = |
280 shared_data_->ConsumeTexture(mailbox, last_waited_sync_point_); | 291 shared_data_->ConsumeTexture(mailbox, last_waited_sync_token_); |
281 namespace_->textures.Replace(texture_id, texture); | 292 namespace_->textures.Replace(texture_id, texture); |
282 return texture_id; | 293 return texture_id; |
283 } | 294 } |
284 | 295 |
285 void GetPixels(const gfx::Size& size, | 296 void GetPixels(const gfx::Size& size, |
286 ResourceFormat format, | 297 ResourceFormat format, |
287 uint8_t* pixels) { | 298 uint8_t* pixels) { |
288 CheckTextureIsBound(GL_TEXTURE_2D); | 299 CheckTextureIsBound(GL_TEXTURE_2D); |
289 base::AutoLock lock_for_texture_access(namespace_->lock); | 300 base::AutoLock lock_for_texture_access(namespace_->lock); |
290 scoped_refptr<TestTexture> texture = BoundTexture(GL_TEXTURE_2D); | 301 scoped_refptr<TestTexture> texture = BoundTexture(GL_TEXTURE_2D); |
291 ASSERT_EQ(texture->size, size); | 302 ASSERT_EQ(texture->size, size); |
292 ASSERT_EQ(texture->format, format); | 303 ASSERT_EQ(texture->format, format); |
293 memcpy(pixels, texture->data.get(), TextureSizeBytes(size, format)); | 304 memcpy(pixels, texture->data.get(), TextureSizeBytes(size, format)); |
294 } | 305 } |
295 | 306 |
296 protected: | 307 protected: |
297 explicit ResourceProviderContext(ContextSharedData* shared_data) | 308 explicit ResourceProviderContext(ContextSharedData* shared_data) |
298 : shared_data_(shared_data), | 309 : shared_data_(shared_data) {} |
299 last_waited_sync_point_(0) {} | |
300 | 310 |
301 private: | 311 private: |
302 void AllocateTexture(const gfx::Size& size, GLenum format) { | 312 void AllocateTexture(const gfx::Size& size, GLenum format) { |
303 CheckTextureIsBound(GL_TEXTURE_2D); | 313 CheckTextureIsBound(GL_TEXTURE_2D); |
304 ResourceFormat texture_format = RGBA_8888; | 314 ResourceFormat texture_format = RGBA_8888; |
305 switch (format) { | 315 switch (format) { |
306 case GL_RGBA: | 316 case GL_RGBA: |
307 texture_format = RGBA_8888; | 317 texture_format = RGBA_8888; |
308 break; | 318 break; |
309 case GL_BGRA_EXT: | 319 case GL_BGRA_EXT: |
(...skipping 28 matching lines...) Expand all Loading... |
338 src += in_pitch; | 348 src += in_pitch; |
339 } | 349 } |
340 } | 350 } |
341 | 351 |
342 struct PendingProduceTexture { | 352 struct PendingProduceTexture { |
343 GLbyte mailbox[GL_MAILBOX_SIZE_CHROMIUM]; | 353 GLbyte mailbox[GL_MAILBOX_SIZE_CHROMIUM]; |
344 scoped_refptr<TestTexture> texture; | 354 scoped_refptr<TestTexture> texture; |
345 }; | 355 }; |
346 typedef ScopedPtrDeque<PendingProduceTexture> PendingProduceTextureList; | 356 typedef ScopedPtrDeque<PendingProduceTexture> PendingProduceTextureList; |
347 ContextSharedData* shared_data_; | 357 ContextSharedData* shared_data_; |
348 GLuint last_waited_sync_point_; | 358 gpu::SyncToken last_waited_sync_token_; |
349 PendingProduceTextureList pending_produce_textures_; | 359 PendingProduceTextureList pending_produce_textures_; |
350 }; | 360 }; |
351 | 361 |
352 void GetResourcePixels(ResourceProvider* resource_provider, | 362 void GetResourcePixels(ResourceProvider* resource_provider, |
353 ResourceProviderContext* context, | 363 ResourceProviderContext* context, |
354 ResourceId id, | 364 ResourceId id, |
355 const gfx::Size& size, | 365 const gfx::Size& size, |
356 ResourceFormat format, | 366 ResourceFormat format, |
357 uint8_t* pixels) { | 367 uint8_t* pixels) { |
358 resource_provider->WaitSyncPointIfNeeded(id); | 368 resource_provider->WaitSyncTokenIfNeeded(id); |
359 switch (resource_provider->default_resource_type()) { | 369 switch (resource_provider->default_resource_type()) { |
360 case ResourceProvider::RESOURCE_TYPE_GL_TEXTURE: { | 370 case ResourceProvider::RESOURCE_TYPE_GL_TEXTURE: { |
361 ResourceProvider::ScopedReadLockGL lock_gl(resource_provider, id); | 371 ResourceProvider::ScopedReadLockGL lock_gl(resource_provider, id); |
362 ASSERT_NE(0U, lock_gl.texture_id()); | 372 ASSERT_NE(0U, lock_gl.texture_id()); |
363 context->bindTexture(GL_TEXTURE_2D, lock_gl.texture_id()); | 373 context->bindTexture(GL_TEXTURE_2D, lock_gl.texture_id()); |
364 context->GetPixels(size, format, pixels); | 374 context->GetPixels(size, format, pixels); |
365 break; | 375 break; |
366 } | 376 } |
367 case ResourceProvider::RESOURCE_TYPE_BITMAP: { | 377 case ResourceProvider::RESOURCE_TYPE_BITMAP: { |
368 ResourceProvider::ScopedReadLockSoftware lock_software(resource_provider, | 378 ResourceProvider::ScopedReadLockSoftware lock_software(resource_provider, |
369 id); | 379 id); |
370 memcpy(pixels, | 380 memcpy(pixels, |
371 lock_software.sk_bitmap()->getPixels(), | 381 lock_software.sk_bitmap()->getPixels(), |
372 lock_software.sk_bitmap()->getSize()); | 382 lock_software.sk_bitmap()->getSize()); |
373 break; | 383 break; |
374 } | 384 } |
375 } | 385 } |
376 } | 386 } |
377 | 387 |
378 class ResourceProviderTest | 388 class ResourceProviderTest |
379 : public testing::TestWithParam<ResourceProvider::ResourceType> { | 389 : public testing::TestWithParam<ResourceProvider::ResourceType> { |
380 public: | 390 public: |
381 explicit ResourceProviderTest(bool child_needs_sync_point) | 391 explicit ResourceProviderTest(bool child_needs_sync_token) |
382 : shared_data_(ContextSharedData::Create()), | 392 : shared_data_(ContextSharedData::Create()), |
383 context3d_(NULL), | 393 context3d_(NULL), |
384 child_context_(NULL), | 394 child_context_(NULL), |
385 main_thread_task_runner_(BlockingTaskRunner::Create(NULL)) { | 395 main_thread_task_runner_(BlockingTaskRunner::Create(NULL)) { |
386 switch (GetParam()) { | 396 switch (GetParam()) { |
387 case ResourceProvider::RESOURCE_TYPE_GL_TEXTURE: { | 397 case ResourceProvider::RESOURCE_TYPE_GL_TEXTURE: { |
388 scoped_ptr<ResourceProviderContext> context3d( | 398 scoped_ptr<ResourceProviderContext> context3d( |
389 ResourceProviderContext::Create(shared_data_.get())); | 399 ResourceProviderContext::Create(shared_data_.get())); |
390 context3d_ = context3d.get(); | 400 context3d_ = context3d.get(); |
391 | 401 |
392 scoped_refptr<TestContextProvider> context_provider = | 402 scoped_refptr<TestContextProvider> context_provider = |
393 TestContextProvider::Create(context3d.Pass()); | 403 TestContextProvider::Create(context3d.Pass()); |
394 | 404 |
395 output_surface_ = FakeOutputSurface::Create3d(context_provider); | 405 output_surface_ = FakeOutputSurface::Create3d(context_provider); |
396 | 406 |
397 scoped_ptr<ResourceProviderContext> child_context_owned = | 407 scoped_ptr<ResourceProviderContext> child_context_owned = |
398 ResourceProviderContext::Create(shared_data_.get()); | 408 ResourceProviderContext::Create(shared_data_.get()); |
399 child_context_ = child_context_owned.get(); | 409 child_context_ = child_context_owned.get(); |
400 if (child_needs_sync_point) { | 410 if (child_needs_sync_token) { |
401 child_output_surface_ = | 411 child_output_surface_ = |
402 FakeOutputSurface::Create3d(child_context_owned.Pass()); | 412 FakeOutputSurface::Create3d(child_context_owned.Pass()); |
403 } else { | 413 } else { |
404 child_output_surface_ = FakeOutputSurface::CreateNoRequireSyncPoint( | 414 child_output_surface_ = FakeOutputSurface::CreateNoRequireSyncPoint( |
405 child_context_owned.Pass()); | 415 child_context_owned.Pass()); |
406 } | 416 } |
407 break; | 417 break; |
408 } | 418 } |
409 case ResourceProvider::RESOURCE_TYPE_BITMAP: | 419 case ResourceProvider::RESOURCE_TYPE_BITMAP: |
410 output_surface_ = FakeOutputSurface::CreateSoftware( | 420 output_surface_ = FakeOutputSurface::CreateSoftware( |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 | 453 |
444 static void SetResourceFilter(ResourceProvider* resource_provider, | 454 static void SetResourceFilter(ResourceProvider* resource_provider, |
445 ResourceId id, | 455 ResourceId id, |
446 GLenum filter) { | 456 GLenum filter) { |
447 ResourceProvider::ScopedSamplerGL sampler( | 457 ResourceProvider::ScopedSamplerGL sampler( |
448 resource_provider, id, GL_TEXTURE_2D, filter); | 458 resource_provider, id, GL_TEXTURE_2D, filter); |
449 } | 459 } |
450 | 460 |
451 ResourceProviderContext* context() { return context3d_; } | 461 ResourceProviderContext* context() { return context3d_; } |
452 | 462 |
453 ResourceId CreateChildMailbox(uint32* release_sync_point, | 463 ResourceId CreateChildMailbox(gpu::SyncToken* release_sync_token, |
454 bool* lost_resource, | 464 bool* lost_resource, |
455 bool* release_called, | 465 bool* release_called, |
456 uint32* sync_point) { | 466 gpu::SyncToken* sync_token) { |
457 if (GetParam() == ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) { | 467 if (GetParam() == ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) { |
458 unsigned texture = child_context_->createTexture(); | 468 unsigned texture = child_context_->createTexture(); |
459 gpu::Mailbox gpu_mailbox; | 469 gpu::Mailbox gpu_mailbox; |
460 child_context_->genMailboxCHROMIUM(gpu_mailbox.name); | 470 child_context_->genMailboxCHROMIUM(gpu_mailbox.name); |
461 child_context_->produceTextureDirectCHROMIUM(texture, GL_TEXTURE_2D, | 471 child_context_->produceTextureDirectCHROMIUM(texture, GL_TEXTURE_2D, |
462 gpu_mailbox.name); | 472 gpu_mailbox.name); |
463 *sync_point = child_context_->insertSyncPoint(); | 473 *sync_token = gpu::SyncToken(child_context_->insertSyncPoint()); |
464 EXPECT_LT(0u, *sync_point); | 474 EXPECT_TRUE(sync_token->HasData()); |
465 | 475 |
466 scoped_ptr<SharedBitmap> shared_bitmap; | 476 scoped_ptr<SharedBitmap> shared_bitmap; |
467 scoped_ptr<SingleReleaseCallbackImpl> callback = | 477 scoped_ptr<SingleReleaseCallbackImpl> callback = |
468 SingleReleaseCallbackImpl::Create(base::Bind( | 478 SingleReleaseCallbackImpl::Create(base::Bind( |
469 ReleaseSharedBitmapCallback, base::Passed(&shared_bitmap), | 479 ReleaseSharedBitmapCallback, base::Passed(&shared_bitmap), |
470 release_called, release_sync_point, lost_resource)); | 480 release_called, release_sync_token, lost_resource)); |
471 return child_resource_provider_->CreateResourceFromTextureMailbox( | 481 return child_resource_provider_->CreateResourceFromTextureMailbox( |
472 TextureMailbox(gpu_mailbox, GL_TEXTURE_2D, *sync_point), | 482 TextureMailbox(gpu_mailbox, *sync_token, GL_TEXTURE_2D), |
473 callback.Pass()); | 483 callback.Pass()); |
474 } else { | 484 } else { |
475 gfx::Size size(64, 64); | 485 gfx::Size size(64, 64); |
476 scoped_ptr<SharedBitmap> shared_bitmap( | 486 scoped_ptr<SharedBitmap> shared_bitmap( |
477 CreateAndFillSharedBitmap(shared_bitmap_manager_.get(), size, 0)); | 487 CreateAndFillSharedBitmap(shared_bitmap_manager_.get(), size, 0)); |
478 | 488 |
479 SharedBitmap* shared_bitmap_ptr = shared_bitmap.get(); | 489 SharedBitmap* shared_bitmap_ptr = shared_bitmap.get(); |
480 scoped_ptr<SingleReleaseCallbackImpl> callback = | 490 scoped_ptr<SingleReleaseCallbackImpl> callback = |
481 SingleReleaseCallbackImpl::Create(base::Bind( | 491 SingleReleaseCallbackImpl::Create(base::Bind( |
482 ReleaseSharedBitmapCallback, base::Passed(&shared_bitmap), | 492 ReleaseSharedBitmapCallback, base::Passed(&shared_bitmap), |
483 release_called, release_sync_point, lost_resource)); | 493 release_called, release_sync_token, lost_resource)); |
484 return child_resource_provider_->CreateResourceFromTextureMailbox( | 494 return child_resource_provider_->CreateResourceFromTextureMailbox( |
485 TextureMailbox(shared_bitmap_ptr, size), callback.Pass()); | 495 TextureMailbox(shared_bitmap_ptr, size), callback.Pass()); |
486 } | 496 } |
487 } | 497 } |
488 | 498 |
489 public: | 499 public: |
490 static std::vector<unsigned> use_image_texture_targets() { | 500 static std::vector<unsigned> use_image_texture_targets() { |
491 return use_image_texture_targets_; | 501 return use_image_texture_targets_; |
492 } | 502 } |
493 | 503 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 child_resource_provider_.get(), id3); | 613 child_resource_provider_.get(), id3); |
604 EXPECT_TRUE(lock.GetGpuMemoryBuffer()); | 614 EXPECT_TRUE(lock.GetGpuMemoryBuffer()); |
605 } | 615 } |
606 | 616 |
607 GLuint external_texture_id = child_context_->createExternalTexture(); | 617 GLuint external_texture_id = child_context_->createExternalTexture(); |
608 | 618 |
609 gpu::Mailbox external_mailbox; | 619 gpu::Mailbox external_mailbox; |
610 child_context_->genMailboxCHROMIUM(external_mailbox.name); | 620 child_context_->genMailboxCHROMIUM(external_mailbox.name); |
611 child_context_->produceTextureDirectCHROMIUM( | 621 child_context_->produceTextureDirectCHROMIUM( |
612 external_texture_id, GL_TEXTURE_EXTERNAL_OES, external_mailbox.name); | 622 external_texture_id, GL_TEXTURE_EXTERNAL_OES, external_mailbox.name); |
613 const GLuint external_sync_point = child_context_->insertSyncPoint(); | 623 const gpu::SyncToken external_sync_token(child_context_->insertSyncPoint()); |
614 ResourceId id4 = child_resource_provider_->CreateResourceFromTextureMailbox( | 624 ResourceId id4 = child_resource_provider_->CreateResourceFromTextureMailbox( |
615 TextureMailbox(external_mailbox, GL_TEXTURE_EXTERNAL_OES, | 625 TextureMailbox(external_mailbox, external_sync_token, |
616 external_sync_point), | 626 GL_TEXTURE_EXTERNAL_OES), |
617 SingleReleaseCallbackImpl::Create(base::Bind(&EmptyReleaseCallback))); | 627 SingleReleaseCallbackImpl::Create(base::Bind(&EmptyReleaseCallback))); |
618 | 628 |
619 ReturnedResourceArray returned_to_child; | 629 ReturnedResourceArray returned_to_child; |
620 int child_id = | 630 int child_id = |
621 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); | 631 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); |
622 { | 632 { |
623 // Transfer some resources to the parent. | 633 // Transfer some resources to the parent. |
624 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 634 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
625 resource_ids_to_transfer.push_back(id1); | 635 resource_ids_to_transfer.push_back(id1); |
626 resource_ids_to_transfer.push_back(id2); | 636 resource_ids_to_transfer.push_back(id2); |
627 resource_ids_to_transfer.push_back(id3); | 637 resource_ids_to_transfer.push_back(id3); |
628 resource_ids_to_transfer.push_back(id4); | 638 resource_ids_to_transfer.push_back(id4); |
629 TransferableResourceArray list; | 639 TransferableResourceArray list; |
630 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, | 640 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, |
631 &list); | 641 &list); |
632 ASSERT_EQ(4u, list.size()); | 642 ASSERT_EQ(4u, list.size()); |
633 EXPECT_NE(0u, list[0].mailbox_holder.sync_point); | 643 EXPECT_TRUE(list[0].mailbox_holder.sync_token.HasData()); |
634 EXPECT_NE(0u, list[1].mailbox_holder.sync_point); | 644 EXPECT_TRUE(list[1].mailbox_holder.sync_token.HasData()); |
635 EXPECT_EQ(list[0].mailbox_holder.sync_point, | 645 EXPECT_EQ(list[0].mailbox_holder.sync_token, |
636 list[1].mailbox_holder.sync_point); | 646 list[1].mailbox_holder.sync_token); |
637 EXPECT_NE(0u, list[2].mailbox_holder.sync_point); | 647 EXPECT_TRUE(list[2].mailbox_holder.sync_token.HasData()); |
638 EXPECT_EQ(list[0].mailbox_holder.sync_point, | 648 EXPECT_EQ(list[0].mailbox_holder.sync_token, |
639 list[2].mailbox_holder.sync_point); | 649 list[2].mailbox_holder.sync_token); |
640 EXPECT_EQ(external_sync_point, list[3].mailbox_holder.sync_point); | 650 EXPECT_EQ(external_sync_token, list[3].mailbox_holder.sync_token); |
641 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), | 651 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), |
642 list[0].mailbox_holder.texture_target); | 652 list[0].mailbox_holder.texture_target); |
643 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), | 653 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), |
644 list[1].mailbox_holder.texture_target); | 654 list[1].mailbox_holder.texture_target); |
645 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), | 655 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), |
646 list[2].mailbox_holder.texture_target); | 656 list[2].mailbox_holder.texture_target); |
647 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_EXTERNAL_OES), | 657 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_EXTERNAL_OES), |
648 list[3].mailbox_holder.texture_target); | 658 list[3].mailbox_holder.texture_target); |
649 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); | 659 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); |
650 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); | 660 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); |
651 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id3)); | 661 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id3)); |
652 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id4)); | 662 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id4)); |
653 resource_provider_->ReceiveFromChild(child_id, list); | 663 resource_provider_->ReceiveFromChild(child_id, list); |
654 EXPECT_NE(list[0].mailbox_holder.sync_point, | 664 EXPECT_NE(list[0].mailbox_holder.sync_token, |
655 context3d_->last_waited_sync_point()); | 665 context3d_->last_waited_sync_token()); |
656 { | 666 { |
657 resource_provider_->WaitSyncPointIfNeeded(list[0].id); | 667 resource_provider_->WaitSyncTokenIfNeeded(list[0].id); |
658 ResourceProvider::ScopedReadLockGL lock(resource_provider_.get(), | 668 ResourceProvider::ScopedReadLockGL lock(resource_provider_.get(), |
659 list[0].id); | 669 list[0].id); |
660 } | 670 } |
661 EXPECT_EQ(list[0].mailbox_holder.sync_point, | 671 EXPECT_EQ(list[0].mailbox_holder.sync_token, |
662 context3d_->last_waited_sync_point()); | 672 context3d_->last_waited_sync_token()); |
663 ResourceProvider::ResourceIdSet resource_ids_to_receive; | 673 ResourceProvider::ResourceIdSet resource_ids_to_receive; |
664 resource_ids_to_receive.insert(id1); | 674 resource_ids_to_receive.insert(id1); |
665 resource_ids_to_receive.insert(id2); | 675 resource_ids_to_receive.insert(id2); |
666 resource_ids_to_receive.insert(id3); | 676 resource_ids_to_receive.insert(id3); |
667 resource_ids_to_receive.insert(id4); | 677 resource_ids_to_receive.insert(id4); |
668 resource_provider_->DeclareUsedResourcesFromChild(child_id, | 678 resource_provider_->DeclareUsedResourcesFromChild(child_id, |
669 resource_ids_to_receive); | 679 resource_ids_to_receive); |
670 } | 680 } |
671 | 681 |
672 EXPECT_EQ(4u, resource_provider_->num_resources()); | 682 EXPECT_EQ(4u, resource_provider_->num_resources()); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 } | 735 } |
726 { | 736 { |
727 EXPECT_EQ(0u, returned_to_child.size()); | 737 EXPECT_EQ(0u, returned_to_child.size()); |
728 | 738 |
729 // Transfer resources back from the parent to the child. Set no resources as | 739 // Transfer resources back from the parent to the child. Set no resources as |
730 // being in use. | 740 // being in use. |
731 ResourceProvider::ResourceIdSet no_resources; | 741 ResourceProvider::ResourceIdSet no_resources; |
732 resource_provider_->DeclareUsedResourcesFromChild(child_id, no_resources); | 742 resource_provider_->DeclareUsedResourcesFromChild(child_id, no_resources); |
733 | 743 |
734 ASSERT_EQ(4u, returned_to_child.size()); | 744 ASSERT_EQ(4u, returned_to_child.size()); |
735 EXPECT_NE(0u, returned_to_child[0].sync_point); | 745 EXPECT_TRUE(returned_to_child[0].sync_token.HasData()); |
736 EXPECT_NE(0u, returned_to_child[1].sync_point); | 746 EXPECT_TRUE(returned_to_child[1].sync_token.HasData()); |
737 EXPECT_NE(0u, returned_to_child[2].sync_point); | 747 EXPECT_TRUE(returned_to_child[2].sync_token.HasData()); |
738 EXPECT_NE(0u, returned_to_child[3].sync_point); | 748 EXPECT_TRUE(returned_to_child[3].sync_token.HasData()); |
739 EXPECT_FALSE(returned_to_child[0].lost); | 749 EXPECT_FALSE(returned_to_child[0].lost); |
740 EXPECT_FALSE(returned_to_child[1].lost); | 750 EXPECT_FALSE(returned_to_child[1].lost); |
741 EXPECT_FALSE(returned_to_child[2].lost); | 751 EXPECT_FALSE(returned_to_child[2].lost); |
742 EXPECT_FALSE(returned_to_child[3].lost); | 752 EXPECT_FALSE(returned_to_child[3].lost); |
743 child_resource_provider_->ReceiveReturnsFromParent(returned_to_child); | 753 child_resource_provider_->ReceiveReturnsFromParent(returned_to_child); |
744 returned_to_child.clear(); | 754 returned_to_child.clear(); |
745 } | 755 } |
746 EXPECT_FALSE(child_resource_provider_->InUseByConsumer(id1)); | 756 EXPECT_FALSE(child_resource_provider_->InUseByConsumer(id1)); |
747 EXPECT_FALSE(child_resource_provider_->InUseByConsumer(id2)); | 757 EXPECT_FALSE(child_resource_provider_->InUseByConsumer(id2)); |
748 EXPECT_FALSE(child_resource_provider_->InUseByConsumer(id3)); | 758 EXPECT_FALSE(child_resource_provider_->InUseByConsumer(id3)); |
749 EXPECT_FALSE(child_resource_provider_->InUseByConsumer(id4)); | 759 EXPECT_FALSE(child_resource_provider_->InUseByConsumer(id4)); |
750 | 760 |
751 { | 761 { |
752 child_resource_provider_->WaitSyncPointIfNeeded(id1); | 762 child_resource_provider_->WaitSyncTokenIfNeeded(id1); |
753 ResourceProvider::ScopedReadLockGL lock(child_resource_provider_.get(), | 763 ResourceProvider::ScopedReadLockGL lock(child_resource_provider_.get(), |
754 id1); | 764 id1); |
755 ASSERT_NE(0U, lock.texture_id()); | 765 ASSERT_NE(0U, lock.texture_id()); |
756 child_context_->bindTexture(GL_TEXTURE_2D, lock.texture_id()); | 766 child_context_->bindTexture(GL_TEXTURE_2D, lock.texture_id()); |
757 child_context_->GetPixels(size, format, result); | 767 child_context_->GetPixels(size, format, result); |
758 EXPECT_EQ(0, memcmp(data1, result, pixel_size)); | 768 EXPECT_EQ(0, memcmp(data1, result, pixel_size)); |
759 } | 769 } |
760 { | 770 { |
761 child_resource_provider_->WaitSyncPointIfNeeded(id2); | 771 child_resource_provider_->WaitSyncTokenIfNeeded(id2); |
762 ResourceProvider::ScopedReadLockGL lock(child_resource_provider_.get(), | 772 ResourceProvider::ScopedReadLockGL lock(child_resource_provider_.get(), |
763 id2); | 773 id2); |
764 ASSERT_NE(0U, lock.texture_id()); | 774 ASSERT_NE(0U, lock.texture_id()); |
765 child_context_->bindTexture(GL_TEXTURE_2D, lock.texture_id()); | 775 child_context_->bindTexture(GL_TEXTURE_2D, lock.texture_id()); |
766 child_context_->GetPixels(size, format, result); | 776 child_context_->GetPixels(size, format, result); |
767 EXPECT_EQ(0, memcmp(data2, result, pixel_size)); | 777 EXPECT_EQ(0, memcmp(data2, result, pixel_size)); |
768 } | 778 } |
769 { | 779 { |
770 child_resource_provider_->WaitSyncPointIfNeeded(id3); | 780 child_resource_provider_->WaitSyncTokenIfNeeded(id3); |
771 ResourceProvider::ScopedReadLockGL lock(child_resource_provider_.get(), | 781 ResourceProvider::ScopedReadLockGL lock(child_resource_provider_.get(), |
772 id3); | 782 id3); |
773 ASSERT_NE(0U, lock.texture_id()); | 783 ASSERT_NE(0U, lock.texture_id()); |
774 child_context_->bindTexture(GL_TEXTURE_2D, lock.texture_id()); | 784 child_context_->bindTexture(GL_TEXTURE_2D, lock.texture_id()); |
775 } | 785 } |
776 { | 786 { |
777 // Transfer resources to the parent again. | 787 // Transfer resources to the parent again. |
778 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 788 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
779 resource_ids_to_transfer.push_back(id1); | 789 resource_ids_to_transfer.push_back(id1); |
780 resource_ids_to_transfer.push_back(id2); | 790 resource_ids_to_transfer.push_back(id2); |
781 resource_ids_to_transfer.push_back(id3); | 791 resource_ids_to_transfer.push_back(id3); |
782 resource_ids_to_transfer.push_back(id4); | 792 resource_ids_to_transfer.push_back(id4); |
783 TransferableResourceArray list; | 793 TransferableResourceArray list; |
784 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, | 794 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, |
785 &list); | 795 &list); |
786 ASSERT_EQ(4u, list.size()); | 796 ASSERT_EQ(4u, list.size()); |
787 EXPECT_EQ(id1, list[0].id); | 797 EXPECT_EQ(id1, list[0].id); |
788 EXPECT_EQ(id2, list[1].id); | 798 EXPECT_EQ(id2, list[1].id); |
789 EXPECT_EQ(id3, list[2].id); | 799 EXPECT_EQ(id3, list[2].id); |
790 EXPECT_EQ(id4, list[3].id); | 800 EXPECT_EQ(id4, list[3].id); |
791 EXPECT_NE(0u, list[0].mailbox_holder.sync_point); | 801 EXPECT_TRUE(list[0].mailbox_holder.sync_token.HasData()); |
792 EXPECT_NE(0u, list[1].mailbox_holder.sync_point); | 802 EXPECT_TRUE(list[1].mailbox_holder.sync_token.HasData()); |
793 EXPECT_NE(0u, list[2].mailbox_holder.sync_point); | 803 EXPECT_TRUE(list[2].mailbox_holder.sync_token.HasData()); |
794 EXPECT_NE(0u, list[3].mailbox_holder.sync_point); | 804 EXPECT_TRUE(list[3].mailbox_holder.sync_token.HasData()); |
795 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), | 805 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), |
796 list[0].mailbox_holder.texture_target); | 806 list[0].mailbox_holder.texture_target); |
797 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), | 807 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), |
798 list[1].mailbox_holder.texture_target); | 808 list[1].mailbox_holder.texture_target); |
799 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), | 809 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), |
800 list[2].mailbox_holder.texture_target); | 810 list[2].mailbox_holder.texture_target); |
801 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_EXTERNAL_OES), | 811 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_EXTERNAL_OES), |
802 list[3].mailbox_holder.texture_target); | 812 list[3].mailbox_holder.texture_target); |
803 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); | 813 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); |
804 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); | 814 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); |
805 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id3)); | 815 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id3)); |
806 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id4)); | 816 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id4)); |
807 resource_provider_->ReceiveFromChild(child_id, list); | 817 resource_provider_->ReceiveFromChild(child_id, list); |
808 ResourceProvider::ResourceIdSet resource_ids_to_receive; | 818 ResourceProvider::ResourceIdSet resource_ids_to_receive; |
809 resource_ids_to_receive.insert(id1); | 819 resource_ids_to_receive.insert(id1); |
810 resource_ids_to_receive.insert(id2); | 820 resource_ids_to_receive.insert(id2); |
811 resource_ids_to_receive.insert(id3); | 821 resource_ids_to_receive.insert(id3); |
812 resource_ids_to_receive.insert(id4); | 822 resource_ids_to_receive.insert(id4); |
813 resource_provider_->DeclareUsedResourcesFromChild(child_id, | 823 resource_provider_->DeclareUsedResourcesFromChild(child_id, |
814 resource_ids_to_receive); | 824 resource_ids_to_receive); |
815 } | 825 } |
816 | 826 |
817 EXPECT_EQ(0u, returned_to_child.size()); | 827 EXPECT_EQ(0u, returned_to_child.size()); |
818 | 828 |
819 EXPECT_EQ(4u, resource_provider_->num_resources()); | 829 EXPECT_EQ(4u, resource_provider_->num_resources()); |
820 resource_provider_->DestroyChild(child_id); | 830 resource_provider_->DestroyChild(child_id); |
821 EXPECT_EQ(0u, resource_provider_->num_resources()); | 831 EXPECT_EQ(0u, resource_provider_->num_resources()); |
822 | 832 |
823 ASSERT_EQ(4u, returned_to_child.size()); | 833 ASSERT_EQ(4u, returned_to_child.size()); |
824 EXPECT_NE(0u, returned_to_child[0].sync_point); | 834 EXPECT_TRUE(returned_to_child[0].sync_token.HasData()); |
825 EXPECT_NE(0u, returned_to_child[1].sync_point); | 835 EXPECT_TRUE(returned_to_child[1].sync_token.HasData()); |
826 EXPECT_NE(0u, returned_to_child[2].sync_point); | 836 EXPECT_TRUE(returned_to_child[2].sync_token.HasData()); |
827 EXPECT_NE(0u, returned_to_child[3].sync_point); | 837 EXPECT_TRUE(returned_to_child[3].sync_token.HasData()); |
828 EXPECT_FALSE(returned_to_child[0].lost); | 838 EXPECT_FALSE(returned_to_child[0].lost); |
829 EXPECT_FALSE(returned_to_child[1].lost); | 839 EXPECT_FALSE(returned_to_child[1].lost); |
830 EXPECT_FALSE(returned_to_child[2].lost); | 840 EXPECT_FALSE(returned_to_child[2].lost); |
831 EXPECT_FALSE(returned_to_child[3].lost); | 841 EXPECT_FALSE(returned_to_child[3].lost); |
832 } | 842 } |
833 | 843 |
834 class ResourceProviderTestNoSyncPoint : public ResourceProviderTest { | 844 class ResourceProviderTestNoSyncToken : public ResourceProviderTest { |
835 public: | 845 public: |
836 ResourceProviderTestNoSyncPoint() : ResourceProviderTest(false) { | 846 ResourceProviderTestNoSyncToken() : ResourceProviderTest(false) { |
837 EXPECT_EQ(ResourceProvider::RESOURCE_TYPE_GL_TEXTURE, GetParam()); | 847 EXPECT_EQ(ResourceProvider::RESOURCE_TYPE_GL_TEXTURE, GetParam()); |
838 } | 848 } |
839 }; | 849 }; |
840 | 850 |
841 TEST_P(ResourceProviderTestNoSyncPoint, TransferGLResources) { | 851 TEST_P(ResourceProviderTestNoSyncToken, TransferGLResources) { |
842 gfx::Size size(1, 1); | 852 gfx::Size size(1, 1); |
843 ResourceFormat format = RGBA_8888; | 853 ResourceFormat format = RGBA_8888; |
844 size_t pixel_size = TextureSizeBytes(size, format); | 854 size_t pixel_size = TextureSizeBytes(size, format); |
845 ASSERT_EQ(4U, pixel_size); | 855 ASSERT_EQ(4U, pixel_size); |
846 | 856 |
847 ResourceId id1 = child_resource_provider_->CreateResource( | 857 ResourceId id1 = child_resource_provider_->CreateResource( |
848 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 858 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); |
849 uint8_t data1[4] = {1, 2, 3, 4}; | 859 uint8_t data1[4] = {1, 2, 3, 4}; |
850 child_resource_provider_->CopyToResource(id1, data1, size); | 860 child_resource_provider_->CopyToResource(id1, data1, size); |
851 | 861 |
852 ResourceId id2 = child_resource_provider_->CreateResource( | 862 ResourceId id2 = child_resource_provider_->CreateResource( |
853 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 863 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); |
854 { | 864 { |
855 // Ensure locking the memory buffer doesn't create an unnecessary sync | 865 // Ensure locking the memory buffer doesn't create an unnecessary sync |
856 // point. | 866 // point. |
857 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock( | 867 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock( |
858 child_resource_provider_.get(), id2); | 868 child_resource_provider_.get(), id2); |
859 EXPECT_TRUE(lock.GetGpuMemoryBuffer()); | 869 EXPECT_TRUE(lock.GetGpuMemoryBuffer()); |
860 } | 870 } |
861 | 871 |
862 GLuint external_texture_id = child_context_->createExternalTexture(); | 872 GLuint external_texture_id = child_context_->createExternalTexture(); |
863 | 873 |
864 // A sync point is specified directly and should be used. | 874 // A sync point is specified directly and should be used. |
865 gpu::Mailbox external_mailbox; | 875 gpu::Mailbox external_mailbox; |
866 child_context_->genMailboxCHROMIUM(external_mailbox.name); | 876 child_context_->genMailboxCHROMIUM(external_mailbox.name); |
867 child_context_->produceTextureDirectCHROMIUM( | 877 child_context_->produceTextureDirectCHROMIUM( |
868 external_texture_id, GL_TEXTURE_EXTERNAL_OES, external_mailbox.name); | 878 external_texture_id, GL_TEXTURE_EXTERNAL_OES, external_mailbox.name); |
869 const GLuint external_sync_point = child_context_->insertSyncPoint(); | 879 const gpu::SyncToken external_sync_token(child_context_->insertSyncPoint()); |
870 ResourceId id3 = child_resource_provider_->CreateResourceFromTextureMailbox( | 880 ResourceId id3 = child_resource_provider_->CreateResourceFromTextureMailbox( |
871 TextureMailbox(external_mailbox, GL_TEXTURE_EXTERNAL_OES, | 881 TextureMailbox(external_mailbox, external_sync_token, |
872 external_sync_point), | 882 GL_TEXTURE_EXTERNAL_OES), |
873 SingleReleaseCallbackImpl::Create(base::Bind(&EmptyReleaseCallback))); | 883 SingleReleaseCallbackImpl::Create(base::Bind(&EmptyReleaseCallback))); |
874 | 884 |
875 ReturnedResourceArray returned_to_child; | 885 ReturnedResourceArray returned_to_child; |
876 int child_id = | 886 int child_id = |
877 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); | 887 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); |
878 resource_provider_->SetChildNeedsSyncPoints(child_id, false); | 888 resource_provider_->SetChildNeedsSyncTokens(child_id, false); |
879 { | 889 { |
880 // Transfer some resources to the parent. | 890 // Transfer some resources to the parent. |
881 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 891 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
882 resource_ids_to_transfer.push_back(id1); | 892 resource_ids_to_transfer.push_back(id1); |
883 resource_ids_to_transfer.push_back(id2); | 893 resource_ids_to_transfer.push_back(id2); |
884 resource_ids_to_transfer.push_back(id3); | 894 resource_ids_to_transfer.push_back(id3); |
885 TransferableResourceArray list; | 895 TransferableResourceArray list; |
886 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, | 896 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, |
887 &list); | 897 &list); |
888 ASSERT_EQ(3u, list.size()); | 898 ASSERT_EQ(3u, list.size()); |
889 // Standard resources shouldn't require creating and sending a sync point. | 899 // Standard resources shouldn't require creating and sending a sync point. |
890 EXPECT_EQ(0u, list[0].mailbox_holder.sync_point); | 900 EXPECT_TRUE(list[0].mailbox_holder.sync_token.HasData()); |
891 EXPECT_EQ(0u, list[1].mailbox_holder.sync_point); | 901 EXPECT_TRUE(list[1].mailbox_holder.sync_token.HasData()); |
892 // A given sync point should be passed through. | 902 // A given sync point should be passed through. |
893 EXPECT_EQ(external_sync_point, list[2].mailbox_holder.sync_point); | 903 EXPECT_EQ(external_sync_token, list[2].mailbox_holder.sync_token); |
894 resource_provider_->ReceiveFromChild(child_id, list); | 904 resource_provider_->ReceiveFromChild(child_id, list); |
895 | 905 |
896 ResourceProvider::ResourceIdSet resource_ids_to_receive; | 906 ResourceProvider::ResourceIdSet resource_ids_to_receive; |
897 resource_ids_to_receive.insert(id1); | 907 resource_ids_to_receive.insert(id1); |
898 resource_ids_to_receive.insert(id2); | 908 resource_ids_to_receive.insert(id2); |
899 resource_ids_to_receive.insert(id3); | 909 resource_ids_to_receive.insert(id3); |
900 resource_provider_->DeclareUsedResourcesFromChild(child_id, | 910 resource_provider_->DeclareUsedResourcesFromChild(child_id, |
901 resource_ids_to_receive); | 911 resource_ids_to_receive); |
902 } | 912 } |
903 | 913 |
904 { | 914 { |
905 EXPECT_EQ(0u, returned_to_child.size()); | 915 EXPECT_EQ(0u, returned_to_child.size()); |
906 | 916 |
907 // Transfer resources back from the parent to the child. Set no resources as | 917 // Transfer resources back from the parent to the child. Set no resources as |
908 // being in use. | 918 // being in use. |
909 ResourceProvider::ResourceIdSet no_resources; | 919 ResourceProvider::ResourceIdSet no_resources; |
910 resource_provider_->DeclareUsedResourcesFromChild(child_id, no_resources); | 920 resource_provider_->DeclareUsedResourcesFromChild(child_id, no_resources); |
911 | 921 |
912 ASSERT_EQ(3u, returned_to_child.size()); | 922 ASSERT_EQ(3u, returned_to_child.size()); |
913 std::map<ResourceId, unsigned int> returned_sync_points; | 923 std::map<ResourceId, gpu::SyncToken> returned_sync_tokens; |
914 for (const auto& returned : returned_to_child) | 924 for (const auto& returned : returned_to_child) |
915 returned_sync_points[returned.id] = returned.sync_point; | 925 returned_sync_tokens[returned.id] = returned.sync_token; |
916 | 926 |
917 EXPECT_TRUE(returned_sync_points.find(id1) != returned_sync_points.end()); | 927 ASSERT_TRUE(returned_sync_tokens.find(id1) != returned_sync_tokens.end()); |
918 // No new sync point should be created transferring back. | 928 // No new sync point should be created transferring back. |
919 EXPECT_TRUE(returned_sync_points.find(id1) != returned_sync_points.end()); | 929 ASSERT_TRUE(returned_sync_tokens.find(id1) != returned_sync_tokens.end()); |
920 EXPECT_EQ(0u, returned_sync_points[id1]); | 930 EXPECT_FALSE(returned_sync_tokens[id1].HasData()); |
921 EXPECT_TRUE(returned_sync_points.find(id2) != returned_sync_points.end()); | 931 ASSERT_TRUE(returned_sync_tokens.find(id2) != returned_sync_tokens.end()); |
922 EXPECT_EQ(0u, returned_sync_points[id2]); | 932 EXPECT_FALSE(returned_sync_tokens[id2].HasData()); |
923 // Original sync point given should be returned. | 933 // Original sync point given should be returned. |
924 EXPECT_TRUE(returned_sync_points.find(id3) != returned_sync_points.end()); | 934 ASSERT_TRUE(returned_sync_tokens.find(id3) != returned_sync_tokens.end()); |
925 EXPECT_EQ(external_sync_point, returned_sync_points[id3]); | 935 EXPECT_EQ(external_sync_token, returned_sync_tokens[id3]); |
926 EXPECT_FALSE(returned_to_child[0].lost); | 936 EXPECT_FALSE(returned_to_child[0].lost); |
927 EXPECT_FALSE(returned_to_child[1].lost); | 937 EXPECT_FALSE(returned_to_child[1].lost); |
928 EXPECT_FALSE(returned_to_child[2].lost); | 938 EXPECT_FALSE(returned_to_child[2].lost); |
929 child_resource_provider_->ReceiveReturnsFromParent(returned_to_child); | 939 child_resource_provider_->ReceiveReturnsFromParent(returned_to_child); |
930 returned_to_child.clear(); | 940 returned_to_child.clear(); |
931 } | 941 } |
932 | 942 |
933 resource_provider_->DestroyChild(child_id); | 943 resource_provider_->DestroyChild(child_id); |
934 } | 944 } |
935 | 945 |
936 INSTANTIATE_TEST_CASE_P( | 946 INSTANTIATE_TEST_CASE_P( |
937 ResourceProviderTests, | 947 ResourceProviderTests, |
938 ResourceProviderTestNoSyncPoint, | 948 ResourceProviderTestNoSyncToken, |
939 ::testing::Values(ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)); | 949 ::testing::Values(ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)); |
940 | 950 |
941 TEST_P(ResourceProviderTest, ReadLockCountStopsReturnToChildOrDelete) { | 951 TEST_P(ResourceProviderTest, ReadLockCountStopsReturnToChildOrDelete) { |
942 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) | 952 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) |
943 return; | 953 return; |
944 gfx::Size size(1, 1); | 954 gfx::Size size(1, 1); |
945 ResourceFormat format = RGBA_8888; | 955 ResourceFormat format = RGBA_8888; |
946 | 956 |
947 ResourceId id1 = child_resource_provider_->CreateResource( | 957 ResourceId id1 = child_resource_provider_->CreateResource( |
948 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 958 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); |
949 uint8_t data1[4] = {1, 2, 3, 4}; | 959 uint8_t data1[4] = {1, 2, 3, 4}; |
950 child_resource_provider_->CopyToResource(id1, data1, size); | 960 child_resource_provider_->CopyToResource(id1, data1, size); |
951 | 961 |
952 ReturnedResourceArray returned_to_child; | 962 ReturnedResourceArray returned_to_child; |
953 int child_id = | 963 int child_id = |
954 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); | 964 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); |
955 { | 965 { |
956 // Transfer some resources to the parent. | 966 // Transfer some resources to the parent. |
957 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 967 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
958 resource_ids_to_transfer.push_back(id1); | 968 resource_ids_to_transfer.push_back(id1); |
959 TransferableResourceArray list; | 969 TransferableResourceArray list; |
960 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, | 970 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, |
961 &list); | 971 &list); |
962 ASSERT_EQ(1u, list.size()); | 972 ASSERT_EQ(1u, list.size()); |
963 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); | 973 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); |
964 | 974 |
965 resource_provider_->ReceiveFromChild(child_id, list); | 975 resource_provider_->ReceiveFromChild(child_id, list); |
966 | 976 |
967 resource_provider_->WaitSyncPointIfNeeded(list[0].id); | 977 resource_provider_->WaitSyncTokenIfNeeded(list[0].id); |
968 ResourceProvider::ScopedReadLockGL lock(resource_provider_.get(), | 978 ResourceProvider::ScopedReadLockGL lock(resource_provider_.get(), |
969 list[0].id); | 979 list[0].id); |
970 | 980 |
971 resource_provider_->DeclareUsedResourcesFromChild( | 981 resource_provider_->DeclareUsedResourcesFromChild( |
972 child_id, ResourceProvider::ResourceIdSet()); | 982 child_id, ResourceProvider::ResourceIdSet()); |
973 EXPECT_EQ(0u, returned_to_child.size()); | 983 EXPECT_EQ(0u, returned_to_child.size()); |
974 } | 984 } |
975 | 985 |
976 EXPECT_EQ(1u, returned_to_child.size()); | 986 EXPECT_EQ(1u, returned_to_child.size()); |
977 child_resource_provider_->ReceiveReturnsFromParent(returned_to_child); | 987 child_resource_provider_->ReceiveReturnsFromParent(returned_to_child); |
978 | 988 |
979 { | 989 { |
980 child_resource_provider_->WaitSyncPointIfNeeded(id1); | 990 child_resource_provider_->WaitSyncTokenIfNeeded(id1); |
981 ResourceProvider::ScopedReadLockGL lock(child_resource_provider_.get(), | 991 ResourceProvider::ScopedReadLockGL lock(child_resource_provider_.get(), |
982 id1); | 992 id1); |
983 child_resource_provider_->DeleteResource(id1); | 993 child_resource_provider_->DeleteResource(id1); |
984 EXPECT_EQ(1u, child_resource_provider_->num_resources()); | 994 EXPECT_EQ(1u, child_resource_provider_->num_resources()); |
985 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); | 995 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); |
986 } | 996 } |
987 | 997 |
988 EXPECT_EQ(0u, child_resource_provider_->num_resources()); | 998 EXPECT_EQ(0u, child_resource_provider_->num_resources()); |
989 resource_provider_->DestroyChild(child_id); | 999 resource_provider_->DestroyChild(child_id); |
990 } | 1000 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1027 ASSERT_EQ(1u, list.size()); | 1037 ASSERT_EQ(1u, list.size()); |
1028 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); | 1038 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); |
1029 EXPECT_TRUE(list[0].read_lock_fences_enabled); | 1039 EXPECT_TRUE(list[0].read_lock_fences_enabled); |
1030 | 1040 |
1031 resource_provider_->ReceiveFromChild(child_id, list); | 1041 resource_provider_->ReceiveFromChild(child_id, list); |
1032 | 1042 |
1033 scoped_refptr<TestFence> fence(new TestFence); | 1043 scoped_refptr<TestFence> fence(new TestFence); |
1034 resource_provider_->SetReadLockFence(fence.get()); | 1044 resource_provider_->SetReadLockFence(fence.get()); |
1035 { | 1045 { |
1036 unsigned parent_id = list.front().id; | 1046 unsigned parent_id = list.front().id; |
1037 resource_provider_->WaitSyncPointIfNeeded(parent_id); | 1047 resource_provider_->WaitSyncTokenIfNeeded(parent_id); |
1038 ResourceProvider::ScopedReadLockGL lock(resource_provider_.get(), | 1048 ResourceProvider::ScopedReadLockGL lock(resource_provider_.get(), |
1039 parent_id); | 1049 parent_id); |
1040 } | 1050 } |
1041 resource_provider_->DeclareUsedResourcesFromChild( | 1051 resource_provider_->DeclareUsedResourcesFromChild( |
1042 child_id, ResourceProvider::ResourceIdSet()); | 1052 child_id, ResourceProvider::ResourceIdSet()); |
1043 EXPECT_EQ(0u, returned_to_child.size()); | 1053 EXPECT_EQ(0u, returned_to_child.size()); |
1044 | 1054 |
1045 resource_provider_->DeclareUsedResourcesFromChild( | 1055 resource_provider_->DeclareUsedResourcesFromChild( |
1046 child_id, ResourceProvider::ResourceIdSet()); | 1056 child_id, ResourceProvider::ResourceIdSet()); |
1047 EXPECT_EQ(0u, returned_to_child.size()); | 1057 EXPECT_EQ(0u, returned_to_child.size()); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1087 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); | 1097 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); |
1088 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); | 1098 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); |
1089 | 1099 |
1090 resource_provider_->ReceiveFromChild(child_id, list); | 1100 resource_provider_->ReceiveFromChild(child_id, list); |
1091 | 1101 |
1092 scoped_refptr<TestFence> fence(new TestFence); | 1102 scoped_refptr<TestFence> fence(new TestFence); |
1093 resource_provider_->SetReadLockFence(fence.get()); | 1103 resource_provider_->SetReadLockFence(fence.get()); |
1094 { | 1104 { |
1095 for (size_t i = 0; i < list.size(); i++) { | 1105 for (size_t i = 0; i < list.size(); i++) { |
1096 unsigned parent_id = list[i].id; | 1106 unsigned parent_id = list[i].id; |
1097 resource_provider_->WaitSyncPointIfNeeded(parent_id); | 1107 resource_provider_->WaitSyncTokenIfNeeded(parent_id); |
1098 ResourceProvider::ScopedReadLockGL lock(resource_provider_.get(), | 1108 ResourceProvider::ScopedReadLockGL lock(resource_provider_.get(), |
1099 parent_id); | 1109 parent_id); |
1100 } | 1110 } |
1101 } | 1111 } |
1102 EXPECT_EQ(0u, returned_to_child.size()); | 1112 EXPECT_EQ(0u, returned_to_child.size()); |
1103 | 1113 |
1104 EXPECT_EQ(2u, resource_provider_->num_resources()); | 1114 EXPECT_EQ(2u, resource_provider_->num_resources()); |
1105 | 1115 |
1106 resource_provider_->DestroyChild(child_id); | 1116 resource_provider_->DestroyChild(child_id); |
1107 | 1117 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1149 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); | 1159 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); |
1150 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); | 1160 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); |
1151 | 1161 |
1152 resource_provider_->ReceiveFromChild(child_id, list); | 1162 resource_provider_->ReceiveFromChild(child_id, list); |
1153 | 1163 |
1154 scoped_refptr<TestFence> fence(new TestFence); | 1164 scoped_refptr<TestFence> fence(new TestFence); |
1155 resource_provider_->SetReadLockFence(fence.get()); | 1165 resource_provider_->SetReadLockFence(fence.get()); |
1156 { | 1166 { |
1157 for (size_t i = 0; i < list.size(); i++) { | 1167 for (size_t i = 0; i < list.size(); i++) { |
1158 unsigned parent_id = list[i].id; | 1168 unsigned parent_id = list[i].id; |
1159 resource_provider_->WaitSyncPointIfNeeded(parent_id); | 1169 resource_provider_->WaitSyncTokenIfNeeded(parent_id); |
1160 ResourceProvider::ScopedReadLockGL lock(resource_provider_.get(), | 1170 ResourceProvider::ScopedReadLockGL lock(resource_provider_.get(), |
1161 parent_id); | 1171 parent_id); |
1162 } | 1172 } |
1163 } | 1173 } |
1164 EXPECT_EQ(0u, returned_to_child.size()); | 1174 EXPECT_EQ(0u, returned_to_child.size()); |
1165 | 1175 |
1166 EXPECT_EQ(2u, resource_provider_->num_resources()); | 1176 EXPECT_EQ(2u, resource_provider_->num_resources()); |
1167 resource_provider_->DidLoseOutputSurface(); | 1177 resource_provider_->DidLoseOutputSurface(); |
1168 resource_provider_ = nullptr; | 1178 resource_provider_ = nullptr; |
1169 | 1179 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1206 { | 1216 { |
1207 // Transfer some resources to the parent. | 1217 // Transfer some resources to the parent. |
1208 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 1218 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
1209 resource_ids_to_transfer.push_back(id1); | 1219 resource_ids_to_transfer.push_back(id1); |
1210 resource_ids_to_transfer.push_back(id2); | 1220 resource_ids_to_transfer.push_back(id2); |
1211 resource_ids_to_transfer.push_back(id3); | 1221 resource_ids_to_transfer.push_back(id3); |
1212 TransferableResourceArray list; | 1222 TransferableResourceArray list; |
1213 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, | 1223 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, |
1214 &list); | 1224 &list); |
1215 ASSERT_EQ(3u, list.size()); | 1225 ASSERT_EQ(3u, list.size()); |
1216 EXPECT_EQ(0u, list[0].mailbox_holder.sync_point); | 1226 EXPECT_FALSE(list[0].mailbox_holder.sync_token.HasData()); |
1217 EXPECT_EQ(0u, list[1].mailbox_holder.sync_point); | 1227 EXPECT_FALSE(list[1].mailbox_holder.sync_token.HasData()); |
1218 EXPECT_EQ(0u, list[2].mailbox_holder.sync_point); | 1228 EXPECT_FALSE(list[2].mailbox_holder.sync_token.HasData()); |
1219 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); | 1229 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); |
1220 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); | 1230 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); |
1221 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id3)); | 1231 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id3)); |
1222 resource_provider_->ReceiveFromChild(child_id, list); | 1232 resource_provider_->ReceiveFromChild(child_id, list); |
1223 ResourceProvider::ResourceIdSet resource_ids_to_receive; | 1233 ResourceProvider::ResourceIdSet resource_ids_to_receive; |
1224 resource_ids_to_receive.insert(id1); | 1234 resource_ids_to_receive.insert(id1); |
1225 resource_ids_to_receive.insert(id2); | 1235 resource_ids_to_receive.insert(id2); |
1226 resource_ids_to_receive.insert(id3); | 1236 resource_ids_to_receive.insert(id3); |
1227 resource_provider_->DeclareUsedResourcesFromChild(child_id, | 1237 resource_provider_->DeclareUsedResourcesFromChild(child_id, |
1228 resource_ids_to_receive); | 1238 resource_ids_to_receive); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1272 } | 1282 } |
1273 { | 1283 { |
1274 EXPECT_EQ(0u, returned_to_child.size()); | 1284 EXPECT_EQ(0u, returned_to_child.size()); |
1275 | 1285 |
1276 // Transfer resources back from the parent to the child. Set no resources as | 1286 // Transfer resources back from the parent to the child. Set no resources as |
1277 // being in use. | 1287 // being in use. |
1278 ResourceProvider::ResourceIdSet no_resources; | 1288 ResourceProvider::ResourceIdSet no_resources; |
1279 resource_provider_->DeclareUsedResourcesFromChild(child_id, no_resources); | 1289 resource_provider_->DeclareUsedResourcesFromChild(child_id, no_resources); |
1280 | 1290 |
1281 ASSERT_EQ(3u, returned_to_child.size()); | 1291 ASSERT_EQ(3u, returned_to_child.size()); |
1282 EXPECT_EQ(0u, returned_to_child[0].sync_point); | 1292 EXPECT_FALSE(returned_to_child[0].sync_token.HasData()); |
1283 EXPECT_EQ(0u, returned_to_child[1].sync_point); | 1293 EXPECT_FALSE(returned_to_child[1].sync_token.HasData()); |
1284 EXPECT_EQ(0u, returned_to_child[2].sync_point); | 1294 EXPECT_FALSE(returned_to_child[2].sync_token.HasData()); |
1285 std::set<ResourceId> expected_ids; | 1295 std::set<ResourceId> expected_ids; |
1286 expected_ids.insert(id1); | 1296 expected_ids.insert(id1); |
1287 expected_ids.insert(id2); | 1297 expected_ids.insert(id2); |
1288 expected_ids.insert(id3); | 1298 expected_ids.insert(id3); |
1289 std::set<ResourceId> returned_ids; | 1299 std::set<ResourceId> returned_ids; |
1290 for (unsigned i = 0; i < 3; i++) | 1300 for (unsigned i = 0; i < 3; i++) |
1291 returned_ids.insert(returned_to_child[i].id); | 1301 returned_ids.insert(returned_to_child[i].id); |
1292 EXPECT_EQ(expected_ids, returned_ids); | 1302 EXPECT_EQ(expected_ids, returned_ids); |
1293 EXPECT_FALSE(returned_to_child[0].lost); | 1303 EXPECT_FALSE(returned_to_child[0].lost); |
1294 EXPECT_FALSE(returned_to_child[1].lost); | 1304 EXPECT_FALSE(returned_to_child[1].lost); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1341 resource_ids_to_receive); | 1351 resource_ids_to_receive); |
1342 } | 1352 } |
1343 | 1353 |
1344 EXPECT_EQ(0u, returned_to_child.size()); | 1354 EXPECT_EQ(0u, returned_to_child.size()); |
1345 | 1355 |
1346 EXPECT_EQ(3u, resource_provider_->num_resources()); | 1356 EXPECT_EQ(3u, resource_provider_->num_resources()); |
1347 resource_provider_->DestroyChild(child_id); | 1357 resource_provider_->DestroyChild(child_id); |
1348 EXPECT_EQ(0u, resource_provider_->num_resources()); | 1358 EXPECT_EQ(0u, resource_provider_->num_resources()); |
1349 | 1359 |
1350 ASSERT_EQ(3u, returned_to_child.size()); | 1360 ASSERT_EQ(3u, returned_to_child.size()); |
1351 EXPECT_EQ(0u, returned_to_child[0].sync_point); | 1361 EXPECT_FALSE(returned_to_child[0].sync_token.HasData()); |
1352 EXPECT_EQ(0u, returned_to_child[1].sync_point); | 1362 EXPECT_FALSE(returned_to_child[1].sync_token.HasData()); |
1353 EXPECT_EQ(0u, returned_to_child[2].sync_point); | 1363 EXPECT_FALSE(returned_to_child[2].sync_token.HasData()); |
1354 std::set<ResourceId> expected_ids; | 1364 std::set<ResourceId> expected_ids; |
1355 expected_ids.insert(id1); | 1365 expected_ids.insert(id1); |
1356 expected_ids.insert(id2); | 1366 expected_ids.insert(id2); |
1357 expected_ids.insert(id3); | 1367 expected_ids.insert(id3); |
1358 std::set<ResourceId> returned_ids; | 1368 std::set<ResourceId> returned_ids; |
1359 for (unsigned i = 0; i < 3; i++) | 1369 for (unsigned i = 0; i < 3; i++) |
1360 returned_ids.insert(returned_to_child[i].id); | 1370 returned_ids.insert(returned_to_child[i].id); |
1361 EXPECT_EQ(expected_ids, returned_ids); | 1371 EXPECT_EQ(expected_ids, returned_ids); |
1362 EXPECT_FALSE(returned_to_child[0].lost); | 1372 EXPECT_FALSE(returned_to_child[0].lost); |
1363 EXPECT_FALSE(returned_to_child[1].lost); | 1373 EXPECT_FALSE(returned_to_child[1].lost); |
(...skipping 30 matching lines...) Expand all Loading... |
1394 ReturnedResourceArray returned_to_child; | 1404 ReturnedResourceArray returned_to_child; |
1395 int child_id = | 1405 int child_id = |
1396 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); | 1406 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); |
1397 { | 1407 { |
1398 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 1408 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
1399 resource_ids_to_transfer.push_back(id1); | 1409 resource_ids_to_transfer.push_back(id1); |
1400 TransferableResourceArray list; | 1410 TransferableResourceArray list; |
1401 child_resource_provider->PrepareSendToParent(resource_ids_to_transfer, | 1411 child_resource_provider->PrepareSendToParent(resource_ids_to_transfer, |
1402 &list); | 1412 &list); |
1403 ASSERT_EQ(1u, list.size()); | 1413 ASSERT_EQ(1u, list.size()); |
1404 EXPECT_NE(0u, list[0].mailbox_holder.sync_point); | 1414 EXPECT_TRUE(list[0].mailbox_holder.sync_token.HasData()); |
1405 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), | 1415 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), |
1406 list[0].mailbox_holder.texture_target); | 1416 list[0].mailbox_holder.texture_target); |
1407 EXPECT_TRUE(child_resource_provider->InUseByConsumer(id1)); | 1417 EXPECT_TRUE(child_resource_provider->InUseByConsumer(id1)); |
1408 resource_provider_->ReceiveFromChild(child_id, list); | 1418 resource_provider_->ReceiveFromChild(child_id, list); |
1409 } | 1419 } |
1410 | 1420 |
1411 EXPECT_EQ(0u, resource_provider_->num_resources()); | 1421 EXPECT_EQ(0u, resource_provider_->num_resources()); |
1412 ASSERT_EQ(1u, returned_to_child.size()); | 1422 ASSERT_EQ(1u, returned_to_child.size()); |
1413 EXPECT_EQ(returned_to_child[0].id, id1); | 1423 EXPECT_EQ(returned_to_child[0].id, id1); |
1414 ResourceProvider::ResourceIdMap resource_map = | 1424 ResourceProvider::ResourceIdMap resource_map = |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1495 { | 1505 { |
1496 // Transfer some resources to the parent. | 1506 // Transfer some resources to the parent. |
1497 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 1507 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
1498 resource_ids_to_transfer.push_back(id1); | 1508 resource_ids_to_transfer.push_back(id1); |
1499 resource_ids_to_transfer.push_back(id2); | 1509 resource_ids_to_transfer.push_back(id2); |
1500 TransferableResourceArray list; | 1510 TransferableResourceArray list; |
1501 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, | 1511 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, |
1502 &list); | 1512 &list); |
1503 ASSERT_EQ(2u, list.size()); | 1513 ASSERT_EQ(2u, list.size()); |
1504 if (GetParam() == ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) { | 1514 if (GetParam() == ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) { |
1505 EXPECT_NE(0u, list[0].mailbox_holder.sync_point); | 1515 EXPECT_TRUE(list[0].mailbox_holder.sync_token.HasData()); |
1506 EXPECT_NE(0u, list[1].mailbox_holder.sync_point); | 1516 EXPECT_TRUE(list[1].mailbox_holder.sync_token.HasData()); |
1507 } | 1517 } |
1508 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); | 1518 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); |
1509 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); | 1519 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); |
1510 resource_provider_->ReceiveFromChild(child_id, list); | 1520 resource_provider_->ReceiveFromChild(child_id, list); |
1511 ResourceProvider::ResourceIdSet resource_ids_to_receive; | 1521 ResourceProvider::ResourceIdSet resource_ids_to_receive; |
1512 resource_ids_to_receive.insert(id1); | 1522 resource_ids_to_receive.insert(id1); |
1513 resource_ids_to_receive.insert(id2); | 1523 resource_ids_to_receive.insert(id2); |
1514 resource_provider_->DeclareUsedResourcesFromChild(child_id, | 1524 resource_provider_->DeclareUsedResourcesFromChild(child_id, |
1515 resource_ids_to_receive); | 1525 resource_ids_to_receive); |
1516 } | 1526 } |
(...skipping 11 matching lines...) Expand all Loading... |
1528 { | 1538 { |
1529 // The parent transfers the resources to the grandparent. | 1539 // The parent transfers the resources to the grandparent. |
1530 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 1540 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
1531 resource_ids_to_transfer.push_back(mapped_id1); | 1541 resource_ids_to_transfer.push_back(mapped_id1); |
1532 resource_ids_to_transfer.push_back(mapped_id2); | 1542 resource_ids_to_transfer.push_back(mapped_id2); |
1533 TransferableResourceArray list; | 1543 TransferableResourceArray list; |
1534 resource_provider_->PrepareSendToParent(resource_ids_to_transfer, &list); | 1544 resource_provider_->PrepareSendToParent(resource_ids_to_transfer, &list); |
1535 | 1545 |
1536 ASSERT_EQ(2u, list.size()); | 1546 ASSERT_EQ(2u, list.size()); |
1537 if (GetParam() == ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) { | 1547 if (GetParam() == ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) { |
1538 EXPECT_NE(0u, list[0].mailbox_holder.sync_point); | 1548 EXPECT_TRUE(list[0].mailbox_holder.sync_token.HasData()); |
1539 EXPECT_NE(0u, list[1].mailbox_holder.sync_point); | 1549 EXPECT_TRUE(list[1].mailbox_holder.sync_token.HasData()); |
1540 } | 1550 } |
1541 EXPECT_TRUE(resource_provider_->InUseByConsumer(id1)); | 1551 EXPECT_TRUE(resource_provider_->InUseByConsumer(id1)); |
1542 EXPECT_TRUE(resource_provider_->InUseByConsumer(id2)); | 1552 EXPECT_TRUE(resource_provider_->InUseByConsumer(id2)); |
1543 | 1553 |
1544 // Release the resource in the parent. Set no resources as being in use. The | 1554 // Release the resource in the parent. Set no resources as being in use. The |
1545 // resources are exported so that can't be transferred back yet. | 1555 // resources are exported so that can't be transferred back yet. |
1546 ResourceProvider::ResourceIdSet no_resources; | 1556 ResourceProvider::ResourceIdSet no_resources; |
1547 resource_provider_->DeclareUsedResourcesFromChild(child_id, no_resources); | 1557 resource_provider_->DeclareUsedResourcesFromChild(child_id, no_resources); |
1548 | 1558 |
1549 EXPECT_EQ(0u, returned_to_child.size()); | 1559 EXPECT_EQ(0u, returned_to_child.size()); |
1550 EXPECT_EQ(2u, resource_provider_->num_resources()); | 1560 EXPECT_EQ(2u, resource_provider_->num_resources()); |
1551 | 1561 |
1552 // Return the resources from the grandparent to the parent. They should be | 1562 // Return the resources from the grandparent to the parent. They should be |
1553 // returned to the child then. | 1563 // returned to the child then. |
1554 EXPECT_EQ(2u, list.size()); | 1564 EXPECT_EQ(2u, list.size()); |
1555 EXPECT_EQ(mapped_id1, list[0].id); | 1565 EXPECT_EQ(mapped_id1, list[0].id); |
1556 EXPECT_EQ(mapped_id2, list[1].id); | 1566 EXPECT_EQ(mapped_id2, list[1].id); |
1557 ReturnedResourceArray returned; | 1567 ReturnedResourceArray returned; |
1558 TransferableResource::ReturnResources(list, &returned); | 1568 TransferableResource::ReturnResources(list, &returned); |
1559 resource_provider_->ReceiveReturnsFromParent(returned); | 1569 resource_provider_->ReceiveReturnsFromParent(returned); |
1560 | 1570 |
1561 EXPECT_EQ(0u, resource_provider_->num_resources()); | 1571 EXPECT_EQ(0u, resource_provider_->num_resources()); |
1562 ASSERT_EQ(2u, returned_to_child.size()); | 1572 ASSERT_EQ(2u, returned_to_child.size()); |
1563 if (GetParam() == ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) { | 1573 if (GetParam() == ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) { |
1564 EXPECT_NE(0u, returned_to_child[0].sync_point); | 1574 EXPECT_TRUE(returned_to_child[0].sync_token.HasData()); |
1565 EXPECT_NE(0u, returned_to_child[1].sync_point); | 1575 EXPECT_TRUE(returned_to_child[1].sync_token.HasData()); |
1566 } | 1576 } |
1567 EXPECT_FALSE(returned_to_child[0].lost); | 1577 EXPECT_FALSE(returned_to_child[0].lost); |
1568 EXPECT_FALSE(returned_to_child[1].lost); | 1578 EXPECT_FALSE(returned_to_child[1].lost); |
1569 } | 1579 } |
1570 } | 1580 } |
1571 | 1581 |
1572 TEST_P(ResourceProviderTest, DestroyChildWithExportedResources) { | 1582 TEST_P(ResourceProviderTest, DestroyChildWithExportedResources) { |
1573 gfx::Size size(1, 1); | 1583 gfx::Size size(1, 1); |
1574 ResourceFormat format = RGBA_8888; | 1584 ResourceFormat format = RGBA_8888; |
1575 size_t pixel_size = TextureSizeBytes(size, format); | 1585 size_t pixel_size = TextureSizeBytes(size, format); |
(...skipping 15 matching lines...) Expand all Loading... |
1591 { | 1601 { |
1592 // Transfer some resources to the parent. | 1602 // Transfer some resources to the parent. |
1593 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 1603 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
1594 resource_ids_to_transfer.push_back(id1); | 1604 resource_ids_to_transfer.push_back(id1); |
1595 resource_ids_to_transfer.push_back(id2); | 1605 resource_ids_to_transfer.push_back(id2); |
1596 TransferableResourceArray list; | 1606 TransferableResourceArray list; |
1597 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, | 1607 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, |
1598 &list); | 1608 &list); |
1599 ASSERT_EQ(2u, list.size()); | 1609 ASSERT_EQ(2u, list.size()); |
1600 if (GetParam() == ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) { | 1610 if (GetParam() == ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) { |
1601 EXPECT_NE(0u, list[0].mailbox_holder.sync_point); | 1611 EXPECT_TRUE(list[0].mailbox_holder.sync_token.HasData()); |
1602 EXPECT_NE(0u, list[1].mailbox_holder.sync_point); | 1612 EXPECT_TRUE(list[1].mailbox_holder.sync_token.HasData()); |
1603 } | 1613 } |
1604 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); | 1614 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); |
1605 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); | 1615 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); |
1606 resource_provider_->ReceiveFromChild(child_id, list); | 1616 resource_provider_->ReceiveFromChild(child_id, list); |
1607 ResourceProvider::ResourceIdSet resource_ids_to_receive; | 1617 ResourceProvider::ResourceIdSet resource_ids_to_receive; |
1608 resource_ids_to_receive.insert(id1); | 1618 resource_ids_to_receive.insert(id1); |
1609 resource_ids_to_receive.insert(id2); | 1619 resource_ids_to_receive.insert(id2); |
1610 resource_provider_->DeclareUsedResourcesFromChild(child_id, | 1620 resource_provider_->DeclareUsedResourcesFromChild(child_id, |
1611 resource_ids_to_receive); | 1621 resource_ids_to_receive); |
1612 } | 1622 } |
(...skipping 11 matching lines...) Expand all Loading... |
1624 { | 1634 { |
1625 // The parent transfers the resources to the grandparent. | 1635 // The parent transfers the resources to the grandparent. |
1626 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 1636 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
1627 resource_ids_to_transfer.push_back(mapped_id1); | 1637 resource_ids_to_transfer.push_back(mapped_id1); |
1628 resource_ids_to_transfer.push_back(mapped_id2); | 1638 resource_ids_to_transfer.push_back(mapped_id2); |
1629 TransferableResourceArray list; | 1639 TransferableResourceArray list; |
1630 resource_provider_->PrepareSendToParent(resource_ids_to_transfer, &list); | 1640 resource_provider_->PrepareSendToParent(resource_ids_to_transfer, &list); |
1631 | 1641 |
1632 ASSERT_EQ(2u, list.size()); | 1642 ASSERT_EQ(2u, list.size()); |
1633 if (GetParam() == ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) { | 1643 if (GetParam() == ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) { |
1634 EXPECT_NE(0u, list[0].mailbox_holder.sync_point); | 1644 EXPECT_TRUE(list[0].mailbox_holder.sync_token.HasData()); |
1635 EXPECT_NE(0u, list[1].mailbox_holder.sync_point); | 1645 EXPECT_TRUE(list[1].mailbox_holder.sync_token.HasData()); |
1636 } | 1646 } |
1637 EXPECT_TRUE(resource_provider_->InUseByConsumer(id1)); | 1647 EXPECT_TRUE(resource_provider_->InUseByConsumer(id1)); |
1638 EXPECT_TRUE(resource_provider_->InUseByConsumer(id2)); | 1648 EXPECT_TRUE(resource_provider_->InUseByConsumer(id2)); |
1639 | 1649 |
1640 // Release the resource in the parent. Set no resources as being in use. The | 1650 // Release the resource in the parent. Set no resources as being in use. The |
1641 // resources are exported so that can't be transferred back yet. | 1651 // resources are exported so that can't be transferred back yet. |
1642 ResourceProvider::ResourceIdSet no_resources; | 1652 ResourceProvider::ResourceIdSet no_resources; |
1643 resource_provider_->DeclareUsedResourcesFromChild(child_id, no_resources); | 1653 resource_provider_->DeclareUsedResourcesFromChild(child_id, no_resources); |
1644 | 1654 |
1645 // Destroy the child, the resources should not be returned yet. | 1655 // Destroy the child, the resources should not be returned yet. |
(...skipping 13 matching lines...) Expand all Loading... |
1659 TransferableResourceArray return_list; | 1669 TransferableResourceArray return_list; |
1660 return_list.push_back(list[1]); | 1670 return_list.push_back(list[1]); |
1661 list.pop_back(); | 1671 list.pop_back(); |
1662 ReturnedResourceArray returned; | 1672 ReturnedResourceArray returned; |
1663 TransferableResource::ReturnResources(return_list, &returned); | 1673 TransferableResource::ReturnResources(return_list, &returned); |
1664 resource_provider_->ReceiveReturnsFromParent(returned); | 1674 resource_provider_->ReceiveReturnsFromParent(returned); |
1665 | 1675 |
1666 EXPECT_EQ(1u, resource_provider_->num_resources()); | 1676 EXPECT_EQ(1u, resource_provider_->num_resources()); |
1667 ASSERT_EQ(1u, returned_to_child.size()); | 1677 ASSERT_EQ(1u, returned_to_child.size()); |
1668 if (GetParam() == ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) { | 1678 if (GetParam() == ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) { |
1669 EXPECT_NE(0u, returned_to_child[0].sync_point); | 1679 EXPECT_TRUE(returned_to_child[0].sync_token.HasData()); |
1670 } | 1680 } |
1671 EXPECT_FALSE(returned_to_child[0].lost); | 1681 EXPECT_FALSE(returned_to_child[0].lost); |
1672 returned_to_child.clear(); | 1682 returned_to_child.clear(); |
1673 | 1683 |
1674 // Destroy the parent resource provider. The resource that's left should be | 1684 // Destroy the parent resource provider. The resource that's left should be |
1675 // lost at this point, and returned. | 1685 // lost at this point, and returned. |
1676 resource_provider_ = nullptr; | 1686 resource_provider_ = nullptr; |
1677 ASSERT_EQ(1u, returned_to_child.size()); | 1687 ASSERT_EQ(1u, returned_to_child.size()); |
1678 if (GetParam() == ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) { | 1688 if (GetParam() == ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) { |
1679 EXPECT_NE(0u, returned_to_child[0].sync_point); | 1689 EXPECT_TRUE(returned_to_child[0].sync_token.HasData()); |
1680 } | 1690 } |
1681 EXPECT_TRUE(returned_to_child[0].lost); | 1691 EXPECT_TRUE(returned_to_child[0].lost); |
1682 } | 1692 } |
1683 } | 1693 } |
1684 | 1694 |
1685 TEST_P(ResourceProviderTest, DeleteTransferredResources) { | 1695 TEST_P(ResourceProviderTest, DeleteTransferredResources) { |
1686 gfx::Size size(1, 1); | 1696 gfx::Size size(1, 1); |
1687 ResourceFormat format = RGBA_8888; | 1697 ResourceFormat format = RGBA_8888; |
1688 size_t pixel_size = TextureSizeBytes(size, format); | 1698 size_t pixel_size = TextureSizeBytes(size, format); |
1689 ASSERT_EQ(4U, pixel_size); | 1699 ASSERT_EQ(4U, pixel_size); |
1690 | 1700 |
1691 ResourceId id = child_resource_provider_->CreateResource( | 1701 ResourceId id = child_resource_provider_->CreateResource( |
1692 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 1702 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); |
1693 uint8_t data[4] = { 1, 2, 3, 4 }; | 1703 uint8_t data[4] = { 1, 2, 3, 4 }; |
1694 child_resource_provider_->CopyToResource(id, data, size); | 1704 child_resource_provider_->CopyToResource(id, data, size); |
1695 | 1705 |
1696 ReturnedResourceArray returned_to_child; | 1706 ReturnedResourceArray returned_to_child; |
1697 int child_id = | 1707 int child_id = |
1698 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); | 1708 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); |
1699 { | 1709 { |
1700 // Transfer some resource to the parent. | 1710 // Transfer some resource to the parent. |
1701 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 1711 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
1702 resource_ids_to_transfer.push_back(id); | 1712 resource_ids_to_transfer.push_back(id); |
1703 TransferableResourceArray list; | 1713 TransferableResourceArray list; |
1704 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, | 1714 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, |
1705 &list); | 1715 &list); |
1706 ASSERT_EQ(1u, list.size()); | 1716 ASSERT_EQ(1u, list.size()); |
1707 if (GetParam() == ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) | 1717 if (GetParam() == ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) |
1708 EXPECT_NE(0u, list[0].mailbox_holder.sync_point); | 1718 EXPECT_TRUE(list[0].mailbox_holder.sync_token.HasData()); |
1709 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id)); | 1719 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id)); |
1710 resource_provider_->ReceiveFromChild(child_id, list); | 1720 resource_provider_->ReceiveFromChild(child_id, list); |
1711 ResourceProvider::ResourceIdSet resource_ids_to_receive; | 1721 ResourceProvider::ResourceIdSet resource_ids_to_receive; |
1712 resource_ids_to_receive.insert(id); | 1722 resource_ids_to_receive.insert(id); |
1713 resource_provider_->DeclareUsedResourcesFromChild(child_id, | 1723 resource_provider_->DeclareUsedResourcesFromChild(child_id, |
1714 resource_ids_to_receive); | 1724 resource_ids_to_receive); |
1715 } | 1725 } |
1716 | 1726 |
1717 // Delete textures in the child, while they are transfered. | 1727 // Delete textures in the child, while they are transfered. |
1718 child_resource_provider_->DeleteResource(id); | 1728 child_resource_provider_->DeleteResource(id); |
1719 EXPECT_EQ(1u, child_resource_provider_->num_resources()); | 1729 EXPECT_EQ(1u, child_resource_provider_->num_resources()); |
1720 { | 1730 { |
1721 EXPECT_EQ(0u, returned_to_child.size()); | 1731 EXPECT_EQ(0u, returned_to_child.size()); |
1722 | 1732 |
1723 // Transfer resources back from the parent to the child. Set no resources as | 1733 // Transfer resources back from the parent to the child. Set no resources as |
1724 // being in use. | 1734 // being in use. |
1725 ResourceProvider::ResourceIdSet no_resources; | 1735 ResourceProvider::ResourceIdSet no_resources; |
1726 resource_provider_->DeclareUsedResourcesFromChild(child_id, no_resources); | 1736 resource_provider_->DeclareUsedResourcesFromChild(child_id, no_resources); |
1727 | 1737 |
1728 ASSERT_EQ(1u, returned_to_child.size()); | 1738 ASSERT_EQ(1u, returned_to_child.size()); |
1729 if (GetParam() == ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) | 1739 if (GetParam() == ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) |
1730 EXPECT_NE(0u, returned_to_child[0].sync_point); | 1740 EXPECT_TRUE(returned_to_child[0].sync_token.HasData()); |
1731 child_resource_provider_->ReceiveReturnsFromParent(returned_to_child); | 1741 child_resource_provider_->ReceiveReturnsFromParent(returned_to_child); |
1732 } | 1742 } |
1733 EXPECT_EQ(0u, child_resource_provider_->num_resources()); | 1743 EXPECT_EQ(0u, child_resource_provider_->num_resources()); |
1734 } | 1744 } |
1735 | 1745 |
1736 TEST_P(ResourceProviderTest, UnuseTransferredResources) { | 1746 TEST_P(ResourceProviderTest, UnuseTransferredResources) { |
1737 gfx::Size size(1, 1); | 1747 gfx::Size size(1, 1); |
1738 ResourceFormat format = RGBA_8888; | 1748 ResourceFormat format = RGBA_8888; |
1739 size_t pixel_size = TextureSizeBytes(size, format); | 1749 size_t pixel_size = TextureSizeBytes(size, format); |
1740 ASSERT_EQ(4U, pixel_size); | 1750 ASSERT_EQ(4U, pixel_size); |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1943 | 1953 |
1944 ASSERT_EQ(1u, list.size()); | 1954 ASSERT_EQ(1u, list.size()); |
1945 EXPECT_EQ(static_cast<unsigned>(child_filter), list[0].filter); | 1955 EXPECT_EQ(static_cast<unsigned>(child_filter), list[0].filter); |
1946 | 1956 |
1947 EXPECT_CALL(*parent_context, | 1957 EXPECT_CALL(*parent_context, |
1948 createAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, _)) | 1958 createAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, _)) |
1949 .WillOnce(Return(parent_texture_id)); | 1959 .WillOnce(Return(parent_texture_id)); |
1950 | 1960 |
1951 parent_resource_provider->ReceiveFromChild(child_id, list); | 1961 parent_resource_provider->ReceiveFromChild(child_id, list); |
1952 { | 1962 { |
1953 parent_resource_provider->WaitSyncPointIfNeeded(list[0].id); | 1963 parent_resource_provider->WaitSyncTokenIfNeeded(list[0].id); |
1954 ResourceProvider::ScopedReadLockGL lock(parent_resource_provider.get(), | 1964 ResourceProvider::ScopedReadLockGL lock(parent_resource_provider.get(), |
1955 list[0].id); | 1965 list[0].id); |
1956 } | 1966 } |
1957 Mock::VerifyAndClearExpectations(parent_context); | 1967 Mock::VerifyAndClearExpectations(parent_context); |
1958 | 1968 |
1959 ResourceProvider::ResourceIdSet resource_ids_to_receive; | 1969 ResourceProvider::ResourceIdSet resource_ids_to_receive; |
1960 resource_ids_to_receive.insert(id); | 1970 resource_ids_to_receive.insert(id); |
1961 parent_resource_provider->DeclareUsedResourcesFromChild( | 1971 parent_resource_provider->DeclareUsedResourcesFromChild( |
1962 child_id, resource_ids_to_receive); | 1972 child_id, resource_ids_to_receive); |
1963 Mock::VerifyAndClearExpectations(parent_context); | 1973 Mock::VerifyAndClearExpectations(parent_context); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2027 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) | 2037 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) |
2028 return; | 2038 return; |
2029 unsigned texture = context()->createTexture(); | 2039 unsigned texture = context()->createTexture(); |
2030 context()->bindTexture(GL_TEXTURE_2D, texture); | 2040 context()->bindTexture(GL_TEXTURE_2D, texture); |
2031 uint8_t data[4] = { 1, 2, 3, 4 }; | 2041 uint8_t data[4] = { 1, 2, 3, 4 }; |
2032 context()->texImage2D( | 2042 context()->texImage2D( |
2033 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &data); | 2043 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &data); |
2034 gpu::Mailbox mailbox; | 2044 gpu::Mailbox mailbox; |
2035 context()->genMailboxCHROMIUM(mailbox.name); | 2045 context()->genMailboxCHROMIUM(mailbox.name); |
2036 context()->produceTextureDirectCHROMIUM(texture, GL_TEXTURE_2D, mailbox.name); | 2046 context()->produceTextureDirectCHROMIUM(texture, GL_TEXTURE_2D, mailbox.name); |
2037 uint32 sync_point = context()->insertSyncPoint(); | 2047 gpu::SyncToken sync_token(context()->insertSyncPoint()); |
2038 | 2048 |
2039 // All the logic below assumes that the sync points are all positive. | 2049 // All the logic below assumes that the sync token releases are all positive. |
2040 EXPECT_LT(0u, sync_point); | 2050 EXPECT_LT(0u, sync_token.release_count()); |
2041 | 2051 |
2042 uint32 release_sync_point = 0; | 2052 gpu::SyncToken release_sync_token; |
2043 bool lost_resource = false; | 2053 bool lost_resource = false; |
2044 BlockingTaskRunner* main_thread_task_runner = NULL; | 2054 BlockingTaskRunner* main_thread_task_runner = NULL; |
2045 ReleaseCallbackImpl callback = base::Bind(ReleaseCallback, | 2055 ReleaseCallbackImpl callback = |
2046 &release_sync_point, | 2056 base::Bind(ReleaseCallback, &release_sync_token, &lost_resource, |
2047 &lost_resource, | 2057 &main_thread_task_runner); |
2048 &main_thread_task_runner); | |
2049 ResourceId resource = resource_provider_->CreateResourceFromTextureMailbox( | 2058 ResourceId resource = resource_provider_->CreateResourceFromTextureMailbox( |
2050 TextureMailbox(mailbox, GL_TEXTURE_2D, sync_point), | 2059 TextureMailbox(mailbox, sync_token, GL_TEXTURE_2D), |
2051 SingleReleaseCallbackImpl::Create(callback)); | 2060 SingleReleaseCallbackImpl::Create(callback)); |
2052 EXPECT_EQ(1u, context()->NumTextures()); | 2061 EXPECT_EQ(1u, context()->NumTextures()); |
2053 EXPECT_EQ(0u, release_sync_point); | 2062 EXPECT_FALSE(release_sync_token.HasData()); |
2054 { | 2063 { |
2055 // Transfer the resource, expect the sync points to be consistent. | 2064 // Transfer the resource, expect the sync points to be consistent. |
2056 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 2065 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
2057 resource_ids_to_transfer.push_back(resource); | 2066 resource_ids_to_transfer.push_back(resource); |
2058 TransferableResourceArray list; | 2067 TransferableResourceArray list; |
2059 resource_provider_->PrepareSendToParent(resource_ids_to_transfer, &list); | 2068 resource_provider_->PrepareSendToParent(resource_ids_to_transfer, &list); |
2060 ASSERT_EQ(1u, list.size()); | 2069 ASSERT_EQ(1u, list.size()); |
2061 EXPECT_LE(sync_point, list[0].mailbox_holder.sync_point); | 2070 EXPECT_LE(sync_token.release_count(), |
| 2071 list[0].mailbox_holder.sync_token.release_count()); |
2062 EXPECT_EQ(0, | 2072 EXPECT_EQ(0, |
2063 memcmp(mailbox.name, | 2073 memcmp(mailbox.name, |
2064 list[0].mailbox_holder.mailbox.name, | 2074 list[0].mailbox_holder.mailbox.name, |
2065 sizeof(mailbox.name))); | 2075 sizeof(mailbox.name))); |
2066 EXPECT_EQ(0u, release_sync_point); | 2076 EXPECT_FALSE(release_sync_token.HasData()); |
2067 | 2077 |
2068 context()->waitSyncPoint(list[0].mailbox_holder.sync_point); | 2078 context()->waitSyncToken(list[0].mailbox_holder.sync_token.GetConstData()); |
2069 unsigned other_texture = | 2079 unsigned other_texture = |
2070 context()->createAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); | 2080 context()->createAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); |
2071 uint8_t test_data[4] = { 0 }; | 2081 uint8_t test_data[4] = { 0 }; |
2072 context()->GetPixels( | 2082 context()->GetPixels( |
2073 gfx::Size(1, 1), RGBA_8888, test_data); | 2083 gfx::Size(1, 1), RGBA_8888, test_data); |
2074 EXPECT_EQ(0, memcmp(data, test_data, sizeof(data))); | 2084 EXPECT_EQ(0, memcmp(data, test_data, sizeof(data))); |
2075 | 2085 |
2076 context()->produceTextureDirectCHROMIUM(other_texture, GL_TEXTURE_2D, | 2086 context()->produceTextureDirectCHROMIUM(other_texture, GL_TEXTURE_2D, |
2077 mailbox.name); | 2087 mailbox.name); |
2078 context()->deleteTexture(other_texture); | 2088 context()->deleteTexture(other_texture); |
2079 list[0].mailbox_holder.sync_point = context()->insertSyncPoint(); | 2089 list[0].mailbox_holder.sync_token = |
2080 EXPECT_LT(0u, list[0].mailbox_holder.sync_point); | 2090 gpu::SyncToken(context()->insertSyncPoint()); |
2081 | 2091 |
2082 // Receive the resource, then delete it, expect the sync points to be | 2092 // Receive the resource, then delete it, expect the sync points to be |
2083 // consistent. | 2093 // consistent. |
2084 ReturnedResourceArray returned; | 2094 ReturnedResourceArray returned; |
2085 TransferableResource::ReturnResources(list, &returned); | 2095 TransferableResource::ReturnResources(list, &returned); |
2086 resource_provider_->ReceiveReturnsFromParent(returned); | 2096 resource_provider_->ReceiveReturnsFromParent(returned); |
2087 EXPECT_EQ(1u, context()->NumTextures()); | 2097 EXPECT_EQ(1u, context()->NumTextures()); |
2088 EXPECT_EQ(0u, release_sync_point); | 2098 EXPECT_FALSE(release_sync_token.HasData()); |
2089 | 2099 |
2090 resource_provider_->DeleteResource(resource); | 2100 resource_provider_->DeleteResource(resource); |
2091 EXPECT_LE(list[0].mailbox_holder.sync_point, release_sync_point); | 2101 EXPECT_LE(list[0].mailbox_holder.sync_token.release_count(), |
| 2102 release_sync_token.release_count()); |
2092 EXPECT_FALSE(lost_resource); | 2103 EXPECT_FALSE(lost_resource); |
2093 EXPECT_EQ(main_thread_task_runner_.get(), main_thread_task_runner); | 2104 EXPECT_EQ(main_thread_task_runner_.get(), main_thread_task_runner); |
2094 } | 2105 } |
2095 | 2106 |
2096 // We're going to do the same thing as above, but testing the case where we | 2107 // We're going to do the same thing as above, but testing the case where we |
2097 // delete the resource before we receive it back. | 2108 // delete the resource before we receive it back. |
2098 sync_point = release_sync_point; | 2109 sync_token = release_sync_token; |
2099 EXPECT_LT(0u, sync_point); | 2110 EXPECT_LT(0u, sync_token.release_count()); |
2100 release_sync_point = 0; | 2111 release_sync_token.Clear(); |
2101 resource = resource_provider_->CreateResourceFromTextureMailbox( | 2112 resource = resource_provider_->CreateResourceFromTextureMailbox( |
2102 TextureMailbox(mailbox, GL_TEXTURE_2D, sync_point), | 2113 TextureMailbox(mailbox, sync_token, GL_TEXTURE_2D), |
2103 SingleReleaseCallbackImpl::Create(callback)); | 2114 SingleReleaseCallbackImpl::Create(callback)); |
2104 EXPECT_EQ(1u, context()->NumTextures()); | 2115 EXPECT_EQ(1u, context()->NumTextures()); |
2105 EXPECT_EQ(0u, release_sync_point); | 2116 EXPECT_FALSE(release_sync_token.HasData()); |
2106 { | 2117 { |
2107 // Transfer the resource, expect the sync points to be consistent. | 2118 // Transfer the resource, expect the sync points to be consistent. |
2108 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 2119 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
2109 resource_ids_to_transfer.push_back(resource); | 2120 resource_ids_to_transfer.push_back(resource); |
2110 TransferableResourceArray list; | 2121 TransferableResourceArray list; |
2111 resource_provider_->PrepareSendToParent(resource_ids_to_transfer, &list); | 2122 resource_provider_->PrepareSendToParent(resource_ids_to_transfer, &list); |
2112 ASSERT_EQ(1u, list.size()); | 2123 ASSERT_EQ(1u, list.size()); |
2113 EXPECT_LE(sync_point, list[0].mailbox_holder.sync_point); | 2124 EXPECT_LE(sync_token.release_count(), |
| 2125 list[0].mailbox_holder.sync_token.release_count()); |
2114 EXPECT_EQ(0, | 2126 EXPECT_EQ(0, |
2115 memcmp(mailbox.name, | 2127 memcmp(mailbox.name, |
2116 list[0].mailbox_holder.mailbox.name, | 2128 list[0].mailbox_holder.mailbox.name, |
2117 sizeof(mailbox.name))); | 2129 sizeof(mailbox.name))); |
2118 EXPECT_EQ(0u, release_sync_point); | 2130 EXPECT_TRUE(release_sync_token.HasData()); |
2119 | 2131 |
2120 context()->waitSyncPoint(list[0].mailbox_holder.sync_point); | 2132 context()->waitSyncToken(list[0].mailbox_holder.sync_token.GetConstData()); |
2121 unsigned other_texture = | 2133 unsigned other_texture = |
2122 context()->createAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); | 2134 context()->createAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); |
2123 uint8_t test_data[4] = { 0 }; | 2135 uint8_t test_data[4] = { 0 }; |
2124 context()->GetPixels( | 2136 context()->GetPixels( |
2125 gfx::Size(1, 1), RGBA_8888, test_data); | 2137 gfx::Size(1, 1), RGBA_8888, test_data); |
2126 EXPECT_EQ(0, memcmp(data, test_data, sizeof(data))); | 2138 EXPECT_EQ(0, memcmp(data, test_data, sizeof(data))); |
2127 | 2139 |
2128 context()->produceTextureDirectCHROMIUM(other_texture, GL_TEXTURE_2D, | 2140 context()->produceTextureDirectCHROMIUM(other_texture, GL_TEXTURE_2D, |
2129 mailbox.name); | 2141 mailbox.name); |
2130 context()->deleteTexture(other_texture); | 2142 context()->deleteTexture(other_texture); |
2131 list[0].mailbox_holder.sync_point = context()->insertSyncPoint(); | 2143 list[0].mailbox_holder.sync_token = |
2132 EXPECT_LT(0u, list[0].mailbox_holder.sync_point); | 2144 gpu::SyncToken(context()->insertSyncPoint()); |
| 2145 EXPECT_LT(0u, list[0].mailbox_holder.sync_token.release_count()); |
2133 | 2146 |
2134 // Delete the resource, which shouldn't do anything. | 2147 // Delete the resource, which shouldn't do anything. |
2135 resource_provider_->DeleteResource(resource); | 2148 resource_provider_->DeleteResource(resource); |
2136 EXPECT_EQ(1u, context()->NumTextures()); | 2149 EXPECT_EQ(1u, context()->NumTextures()); |
2137 EXPECT_EQ(0u, release_sync_point); | 2150 EXPECT_FALSE(release_sync_token.HasData()); |
2138 | 2151 |
2139 // Then receive the resource which should release the mailbox, expect the | 2152 // Then receive the resource which should release the mailbox, expect the |
2140 // sync points to be consistent. | 2153 // sync points to be consistent. |
2141 ReturnedResourceArray returned; | 2154 ReturnedResourceArray returned; |
2142 TransferableResource::ReturnResources(list, &returned); | 2155 TransferableResource::ReturnResources(list, &returned); |
2143 resource_provider_->ReceiveReturnsFromParent(returned); | 2156 resource_provider_->ReceiveReturnsFromParent(returned); |
2144 EXPECT_LE(list[0].mailbox_holder.sync_point, release_sync_point); | 2157 EXPECT_LE(list[0].mailbox_holder.sync_token.release_count(), |
| 2158 release_sync_token.release_count()); |
2145 EXPECT_FALSE(lost_resource); | 2159 EXPECT_FALSE(lost_resource); |
2146 EXPECT_EQ(main_thread_task_runner_.get(), main_thread_task_runner); | 2160 EXPECT_EQ(main_thread_task_runner_.get(), main_thread_task_runner); |
2147 } | 2161 } |
2148 | 2162 |
2149 context()->waitSyncPoint(release_sync_point); | 2163 context()->waitSyncToken(release_sync_token.GetConstData()); |
2150 texture = | 2164 texture = |
2151 context()->createAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); | 2165 context()->createAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); |
2152 context()->deleteTexture(texture); | 2166 context()->deleteTexture(texture); |
2153 } | 2167 } |
2154 | 2168 |
2155 TEST_P(ResourceProviderTest, LostResourceInParent) { | 2169 TEST_P(ResourceProviderTest, LostResourceInParent) { |
2156 gfx::Size size(1, 1); | 2170 gfx::Size size(1, 1); |
2157 ResourceFormat format = RGBA_8888; | 2171 ResourceFormat format = RGBA_8888; |
2158 ResourceId resource = child_resource_provider_->CreateResource( | 2172 ResourceId resource = child_resource_provider_->CreateResource( |
2159 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 2173 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2278 } | 2292 } |
2279 | 2293 |
2280 // The resource should be lost. | 2294 // The resource should be lost. |
2281 EXPECT_TRUE(child_resource_provider_->IsLost(resource)); | 2295 EXPECT_TRUE(child_resource_provider_->IsLost(resource)); |
2282 | 2296 |
2283 // Lost resources stay in use in the parent forever. | 2297 // Lost resources stay in use in the parent forever. |
2284 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(resource)); | 2298 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(resource)); |
2285 } | 2299 } |
2286 | 2300 |
2287 TEST_P(ResourceProviderTest, LostMailboxInParent) { | 2301 TEST_P(ResourceProviderTest, LostMailboxInParent) { |
2288 uint32 release_sync_point = 0; | 2302 gpu::SyncToken release_sync_token; |
2289 bool lost_resource = false; | 2303 bool lost_resource = false; |
2290 bool release_called = false; | 2304 bool release_called = false; |
2291 uint32 sync_point = 0; | 2305 gpu::SyncToken sync_token; |
2292 ResourceId resource = CreateChildMailbox(&release_sync_point, &lost_resource, | 2306 ResourceId resource = CreateChildMailbox(&release_sync_token, &lost_resource, |
2293 &release_called, &sync_point); | 2307 &release_called, &sync_token); |
2294 | 2308 |
2295 ReturnedResourceArray returned_to_child; | 2309 ReturnedResourceArray returned_to_child; |
2296 int child_id = | 2310 int child_id = |
2297 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); | 2311 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); |
2298 { | 2312 { |
2299 // Transfer the resource to the parent. | 2313 // Transfer the resource to the parent. |
2300 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 2314 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
2301 resource_ids_to_transfer.push_back(resource); | 2315 resource_ids_to_transfer.push_back(resource); |
2302 TransferableResourceArray list; | 2316 TransferableResourceArray list; |
2303 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, | 2317 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, |
(...skipping 27 matching lines...) Expand all Loading... |
2331 } | 2345 } |
2332 | 2346 |
2333 // Delete the resource in the child. Expect the resource to be lost if it's | 2347 // Delete the resource in the child. Expect the resource to be lost if it's |
2334 // a GL texture. | 2348 // a GL texture. |
2335 child_resource_provider_->DeleteResource(resource); | 2349 child_resource_provider_->DeleteResource(resource); |
2336 EXPECT_EQ(lost_resource, | 2350 EXPECT_EQ(lost_resource, |
2337 GetParam() == ResourceProvider::RESOURCE_TYPE_GL_TEXTURE); | 2351 GetParam() == ResourceProvider::RESOURCE_TYPE_GL_TEXTURE); |
2338 } | 2352 } |
2339 | 2353 |
2340 TEST_P(ResourceProviderTest, LostMailboxInGrandParent) { | 2354 TEST_P(ResourceProviderTest, LostMailboxInGrandParent) { |
2341 uint32 release_sync_point = 0; | 2355 gpu::SyncToken release_sync_token; |
2342 bool lost_resource = false; | 2356 bool lost_resource = false; |
2343 bool release_called = false; | 2357 bool release_called = false; |
2344 uint32 sync_point = 0; | 2358 gpu::SyncToken sync_token; |
2345 ResourceId resource = CreateChildMailbox(&release_sync_point, &lost_resource, | 2359 ResourceId resource = CreateChildMailbox(&release_sync_token, &lost_resource, |
2346 &release_called, &sync_point); | 2360 &release_called, &sync_token); |
2347 | 2361 |
2348 ReturnedResourceArray returned_to_child; | 2362 ReturnedResourceArray returned_to_child; |
2349 int child_id = | 2363 int child_id = |
2350 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); | 2364 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); |
2351 { | 2365 { |
2352 // Transfer the resource to the parent. | 2366 // Transfer the resource to the parent. |
2353 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 2367 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
2354 resource_ids_to_transfer.push_back(resource); | 2368 resource_ids_to_transfer.push_back(resource); |
2355 TransferableResourceArray list; | 2369 TransferableResourceArray list; |
2356 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, | 2370 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2401 child_resource_provider_->ReceiveReturnsFromParent(returned_to_child); | 2415 child_resource_provider_->ReceiveReturnsFromParent(returned_to_child); |
2402 returned_to_child.clear(); | 2416 returned_to_child.clear(); |
2403 } | 2417 } |
2404 | 2418 |
2405 // Delete the resource in the child. Expect the resource to be lost. | 2419 // Delete the resource in the child. Expect the resource to be lost. |
2406 child_resource_provider_->DeleteResource(resource); | 2420 child_resource_provider_->DeleteResource(resource); |
2407 EXPECT_TRUE(lost_resource); | 2421 EXPECT_TRUE(lost_resource); |
2408 } | 2422 } |
2409 | 2423 |
2410 TEST_P(ResourceProviderTest, Shutdown) { | 2424 TEST_P(ResourceProviderTest, Shutdown) { |
2411 uint32 release_sync_point = 0; | 2425 gpu::SyncToken release_sync_token; |
2412 bool lost_resource = false; | 2426 bool lost_resource = false; |
2413 bool release_called = false; | 2427 bool release_called = false; |
2414 uint32 sync_point = 0; | 2428 gpu::SyncToken sync_token; |
2415 CreateChildMailbox( | 2429 CreateChildMailbox(&release_sync_token, &lost_resource, &release_called, |
2416 &release_sync_point, &lost_resource, &release_called, &sync_point); | 2430 &sync_token); |
2417 | 2431 |
2418 EXPECT_EQ(0u, release_sync_point); | 2432 EXPECT_FALSE(release_sync_token.HasData()); |
2419 EXPECT_FALSE(lost_resource); | 2433 EXPECT_FALSE(lost_resource); |
2420 | 2434 |
2421 child_resource_provider_ = nullptr; | 2435 child_resource_provider_ = nullptr; |
2422 | 2436 |
2423 if (GetParam() == ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) { | 2437 if (GetParam() == ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) { |
2424 EXPECT_LE(sync_point, release_sync_point); | 2438 EXPECT_LE(sync_token.release_count(), release_sync_token.release_count()); |
2425 } | 2439 } |
2426 EXPECT_TRUE(release_called); | 2440 EXPECT_TRUE(release_called); |
2427 EXPECT_FALSE(lost_resource); | 2441 EXPECT_FALSE(lost_resource); |
2428 } | 2442 } |
2429 | 2443 |
2430 TEST_P(ResourceProviderTest, ShutdownWithExportedResource) { | 2444 TEST_P(ResourceProviderTest, ShutdownWithExportedResource) { |
2431 uint32 release_sync_point = 0; | 2445 gpu::SyncToken release_sync_token; |
2432 bool lost_resource = false; | 2446 bool lost_resource = false; |
2433 bool release_called = false; | 2447 bool release_called = false; |
2434 uint32 sync_point = 0; | 2448 gpu::SyncToken sync_token; |
2435 ResourceId resource = CreateChildMailbox(&release_sync_point, &lost_resource, | 2449 ResourceId resource = CreateChildMailbox(&release_sync_token, &lost_resource, |
2436 &release_called, &sync_point); | 2450 &release_called, &sync_token); |
2437 | 2451 |
2438 // Transfer the resource, so we can't release it properly on shutdown. | 2452 // Transfer the resource, so we can't release it properly on shutdown. |
2439 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 2453 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
2440 resource_ids_to_transfer.push_back(resource); | 2454 resource_ids_to_transfer.push_back(resource); |
2441 TransferableResourceArray list; | 2455 TransferableResourceArray list; |
2442 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, | 2456 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, |
2443 &list); | 2457 &list); |
2444 | 2458 |
2445 EXPECT_EQ(0u, release_sync_point); | 2459 EXPECT_FALSE(release_sync_token.HasData()); |
2446 EXPECT_FALSE(lost_resource); | 2460 EXPECT_FALSE(lost_resource); |
2447 | 2461 |
2448 child_resource_provider_ = nullptr; | 2462 child_resource_provider_ = nullptr; |
2449 | 2463 |
2450 // Since the resource is in the parent, the child considers it lost. | 2464 // Since the resource is in the parent, the child considers it lost. |
2451 EXPECT_EQ(0u, release_sync_point); | 2465 EXPECT_FALSE(release_sync_token.HasData()); |
2452 EXPECT_TRUE(lost_resource); | 2466 EXPECT_TRUE(lost_resource); |
2453 } | 2467 } |
2454 | 2468 |
2455 TEST_P(ResourceProviderTest, LostContext) { | 2469 TEST_P(ResourceProviderTest, LostContext) { |
2456 // TextureMailbox callbacks only exist for GL textures for now. | 2470 // TextureMailbox callbacks only exist for GL textures for now. |
2457 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) | 2471 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) |
2458 return; | 2472 return; |
2459 unsigned texture = context()->createTexture(); | 2473 unsigned texture = context()->createTexture(); |
2460 context()->bindTexture(GL_TEXTURE_2D, texture); | 2474 context()->bindTexture(GL_TEXTURE_2D, texture); |
2461 gpu::Mailbox mailbox; | 2475 gpu::Mailbox mailbox; |
2462 context()->genMailboxCHROMIUM(mailbox.name); | 2476 context()->genMailboxCHROMIUM(mailbox.name); |
2463 context()->produceTextureDirectCHROMIUM(texture, GL_TEXTURE_2D, mailbox.name); | 2477 context()->produceTextureDirectCHROMIUM(texture, GL_TEXTURE_2D, mailbox.name); |
2464 uint32 sync_point = context()->insertSyncPoint(); | 2478 gpu::SyncToken sync_token(context()->insertSyncPoint()); |
2465 | 2479 |
2466 EXPECT_LT(0u, sync_point); | 2480 EXPECT_LT(0u, sync_token.release_count()); |
2467 | 2481 |
2468 uint32 release_sync_point = 0; | 2482 gpu::SyncToken release_sync_token; |
2469 bool lost_resource = false; | 2483 bool lost_resource = false; |
2470 BlockingTaskRunner* main_thread_task_runner = NULL; | 2484 BlockingTaskRunner* main_thread_task_runner = NULL; |
2471 scoped_ptr<SingleReleaseCallbackImpl> callback = | 2485 scoped_ptr<SingleReleaseCallbackImpl> callback = |
2472 SingleReleaseCallbackImpl::Create(base::Bind(ReleaseCallback, | 2486 SingleReleaseCallbackImpl::Create( |
2473 &release_sync_point, | 2487 base::Bind(ReleaseCallback, &release_sync_token, &lost_resource, |
2474 &lost_resource, | 2488 &main_thread_task_runner)); |
2475 &main_thread_task_runner)); | |
2476 resource_provider_->CreateResourceFromTextureMailbox( | 2489 resource_provider_->CreateResourceFromTextureMailbox( |
2477 TextureMailbox(mailbox, GL_TEXTURE_2D, sync_point), callback.Pass()); | 2490 TextureMailbox(mailbox, sync_token, GL_TEXTURE_2D), callback.Pass()); |
2478 | 2491 |
2479 EXPECT_EQ(0u, release_sync_point); | 2492 EXPECT_FALSE(release_sync_token.HasData()); |
2480 EXPECT_FALSE(lost_resource); | 2493 EXPECT_FALSE(lost_resource); |
2481 EXPECT_EQ(NULL, main_thread_task_runner); | 2494 EXPECT_EQ(NULL, main_thread_task_runner); |
2482 | 2495 |
2483 resource_provider_->DidLoseOutputSurface(); | 2496 resource_provider_->DidLoseOutputSurface(); |
2484 resource_provider_ = nullptr; | 2497 resource_provider_ = nullptr; |
2485 | 2498 |
2486 EXPECT_LE(sync_point, release_sync_point); | 2499 EXPECT_LE(sync_token.release_count(), release_sync_token.release_count()); |
2487 EXPECT_TRUE(lost_resource); | 2500 EXPECT_TRUE(lost_resource); |
2488 EXPECT_EQ(main_thread_task_runner_.get(), main_thread_task_runner); | 2501 EXPECT_EQ(main_thread_task_runner_.get(), main_thread_task_runner); |
2489 } | 2502 } |
2490 | 2503 |
2491 TEST_P(ResourceProviderTest, ScopedSampler) { | 2504 TEST_P(ResourceProviderTest, ScopedSampler) { |
2492 // Sampling is only supported for GL textures. | 2505 // Sampling is only supported for GL textures. |
2493 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) | 2506 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) |
2494 return; | 2507 return; |
2495 | 2508 |
2496 scoped_ptr<TextureStateTrackingContext> context_owned( | 2509 scoped_ptr<TextureStateTrackingContext> context_owned( |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2725 scoped_ptr<OutputSurface> output_surface( | 2738 scoped_ptr<OutputSurface> output_surface( |
2726 FakeOutputSurface::CreateSoftware(make_scoped_ptr( | 2739 FakeOutputSurface::CreateSoftware(make_scoped_ptr( |
2727 new SoftwareOutputDevice))); | 2740 new SoftwareOutputDevice))); |
2728 CHECK(output_surface->BindToClient(&output_surface_client)); | 2741 CHECK(output_surface->BindToClient(&output_surface_client)); |
2729 | 2742 |
2730 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( | 2743 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
2731 output_surface.get(), shared_bitmap_manager_.get(), | 2744 output_surface.get(), shared_bitmap_manager_.get(), |
2732 gpu_memory_buffer_manager_.get(), main_thread_task_runner_.get(), 0, 1, | 2745 gpu_memory_buffer_manager_.get(), main_thread_task_runner_.get(), 0, 1, |
2733 use_image_texture_targets_)); | 2746 use_image_texture_targets_)); |
2734 | 2747 |
2735 uint32 release_sync_point = 0; | 2748 gpu::SyncToken release_sync_token; |
2736 bool lost_resource = false; | 2749 bool lost_resource = false; |
2737 BlockingTaskRunner* main_thread_task_runner = NULL; | 2750 BlockingTaskRunner* main_thread_task_runner = NULL; |
2738 scoped_ptr<SingleReleaseCallbackImpl> callback = | 2751 scoped_ptr<SingleReleaseCallbackImpl> callback = |
2739 SingleReleaseCallbackImpl::Create(base::Bind(&ReleaseCallback, | 2752 SingleReleaseCallbackImpl::Create( |
2740 &release_sync_point, | 2753 base::Bind(&ReleaseCallback, &release_sync_token, &lost_resource, |
2741 &lost_resource, | 2754 &main_thread_task_runner)); |
2742 &main_thread_task_runner)); | |
2743 TextureMailbox mailbox(shared_bitmap.get(), size); | 2755 TextureMailbox mailbox(shared_bitmap.get(), size); |
2744 | 2756 |
2745 ResourceId id = resource_provider->CreateResourceFromTextureMailbox( | 2757 ResourceId id = resource_provider->CreateResourceFromTextureMailbox( |
2746 mailbox, callback.Pass()); | 2758 mailbox, callback.Pass()); |
2747 EXPECT_NE(0u, id); | 2759 EXPECT_NE(0u, id); |
2748 | 2760 |
2749 { | 2761 { |
2750 ResourceProvider::ScopedReadLockSoftware lock(resource_provider.get(), id); | 2762 ResourceProvider::ScopedReadLockSoftware lock(resource_provider.get(), id); |
2751 const SkBitmap* sk_bitmap = lock.sk_bitmap(); | 2763 const SkBitmap* sk_bitmap = lock.sk_bitmap(); |
2752 EXPECT_EQ(sk_bitmap->width(), size.width()); | 2764 EXPECT_EQ(sk_bitmap->width(), size.width()); |
2753 EXPECT_EQ(sk_bitmap->height(), size.height()); | 2765 EXPECT_EQ(sk_bitmap->height(), size.height()); |
2754 EXPECT_EQ(*sk_bitmap->getAddr32(16, 16), kBadBeef); | 2766 EXPECT_EQ(*sk_bitmap->getAddr32(16, 16), kBadBeef); |
2755 } | 2767 } |
2756 | 2768 |
2757 resource_provider->DeleteResource(id); | 2769 resource_provider->DeleteResource(id); |
2758 EXPECT_EQ(0u, release_sync_point); | 2770 EXPECT_FALSE(release_sync_token.HasData()); |
2759 EXPECT_FALSE(lost_resource); | 2771 EXPECT_FALSE(lost_resource); |
2760 EXPECT_EQ(main_thread_task_runner_.get(), main_thread_task_runner); | 2772 EXPECT_EQ(main_thread_task_runner_.get(), main_thread_task_runner); |
2761 } | 2773 } |
2762 | 2774 |
2763 class ResourceProviderTestTextureMailboxGLFilters | 2775 class ResourceProviderTestTextureMailboxGLFilters |
2764 : public ResourceProviderTest { | 2776 : public ResourceProviderTest { |
2765 public: | 2777 public: |
2766 static void RunTest(TestSharedBitmapManager* shared_bitmap_manager, | 2778 static void RunTest(TestSharedBitmapManager* shared_bitmap_manager, |
2767 TestGpuMemoryBufferManager* gpu_memory_buffer_manager, | 2779 TestGpuMemoryBufferManager* gpu_memory_buffer_manager, |
2768 BlockingTaskRunner* main_thread_task_runner, | 2780 BlockingTaskRunner* main_thread_task_runner, |
2769 bool mailbox_nearest_neighbor, | 2781 bool mailbox_nearest_neighbor, |
2770 GLenum sampler_filter) { | 2782 GLenum sampler_filter) { |
2771 scoped_ptr<TextureStateTrackingContext> context_owned( | 2783 scoped_ptr<TextureStateTrackingContext> context_owned( |
2772 new TextureStateTrackingContext); | 2784 new TextureStateTrackingContext); |
2773 TextureStateTrackingContext* context = context_owned.get(); | 2785 TextureStateTrackingContext* context = context_owned.get(); |
2774 | 2786 |
2775 FakeOutputSurfaceClient output_surface_client; | 2787 FakeOutputSurfaceClient output_surface_client; |
2776 scoped_ptr<OutputSurface> output_surface( | 2788 scoped_ptr<OutputSurface> output_surface( |
2777 FakeOutputSurface::Create3d(context_owned.Pass())); | 2789 FakeOutputSurface::Create3d(context_owned.Pass())); |
2778 CHECK(output_surface->BindToClient(&output_surface_client)); | 2790 CHECK(output_surface->BindToClient(&output_surface_client)); |
2779 | 2791 |
2780 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( | 2792 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
2781 output_surface.get(), shared_bitmap_manager, gpu_memory_buffer_manager, | 2793 output_surface.get(), shared_bitmap_manager, gpu_memory_buffer_manager, |
2782 main_thread_task_runner, 0, 1, use_image_texture_targets_)); | 2794 main_thread_task_runner, 0, 1, use_image_texture_targets_)); |
2783 | 2795 |
2784 unsigned texture_id = 1; | 2796 unsigned texture_id = 1; |
2785 uint32 sync_point = 30; | 2797 gpu::SyncToken sync_token(30); |
2786 unsigned target = GL_TEXTURE_2D; | 2798 unsigned target = GL_TEXTURE_2D; |
2787 | 2799 |
2788 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); | 2800 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); |
2789 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); | 2801 EXPECT_CALL(*context, waitSyncToken(_)).Times(0); |
2790 EXPECT_CALL(*context, insertSyncPoint()).Times(0); | 2802 EXPECT_CALL(*context, insertSyncPoint()).Times(0); |
2791 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); | 2803 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); |
2792 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); | 2804 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); |
2793 | 2805 |
2794 gpu::Mailbox gpu_mailbox; | 2806 gpu::Mailbox gpu_mailbox; |
2795 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1); | 2807 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1); |
2796 uint32 release_sync_point = 0; | 2808 gpu::SyncToken release_sync_token; |
2797 bool lost_resource = false; | 2809 bool lost_resource = false; |
2798 BlockingTaskRunner* mailbox_task_runner = NULL; | 2810 BlockingTaskRunner* mailbox_task_runner = NULL; |
2799 scoped_ptr<SingleReleaseCallbackImpl> callback = | 2811 scoped_ptr<SingleReleaseCallbackImpl> callback = |
2800 SingleReleaseCallbackImpl::Create(base::Bind(&ReleaseCallback, | 2812 SingleReleaseCallbackImpl::Create( |
2801 &release_sync_point, | 2813 base::Bind(&ReleaseCallback, &release_sync_token, &lost_resource, |
2802 &lost_resource, | 2814 &mailbox_task_runner)); |
2803 &mailbox_task_runner)); | |
2804 | 2815 |
2805 TextureMailbox mailbox(gpu_mailbox, target, sync_point); | 2816 TextureMailbox mailbox(gpu_mailbox, sync_token, target); |
2806 mailbox.set_nearest_neighbor(mailbox_nearest_neighbor); | 2817 mailbox.set_nearest_neighbor(mailbox_nearest_neighbor); |
2807 | 2818 |
2808 ResourceId id = resource_provider->CreateResourceFromTextureMailbox( | 2819 ResourceId id = resource_provider->CreateResourceFromTextureMailbox( |
2809 mailbox, callback.Pass()); | 2820 mailbox, callback.Pass()); |
2810 EXPECT_NE(0u, id); | 2821 EXPECT_NE(0u, id); |
2811 | 2822 |
2812 Mock::VerifyAndClearExpectations(context); | 2823 Mock::VerifyAndClearExpectations(context); |
2813 | 2824 |
2814 { | 2825 { |
2815 // Mailbox sync point WaitSyncPoint before using the texture. | 2826 // Mailbox sync point WaitSyncToken before using the texture. |
2816 EXPECT_CALL(*context, waitSyncPoint(sync_point)); | 2827 EXPECT_CALL(*context, waitSyncToken(sync_token.GetConstData())); |
2817 resource_provider->WaitSyncPointIfNeeded(id); | 2828 resource_provider->WaitSyncTokenIfNeeded(id); |
2818 Mock::VerifyAndClearExpectations(context); | 2829 Mock::VerifyAndClearExpectations(context); |
2819 | 2830 |
2820 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(target, _)) | 2831 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(target, _)) |
2821 .WillOnce(Return(texture_id)); | 2832 .WillOnce(Return(texture_id)); |
2822 EXPECT_CALL(*context, bindTexture(target, texture_id)); | 2833 EXPECT_CALL(*context, bindTexture(target, texture_id)); |
2823 | 2834 |
2824 EXPECT_CALL(*context, insertSyncPoint()).Times(0); | 2835 EXPECT_CALL(*context, insertSyncPoint()).Times(0); |
2825 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); | 2836 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); |
2826 | 2837 |
2827 // The sampler will reset these if |mailbox_nearest_neighbor| does not | 2838 // The sampler will reset these if |mailbox_nearest_neighbor| does not |
2828 // match |sampler_filter|. | 2839 // match |sampler_filter|. |
2829 if (mailbox_nearest_neighbor != (sampler_filter == GL_NEAREST)) { | 2840 if (mailbox_nearest_neighbor != (sampler_filter == GL_NEAREST)) { |
2830 EXPECT_CALL(*context, texParameteri( | 2841 EXPECT_CALL(*context, texParameteri( |
2831 GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, sampler_filter)); | 2842 GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, sampler_filter)); |
2832 EXPECT_CALL(*context, texParameteri( | 2843 EXPECT_CALL(*context, texParameteri( |
2833 GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, sampler_filter)); | 2844 GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, sampler_filter)); |
2834 } | 2845 } |
2835 | 2846 |
2836 ResourceProvider::ScopedSamplerGL lock( | 2847 ResourceProvider::ScopedSamplerGL lock( |
2837 resource_provider.get(), id, sampler_filter); | 2848 resource_provider.get(), id, sampler_filter); |
2838 Mock::VerifyAndClearExpectations(context); | 2849 Mock::VerifyAndClearExpectations(context); |
2839 | 2850 |
2840 // When done with it, a sync point should be inserted, but no produce is | 2851 // When done with it, a sync point should be inserted, but no produce is |
2841 // necessary. | 2852 // necessary. |
2842 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); | 2853 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); |
2843 EXPECT_CALL(*context, insertSyncPoint()); | 2854 EXPECT_CALL(*context, insertSyncPoint()); |
2844 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); | 2855 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); |
2845 | 2856 |
2846 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); | 2857 EXPECT_CALL(*context, waitSyncToken(_)).Times(0); |
2847 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); | 2858 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); |
2848 } | 2859 } |
2849 | 2860 |
2850 resource_provider->DeleteResource(id); | 2861 resource_provider->DeleteResource(id); |
2851 EXPECT_EQ(0u, release_sync_point); | 2862 EXPECT_FALSE(release_sync_token.HasData()); |
2852 EXPECT_FALSE(lost_resource); | 2863 EXPECT_FALSE(lost_resource); |
2853 EXPECT_EQ(main_thread_task_runner, mailbox_task_runner); | 2864 EXPECT_EQ(main_thread_task_runner, mailbox_task_runner); |
2854 } | 2865 } |
2855 }; | 2866 }; |
2856 | 2867 |
2857 TEST_P(ResourceProviderTest, TextureMailbox_GLTexture2D_LinearToLinear) { | 2868 TEST_P(ResourceProviderTest, TextureMailbox_GLTexture2D_LinearToLinear) { |
2858 // Mailboxing is only supported for GL textures. | 2869 // Mailboxing is only supported for GL textures. |
2859 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) | 2870 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) |
2860 return; | 2871 return; |
2861 | 2872 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2918 FakeOutputSurfaceClient output_surface_client; | 2929 FakeOutputSurfaceClient output_surface_client; |
2919 scoped_ptr<OutputSurface> output_surface( | 2930 scoped_ptr<OutputSurface> output_surface( |
2920 FakeOutputSurface::Create3d(context_owned.Pass())); | 2931 FakeOutputSurface::Create3d(context_owned.Pass())); |
2921 CHECK(output_surface->BindToClient(&output_surface_client)); | 2932 CHECK(output_surface->BindToClient(&output_surface_client)); |
2922 | 2933 |
2923 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( | 2934 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
2924 output_surface.get(), shared_bitmap_manager_.get(), | 2935 output_surface.get(), shared_bitmap_manager_.get(), |
2925 gpu_memory_buffer_manager_.get(), NULL, 0, 1, | 2936 gpu_memory_buffer_manager_.get(), NULL, 0, 1, |
2926 use_image_texture_targets_)); | 2937 use_image_texture_targets_)); |
2927 | 2938 |
2928 uint32 sync_point = 30; | 2939 gpu::SyncToken sync_token(30); |
2929 unsigned target = GL_TEXTURE_EXTERNAL_OES; | 2940 unsigned target = GL_TEXTURE_EXTERNAL_OES; |
2930 | 2941 |
2931 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); | 2942 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); |
2932 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); | 2943 EXPECT_CALL(*context, waitSyncToken(_)).Times(0); |
2933 EXPECT_CALL(*context, insertSyncPoint()).Times(0); | 2944 EXPECT_CALL(*context, insertSyncPoint()).Times(0); |
2934 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); | 2945 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); |
2935 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); | 2946 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); |
2936 | 2947 |
2937 gpu::Mailbox gpu_mailbox; | 2948 gpu::Mailbox gpu_mailbox; |
2938 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1); | 2949 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1); |
2939 scoped_ptr<SingleReleaseCallbackImpl> callback = | 2950 scoped_ptr<SingleReleaseCallbackImpl> callback = |
2940 SingleReleaseCallbackImpl::Create(base::Bind(&EmptyReleaseCallback)); | 2951 SingleReleaseCallbackImpl::Create(base::Bind(&EmptyReleaseCallback)); |
2941 | 2952 |
2942 TextureMailbox mailbox(gpu_mailbox, target, sync_point); | 2953 TextureMailbox mailbox(gpu_mailbox, sync_token, target); |
2943 | 2954 |
2944 ResourceId id = resource_provider->CreateResourceFromTextureMailbox( | 2955 ResourceId id = resource_provider->CreateResourceFromTextureMailbox( |
2945 mailbox, callback.Pass()); | 2956 mailbox, callback.Pass()); |
2946 EXPECT_NE(0u, id); | 2957 EXPECT_NE(0u, id); |
2947 | 2958 |
2948 Mock::VerifyAndClearExpectations(context); | 2959 Mock::VerifyAndClearExpectations(context); |
2949 | 2960 |
2950 { | 2961 { |
2951 // Mailbox sync point WaitSyncPoint before using the texture. | 2962 // Mailbox sync point WaitSyncToken before using the texture. |
2952 EXPECT_CALL(*context, waitSyncPoint(sync_point)); | 2963 EXPECT_CALL(*context, waitSyncToken(sync_token.GetConstData())); |
2953 resource_provider->WaitSyncPointIfNeeded(id); | 2964 resource_provider->WaitSyncTokenIfNeeded(id); |
2954 Mock::VerifyAndClearExpectations(context); | 2965 Mock::VerifyAndClearExpectations(context); |
2955 | 2966 |
2956 unsigned texture_id = 1; | 2967 unsigned texture_id = 1; |
2957 | 2968 |
2958 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(target, _)) | 2969 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(target, _)) |
2959 .WillOnce(Return(texture_id)); | 2970 .WillOnce(Return(texture_id)); |
2960 | 2971 |
2961 EXPECT_CALL(*context, insertSyncPoint()).Times(0); | 2972 EXPECT_CALL(*context, insertSyncPoint()).Times(0); |
2962 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); | 2973 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); |
2963 | 2974 |
2964 ResourceProvider::ScopedReadLockGL lock(resource_provider.get(), id); | 2975 ResourceProvider::ScopedReadLockGL lock(resource_provider.get(), id); |
2965 Mock::VerifyAndClearExpectations(context); | 2976 Mock::VerifyAndClearExpectations(context); |
2966 | 2977 |
2967 // When done with it, a sync point should be inserted, but no produce is | 2978 // When done with it, a sync point should be inserted, but no produce is |
2968 // necessary. | 2979 // necessary. |
2969 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); | 2980 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); |
2970 EXPECT_CALL(*context, insertSyncPoint()); | 2981 EXPECT_CALL(*context, insertSyncPoint()); |
2971 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); | 2982 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); |
2972 | 2983 |
2973 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); | 2984 EXPECT_CALL(*context, waitSyncToken(_)).Times(0); |
2974 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); | 2985 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); |
2975 } | 2986 } |
2976 } | 2987 } |
2977 | 2988 |
2978 TEST_P(ResourceProviderTest, | 2989 TEST_P(ResourceProviderTest, |
2979 TextureMailbox_WaitSyncPointIfNeeded_WithSyncPoint) { | 2990 TextureMailbox_WaitSyncTokenIfNeeded_WithSyncToken) { |
2980 // Mailboxing is only supported for GL textures. | 2991 // Mailboxing is only supported for GL textures. |
2981 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) | 2992 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) |
2982 return; | 2993 return; |
2983 | 2994 |
2984 scoped_ptr<TextureStateTrackingContext> context_owned( | 2995 scoped_ptr<TextureStateTrackingContext> context_owned( |
2985 new TextureStateTrackingContext); | 2996 new TextureStateTrackingContext); |
2986 TextureStateTrackingContext* context = context_owned.get(); | 2997 TextureStateTrackingContext* context = context_owned.get(); |
2987 | 2998 |
2988 FakeOutputSurfaceClient output_surface_client; | 2999 FakeOutputSurfaceClient output_surface_client; |
2989 scoped_ptr<OutputSurface> output_surface( | 3000 scoped_ptr<OutputSurface> output_surface( |
2990 FakeOutputSurface::Create3d(context_owned.Pass())); | 3001 FakeOutputSurface::Create3d(context_owned.Pass())); |
2991 CHECK(output_surface->BindToClient(&output_surface_client)); | 3002 CHECK(output_surface->BindToClient(&output_surface_client)); |
2992 | 3003 |
2993 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( | 3004 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
2994 output_surface.get(), shared_bitmap_manager_.get(), | 3005 output_surface.get(), shared_bitmap_manager_.get(), |
2995 gpu_memory_buffer_manager_.get(), NULL, 0, 1, | 3006 gpu_memory_buffer_manager_.get(), NULL, 0, 1, |
2996 use_image_texture_targets_)); | 3007 use_image_texture_targets_)); |
2997 | 3008 |
2998 uint32 sync_point = 30; | 3009 gpu::SyncToken sync_token(30); |
2999 unsigned target = GL_TEXTURE_2D; | 3010 unsigned target = GL_TEXTURE_2D; |
3000 | 3011 |
3001 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); | 3012 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); |
3002 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); | 3013 EXPECT_CALL(*context, waitSyncToken(_)).Times(0); |
3003 EXPECT_CALL(*context, insertSyncPoint()).Times(0); | 3014 EXPECT_CALL(*context, insertSyncPoint()).Times(0); |
3004 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); | 3015 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); |
3005 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); | 3016 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); |
3006 | 3017 |
3007 gpu::Mailbox gpu_mailbox; | 3018 gpu::Mailbox gpu_mailbox; |
3008 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1); | 3019 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1); |
3009 scoped_ptr<SingleReleaseCallbackImpl> callback = | 3020 scoped_ptr<SingleReleaseCallbackImpl> callback = |
3010 SingleReleaseCallbackImpl::Create(base::Bind(&EmptyReleaseCallback)); | 3021 SingleReleaseCallbackImpl::Create(base::Bind(&EmptyReleaseCallback)); |
3011 | 3022 |
3012 TextureMailbox mailbox(gpu_mailbox, target, sync_point); | 3023 TextureMailbox mailbox(gpu_mailbox, sync_token, target); |
3013 | 3024 |
3014 ResourceId id = resource_provider->CreateResourceFromTextureMailbox( | 3025 ResourceId id = resource_provider->CreateResourceFromTextureMailbox( |
3015 mailbox, callback.Pass()); | 3026 mailbox, callback.Pass()); |
3016 EXPECT_NE(0u, id); | 3027 EXPECT_NE(0u, id); |
3017 | 3028 |
3018 Mock::VerifyAndClearExpectations(context); | 3029 Mock::VerifyAndClearExpectations(context); |
3019 | 3030 |
3020 { | 3031 { |
3021 // First call to WaitSyncPointIfNeeded should call waitSyncPoint. | 3032 // First call to WaitSyncTokenIfNeeded should call waitSyncToken. |
3022 EXPECT_CALL(*context, waitSyncPoint(sync_point)); | 3033 EXPECT_CALL(*context, waitSyncToken(sync_token.GetConstData())); |
3023 resource_provider->WaitSyncPointIfNeeded(id); | 3034 resource_provider->WaitSyncTokenIfNeeded(id); |
3024 Mock::VerifyAndClearExpectations(context); | 3035 Mock::VerifyAndClearExpectations(context); |
3025 | 3036 |
3026 // Subsequent calls to WaitSyncPointIfNeeded shouldn't call waitSyncPoint. | 3037 // Subsequent calls to WaitSyncTokenIfNeeded shouldn't call waitSyncToken. |
3027 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); | 3038 EXPECT_CALL(*context, waitSyncToken(_)).Times(0); |
3028 resource_provider->WaitSyncPointIfNeeded(id); | 3039 resource_provider->WaitSyncTokenIfNeeded(id); |
3029 Mock::VerifyAndClearExpectations(context); | 3040 Mock::VerifyAndClearExpectations(context); |
3030 } | 3041 } |
3031 } | 3042 } |
3032 | 3043 |
3033 TEST_P(ResourceProviderTest, TextureMailbox_WaitSyncPointIfNeeded_NoSyncPoint) { | 3044 TEST_P(ResourceProviderTest, TextureMailbox_WaitSyncTokenIfNeeded_NoSyncToken) { |
3034 // Mailboxing is only supported for GL textures. | 3045 // Mailboxing is only supported for GL textures. |
3035 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) | 3046 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) |
3036 return; | 3047 return; |
3037 | 3048 |
3038 scoped_ptr<TextureStateTrackingContext> context_owned( | 3049 scoped_ptr<TextureStateTrackingContext> context_owned( |
3039 new TextureStateTrackingContext); | 3050 new TextureStateTrackingContext); |
3040 TextureStateTrackingContext* context = context_owned.get(); | 3051 TextureStateTrackingContext* context = context_owned.get(); |
3041 | 3052 |
3042 FakeOutputSurfaceClient output_surface_client; | 3053 FakeOutputSurfaceClient output_surface_client; |
3043 scoped_ptr<OutputSurface> output_surface( | 3054 scoped_ptr<OutputSurface> output_surface( |
3044 FakeOutputSurface::Create3d(context_owned.Pass())); | 3055 FakeOutputSurface::Create3d(context_owned.Pass())); |
3045 CHECK(output_surface->BindToClient(&output_surface_client)); | 3056 CHECK(output_surface->BindToClient(&output_surface_client)); |
3046 | 3057 |
3047 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( | 3058 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
3048 output_surface.get(), shared_bitmap_manager_.get(), | 3059 output_surface.get(), shared_bitmap_manager_.get(), |
3049 gpu_memory_buffer_manager_.get(), NULL, 0, 1, | 3060 gpu_memory_buffer_manager_.get(), NULL, 0, 1, |
3050 use_image_texture_targets_)); | 3061 use_image_texture_targets_)); |
3051 | 3062 |
3052 uint32 sync_point = 0; | 3063 gpu::SyncToken sync_token; |
3053 unsigned target = GL_TEXTURE_2D; | 3064 unsigned target = GL_TEXTURE_2D; |
3054 | 3065 |
3055 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); | 3066 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); |
3056 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); | 3067 EXPECT_CALL(*context, waitSyncToken(_)).Times(0); |
3057 EXPECT_CALL(*context, insertSyncPoint()).Times(0); | 3068 EXPECT_CALL(*context, insertSyncPoint()).Times(0); |
3058 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); | 3069 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); |
3059 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); | 3070 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); |
3060 | 3071 |
3061 gpu::Mailbox gpu_mailbox; | 3072 gpu::Mailbox gpu_mailbox; |
3062 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1); | 3073 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1); |
3063 scoped_ptr<SingleReleaseCallbackImpl> callback = | 3074 scoped_ptr<SingleReleaseCallbackImpl> callback = |
3064 SingleReleaseCallbackImpl::Create(base::Bind(&EmptyReleaseCallback)); | 3075 SingleReleaseCallbackImpl::Create(base::Bind(&EmptyReleaseCallback)); |
3065 | 3076 |
3066 TextureMailbox mailbox(gpu_mailbox, target, sync_point); | 3077 TextureMailbox mailbox(gpu_mailbox, sync_token, target); |
3067 | 3078 |
3068 ResourceId id = resource_provider->CreateResourceFromTextureMailbox( | 3079 ResourceId id = resource_provider->CreateResourceFromTextureMailbox( |
3069 mailbox, callback.Pass()); | 3080 mailbox, callback.Pass()); |
3070 EXPECT_NE(0u, id); | 3081 EXPECT_NE(0u, id); |
3071 | 3082 |
3072 Mock::VerifyAndClearExpectations(context); | 3083 Mock::VerifyAndClearExpectations(context); |
3073 | 3084 |
3074 { | 3085 { |
3075 // WaitSyncPointIfNeeded with sync_point == 0 shouldn't call waitSyncPoint. | 3086 // WaitSyncTokenIfNeeded with empty sync_token shouldn't call waitSyncToken. |
3076 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); | 3087 EXPECT_CALL(*context, waitSyncToken(_)).Times(0); |
3077 resource_provider->WaitSyncPointIfNeeded(id); | 3088 resource_provider->WaitSyncTokenIfNeeded(id); |
3078 Mock::VerifyAndClearExpectations(context); | 3089 Mock::VerifyAndClearExpectations(context); |
3079 } | 3090 } |
3080 } | 3091 } |
3081 | 3092 |
3082 class AllocationTrackingContext3D : public TestWebGraphicsContext3D { | 3093 class AllocationTrackingContext3D : public TestWebGraphicsContext3D { |
3083 public: | 3094 public: |
3084 MOCK_METHOD0(NextTextureId, GLuint()); | 3095 MOCK_METHOD0(NextTextureId, GLuint()); |
3085 MOCK_METHOD1(RetireTextureId, void(GLuint id)); | 3096 MOCK_METHOD1(RetireTextureId, void(GLuint id)); |
3086 MOCK_METHOD2(bindTexture, void(GLenum target, GLuint texture)); | 3097 MOCK_METHOD2(bindTexture, void(GLenum target, GLuint texture)); |
3087 MOCK_METHOD5(texStorage2DEXT, | 3098 MOCK_METHOD5(texStorage2DEXT, |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3529 resource_provider->AllocateForTesting(id); | 3540 resource_provider->AllocateForTesting(id); |
3530 Mock::VerifyAndClearExpectations(context); | 3541 Mock::VerifyAndClearExpectations(context); |
3531 | 3542 |
3532 DCHECK_EQ(10u, context->PeekTextureId()); | 3543 DCHECK_EQ(10u, context->PeekTextureId()); |
3533 resource_provider->DeleteResource(id); | 3544 resource_provider->DeleteResource(id); |
3534 } | 3545 } |
3535 } | 3546 } |
3536 | 3547 |
3537 } // namespace | 3548 } // namespace |
3538 } // namespace cc | 3549 } // namespace cc |
OLD | NEW |