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

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

Issue 1455023002: cc: Replace Pass() with std::move() in some subdirs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pass-cc
Patch Set: pass-cc2: . Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/resources/resource_provider.cc ('k') | cc/resources/video_resource_updater_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/resources/resource_provider.h" 5 #include "cc/resources/resource_provider.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <deque> 8 #include <deque>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 86
87 static scoped_ptr<SharedBitmap> CreateAndFillSharedBitmap( 87 static scoped_ptr<SharedBitmap> CreateAndFillSharedBitmap(
88 SharedBitmapManager* manager, 88 SharedBitmapManager* manager,
89 const gfx::Size& size, 89 const gfx::Size& size,
90 uint32_t value) { 90 uint32_t value) {
91 scoped_ptr<SharedBitmap> shared_bitmap = manager->AllocateSharedBitmap(size); 91 scoped_ptr<SharedBitmap> shared_bitmap = manager->AllocateSharedBitmap(size);
92 CHECK(shared_bitmap); 92 CHECK(shared_bitmap);
93 uint32_t* pixels = reinterpret_cast<uint32_t*>(shared_bitmap->pixels()); 93 uint32_t* pixels = reinterpret_cast<uint32_t*>(shared_bitmap->pixels());
94 CHECK(pixels); 94 CHECK(pixels);
95 std::fill_n(pixels, size.GetArea(), value); 95 std::fill_n(pixels, size.GetArea(), value);
96 return shared_bitmap.Pass(); 96 return shared_bitmap;
97 } 97 }
98 98
99 class TextureStateTrackingContext : public TestWebGraphicsContext3D { 99 class TextureStateTrackingContext : public TestWebGraphicsContext3D {
100 public: 100 public:
101 MOCK_METHOD2(bindTexture, void(GLenum target, GLuint texture)); 101 MOCK_METHOD2(bindTexture, void(GLenum target, GLuint texture));
102 MOCK_METHOD3(texParameteri, void(GLenum target, GLenum pname, GLint param)); 102 MOCK_METHOD3(texParameteri, void(GLenum target, GLenum pname, GLint param));
103 MOCK_METHOD1(waitSyncToken, void(const GLbyte* sync_token)); 103 MOCK_METHOD1(waitSyncToken, void(const GLbyte* sync_token));
104 MOCK_METHOD0(insertSyncPoint, GLuint(void)); 104 MOCK_METHOD0(insertSyncPoint, GLuint(void));
105 MOCK_METHOD3(produceTextureDirectCHROMIUM, 105 MOCK_METHOD3(produceTextureDirectCHROMIUM,
106 void(GLuint texture, GLenum target, const GLbyte* mailbox)); 106 void(GLuint texture, GLenum target, const GLbyte* mailbox));
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 void produceTextureDirectCHROMIUM(GLuint texture, 276 void produceTextureDirectCHROMIUM(GLuint texture,
277 GLenum target, 277 GLenum target,
278 const GLbyte* mailbox) override { 278 const GLbyte* mailbox) override {
279 // Delay moving the texture into the mailbox until the next 279 // Delay moving the texture into the mailbox until the next
280 // InsertSyncPoint, so that it is not visible to other contexts that 280 // InsertSyncPoint, so that it is not visible to other contexts that
281 // haven't waited on that sync point. 281 // haven't waited on that sync point.
282 scoped_ptr<PendingProduceTexture> pending(new PendingProduceTexture); 282 scoped_ptr<PendingProduceTexture> pending(new PendingProduceTexture);
283 memcpy(pending->mailbox, mailbox, sizeof(pending->mailbox)); 283 memcpy(pending->mailbox, mailbox, sizeof(pending->mailbox));
284 base::AutoLock lock_for_texture_access(namespace_->lock); 284 base::AutoLock lock_for_texture_access(namespace_->lock);
285 pending->texture = UnboundTexture(texture); 285 pending->texture = UnboundTexture(texture);
286 pending_produce_textures_.push_back(pending.Pass()); 286 pending_produce_textures_.push_back(std::move(pending));
287 } 287 }
288 288
289 GLuint createAndConsumeTextureCHROMIUM(GLenum target, 289 GLuint createAndConsumeTextureCHROMIUM(GLenum target,
290 const GLbyte* mailbox) override { 290 const GLbyte* mailbox) override {
291 GLuint texture_id = createTexture(); 291 GLuint texture_id = createTexture();
292 base::AutoLock lock_for_texture_access(namespace_->lock); 292 base::AutoLock lock_for_texture_access(namespace_->lock);
293 scoped_refptr<TestTexture> texture = 293 scoped_refptr<TestTexture> texture =
294 shared_data_->ConsumeTexture(mailbox, last_waited_sync_token_); 294 shared_data_->ConsumeTexture(mailbox, last_waited_sync_token_);
295 namespace_->textures.Replace(texture_id, texture); 295 namespace_->textures.Replace(texture_id, texture);
296 return texture_id; 296 return texture_id;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 child_context_(NULL), 397 child_context_(NULL),
398 main_thread_task_runner_(BlockingTaskRunner::Create(NULL)) { 398 main_thread_task_runner_(BlockingTaskRunner::Create(NULL)) {
399 switch (GetParam()) { 399 switch (GetParam()) {
400 case ResourceProvider::RESOURCE_TYPE_GPU_MEMORY_BUFFER: 400 case ResourceProvider::RESOURCE_TYPE_GPU_MEMORY_BUFFER:
401 case ResourceProvider::RESOURCE_TYPE_GL_TEXTURE: { 401 case ResourceProvider::RESOURCE_TYPE_GL_TEXTURE: {
402 scoped_ptr<ResourceProviderContext> context3d( 402 scoped_ptr<ResourceProviderContext> context3d(
403 ResourceProviderContext::Create(shared_data_.get())); 403 ResourceProviderContext::Create(shared_data_.get()));
404 context3d_ = context3d.get(); 404 context3d_ = context3d.get();
405 405
406 scoped_refptr<TestContextProvider> context_provider = 406 scoped_refptr<TestContextProvider> context_provider =
407 TestContextProvider::Create(context3d.Pass()); 407 TestContextProvider::Create(std::move(context3d));
408 408
409 output_surface_ = FakeOutputSurface::Create3d(context_provider); 409 output_surface_ = FakeOutputSurface::Create3d(context_provider);
410 410
411 scoped_ptr<ResourceProviderContext> child_context_owned = 411 scoped_ptr<ResourceProviderContext> child_context_owned =
412 ResourceProviderContext::Create(shared_data_.get()); 412 ResourceProviderContext::Create(shared_data_.get());
413 child_context_ = child_context_owned.get(); 413 child_context_ = child_context_owned.get();
414 if (child_needs_sync_token) { 414 if (child_needs_sync_token) {
415 child_output_surface_ = 415 child_output_surface_ =
416 FakeOutputSurface::Create3d(child_context_owned.Pass()); 416 FakeOutputSurface::Create3d(std::move(child_context_owned));
417 } else { 417 } else {
418 child_output_surface_ = FakeOutputSurface::CreateNoRequireSyncPoint( 418 child_output_surface_ = FakeOutputSurface::CreateNoRequireSyncPoint(
419 child_context_owned.Pass()); 419 std::move(child_context_owned));
420 } 420 }
421 break; 421 break;
422 } 422 }
423 case ResourceProvider::RESOURCE_TYPE_BITMAP: 423 case ResourceProvider::RESOURCE_TYPE_BITMAP:
424 output_surface_ = FakeOutputSurface::CreateSoftware( 424 output_surface_ = FakeOutputSurface::CreateSoftware(
425 make_scoped_ptr(new SoftwareOutputDevice)); 425 make_scoped_ptr(new SoftwareOutputDevice));
426 child_output_surface_ = FakeOutputSurface::CreateSoftware( 426 child_output_surface_ = FakeOutputSurface::CreateSoftware(
427 make_scoped_ptr(new SoftwareOutputDevice)); 427 make_scoped_ptr(new SoftwareOutputDevice));
428 break; 428 break;
429 } 429 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 *sync_token = gpu::SyncToken(child_context_->insertSyncPoint()); 477 *sync_token = gpu::SyncToken(child_context_->insertSyncPoint());
478 EXPECT_TRUE(sync_token->HasData()); 478 EXPECT_TRUE(sync_token->HasData());
479 479
480 scoped_ptr<SharedBitmap> shared_bitmap; 480 scoped_ptr<SharedBitmap> shared_bitmap;
481 scoped_ptr<SingleReleaseCallbackImpl> callback = 481 scoped_ptr<SingleReleaseCallbackImpl> callback =
482 SingleReleaseCallbackImpl::Create(base::Bind( 482 SingleReleaseCallbackImpl::Create(base::Bind(
483 ReleaseSharedBitmapCallback, base::Passed(&shared_bitmap), 483 ReleaseSharedBitmapCallback, base::Passed(&shared_bitmap),
484 release_called, release_sync_token, lost_resource)); 484 release_called, release_sync_token, lost_resource));
485 return child_resource_provider_->CreateResourceFromTextureMailbox( 485 return child_resource_provider_->CreateResourceFromTextureMailbox(
486 TextureMailbox(gpu_mailbox, *sync_token, GL_TEXTURE_2D), 486 TextureMailbox(gpu_mailbox, *sync_token, GL_TEXTURE_2D),
487 callback.Pass()); 487 std::move(callback));
488 } else { 488 } else {
489 gfx::Size size(64, 64); 489 gfx::Size size(64, 64);
490 scoped_ptr<SharedBitmap> shared_bitmap( 490 scoped_ptr<SharedBitmap> shared_bitmap(
491 CreateAndFillSharedBitmap(shared_bitmap_manager_.get(), size, 0)); 491 CreateAndFillSharedBitmap(shared_bitmap_manager_.get(), size, 0));
492 492
493 SharedBitmap* shared_bitmap_ptr = shared_bitmap.get(); 493 SharedBitmap* shared_bitmap_ptr = shared_bitmap.get();
494 scoped_ptr<SingleReleaseCallbackImpl> callback = 494 scoped_ptr<SingleReleaseCallbackImpl> callback =
495 SingleReleaseCallbackImpl::Create(base::Bind( 495 SingleReleaseCallbackImpl::Create(base::Bind(
496 ReleaseSharedBitmapCallback, base::Passed(&shared_bitmap), 496 ReleaseSharedBitmapCallback, base::Passed(&shared_bitmap),
497 release_called, release_sync_token, lost_resource)); 497 release_called, release_sync_token, lost_resource));
498 return child_resource_provider_->CreateResourceFromTextureMailbox( 498 return child_resource_provider_->CreateResourceFromTextureMailbox(
499 TextureMailbox(shared_bitmap_ptr, size), callback.Pass()); 499 TextureMailbox(shared_bitmap_ptr, size), std::move(callback));
500 } 500 }
501 } 501 }
502 502
503 public: 503 public:
504 static bool use_gpu_memory_buffer_resources() { 504 static bool use_gpu_memory_buffer_resources() {
505 return use_gpu_memory_buffer_resources_; 505 return use_gpu_memory_buffer_resources_;
506 } 506 }
507 static std::vector<unsigned> use_image_texture_targets() { 507 static std::vector<unsigned> use_image_texture_targets() {
508 return use_image_texture_targets_; 508 return use_image_texture_targets_;
509 } 509 }
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after
1386 1386
1387 TEST_P(ResourceProviderTest, TransferGLToSoftware) { 1387 TEST_P(ResourceProviderTest, TransferGLToSoftware) {
1388 if (GetParam() != ResourceProvider::RESOURCE_TYPE_BITMAP) 1388 if (GetParam() != ResourceProvider::RESOURCE_TYPE_BITMAP)
1389 return; 1389 return;
1390 1390
1391 scoped_ptr<ResourceProviderContext> child_context_owned( 1391 scoped_ptr<ResourceProviderContext> child_context_owned(
1392 ResourceProviderContext::Create(shared_data_.get())); 1392 ResourceProviderContext::Create(shared_data_.get()));
1393 1393
1394 FakeOutputSurfaceClient child_output_surface_client; 1394 FakeOutputSurfaceClient child_output_surface_client;
1395 scoped_ptr<OutputSurface> child_output_surface( 1395 scoped_ptr<OutputSurface> child_output_surface(
1396 FakeOutputSurface::Create3d(child_context_owned.Pass())); 1396 FakeOutputSurface::Create3d(std::move(child_context_owned)));
1397 CHECK(child_output_surface->BindToClient(&child_output_surface_client)); 1397 CHECK(child_output_surface->BindToClient(&child_output_surface_client));
1398 1398
1399 scoped_ptr<ResourceProvider> child_resource_provider(ResourceProvider::Create( 1399 scoped_ptr<ResourceProvider> child_resource_provider(ResourceProvider::Create(
1400 child_output_surface.get(), shared_bitmap_manager_.get(), 1400 child_output_surface.get(), shared_bitmap_manager_.get(),
1401 gpu_memory_buffer_manager_.get(), NULL, 0, 1, 1401 gpu_memory_buffer_manager_.get(), NULL, 0, 1,
1402 use_gpu_memory_buffer_resources_, use_image_texture_targets_)); 1402 use_gpu_memory_buffer_resources_, use_image_texture_targets_));
1403 1403
1404 gfx::Size size(1, 1); 1404 gfx::Size size(1, 1);
1405 ResourceFormat format = RGBA_8888; 1405 ResourceFormat format = RGBA_8888;
1406 size_t pixel_size = TextureSizeBytes(size, format); 1406 size_t pixel_size = TextureSizeBytes(size, format);
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
1868 1868
1869 class ResourceProviderTestTextureFilters : public ResourceProviderTest { 1869 class ResourceProviderTestTextureFilters : public ResourceProviderTest {
1870 public: 1870 public:
1871 static void RunTest(GLenum child_filter, GLenum parent_filter) { 1871 static void RunTest(GLenum child_filter, GLenum parent_filter) {
1872 scoped_ptr<TextureStateTrackingContext> child_context_owned( 1872 scoped_ptr<TextureStateTrackingContext> child_context_owned(
1873 new TextureStateTrackingContext); 1873 new TextureStateTrackingContext);
1874 TextureStateTrackingContext* child_context = child_context_owned.get(); 1874 TextureStateTrackingContext* child_context = child_context_owned.get();
1875 1875
1876 FakeOutputSurfaceClient child_output_surface_client; 1876 FakeOutputSurfaceClient child_output_surface_client;
1877 scoped_ptr<OutputSurface> child_output_surface( 1877 scoped_ptr<OutputSurface> child_output_surface(
1878 FakeOutputSurface::Create3d(child_context_owned.Pass())); 1878 FakeOutputSurface::Create3d(std::move(child_context_owned)));
1879 CHECK(child_output_surface->BindToClient(&child_output_surface_client)); 1879 CHECK(child_output_surface->BindToClient(&child_output_surface_client));
1880 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 1880 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
1881 new TestSharedBitmapManager()); 1881 new TestSharedBitmapManager());
1882 1882
1883 scoped_ptr<ResourceProvider> child_resource_provider( 1883 scoped_ptr<ResourceProvider> child_resource_provider(
1884 ResourceProvider::Create(child_output_surface.get(), 1884 ResourceProvider::Create(child_output_surface.get(),
1885 shared_bitmap_manager.get(), NULL, NULL, 0, 1, 1885 shared_bitmap_manager.get(), NULL, NULL, 0, 1,
1886 use_gpu_memory_buffer_resources_, 1886 use_gpu_memory_buffer_resources_,
1887 use_image_texture_targets_)); 1887 use_image_texture_targets_));
1888 1888
1889 scoped_ptr<TextureStateTrackingContext> parent_context_owned( 1889 scoped_ptr<TextureStateTrackingContext> parent_context_owned(
1890 new TextureStateTrackingContext); 1890 new TextureStateTrackingContext);
1891 TextureStateTrackingContext* parent_context = parent_context_owned.get(); 1891 TextureStateTrackingContext* parent_context = parent_context_owned.get();
1892 1892
1893 FakeOutputSurfaceClient parent_output_surface_client; 1893 FakeOutputSurfaceClient parent_output_surface_client;
1894 scoped_ptr<OutputSurface> parent_output_surface( 1894 scoped_ptr<OutputSurface> parent_output_surface(
1895 FakeOutputSurface::Create3d(parent_context_owned.Pass())); 1895 FakeOutputSurface::Create3d(std::move(parent_context_owned)));
1896 CHECK(parent_output_surface->BindToClient(&parent_output_surface_client)); 1896 CHECK(parent_output_surface->BindToClient(&parent_output_surface_client));
1897 1897
1898 scoped_ptr<ResourceProvider> parent_resource_provider( 1898 scoped_ptr<ResourceProvider> parent_resource_provider(
1899 ResourceProvider::Create(parent_output_surface.get(), 1899 ResourceProvider::Create(parent_output_surface.get(),
1900 shared_bitmap_manager.get(), NULL, NULL, 0, 1, 1900 shared_bitmap_manager.get(), NULL, NULL, 0, 1,
1901 use_gpu_memory_buffer_resources_, 1901 use_gpu_memory_buffer_resources_,
1902 use_image_texture_targets_)); 1902 use_image_texture_targets_));
1903 1903
1904 gfx::Size size(1, 1); 1904 gfx::Size size(1, 1);
1905 ResourceFormat format = RGBA_8888; 1905 ResourceFormat format = RGBA_8888;
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
2492 EXPECT_TRUE(sync_token.HasData()); 2492 EXPECT_TRUE(sync_token.HasData());
2493 2493
2494 gpu::SyncToken release_sync_token; 2494 gpu::SyncToken release_sync_token;
2495 bool lost_resource = false; 2495 bool lost_resource = false;
2496 BlockingTaskRunner* main_thread_task_runner = NULL; 2496 BlockingTaskRunner* main_thread_task_runner = NULL;
2497 scoped_ptr<SingleReleaseCallbackImpl> callback = 2497 scoped_ptr<SingleReleaseCallbackImpl> callback =
2498 SingleReleaseCallbackImpl::Create( 2498 SingleReleaseCallbackImpl::Create(
2499 base::Bind(ReleaseCallback, &release_sync_token, &lost_resource, 2499 base::Bind(ReleaseCallback, &release_sync_token, &lost_resource,
2500 &main_thread_task_runner)); 2500 &main_thread_task_runner));
2501 resource_provider_->CreateResourceFromTextureMailbox( 2501 resource_provider_->CreateResourceFromTextureMailbox(
2502 TextureMailbox(mailbox, sync_token, GL_TEXTURE_2D), callback.Pass()); 2502 TextureMailbox(mailbox, sync_token, GL_TEXTURE_2D), std::move(callback));
2503 2503
2504 EXPECT_FALSE(release_sync_token.HasData()); 2504 EXPECT_FALSE(release_sync_token.HasData());
2505 EXPECT_FALSE(lost_resource); 2505 EXPECT_FALSE(lost_resource);
2506 EXPECT_EQ(NULL, main_thread_task_runner); 2506 EXPECT_EQ(NULL, main_thread_task_runner);
2507 2507
2508 resource_provider_->DidLoseOutputSurface(); 2508 resource_provider_->DidLoseOutputSurface();
2509 resource_provider_ = nullptr; 2509 resource_provider_ = nullptr;
2510 2510
2511 EXPECT_LE(sync_token.release_count(), release_sync_token.release_count()); 2511 EXPECT_LE(sync_token.release_count(), release_sync_token.release_count());
2512 EXPECT_TRUE(lost_resource); 2512 EXPECT_TRUE(lost_resource);
2513 EXPECT_EQ(main_thread_task_runner_.get(), main_thread_task_runner); 2513 EXPECT_EQ(main_thread_task_runner_.get(), main_thread_task_runner);
2514 } 2514 }
2515 2515
2516 TEST_P(ResourceProviderTest, ScopedSampler) { 2516 TEST_P(ResourceProviderTest, ScopedSampler) {
2517 // Sampling is only supported for GL textures. 2517 // Sampling is only supported for GL textures.
2518 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) 2518 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)
2519 return; 2519 return;
2520 2520
2521 scoped_ptr<TextureStateTrackingContext> context_owned( 2521 scoped_ptr<TextureStateTrackingContext> context_owned(
2522 new TextureStateTrackingContext); 2522 new TextureStateTrackingContext);
2523 TextureStateTrackingContext* context = context_owned.get(); 2523 TextureStateTrackingContext* context = context_owned.get();
2524 2524
2525 FakeOutputSurfaceClient output_surface_client; 2525 FakeOutputSurfaceClient output_surface_client;
2526 scoped_ptr<OutputSurface> output_surface( 2526 scoped_ptr<OutputSurface> output_surface(
2527 FakeOutputSurface::Create3d(context_owned.Pass())); 2527 FakeOutputSurface::Create3d(std::move(context_owned)));
2528 CHECK(output_surface->BindToClient(&output_surface_client)); 2528 CHECK(output_surface->BindToClient(&output_surface_client));
2529 2529
2530 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 2530 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
2531 output_surface.get(), shared_bitmap_manager_.get(), 2531 output_surface.get(), shared_bitmap_manager_.get(),
2532 gpu_memory_buffer_manager_.get(), NULL, 0, 1, 2532 gpu_memory_buffer_manager_.get(), NULL, 0, 1,
2533 use_gpu_memory_buffer_resources_, use_image_texture_targets_)); 2533 use_gpu_memory_buffer_resources_, use_image_texture_targets_));
2534 2534
2535 gfx::Size size(1, 1); 2535 gfx::Size size(1, 1);
2536 ResourceFormat format = RGBA_8888; 2536 ResourceFormat format = RGBA_8888;
2537 int texture_id = 1; 2537 int texture_id = 1;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
2596 // Sampling is only supported for GL textures. 2596 // Sampling is only supported for GL textures.
2597 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) 2597 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)
2598 return; 2598 return;
2599 2599
2600 scoped_ptr<TextureStateTrackingContext> context_owned( 2600 scoped_ptr<TextureStateTrackingContext> context_owned(
2601 new TextureStateTrackingContext); 2601 new TextureStateTrackingContext);
2602 TextureStateTrackingContext* context = context_owned.get(); 2602 TextureStateTrackingContext* context = context_owned.get();
2603 2603
2604 FakeOutputSurfaceClient output_surface_client; 2604 FakeOutputSurfaceClient output_surface_client;
2605 scoped_ptr<OutputSurface> output_surface( 2605 scoped_ptr<OutputSurface> output_surface(
2606 FakeOutputSurface::Create3d(context_owned.Pass())); 2606 FakeOutputSurface::Create3d(std::move(context_owned)));
2607 CHECK(output_surface->BindToClient(&output_surface_client)); 2607 CHECK(output_surface->BindToClient(&output_surface_client));
2608 2608
2609 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 2609 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
2610 output_surface.get(), shared_bitmap_manager_.get(), 2610 output_surface.get(), shared_bitmap_manager_.get(),
2611 gpu_memory_buffer_manager_.get(), NULL, 0, 1, 2611 gpu_memory_buffer_manager_.get(), NULL, 0, 1,
2612 use_gpu_memory_buffer_resources_, use_image_texture_targets_)); 2612 use_gpu_memory_buffer_resources_, use_image_texture_targets_));
2613 2613
2614 gfx::Size size(1, 1); 2614 gfx::Size size(1, 1);
2615 ResourceFormat format = RGBA_8888; 2615 ResourceFormat format = RGBA_8888;
2616 int texture_id = 1; 2616 int texture_id = 1;
(...skipping 22 matching lines...) Expand all
2639 // Sampling is only supported for GL textures. 2639 // Sampling is only supported for GL textures.
2640 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) 2640 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)
2641 return; 2641 return;
2642 2642
2643 scoped_ptr<TextureStateTrackingContext> context_owned( 2643 scoped_ptr<TextureStateTrackingContext> context_owned(
2644 new TextureStateTrackingContext); 2644 new TextureStateTrackingContext);
2645 TextureStateTrackingContext* context = context_owned.get(); 2645 TextureStateTrackingContext* context = context_owned.get();
2646 2646
2647 FakeOutputSurfaceClient output_surface_client; 2647 FakeOutputSurfaceClient output_surface_client;
2648 scoped_ptr<OutputSurface> output_surface( 2648 scoped_ptr<OutputSurface> output_surface(
2649 FakeOutputSurface::Create3d(context_owned.Pass())); 2649 FakeOutputSurface::Create3d(std::move(context_owned)));
2650 CHECK(output_surface->BindToClient(&output_surface_client)); 2650 CHECK(output_surface->BindToClient(&output_surface_client));
2651 2651
2652 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 2652 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
2653 output_surface.get(), shared_bitmap_manager_.get(), 2653 output_surface.get(), shared_bitmap_manager_.get(),
2654 gpu_memory_buffer_manager_.get(), NULL, 0, 1, 2654 gpu_memory_buffer_manager_.get(), NULL, 0, 1,
2655 use_gpu_memory_buffer_resources_, use_image_texture_targets_)); 2655 use_gpu_memory_buffer_resources_, use_image_texture_targets_));
2656 2656
2657 gfx::Size size(1, 1); 2657 gfx::Size size(1, 1);
2658 ResourceFormat format = RGBA_8888; 2658 ResourceFormat format = RGBA_8888;
2659 2659
(...skipping 23 matching lines...) Expand all
2683 return; 2683 return;
2684 2684
2685 scoped_ptr<TextureStateTrackingContext> context_owned( 2685 scoped_ptr<TextureStateTrackingContext> context_owned(
2686 new TextureStateTrackingContext); 2686 new TextureStateTrackingContext);
2687 TextureStateTrackingContext* context = context_owned.get(); 2687 TextureStateTrackingContext* context = context_owned.get();
2688 context->set_support_texture_storage(true); 2688 context->set_support_texture_storage(true);
2689 context->set_support_texture_usage(true); 2689 context->set_support_texture_usage(true);
2690 2690
2691 FakeOutputSurfaceClient output_surface_client; 2691 FakeOutputSurfaceClient output_surface_client;
2692 scoped_ptr<OutputSurface> output_surface( 2692 scoped_ptr<OutputSurface> output_surface(
2693 FakeOutputSurface::Create3d(context_owned.Pass())); 2693 FakeOutputSurface::Create3d(std::move(context_owned)));
2694 CHECK(output_surface->BindToClient(&output_surface_client)); 2694 CHECK(output_surface->BindToClient(&output_surface_client));
2695 2695
2696 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 2696 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
2697 output_surface.get(), shared_bitmap_manager_.get(), 2697 output_surface.get(), shared_bitmap_manager_.get(),
2698 gpu_memory_buffer_manager_.get(), NULL, 0, 1, 2698 gpu_memory_buffer_manager_.get(), NULL, 0, 1,
2699 use_gpu_memory_buffer_resources_, use_image_texture_targets_)); 2699 use_gpu_memory_buffer_resources_, use_image_texture_targets_));
2700 2700
2701 gfx::Size size(1, 1); 2701 gfx::Size size(1, 1);
2702 ResourceFormat format = RGBA_8888; 2702 ResourceFormat format = RGBA_8888;
2703 2703
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
2760 gpu::SyncToken release_sync_token; 2760 gpu::SyncToken release_sync_token;
2761 bool lost_resource = false; 2761 bool lost_resource = false;
2762 BlockingTaskRunner* main_thread_task_runner = NULL; 2762 BlockingTaskRunner* main_thread_task_runner = NULL;
2763 scoped_ptr<SingleReleaseCallbackImpl> callback = 2763 scoped_ptr<SingleReleaseCallbackImpl> callback =
2764 SingleReleaseCallbackImpl::Create( 2764 SingleReleaseCallbackImpl::Create(
2765 base::Bind(&ReleaseCallback, &release_sync_token, &lost_resource, 2765 base::Bind(&ReleaseCallback, &release_sync_token, &lost_resource,
2766 &main_thread_task_runner)); 2766 &main_thread_task_runner));
2767 TextureMailbox mailbox(shared_bitmap.get(), size); 2767 TextureMailbox mailbox(shared_bitmap.get(), size);
2768 2768
2769 ResourceId id = resource_provider->CreateResourceFromTextureMailbox( 2769 ResourceId id = resource_provider->CreateResourceFromTextureMailbox(
2770 mailbox, callback.Pass()); 2770 mailbox, std::move(callback));
2771 EXPECT_NE(0u, id); 2771 EXPECT_NE(0u, id);
2772 2772
2773 { 2773 {
2774 ResourceProvider::ScopedReadLockSoftware lock(resource_provider.get(), id); 2774 ResourceProvider::ScopedReadLockSoftware lock(resource_provider.get(), id);
2775 const SkBitmap* sk_bitmap = lock.sk_bitmap(); 2775 const SkBitmap* sk_bitmap = lock.sk_bitmap();
2776 EXPECT_EQ(sk_bitmap->width(), size.width()); 2776 EXPECT_EQ(sk_bitmap->width(), size.width());
2777 EXPECT_EQ(sk_bitmap->height(), size.height()); 2777 EXPECT_EQ(sk_bitmap->height(), size.height());
2778 EXPECT_EQ(*sk_bitmap->getAddr32(16, 16), kBadBeef); 2778 EXPECT_EQ(*sk_bitmap->getAddr32(16, 16), kBadBeef);
2779 } 2779 }
2780 2780
(...skipping 10 matching lines...) Expand all
2791 TestGpuMemoryBufferManager* gpu_memory_buffer_manager, 2791 TestGpuMemoryBufferManager* gpu_memory_buffer_manager,
2792 BlockingTaskRunner* main_thread_task_runner, 2792 BlockingTaskRunner* main_thread_task_runner,
2793 bool mailbox_nearest_neighbor, 2793 bool mailbox_nearest_neighbor,
2794 GLenum sampler_filter) { 2794 GLenum sampler_filter) {
2795 scoped_ptr<TextureStateTrackingContext> context_owned( 2795 scoped_ptr<TextureStateTrackingContext> context_owned(
2796 new TextureStateTrackingContext); 2796 new TextureStateTrackingContext);
2797 TextureStateTrackingContext* context = context_owned.get(); 2797 TextureStateTrackingContext* context = context_owned.get();
2798 2798
2799 FakeOutputSurfaceClient output_surface_client; 2799 FakeOutputSurfaceClient output_surface_client;
2800 scoped_ptr<OutputSurface> output_surface( 2800 scoped_ptr<OutputSurface> output_surface(
2801 FakeOutputSurface::Create3d(context_owned.Pass())); 2801 FakeOutputSurface::Create3d(std::move(context_owned)));
2802 CHECK(output_surface->BindToClient(&output_surface_client)); 2802 CHECK(output_surface->BindToClient(&output_surface_client));
2803 2803
2804 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 2804 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
2805 output_surface.get(), shared_bitmap_manager, gpu_memory_buffer_manager, 2805 output_surface.get(), shared_bitmap_manager, gpu_memory_buffer_manager,
2806 main_thread_task_runner, 0, 1, use_gpu_memory_buffer_resources_, 2806 main_thread_task_runner, 0, 1, use_gpu_memory_buffer_resources_,
2807 use_image_texture_targets_)); 2807 use_image_texture_targets_));
2808 2808
2809 unsigned texture_id = 1; 2809 unsigned texture_id = 1;
2810 gpu::SyncToken sync_token(30); 2810 gpu::SyncToken sync_token(30);
2811 unsigned target = GL_TEXTURE_2D; 2811 unsigned target = GL_TEXTURE_2D;
(...skipping 11 matching lines...) Expand all
2823 BlockingTaskRunner* mailbox_task_runner = NULL; 2823 BlockingTaskRunner* mailbox_task_runner = NULL;
2824 scoped_ptr<SingleReleaseCallbackImpl> callback = 2824 scoped_ptr<SingleReleaseCallbackImpl> callback =
2825 SingleReleaseCallbackImpl::Create( 2825 SingleReleaseCallbackImpl::Create(
2826 base::Bind(&ReleaseCallback, &release_sync_token, &lost_resource, 2826 base::Bind(&ReleaseCallback, &release_sync_token, &lost_resource,
2827 &mailbox_task_runner)); 2827 &mailbox_task_runner));
2828 2828
2829 TextureMailbox mailbox(gpu_mailbox, sync_token, target); 2829 TextureMailbox mailbox(gpu_mailbox, sync_token, target);
2830 mailbox.set_nearest_neighbor(mailbox_nearest_neighbor); 2830 mailbox.set_nearest_neighbor(mailbox_nearest_neighbor);
2831 2831
2832 ResourceId id = resource_provider->CreateResourceFromTextureMailbox( 2832 ResourceId id = resource_provider->CreateResourceFromTextureMailbox(
2833 mailbox, callback.Pass()); 2833 mailbox, std::move(callback));
2834 EXPECT_NE(0u, id); 2834 EXPECT_NE(0u, id);
2835 2835
2836 Mock::VerifyAndClearExpectations(context); 2836 Mock::VerifyAndClearExpectations(context);
2837 2837
2838 { 2838 {
2839 // Mailbox sync point WaitSyncToken before using the texture. 2839 // Mailbox sync point WaitSyncToken before using the texture.
2840 EXPECT_CALL(*context, waitSyncToken(MatchesSyncToken(sync_token))); 2840 EXPECT_CALL(*context, waitSyncToken(MatchesSyncToken(sync_token)));
2841 resource_provider->WaitSyncTokenIfNeeded(id); 2841 resource_provider->WaitSyncTokenIfNeeded(id);
2842 Mock::VerifyAndClearExpectations(context); 2842 Mock::VerifyAndClearExpectations(context);
2843 2843
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
2934 // Mailboxing is only supported for GL textures. 2934 // Mailboxing is only supported for GL textures.
2935 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) 2935 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)
2936 return; 2936 return;
2937 2937
2938 scoped_ptr<TextureStateTrackingContext> context_owned( 2938 scoped_ptr<TextureStateTrackingContext> context_owned(
2939 new TextureStateTrackingContext); 2939 new TextureStateTrackingContext);
2940 TextureStateTrackingContext* context = context_owned.get(); 2940 TextureStateTrackingContext* context = context_owned.get();
2941 2941
2942 FakeOutputSurfaceClient output_surface_client; 2942 FakeOutputSurfaceClient output_surface_client;
2943 scoped_ptr<OutputSurface> output_surface( 2943 scoped_ptr<OutputSurface> output_surface(
2944 FakeOutputSurface::Create3d(context_owned.Pass())); 2944 FakeOutputSurface::Create3d(std::move(context_owned)));
2945 CHECK(output_surface->BindToClient(&output_surface_client)); 2945 CHECK(output_surface->BindToClient(&output_surface_client));
2946 2946
2947 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 2947 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
2948 output_surface.get(), shared_bitmap_manager_.get(), 2948 output_surface.get(), shared_bitmap_manager_.get(),
2949 gpu_memory_buffer_manager_.get(), NULL, 0, 1, 2949 gpu_memory_buffer_manager_.get(), NULL, 0, 1,
2950 use_gpu_memory_buffer_resources_, use_image_texture_targets_)); 2950 use_gpu_memory_buffer_resources_, use_image_texture_targets_));
2951 2951
2952 gpu::SyncToken sync_token(30); 2952 gpu::SyncToken sync_token(30);
2953 unsigned target = GL_TEXTURE_EXTERNAL_OES; 2953 unsigned target = GL_TEXTURE_EXTERNAL_OES;
2954 2954
2955 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); 2955 EXPECT_CALL(*context, bindTexture(_, _)).Times(0);
2956 EXPECT_CALL(*context, waitSyncToken(_)).Times(0); 2956 EXPECT_CALL(*context, waitSyncToken(_)).Times(0);
2957 EXPECT_CALL(*context, insertSyncPoint()).Times(0); 2957 EXPECT_CALL(*context, insertSyncPoint()).Times(0);
2958 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); 2958 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0);
2959 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); 2959 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0);
2960 2960
2961 gpu::Mailbox gpu_mailbox; 2961 gpu::Mailbox gpu_mailbox;
2962 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1); 2962 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1);
2963 scoped_ptr<SingleReleaseCallbackImpl> callback = 2963 scoped_ptr<SingleReleaseCallbackImpl> callback =
2964 SingleReleaseCallbackImpl::Create(base::Bind(&EmptyReleaseCallback)); 2964 SingleReleaseCallbackImpl::Create(base::Bind(&EmptyReleaseCallback));
2965 2965
2966 TextureMailbox mailbox(gpu_mailbox, sync_token, target); 2966 TextureMailbox mailbox(gpu_mailbox, sync_token, target);
2967 2967
2968 ResourceId id = resource_provider->CreateResourceFromTextureMailbox( 2968 ResourceId id = resource_provider->CreateResourceFromTextureMailbox(
2969 mailbox, callback.Pass()); 2969 mailbox, std::move(callback));
2970 EXPECT_NE(0u, id); 2970 EXPECT_NE(0u, id);
2971 2971
2972 Mock::VerifyAndClearExpectations(context); 2972 Mock::VerifyAndClearExpectations(context);
2973 2973
2974 { 2974 {
2975 // Mailbox sync point WaitSyncToken before using the texture. 2975 // Mailbox sync point WaitSyncToken before using the texture.
2976 EXPECT_CALL(*context, waitSyncToken(MatchesSyncToken(sync_token))); 2976 EXPECT_CALL(*context, waitSyncToken(MatchesSyncToken(sync_token)));
2977 resource_provider->WaitSyncTokenIfNeeded(id); 2977 resource_provider->WaitSyncTokenIfNeeded(id);
2978 Mock::VerifyAndClearExpectations(context); 2978 Mock::VerifyAndClearExpectations(context);
2979 2979
(...skipping 24 matching lines...) Expand all
3004 // Mailboxing is only supported for GL textures. 3004 // Mailboxing is only supported for GL textures.
3005 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) 3005 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)
3006 return; 3006 return;
3007 3007
3008 scoped_ptr<TextureStateTrackingContext> context_owned( 3008 scoped_ptr<TextureStateTrackingContext> context_owned(
3009 new TextureStateTrackingContext); 3009 new TextureStateTrackingContext);
3010 TextureStateTrackingContext* context = context_owned.get(); 3010 TextureStateTrackingContext* context = context_owned.get();
3011 3011
3012 FakeOutputSurfaceClient output_surface_client; 3012 FakeOutputSurfaceClient output_surface_client;
3013 scoped_ptr<OutputSurface> output_surface( 3013 scoped_ptr<OutputSurface> output_surface(
3014 FakeOutputSurface::Create3d(context_owned.Pass())); 3014 FakeOutputSurface::Create3d(std::move(context_owned)));
3015 CHECK(output_surface->BindToClient(&output_surface_client)); 3015 CHECK(output_surface->BindToClient(&output_surface_client));
3016 3016
3017 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3017 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3018 output_surface.get(), shared_bitmap_manager_.get(), 3018 output_surface.get(), shared_bitmap_manager_.get(),
3019 gpu_memory_buffer_manager_.get(), NULL, 0, 1, 3019 gpu_memory_buffer_manager_.get(), NULL, 0, 1,
3020 use_gpu_memory_buffer_resources_, use_image_texture_targets_)); 3020 use_gpu_memory_buffer_resources_, use_image_texture_targets_));
3021 3021
3022 gpu::SyncToken sync_token(30); 3022 gpu::SyncToken sync_token(30);
3023 unsigned target = GL_TEXTURE_2D; 3023 unsigned target = GL_TEXTURE_2D;
3024 3024
3025 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); 3025 EXPECT_CALL(*context, bindTexture(_, _)).Times(0);
3026 EXPECT_CALL(*context, waitSyncToken(_)).Times(0); 3026 EXPECT_CALL(*context, waitSyncToken(_)).Times(0);
3027 EXPECT_CALL(*context, insertSyncPoint()).Times(0); 3027 EXPECT_CALL(*context, insertSyncPoint()).Times(0);
3028 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); 3028 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0);
3029 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); 3029 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0);
3030 3030
3031 gpu::Mailbox gpu_mailbox; 3031 gpu::Mailbox gpu_mailbox;
3032 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1); 3032 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1);
3033 scoped_ptr<SingleReleaseCallbackImpl> callback = 3033 scoped_ptr<SingleReleaseCallbackImpl> callback =
3034 SingleReleaseCallbackImpl::Create(base::Bind(&EmptyReleaseCallback)); 3034 SingleReleaseCallbackImpl::Create(base::Bind(&EmptyReleaseCallback));
3035 3035
3036 TextureMailbox mailbox(gpu_mailbox, sync_token, target); 3036 TextureMailbox mailbox(gpu_mailbox, sync_token, target);
3037 3037
3038 ResourceId id = resource_provider->CreateResourceFromTextureMailbox( 3038 ResourceId id = resource_provider->CreateResourceFromTextureMailbox(
3039 mailbox, callback.Pass()); 3039 mailbox, std::move(callback));
3040 EXPECT_NE(0u, id); 3040 EXPECT_NE(0u, id);
3041 3041
3042 Mock::VerifyAndClearExpectations(context); 3042 Mock::VerifyAndClearExpectations(context);
3043 3043
3044 { 3044 {
3045 // First call to WaitSyncTokenIfNeeded should call waitSyncToken. 3045 // First call to WaitSyncTokenIfNeeded should call waitSyncToken.
3046 EXPECT_CALL(*context, waitSyncToken(MatchesSyncToken(sync_token))); 3046 EXPECT_CALL(*context, waitSyncToken(MatchesSyncToken(sync_token)));
3047 resource_provider->WaitSyncTokenIfNeeded(id); 3047 resource_provider->WaitSyncTokenIfNeeded(id);
3048 Mock::VerifyAndClearExpectations(context); 3048 Mock::VerifyAndClearExpectations(context);
3049 3049
3050 // Subsequent calls to WaitSyncTokenIfNeeded shouldn't call waitSyncToken. 3050 // Subsequent calls to WaitSyncTokenIfNeeded shouldn't call waitSyncToken.
3051 EXPECT_CALL(*context, waitSyncToken(_)).Times(0); 3051 EXPECT_CALL(*context, waitSyncToken(_)).Times(0);
3052 resource_provider->WaitSyncTokenIfNeeded(id); 3052 resource_provider->WaitSyncTokenIfNeeded(id);
3053 Mock::VerifyAndClearExpectations(context); 3053 Mock::VerifyAndClearExpectations(context);
3054 } 3054 }
3055 } 3055 }
3056 3056
3057 TEST_P(ResourceProviderTest, TextureMailbox_WaitSyncTokenIfNeeded_NoSyncToken) { 3057 TEST_P(ResourceProviderTest, TextureMailbox_WaitSyncTokenIfNeeded_NoSyncToken) {
3058 // Mailboxing is only supported for GL textures. 3058 // Mailboxing is only supported for GL textures.
3059 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) 3059 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)
3060 return; 3060 return;
3061 3061
3062 scoped_ptr<TextureStateTrackingContext> context_owned( 3062 scoped_ptr<TextureStateTrackingContext> context_owned(
3063 new TextureStateTrackingContext); 3063 new TextureStateTrackingContext);
3064 TextureStateTrackingContext* context = context_owned.get(); 3064 TextureStateTrackingContext* context = context_owned.get();
3065 3065
3066 FakeOutputSurfaceClient output_surface_client; 3066 FakeOutputSurfaceClient output_surface_client;
3067 scoped_ptr<OutputSurface> output_surface( 3067 scoped_ptr<OutputSurface> output_surface(
3068 FakeOutputSurface::Create3d(context_owned.Pass())); 3068 FakeOutputSurface::Create3d(std::move(context_owned)));
3069 CHECK(output_surface->BindToClient(&output_surface_client)); 3069 CHECK(output_surface->BindToClient(&output_surface_client));
3070 3070
3071 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3071 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3072 output_surface.get(), shared_bitmap_manager_.get(), 3072 output_surface.get(), shared_bitmap_manager_.get(),
3073 gpu_memory_buffer_manager_.get(), NULL, 0, 1, 3073 gpu_memory_buffer_manager_.get(), NULL, 0, 1,
3074 use_gpu_memory_buffer_resources_, use_image_texture_targets_)); 3074 use_gpu_memory_buffer_resources_, use_image_texture_targets_));
3075 3075
3076 gpu::SyncToken sync_token; 3076 gpu::SyncToken sync_token;
3077 unsigned target = GL_TEXTURE_2D; 3077 unsigned target = GL_TEXTURE_2D;
3078 3078
3079 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); 3079 EXPECT_CALL(*context, bindTexture(_, _)).Times(0);
3080 EXPECT_CALL(*context, waitSyncToken(_)).Times(0); 3080 EXPECT_CALL(*context, waitSyncToken(_)).Times(0);
3081 EXPECT_CALL(*context, insertSyncPoint()).Times(0); 3081 EXPECT_CALL(*context, insertSyncPoint()).Times(0);
3082 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); 3082 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0);
3083 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); 3083 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0);
3084 3084
3085 gpu::Mailbox gpu_mailbox; 3085 gpu::Mailbox gpu_mailbox;
3086 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1); 3086 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1);
3087 scoped_ptr<SingleReleaseCallbackImpl> callback = 3087 scoped_ptr<SingleReleaseCallbackImpl> callback =
3088 SingleReleaseCallbackImpl::Create(base::Bind(&EmptyReleaseCallback)); 3088 SingleReleaseCallbackImpl::Create(base::Bind(&EmptyReleaseCallback));
3089 3089
3090 TextureMailbox mailbox(gpu_mailbox, sync_token, target); 3090 TextureMailbox mailbox(gpu_mailbox, sync_token, target);
3091 3091
3092 ResourceId id = resource_provider->CreateResourceFromTextureMailbox( 3092 ResourceId id = resource_provider->CreateResourceFromTextureMailbox(
3093 mailbox, callback.Pass()); 3093 mailbox, std::move(callback));
3094 EXPECT_NE(0u, id); 3094 EXPECT_NE(0u, id);
3095 3095
3096 Mock::VerifyAndClearExpectations(context); 3096 Mock::VerifyAndClearExpectations(context);
3097 3097
3098 { 3098 {
3099 // WaitSyncTokenIfNeeded with empty sync_token shouldn't call waitSyncToken. 3099 // WaitSyncTokenIfNeeded with empty sync_token shouldn't call waitSyncToken.
3100 EXPECT_CALL(*context, waitSyncToken(_)).Times(0); 3100 EXPECT_CALL(*context, waitSyncToken(_)).Times(0);
3101 resource_provider->WaitSyncTokenIfNeeded(id); 3101 resource_provider->WaitSyncTokenIfNeeded(id);
3102 Mock::VerifyAndClearExpectations(context); 3102 Mock::VerifyAndClearExpectations(context);
3103 } 3103 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
3179 TEST_P(ResourceProviderTest, TextureAllocation) { 3179 TEST_P(ResourceProviderTest, TextureAllocation) {
3180 // Only for GL textures. 3180 // Only for GL textures.
3181 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) 3181 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)
3182 return; 3182 return;
3183 scoped_ptr<AllocationTrackingContext3D> context_owned( 3183 scoped_ptr<AllocationTrackingContext3D> context_owned(
3184 new StrictMock<AllocationTrackingContext3D>); 3184 new StrictMock<AllocationTrackingContext3D>);
3185 AllocationTrackingContext3D* context = context_owned.get(); 3185 AllocationTrackingContext3D* context = context_owned.get();
3186 3186
3187 FakeOutputSurfaceClient output_surface_client; 3187 FakeOutputSurfaceClient output_surface_client;
3188 scoped_ptr<OutputSurface> output_surface( 3188 scoped_ptr<OutputSurface> output_surface(
3189 FakeOutputSurface::Create3d(context_owned.Pass())); 3189 FakeOutputSurface::Create3d(std::move(context_owned)));
3190 CHECK(output_surface->BindToClient(&output_surface_client)); 3190 CHECK(output_surface->BindToClient(&output_surface_client));
3191 3191
3192 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3192 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3193 output_surface.get(), shared_bitmap_manager_.get(), 3193 output_surface.get(), shared_bitmap_manager_.get(),
3194 gpu_memory_buffer_manager_.get(), NULL, 0, 1, 3194 gpu_memory_buffer_manager_.get(), NULL, 0, 1,
3195 use_gpu_memory_buffer_resources_, use_image_texture_targets_)); 3195 use_gpu_memory_buffer_resources_, use_image_texture_targets_));
3196 3196
3197 gfx::Size size(2, 2); 3197 gfx::Size size(2, 2);
3198 gfx::Vector2d offset(0, 0); 3198 gfx::Vector2d offset(0, 0);
3199 ResourceFormat format = RGBA_8888; 3199 ResourceFormat format = RGBA_8888;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
3235 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) 3235 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)
3236 return; 3236 return;
3237 scoped_ptr<AllocationTrackingContext3D> context_owned( 3237 scoped_ptr<AllocationTrackingContext3D> context_owned(
3238 new StrictMock<AllocationTrackingContext3D>); 3238 new StrictMock<AllocationTrackingContext3D>);
3239 AllocationTrackingContext3D* context = context_owned.get(); 3239 AllocationTrackingContext3D* context = context_owned.get();
3240 context->set_support_texture_storage(true); 3240 context->set_support_texture_storage(true);
3241 context->set_support_texture_usage(true); 3241 context->set_support_texture_usage(true);
3242 3242
3243 FakeOutputSurfaceClient output_surface_client; 3243 FakeOutputSurfaceClient output_surface_client;
3244 scoped_ptr<OutputSurface> output_surface( 3244 scoped_ptr<OutputSurface> output_surface(
3245 FakeOutputSurface::Create3d(context_owned.Pass())); 3245 FakeOutputSurface::Create3d(std::move(context_owned)));
3246 CHECK(output_surface->BindToClient(&output_surface_client)); 3246 CHECK(output_surface->BindToClient(&output_surface_client));
3247 3247
3248 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3248 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3249 output_surface.get(), shared_bitmap_manager_.get(), 3249 output_surface.get(), shared_bitmap_manager_.get(),
3250 gpu_memory_buffer_manager_.get(), NULL, 0, 1, 3250 gpu_memory_buffer_manager_.get(), NULL, 0, 1,
3251 use_gpu_memory_buffer_resources_, use_image_texture_targets_)); 3251 use_gpu_memory_buffer_resources_, use_image_texture_targets_));
3252 3252
3253 gfx::Size size(2, 2); 3253 gfx::Size size(2, 2);
3254 3254
3255 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888}; 3255 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888};
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
3291 return; 3291 return;
3292 scoped_ptr<AllocationTrackingContext3D> context_owned( 3292 scoped_ptr<AllocationTrackingContext3D> context_owned(
3293 new StrictMock<AllocationTrackingContext3D>); 3293 new StrictMock<AllocationTrackingContext3D>);
3294 AllocationTrackingContext3D* context = context_owned.get(); 3294 AllocationTrackingContext3D* context = context_owned.get();
3295 context->set_support_texture_format_bgra8888(true); 3295 context->set_support_texture_format_bgra8888(true);
3296 context->set_support_texture_storage(true); 3296 context->set_support_texture_storage(true);
3297 context->set_support_texture_usage(true); 3297 context->set_support_texture_usage(true);
3298 3298
3299 FakeOutputSurfaceClient output_surface_client; 3299 FakeOutputSurfaceClient output_surface_client;
3300 scoped_ptr<OutputSurface> output_surface( 3300 scoped_ptr<OutputSurface> output_surface(
3301 FakeOutputSurface::Create3d(context_owned.Pass())); 3301 FakeOutputSurface::Create3d(std::move(context_owned)));
3302 CHECK(output_surface->BindToClient(&output_surface_client)); 3302 CHECK(output_surface->BindToClient(&output_surface_client));
3303 3303
3304 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3304 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3305 output_surface.get(), shared_bitmap_manager_.get(), 3305 output_surface.get(), shared_bitmap_manager_.get(),
3306 gpu_memory_buffer_manager_.get(), NULL, 0, 1, 3306 gpu_memory_buffer_manager_.get(), NULL, 0, 1,
3307 use_gpu_memory_buffer_resources_, use_image_texture_targets_)); 3307 use_gpu_memory_buffer_resources_, use_image_texture_targets_));
3308 3308
3309 gfx::Size size(2, 2); 3309 gfx::Size size(2, 2);
3310 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888}; 3310 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888};
3311 3311
(...skipping 30 matching lines...) Expand all
3342 TEST_P(ResourceProviderTest, Image_GLTexture) { 3342 TEST_P(ResourceProviderTest, Image_GLTexture) {
3343 // Only for GL textures. 3343 // Only for GL textures.
3344 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) 3344 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)
3345 return; 3345 return;
3346 scoped_ptr<AllocationTrackingContext3D> context_owned( 3346 scoped_ptr<AllocationTrackingContext3D> context_owned(
3347 new StrictMock<AllocationTrackingContext3D>); 3347 new StrictMock<AllocationTrackingContext3D>);
3348 AllocationTrackingContext3D* context = context_owned.get(); 3348 AllocationTrackingContext3D* context = context_owned.get();
3349 3349
3350 FakeOutputSurfaceClient output_surface_client; 3350 FakeOutputSurfaceClient output_surface_client;
3351 scoped_ptr<OutputSurface> output_surface( 3351 scoped_ptr<OutputSurface> output_surface(
3352 FakeOutputSurface::Create3d(context_owned.Pass())); 3352 FakeOutputSurface::Create3d(std::move(context_owned)));
3353 CHECK(output_surface->BindToClient(&output_surface_client)); 3353 CHECK(output_surface->BindToClient(&output_surface_client));
3354 3354
3355 const int kWidth = 2; 3355 const int kWidth = 2;
3356 const int kHeight = 2; 3356 const int kHeight = 2;
3357 gfx::Size size(kWidth, kHeight); 3357 gfx::Size size(kWidth, kHeight);
3358 ResourceFormat format = RGBA_8888; 3358 ResourceFormat format = RGBA_8888;
3359 ResourceId id = 0; 3359 ResourceId id = 0;
3360 const unsigned kTextureId = 123u; 3360 const unsigned kTextureId = 123u;
3361 const unsigned kImageId = 234u; 3361 const unsigned kImageId = 234u;
3362 3362
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
3427 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) 3427 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)
3428 return; 3428 return;
3429 3429
3430 scoped_ptr<AllocationTrackingContext3D> context_owned( 3430 scoped_ptr<AllocationTrackingContext3D> context_owned(
3431 new AllocationTrackingContext3D); 3431 new AllocationTrackingContext3D);
3432 AllocationTrackingContext3D* context = context_owned.get(); 3432 AllocationTrackingContext3D* context = context_owned.get();
3433 context_owned->set_support_compressed_texture_etc1(true); 3433 context_owned->set_support_compressed_texture_etc1(true);
3434 3434
3435 FakeOutputSurfaceClient output_surface_client; 3435 FakeOutputSurfaceClient output_surface_client;
3436 scoped_ptr<OutputSurface> output_surface( 3436 scoped_ptr<OutputSurface> output_surface(
3437 FakeOutputSurface::Create3d(context_owned.Pass())); 3437 FakeOutputSurface::Create3d(std::move(context_owned)));
3438 CHECK(output_surface->BindToClient(&output_surface_client)); 3438 CHECK(output_surface->BindToClient(&output_surface_client));
3439 3439
3440 gfx::Size size(4, 4); 3440 gfx::Size size(4, 4);
3441 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3441 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3442 output_surface.get(), shared_bitmap_manager_.get(), 3442 output_surface.get(), shared_bitmap_manager_.get(),
3443 gpu_memory_buffer_manager_.get(), NULL, 0, 1, 3443 gpu_memory_buffer_manager_.get(), NULL, 0, 1,
3444 use_gpu_memory_buffer_resources_, use_image_texture_targets_)); 3444 use_gpu_memory_buffer_resources_, use_image_texture_targets_));
3445 int texture_id = 123; 3445 int texture_id = 123;
3446 3446
3447 ResourceId id = resource_provider->CreateResource( 3447 ResourceId id = resource_provider->CreateResource(
(...skipping 11 matching lines...) Expand all
3459 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) 3459 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)
3460 return; 3460 return;
3461 3461
3462 scoped_ptr<AllocationTrackingContext3D> context_owned( 3462 scoped_ptr<AllocationTrackingContext3D> context_owned(
3463 new AllocationTrackingContext3D); 3463 new AllocationTrackingContext3D);
3464 AllocationTrackingContext3D* context = context_owned.get(); 3464 AllocationTrackingContext3D* context = context_owned.get();
3465 context_owned->set_support_compressed_texture_etc1(true); 3465 context_owned->set_support_compressed_texture_etc1(true);
3466 3466
3467 FakeOutputSurfaceClient output_surface_client; 3467 FakeOutputSurfaceClient output_surface_client;
3468 scoped_ptr<OutputSurface> output_surface( 3468 scoped_ptr<OutputSurface> output_surface(
3469 FakeOutputSurface::Create3d(context_owned.Pass())); 3469 FakeOutputSurface::Create3d(std::move(context_owned)));
3470 CHECK(output_surface->BindToClient(&output_surface_client)); 3470 CHECK(output_surface->BindToClient(&output_surface_client));
3471 3471
3472 gfx::Size size(4, 4); 3472 gfx::Size size(4, 4);
3473 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3473 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3474 output_surface.get(), shared_bitmap_manager_.get(), 3474 output_surface.get(), shared_bitmap_manager_.get(),
3475 gpu_memory_buffer_manager_.get(), NULL, 0, 1, 3475 gpu_memory_buffer_manager_.get(), NULL, 0, 1,
3476 use_gpu_memory_buffer_resources_, use_image_texture_targets_)); 3476 use_gpu_memory_buffer_resources_, use_image_texture_targets_));
3477 int texture_id = 123; 3477 int texture_id = 123;
3478 uint8_t pixels[8]; 3478 uint8_t pixels[8];
3479 3479
(...skipping 30 matching lines...) Expand all
3510 } 3510 }
3511 }; 3511 };
3512 3512
3513 TEST(ResourceProviderTest, TextureAllocationChunkSize) { 3513 TEST(ResourceProviderTest, TextureAllocationChunkSize) {
3514 scoped_ptr<TextureIdAllocationTrackingContext> context_owned( 3514 scoped_ptr<TextureIdAllocationTrackingContext> context_owned(
3515 new TextureIdAllocationTrackingContext); 3515 new TextureIdAllocationTrackingContext);
3516 TextureIdAllocationTrackingContext* context = context_owned.get(); 3516 TextureIdAllocationTrackingContext* context = context_owned.get();
3517 3517
3518 FakeOutputSurfaceClient output_surface_client; 3518 FakeOutputSurfaceClient output_surface_client;
3519 scoped_ptr<OutputSurface> output_surface( 3519 scoped_ptr<OutputSurface> output_surface(
3520 FakeOutputSurface::Create3d(context_owned.Pass())); 3520 FakeOutputSurface::Create3d(std::move(context_owned)));
3521 CHECK(output_surface->BindToClient(&output_surface_client)); 3521 CHECK(output_surface->BindToClient(&output_surface_client));
3522 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 3522 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
3523 new TestSharedBitmapManager()); 3523 new TestSharedBitmapManager());
3524 3524
3525 gfx::Size size(1, 1); 3525 gfx::Size size(1, 1);
3526 ResourceFormat format = RGBA_8888; 3526 ResourceFormat format = RGBA_8888;
3527 3527
3528 { 3528 {
3529 size_t kTextureAllocationChunkSize = 1; 3529 size_t kTextureAllocationChunkSize = 1;
3530 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3530 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
(...skipping 24 matching lines...) Expand all
3555 resource_provider->AllocateForTesting(id); 3555 resource_provider->AllocateForTesting(id);
3556 Mock::VerifyAndClearExpectations(context); 3556 Mock::VerifyAndClearExpectations(context);
3557 3557
3558 DCHECK_EQ(10u, context->PeekTextureId()); 3558 DCHECK_EQ(10u, context->PeekTextureId());
3559 resource_provider->DeleteResource(id); 3559 resource_provider->DeleteResource(id);
3560 } 3560 }
3561 } 3561 }
3562 3562
3563 } // namespace 3563 } // namespace
3564 } // namespace cc 3564 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/resource_provider.cc ('k') | cc/resources/video_resource_updater_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698