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

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

Issue 485043003: cc: Use correct message loop proxy in BlockingTaskRunner (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nits. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/resources/resource_provider.cc ('k') | cc/resources/resource_update_controller_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 <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/containers/hash_tables.h" 12 #include "base/containers/hash_tables.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "cc/base/scoped_ptr_deque.h" 15 #include "cc/base/scoped_ptr_deque.h"
16 #include "cc/output/output_surface.h" 16 #include "cc/output/output_surface.h"
17 #include "cc/resources/returned_resource.h" 17 #include "cc/resources/returned_resource.h"
18 #include "cc/resources/shared_bitmap_manager.h" 18 #include "cc/resources/shared_bitmap_manager.h"
19 #include "cc/resources/single_release_callback.h" 19 #include "cc/resources/single_release_callback.h"
20 #include "cc/test/fake_output_surface.h" 20 #include "cc/test/fake_output_surface.h"
21 #include "cc/test/fake_output_surface_client.h" 21 #include "cc/test/fake_output_surface_client.h"
22 #include "cc/test/test_shared_bitmap_manager.h" 22 #include "cc/test/test_shared_bitmap_manager.h"
23 #include "cc/test/test_texture.h" 23 #include "cc/test/test_texture.h"
24 #include "cc/test/test_web_graphics_context_3d.h" 24 #include "cc/test/test_web_graphics_context_3d.h"
25 #include "cc/trees/blocking_task_runner.h"
25 #include "gpu/GLES2/gl2extchromium.h" 26 #include "gpu/GLES2/gl2extchromium.h"
26 #include "testing/gmock/include/gmock/gmock.h" 27 #include "testing/gmock/include/gmock/gmock.h"
27 #include "testing/gtest/include/gtest/gtest.h" 28 #include "testing/gtest/include/gtest/gtest.h"
28 #include "third_party/khronos/GLES2/gl2.h" 29 #include "third_party/khronos/GLES2/gl2.h"
29 #include "third_party/khronos/GLES2/gl2ext.h" 30 #include "third_party/khronos/GLES2/gl2ext.h"
30 #include "ui/gfx/rect.h" 31 #include "ui/gfx/rect.h"
31 32
32 using testing::Mock; 33 using testing::Mock;
33 using testing::NiceMock; 34 using testing::NiceMock;
34 using testing::Return; 35 using testing::Return;
35 using testing::SetArgPointee; 36 using testing::SetArgPointee;
36 using testing::StrictMock; 37 using testing::StrictMock;
37 using testing::_; 38 using testing::_;
38 39
39 namespace cc { 40 namespace cc {
40 namespace { 41 namespace {
41 42
42 static void EmptyReleaseCallback(uint32 sync_point, bool lost_resource) {} 43 static void EmptyReleaseCallback(uint32 sync_point,
44 bool lost_resource,
45 BlockingTaskRunner* main_thread_task_runner) {
46 }
43 47
44 static void SharedMemoryReleaseCallback(scoped_ptr<base::SharedMemory> memory, 48 static void ReleaseCallback(
45 uint32 sync_point, 49 uint32* release_sync_point,
46 bool lost_resource) {} 50 bool* release_lost_resource,
47 51 BlockingTaskRunner** release_main_thread_task_runner,
48 static void ReleaseTextureMailbox(uint32* release_sync_point, 52 uint32 sync_point,
49 bool* release_lost_resource, 53 bool lost_resource,
50 uint32 sync_point, 54 BlockingTaskRunner* main_thread_task_runner) {
51 bool lost_resource) {
52 *release_sync_point = sync_point; 55 *release_sync_point = sync_point;
53 *release_lost_resource = lost_resource; 56 *release_lost_resource = lost_resource;
57 *release_main_thread_task_runner = main_thread_task_runner;
58 }
59
60 static void SharedMemoryReleaseCallback(
61 scoped_ptr<base::SharedMemory> memory,
62 uint32 sync_point,
63 bool lost_resource,
64 BlockingTaskRunner* main_thread_task_runner) {
54 } 65 }
55 66
56 static void ReleaseSharedMemoryCallback( 67 static void ReleaseSharedMemoryCallback(
57 scoped_ptr<base::SharedMemory> shared_memory, 68 scoped_ptr<base::SharedMemory> shared_memory,
58 bool* release_called, 69 bool* release_called,
59 uint32* release_sync_point, 70 uint32* release_sync_point,
60 bool* lost_resource_result, 71 bool* lost_resource_result,
61 uint32 sync_point, 72 uint32 sync_point,
62 bool lost_resource) { 73 bool lost_resource,
74 BlockingTaskRunner* main_thread_task_runner) {
63 *release_called = true; 75 *release_called = true;
64 *release_sync_point = sync_point; 76 *release_sync_point = sync_point;
65 *lost_resource_result = lost_resource; 77 *lost_resource_result = lost_resource;
66 } 78 }
67 79
68 static scoped_ptr<base::SharedMemory> CreateAndFillSharedMemory( 80 static scoped_ptr<base::SharedMemory> CreateAndFillSharedMemory(
69 const gfx::Size& size, 81 const gfx::Size& size,
70 uint32_t value) { 82 uint32_t value) {
71 scoped_ptr<base::SharedMemory> shared_memory(new base::SharedMemory); 83 scoped_ptr<base::SharedMemory> shared_memory(new base::SharedMemory);
72 CHECK(shared_memory->CreateAndMapAnonymous(4 * size.GetArea())); 84 CHECK(shared_memory->CreateAndMapAnonymous(4 * size.GetArea()));
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 break; 373 break;
362 } 374 }
363 } 375 }
364 376
365 class ResourceProviderTest 377 class ResourceProviderTest
366 : public testing::TestWithParam<ResourceProvider::ResourceType> { 378 : public testing::TestWithParam<ResourceProvider::ResourceType> {
367 public: 379 public:
368 ResourceProviderTest() 380 ResourceProviderTest()
369 : shared_data_(ContextSharedData::Create()), 381 : shared_data_(ContextSharedData::Create()),
370 context3d_(NULL), 382 context3d_(NULL),
371 child_context_(NULL) { 383 child_context_(NULL),
384 main_thread_task_runner_(BlockingTaskRunner::Create(NULL)) {
372 switch (GetParam()) { 385 switch (GetParam()) {
373 case ResourceProvider::GLTexture: { 386 case ResourceProvider::GLTexture: {
374 scoped_ptr<ResourceProviderContext> context3d( 387 scoped_ptr<ResourceProviderContext> context3d(
375 ResourceProviderContext::Create(shared_data_.get())); 388 ResourceProviderContext::Create(shared_data_.get()));
376 context3d_ = context3d.get(); 389 context3d_ = context3d.get();
377 390
378 scoped_refptr<TestContextProvider> context_provider = 391 scoped_refptr<TestContextProvider> context_provider =
379 TestContextProvider::Create( 392 TestContextProvider::Create(
380 context3d.PassAs<TestWebGraphicsContext3D>()); 393 context3d.PassAs<TestWebGraphicsContext3D>());
381 394
(...skipping 14 matching lines...) Expand all
396 break; 409 break;
397 case ResourceProvider::InvalidType: 410 case ResourceProvider::InvalidType:
398 NOTREACHED(); 411 NOTREACHED();
399 break; 412 break;
400 } 413 }
401 CHECK(output_surface_->BindToClient(&output_surface_client_)); 414 CHECK(output_surface_->BindToClient(&output_surface_client_));
402 CHECK(child_output_surface_->BindToClient(&child_output_surface_client_)); 415 CHECK(child_output_surface_->BindToClient(&child_output_surface_client_));
403 416
404 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); 417 shared_bitmap_manager_.reset(new TestSharedBitmapManager());
405 418
406 resource_provider_ = ResourceProvider::Create( 419 resource_provider_ =
407 output_surface_.get(), shared_bitmap_manager_.get(), 0, false, 1, 420 ResourceProvider::Create(output_surface_.get(),
408 false); 421 shared_bitmap_manager_.get(),
409 child_resource_provider_ = ResourceProvider::Create( 422 main_thread_task_runner_.get(),
410 child_output_surface_.get(), 423 0,
411 shared_bitmap_manager_.get(), 424 false,
412 0, 425 1,
413 false, 426 false);
414 1, 427 child_resource_provider_ =
415 false); 428 ResourceProvider::Create(child_output_surface_.get(),
429 shared_bitmap_manager_.get(),
430 main_thread_task_runner_.get(),
431 0,
432 false,
433 1,
434 false);
416 } 435 }
417 436
418 static void CollectResources(ReturnedResourceArray* array, 437 static void CollectResources(ReturnedResourceArray* array,
419 const ReturnedResourceArray& returned) { 438 const ReturnedResourceArray& returned,
439 BlockingTaskRunner* main_thread_task_runner) {
420 array->insert(array->end(), returned.begin(), returned.end()); 440 array->insert(array->end(), returned.begin(), returned.end());
421 } 441 }
422 442
423 static ReturnCallback GetReturnCallback(ReturnedResourceArray* array) { 443 static ReturnCallback GetReturnCallback(ReturnedResourceArray* array) {
424 return base::Bind(&ResourceProviderTest::CollectResources, array); 444 return base::Bind(&ResourceProviderTest::CollectResources, array);
425 } 445 }
426 446
427 static void SetResourceFilter(ResourceProvider* resource_provider, 447 static void SetResourceFilter(ResourceProvider* resource_provider,
428 ResourceProvider::ResourceId id, 448 ResourceProvider::ResourceId id,
429 GLenum filter) { 449 GLenum filter) {
(...skipping 10 matching lines...) Expand all
440 if (GetParam() == ResourceProvider::GLTexture) { 460 if (GetParam() == ResourceProvider::GLTexture) {
441 unsigned texture = child_context_->createTexture(); 461 unsigned texture = child_context_->createTexture();
442 gpu::Mailbox gpu_mailbox; 462 gpu::Mailbox gpu_mailbox;
443 child_context_->bindTexture(GL_TEXTURE_2D, texture); 463 child_context_->bindTexture(GL_TEXTURE_2D, texture);
444 child_context_->genMailboxCHROMIUM(gpu_mailbox.name); 464 child_context_->genMailboxCHROMIUM(gpu_mailbox.name);
445 child_context_->produceTextureCHROMIUM(GL_TEXTURE_2D, gpu_mailbox.name); 465 child_context_->produceTextureCHROMIUM(GL_TEXTURE_2D, gpu_mailbox.name);
446 *sync_point = child_context_->insertSyncPoint(); 466 *sync_point = child_context_->insertSyncPoint();
447 EXPECT_LT(0u, *sync_point); 467 EXPECT_LT(0u, *sync_point);
448 468
449 scoped_ptr<base::SharedMemory> shared_memory; 469 scoped_ptr<base::SharedMemory> shared_memory;
450 scoped_ptr<SingleReleaseCallback> callback = 470 scoped_ptr<SingleReleaseCallbackImpl> callback =
451 SingleReleaseCallback::Create(base::Bind(ReleaseSharedMemoryCallback, 471 SingleReleaseCallbackImpl::Create(
452 base::Passed(&shared_memory), 472 base::Bind(ReleaseSharedMemoryCallback,
453 release_called, 473 base::Passed(&shared_memory),
454 release_sync_point, 474 release_called,
455 lost_resource)); 475 release_sync_point,
476 lost_resource));
456 return child_resource_provider_->CreateResourceFromTextureMailbox( 477 return child_resource_provider_->CreateResourceFromTextureMailbox(
457 TextureMailbox(gpu_mailbox, GL_TEXTURE_2D, *sync_point), 478 TextureMailbox(gpu_mailbox, GL_TEXTURE_2D, *sync_point),
458 callback.Pass()); 479 callback.Pass());
459 } else { 480 } else {
460 gfx::Size size(64, 64); 481 gfx::Size size(64, 64);
461 scoped_ptr<base::SharedMemory> shared_memory( 482 scoped_ptr<base::SharedMemory> shared_memory(
462 CreateAndFillSharedMemory(size, 0)); 483 CreateAndFillSharedMemory(size, 0));
463 484
464 base::SharedMemory* shared_memory_ptr = shared_memory.get(); 485 base::SharedMemory* shared_memory_ptr = shared_memory.get();
465 scoped_ptr<SingleReleaseCallback> callback = 486 scoped_ptr<SingleReleaseCallbackImpl> callback =
466 SingleReleaseCallback::Create(base::Bind(ReleaseSharedMemoryCallback, 487 SingleReleaseCallbackImpl::Create(
467 base::Passed(&shared_memory), 488 base::Bind(ReleaseSharedMemoryCallback,
468 release_called, 489 base::Passed(&shared_memory),
469 release_sync_point, 490 release_called,
470 lost_resource)); 491 release_sync_point,
492 lost_resource));
471 return child_resource_provider_->CreateResourceFromTextureMailbox( 493 return child_resource_provider_->CreateResourceFromTextureMailbox(
472 TextureMailbox(shared_memory_ptr, size), callback.Pass()); 494 TextureMailbox(shared_memory_ptr, size), callback.Pass());
473 } 495 }
474 } 496 }
475 497
476 protected: 498 protected:
477 scoped_ptr<ContextSharedData> shared_data_; 499 scoped_ptr<ContextSharedData> shared_data_;
478 ResourceProviderContext* context3d_; 500 ResourceProviderContext* context3d_;
479 ResourceProviderContext* child_context_; 501 ResourceProviderContext* child_context_;
480 FakeOutputSurfaceClient output_surface_client_; 502 FakeOutputSurfaceClient output_surface_client_;
481 FakeOutputSurfaceClient child_output_surface_client_; 503 FakeOutputSurfaceClient child_output_surface_client_;
482 scoped_ptr<OutputSurface> output_surface_; 504 scoped_ptr<OutputSurface> output_surface_;
483 scoped_ptr<OutputSurface> child_output_surface_; 505 scoped_ptr<OutputSurface> child_output_surface_;
506 scoped_ptr<BlockingTaskRunner> main_thread_task_runner_;
484 scoped_ptr<ResourceProvider> resource_provider_; 507 scoped_ptr<ResourceProvider> resource_provider_;
485 scoped_ptr<ResourceProvider> child_resource_provider_; 508 scoped_ptr<ResourceProvider> child_resource_provider_;
486 scoped_ptr<TestSharedBitmapManager> shared_bitmap_manager_; 509 scoped_ptr<TestSharedBitmapManager> shared_bitmap_manager_;
487 }; 510 };
488 511
489 void CheckCreateResource(ResourceProvider::ResourceType expected_default_type, 512 void CheckCreateResource(ResourceProvider::ResourceType expected_default_type,
490 ResourceProvider* resource_provider, 513 ResourceProvider* resource_provider,
491 ResourceProviderContext* context) { 514 ResourceProviderContext* context) {
492 DCHECK_EQ(expected_default_type, resource_provider->default_resource_type()); 515 DCHECK_EQ(expected_default_type, resource_provider->default_resource_type());
493 516
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 641
619 gpu::Mailbox external_mailbox; 642 gpu::Mailbox external_mailbox;
620 child_context_->genMailboxCHROMIUM(external_mailbox.name); 643 child_context_->genMailboxCHROMIUM(external_mailbox.name);
621 child_context_->produceTextureCHROMIUM(GL_TEXTURE_EXTERNAL_OES, 644 child_context_->produceTextureCHROMIUM(GL_TEXTURE_EXTERNAL_OES,
622 external_mailbox.name); 645 external_mailbox.name);
623 const GLuint external_sync_point = child_context_->insertSyncPoint(); 646 const GLuint external_sync_point = child_context_->insertSyncPoint();
624 ResourceProvider::ResourceId id4 = 647 ResourceProvider::ResourceId id4 =
625 child_resource_provider_->CreateResourceFromTextureMailbox( 648 child_resource_provider_->CreateResourceFromTextureMailbox(
626 TextureMailbox( 649 TextureMailbox(
627 external_mailbox, GL_TEXTURE_EXTERNAL_OES, external_sync_point), 650 external_mailbox, GL_TEXTURE_EXTERNAL_OES, external_sync_point),
628 SingleReleaseCallback::Create(base::Bind(&EmptyReleaseCallback))); 651 SingleReleaseCallbackImpl::Create(base::Bind(&EmptyReleaseCallback)));
629 652
630 ReturnedResourceArray returned_to_child; 653 ReturnedResourceArray returned_to_child;
631 int child_id = 654 int child_id =
632 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); 655 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child));
633 { 656 {
634 // Transfer some resources to the parent. 657 // Transfer some resources to the parent.
635 ResourceProvider::ResourceIdArray resource_ids_to_transfer; 658 ResourceProvider::ResourceIdArray resource_ids_to_transfer;
636 resource_ids_to_transfer.push_back(id1); 659 resource_ids_to_transfer.push_back(id1);
637 resource_ids_to_transfer.push_back(id2); 660 resource_ids_to_transfer.push_back(id2);
638 resource_ids_to_transfer.push_back(id3); 661 resource_ids_to_transfer.push_back(id3);
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 } 908 }
886 909
887 TEST_P(ResourceProviderTest, AllowOverlayTransfersToParent) { 910 TEST_P(ResourceProviderTest, AllowOverlayTransfersToParent) {
888 // Overlays only supported on the GL path. 911 // Overlays only supported on the GL path.
889 if (GetParam() != ResourceProvider::GLTexture) 912 if (GetParam() != ResourceProvider::GLTexture)
890 return; 913 return;
891 914
892 uint32 sync_point = 0; 915 uint32 sync_point = 0;
893 TextureMailbox mailbox(gpu::Mailbox::Generate(), GL_TEXTURE_2D, sync_point); 916 TextureMailbox mailbox(gpu::Mailbox::Generate(), GL_TEXTURE_2D, sync_point);
894 mailbox.set_allow_overlay(true); 917 mailbox.set_allow_overlay(true);
895 scoped_ptr<SingleReleaseCallback> release_callback = 918 scoped_ptr<SingleReleaseCallbackImpl> release_callback =
896 SingleReleaseCallback::Create(base::Bind(&EmptyReleaseCallback)); 919 SingleReleaseCallbackImpl::Create(base::Bind(&EmptyReleaseCallback));
897 ResourceProvider::ResourceId id1 = 920 ResourceProvider::ResourceId id1 =
898 child_resource_provider_->CreateResourceFromTextureMailbox( 921 child_resource_provider_->CreateResourceFromTextureMailbox(
899 mailbox, release_callback.Pass()); 922 mailbox, release_callback.Pass());
900 923
901 TextureMailbox mailbox2(gpu::Mailbox::Generate(), GL_TEXTURE_2D, sync_point); 924 TextureMailbox mailbox2(gpu::Mailbox::Generate(), GL_TEXTURE_2D, sync_point);
902 mailbox2.set_allow_overlay(false); 925 mailbox2.set_allow_overlay(false);
903 scoped_ptr<SingleReleaseCallback> release_callback2 = 926 scoped_ptr<SingleReleaseCallbackImpl> release_callback2 =
904 SingleReleaseCallback::Create(base::Bind(&EmptyReleaseCallback)); 927 SingleReleaseCallbackImpl::Create(base::Bind(&EmptyReleaseCallback));
905 ResourceProvider::ResourceId id2 = 928 ResourceProvider::ResourceId id2 =
906 child_resource_provider_->CreateResourceFromTextureMailbox( 929 child_resource_provider_->CreateResourceFromTextureMailbox(
907 mailbox2, release_callback2.Pass()); 930 mailbox2, release_callback2.Pass());
908 931
909 ReturnedResourceArray returned_to_child; 932 ReturnedResourceArray returned_to_child;
910 int child_id = 933 int child_id =
911 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); 934 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child));
912 935
913 // Transfer some resources to the parent. 936 // Transfer some resources to the parent.
914 ResourceProvider::ResourceIdArray resource_ids_to_transfer; 937 ResourceProvider::ResourceIdArray resource_ids_to_transfer;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 raster_buffer->ReleaseSkCanvas(canvas); 989 raster_buffer->ReleaseSkCanvas(canvas);
967 canvas.clear(); 990 canvas.clear();
968 child_resource_provider_->ReleaseImageRasterBuffer(id3); 991 child_resource_provider_->ReleaseImageRasterBuffer(id3);
969 992
970 scoped_ptr<base::SharedMemory> shared_memory(new base::SharedMemory()); 993 scoped_ptr<base::SharedMemory> shared_memory(new base::SharedMemory());
971 shared_memory->CreateAndMapAnonymous(1); 994 shared_memory->CreateAndMapAnonymous(1);
972 base::SharedMemory* shared_memory_ptr = shared_memory.get(); 995 base::SharedMemory* shared_memory_ptr = shared_memory.get();
973 ResourceProvider::ResourceId id4 = 996 ResourceProvider::ResourceId id4 =
974 child_resource_provider_->CreateResourceFromTextureMailbox( 997 child_resource_provider_->CreateResourceFromTextureMailbox(
975 TextureMailbox(shared_memory_ptr, gfx::Size(1, 1)), 998 TextureMailbox(shared_memory_ptr, gfx::Size(1, 1)),
976 SingleReleaseCallback::Create(base::Bind( 999 SingleReleaseCallbackImpl::Create(base::Bind(
977 &SharedMemoryReleaseCallback, base::Passed(&shared_memory)))); 1000 &SharedMemoryReleaseCallback, base::Passed(&shared_memory))));
978 1001
979 ReturnedResourceArray returned_to_child; 1002 ReturnedResourceArray returned_to_child;
980 int child_id = 1003 int child_id =
981 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); 1004 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child));
982 { 1005 {
983 // Transfer some resources to the parent. 1006 // Transfer some resources to the parent.
984 ResourceProvider::ResourceIdArray resource_ids_to_transfer; 1007 ResourceProvider::ResourceIdArray resource_ids_to_transfer;
985 resource_ids_to_transfer.push_back(id1); 1008 resource_ids_to_transfer.push_back(id1);
986 resource_ids_to_transfer.push_back(id2); 1009 resource_ids_to_transfer.push_back(id2);
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
1168 return; 1191 return;
1169 1192
1170 scoped_ptr<ResourceProviderContext> child_context_owned( 1193 scoped_ptr<ResourceProviderContext> child_context_owned(
1171 ResourceProviderContext::Create(shared_data_.get())); 1194 ResourceProviderContext::Create(shared_data_.get()));
1172 1195
1173 FakeOutputSurfaceClient child_output_surface_client; 1196 FakeOutputSurfaceClient child_output_surface_client;
1174 scoped_ptr<OutputSurface> child_output_surface(FakeOutputSurface::Create3d( 1197 scoped_ptr<OutputSurface> child_output_surface(FakeOutputSurface::Create3d(
1175 child_context_owned.PassAs<TestWebGraphicsContext3D>())); 1198 child_context_owned.PassAs<TestWebGraphicsContext3D>()));
1176 CHECK(child_output_surface->BindToClient(&child_output_surface_client)); 1199 CHECK(child_output_surface->BindToClient(&child_output_surface_client));
1177 1200
1178 scoped_ptr<ResourceProvider> child_resource_provider(ResourceProvider::Create( 1201 scoped_ptr<ResourceProvider> child_resource_provider(
1179 child_output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, 1202 ResourceProvider::Create(child_output_surface.get(),
1180 false)); 1203 shared_bitmap_manager_.get(),
1204 NULL,
1205 0,
1206 false,
1207 1,
1208 false));
1181 1209
1182 gfx::Size size(1, 1); 1210 gfx::Size size(1, 1);
1183 ResourceFormat format = RGBA_8888; 1211 ResourceFormat format = RGBA_8888;
1184 size_t pixel_size = TextureSizeBytes(size, format); 1212 size_t pixel_size = TextureSizeBytes(size, format);
1185 ASSERT_EQ(4U, pixel_size); 1213 ASSERT_EQ(4U, pixel_size);
1186 1214
1187 ResourceProvider::ResourceId id1 = child_resource_provider->CreateResource( 1215 ResourceProvider::ResourceId id1 = child_resource_provider->CreateResource(
1188 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); 1216 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
1189 uint8_t data1[4] = { 1, 2, 3, 4 }; 1217 uint8_t data1[4] = { 1, 2, 3, 4 };
1190 gfx::Rect rect(size); 1218 gfx::Rect rect(size);
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
1648 FakeOutputSurfaceClient child_output_surface_client; 1676 FakeOutputSurfaceClient child_output_surface_client;
1649 scoped_ptr<OutputSurface> child_output_surface(FakeOutputSurface::Create3d( 1677 scoped_ptr<OutputSurface> child_output_surface(FakeOutputSurface::Create3d(
1650 child_context_owned.PassAs<TestWebGraphicsContext3D>())); 1678 child_context_owned.PassAs<TestWebGraphicsContext3D>()));
1651 CHECK(child_output_surface->BindToClient(&child_output_surface_client)); 1679 CHECK(child_output_surface->BindToClient(&child_output_surface_client));
1652 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 1680 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
1653 new TestSharedBitmapManager()); 1681 new TestSharedBitmapManager());
1654 1682
1655 scoped_ptr<ResourceProvider> child_resource_provider( 1683 scoped_ptr<ResourceProvider> child_resource_provider(
1656 ResourceProvider::Create(child_output_surface.get(), 1684 ResourceProvider::Create(child_output_surface.get(),
1657 shared_bitmap_manager.get(), 1685 shared_bitmap_manager.get(),
1686 NULL,
1658 0, 1687 0,
1659 false, 1688 false,
1660 1, 1689 1,
1661 false)); 1690 false));
1662 1691
1663 scoped_ptr<TextureStateTrackingContext> parent_context_owned( 1692 scoped_ptr<TextureStateTrackingContext> parent_context_owned(
1664 new TextureStateTrackingContext); 1693 new TextureStateTrackingContext);
1665 TextureStateTrackingContext* parent_context = parent_context_owned.get(); 1694 TextureStateTrackingContext* parent_context = parent_context_owned.get();
1666 1695
1667 FakeOutputSurfaceClient parent_output_surface_client; 1696 FakeOutputSurfaceClient parent_output_surface_client;
1668 scoped_ptr<OutputSurface> parent_output_surface(FakeOutputSurface::Create3d( 1697 scoped_ptr<OutputSurface> parent_output_surface(FakeOutputSurface::Create3d(
1669 parent_context_owned.PassAs<TestWebGraphicsContext3D>())); 1698 parent_context_owned.PassAs<TestWebGraphicsContext3D>()));
1670 CHECK(parent_output_surface->BindToClient(&parent_output_surface_client)); 1699 CHECK(parent_output_surface->BindToClient(&parent_output_surface_client));
1671 1700
1672 scoped_ptr<ResourceProvider> parent_resource_provider( 1701 scoped_ptr<ResourceProvider> parent_resource_provider(
1673 ResourceProvider::Create(parent_output_surface.get(), 1702 ResourceProvider::Create(parent_output_surface.get(),
1674 shared_bitmap_manager.get(), 1703 shared_bitmap_manager.get(),
1704 NULL,
1675 0, 1705 0,
1676 false, 1706 false,
1677 1, 1707 1,
1678 false)); 1708 false));
1679 1709
1680 gfx::Size size(1, 1); 1710 gfx::Size size(1, 1);
1681 ResourceFormat format = RGBA_8888; 1711 ResourceFormat format = RGBA_8888;
1682 int child_texture_id = 1; 1712 int child_texture_id = 1;
1683 int parent_texture_id = 2; 1713 int parent_texture_id = 2;
1684 1714
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1835 gpu::Mailbox mailbox; 1865 gpu::Mailbox mailbox;
1836 context()->genMailboxCHROMIUM(mailbox.name); 1866 context()->genMailboxCHROMIUM(mailbox.name);
1837 context()->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); 1867 context()->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name);
1838 uint32 sync_point = context()->insertSyncPoint(); 1868 uint32 sync_point = context()->insertSyncPoint();
1839 1869
1840 // All the logic below assumes that the sync points are all positive. 1870 // All the logic below assumes that the sync points are all positive.
1841 EXPECT_LT(0u, sync_point); 1871 EXPECT_LT(0u, sync_point);
1842 1872
1843 uint32 release_sync_point = 0; 1873 uint32 release_sync_point = 0;
1844 bool lost_resource = false; 1874 bool lost_resource = false;
1845 ReleaseCallback callback = 1875 BlockingTaskRunner* main_thread_task_runner = NULL;
1846 base::Bind(ReleaseTextureMailbox, &release_sync_point, &lost_resource); 1876 ReleaseCallbackImpl callback = base::Bind(ReleaseCallback,
1877 &release_sync_point,
1878 &lost_resource,
1879 &main_thread_task_runner);
1847 ResourceProvider::ResourceId resource = 1880 ResourceProvider::ResourceId resource =
1848 resource_provider_->CreateResourceFromTextureMailbox( 1881 resource_provider_->CreateResourceFromTextureMailbox(
1849 TextureMailbox(mailbox, GL_TEXTURE_2D, sync_point), 1882 TextureMailbox(mailbox, GL_TEXTURE_2D, sync_point),
1850 SingleReleaseCallback::Create(callback)); 1883 SingleReleaseCallbackImpl::Create(callback));
1851 EXPECT_EQ(1u, context()->NumTextures()); 1884 EXPECT_EQ(1u, context()->NumTextures());
1852 EXPECT_EQ(0u, release_sync_point); 1885 EXPECT_EQ(0u, release_sync_point);
1853 { 1886 {
1854 // Transfer the resource, expect the sync points to be consistent. 1887 // Transfer the resource, expect the sync points to be consistent.
1855 ResourceProvider::ResourceIdArray resource_ids_to_transfer; 1888 ResourceProvider::ResourceIdArray resource_ids_to_transfer;
1856 resource_ids_to_transfer.push_back(resource); 1889 resource_ids_to_transfer.push_back(resource);
1857 TransferableResourceArray list; 1890 TransferableResourceArray list;
1858 resource_provider_->PrepareSendToParent(resource_ids_to_transfer, &list); 1891 resource_provider_->PrepareSendToParent(resource_ids_to_transfer, &list);
1859 ASSERT_EQ(1u, list.size()); 1892 ASSERT_EQ(1u, list.size());
1860 EXPECT_LE(sync_point, list[0].mailbox_holder.sync_point); 1893 EXPECT_LE(sync_point, list[0].mailbox_holder.sync_point);
(...skipping 20 matching lines...) Expand all
1881 // consistent. 1914 // consistent.
1882 ReturnedResourceArray returned; 1915 ReturnedResourceArray returned;
1883 TransferableResource::ReturnResources(list, &returned); 1916 TransferableResource::ReturnResources(list, &returned);
1884 resource_provider_->ReceiveReturnsFromParent(returned); 1917 resource_provider_->ReceiveReturnsFromParent(returned);
1885 EXPECT_EQ(1u, context()->NumTextures()); 1918 EXPECT_EQ(1u, context()->NumTextures());
1886 EXPECT_EQ(0u, release_sync_point); 1919 EXPECT_EQ(0u, release_sync_point);
1887 1920
1888 resource_provider_->DeleteResource(resource); 1921 resource_provider_->DeleteResource(resource);
1889 EXPECT_LE(list[0].mailbox_holder.sync_point, release_sync_point); 1922 EXPECT_LE(list[0].mailbox_holder.sync_point, release_sync_point);
1890 EXPECT_FALSE(lost_resource); 1923 EXPECT_FALSE(lost_resource);
1924 EXPECT_EQ(main_thread_task_runner_.get(), main_thread_task_runner);
1891 } 1925 }
1892 1926
1893 // We're going to do the same thing as above, but testing the case where we 1927 // We're going to do the same thing as above, but testing the case where we
1894 // delete the resource before we receive it back. 1928 // delete the resource before we receive it back.
1895 sync_point = release_sync_point; 1929 sync_point = release_sync_point;
1896 EXPECT_LT(0u, sync_point); 1930 EXPECT_LT(0u, sync_point);
1897 release_sync_point = 0; 1931 release_sync_point = 0;
1898 resource = resource_provider_->CreateResourceFromTextureMailbox( 1932 resource = resource_provider_->CreateResourceFromTextureMailbox(
1899 TextureMailbox(mailbox, GL_TEXTURE_2D, sync_point), 1933 TextureMailbox(mailbox, GL_TEXTURE_2D, sync_point),
1900 SingleReleaseCallback::Create(callback)); 1934 SingleReleaseCallbackImpl::Create(callback));
1901 EXPECT_EQ(1u, context()->NumTextures()); 1935 EXPECT_EQ(1u, context()->NumTextures());
1902 EXPECT_EQ(0u, release_sync_point); 1936 EXPECT_EQ(0u, release_sync_point);
1903 { 1937 {
1904 // Transfer the resource, expect the sync points to be consistent. 1938 // Transfer the resource, expect the sync points to be consistent.
1905 ResourceProvider::ResourceIdArray resource_ids_to_transfer; 1939 ResourceProvider::ResourceIdArray resource_ids_to_transfer;
1906 resource_ids_to_transfer.push_back(resource); 1940 resource_ids_to_transfer.push_back(resource);
1907 TransferableResourceArray list; 1941 TransferableResourceArray list;
1908 resource_provider_->PrepareSendToParent(resource_ids_to_transfer, &list); 1942 resource_provider_->PrepareSendToParent(resource_ids_to_transfer, &list);
1909 ASSERT_EQ(1u, list.size()); 1943 ASSERT_EQ(1u, list.size());
1910 EXPECT_LE(sync_point, list[0].mailbox_holder.sync_point); 1944 EXPECT_LE(sync_point, list[0].mailbox_holder.sync_point);
(...skipping 21 matching lines...) Expand all
1932 EXPECT_EQ(1u, context()->NumTextures()); 1966 EXPECT_EQ(1u, context()->NumTextures());
1933 EXPECT_EQ(0u, release_sync_point); 1967 EXPECT_EQ(0u, release_sync_point);
1934 1968
1935 // Then receive the resource which should release the mailbox, expect the 1969 // Then receive the resource which should release the mailbox, expect the
1936 // sync points to be consistent. 1970 // sync points to be consistent.
1937 ReturnedResourceArray returned; 1971 ReturnedResourceArray returned;
1938 TransferableResource::ReturnResources(list, &returned); 1972 TransferableResource::ReturnResources(list, &returned);
1939 resource_provider_->ReceiveReturnsFromParent(returned); 1973 resource_provider_->ReceiveReturnsFromParent(returned);
1940 EXPECT_LE(list[0].mailbox_holder.sync_point, release_sync_point); 1974 EXPECT_LE(list[0].mailbox_holder.sync_point, release_sync_point);
1941 EXPECT_FALSE(lost_resource); 1975 EXPECT_FALSE(lost_resource);
1976 EXPECT_EQ(main_thread_task_runner_.get(), main_thread_task_runner);
1942 } 1977 }
1943 1978
1944 context()->waitSyncPoint(release_sync_point); 1979 context()->waitSyncPoint(release_sync_point);
1945 context()->bindTexture(GL_TEXTURE_2D, texture); 1980 context()->bindTexture(GL_TEXTURE_2D, texture);
1946 context()->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); 1981 context()->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name);
1947 context()->deleteTexture(texture); 1982 context()->deleteTexture(texture);
1948 } 1983 }
1949 1984
1950 TEST_P(ResourceProviderTest, LostResourceInParent) { 1985 TEST_P(ResourceProviderTest, LostResourceInParent) {
1951 gfx::Size size(1, 1); 1986 gfx::Size size(1, 1);
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
2253 context()->bindTexture(GL_TEXTURE_2D, texture); 2288 context()->bindTexture(GL_TEXTURE_2D, texture);
2254 gpu::Mailbox mailbox; 2289 gpu::Mailbox mailbox;
2255 context()->genMailboxCHROMIUM(mailbox.name); 2290 context()->genMailboxCHROMIUM(mailbox.name);
2256 context()->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); 2291 context()->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name);
2257 uint32 sync_point = context()->insertSyncPoint(); 2292 uint32 sync_point = context()->insertSyncPoint();
2258 2293
2259 EXPECT_LT(0u, sync_point); 2294 EXPECT_LT(0u, sync_point);
2260 2295
2261 uint32 release_sync_point = 0; 2296 uint32 release_sync_point = 0;
2262 bool lost_resource = false; 2297 bool lost_resource = false;
2263 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( 2298 BlockingTaskRunner* main_thread_task_runner = NULL;
2264 base::Bind(ReleaseTextureMailbox, &release_sync_point, &lost_resource)); 2299 scoped_ptr<SingleReleaseCallbackImpl> callback =
2300 SingleReleaseCallbackImpl::Create(base::Bind(ReleaseCallback,
2301 &release_sync_point,
2302 &lost_resource,
2303 &main_thread_task_runner));
2265 resource_provider_->CreateResourceFromTextureMailbox( 2304 resource_provider_->CreateResourceFromTextureMailbox(
2266 TextureMailbox(mailbox, GL_TEXTURE_2D, sync_point), callback.Pass()); 2305 TextureMailbox(mailbox, GL_TEXTURE_2D, sync_point), callback.Pass());
2267 2306
2268 EXPECT_EQ(0u, release_sync_point); 2307 EXPECT_EQ(0u, release_sync_point);
2269 EXPECT_FALSE(lost_resource); 2308 EXPECT_FALSE(lost_resource);
2309 EXPECT_EQ(NULL, main_thread_task_runner);
2270 2310
2271 resource_provider_->DidLoseOutputSurface(); 2311 resource_provider_->DidLoseOutputSurface();
2272 resource_provider_.reset(); 2312 resource_provider_.reset();
2273 2313
2274 EXPECT_LE(sync_point, release_sync_point); 2314 EXPECT_LE(sync_point, release_sync_point);
2275 EXPECT_TRUE(lost_resource); 2315 EXPECT_TRUE(lost_resource);
2316 EXPECT_EQ(main_thread_task_runner_.get(), main_thread_task_runner);
2276 } 2317 }
2277 2318
2278 TEST_P(ResourceProviderTest, ScopedSampler) { 2319 TEST_P(ResourceProviderTest, ScopedSampler) {
2279 // Sampling is only supported for GL textures. 2320 // Sampling is only supported for GL textures.
2280 if (GetParam() != ResourceProvider::GLTexture) 2321 if (GetParam() != ResourceProvider::GLTexture)
2281 return; 2322 return;
2282 2323
2283 scoped_ptr<TextureStateTrackingContext> context_owned( 2324 scoped_ptr<TextureStateTrackingContext> context_owned(
2284 new TextureStateTrackingContext); 2325 new TextureStateTrackingContext);
2285 TextureStateTrackingContext* context = context_owned.get(); 2326 TextureStateTrackingContext* context = context_owned.get();
2286 2327
2287 FakeOutputSurfaceClient output_surface_client; 2328 FakeOutputSurfaceClient output_surface_client;
2288 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( 2329 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
2289 context_owned.PassAs<TestWebGraphicsContext3D>())); 2330 context_owned.PassAs<TestWebGraphicsContext3D>()));
2290 CHECK(output_surface->BindToClient(&output_surface_client)); 2331 CHECK(output_surface->BindToClient(&output_surface_client));
2291 2332
2292 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 2333 scoped_ptr<ResourceProvider> resource_provider(
2293 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); 2334 ResourceProvider::Create(output_surface.get(),
2335 shared_bitmap_manager_.get(),
2336 NULL,
2337 0,
2338 false,
2339 1,
2340 false));
2294 2341
2295 gfx::Size size(1, 1); 2342 gfx::Size size(1, 1);
2296 ResourceFormat format = RGBA_8888; 2343 ResourceFormat format = RGBA_8888;
2297 int texture_id = 1; 2344 int texture_id = 1;
2298 2345
2299 ResourceProvider::ResourceId id = resource_provider->CreateResource( 2346 ResourceProvider::ResourceId id = resource_provider->CreateResource(
2300 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); 2347 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
2301 2348
2302 // Check that the texture gets created with the right sampler settings. 2349 // Check that the texture gets created with the right sampler settings.
2303 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)) 2350 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id))
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
2363 2410
2364 scoped_ptr<TextureStateTrackingContext> context_owned( 2411 scoped_ptr<TextureStateTrackingContext> context_owned(
2365 new TextureStateTrackingContext); 2412 new TextureStateTrackingContext);
2366 TextureStateTrackingContext* context = context_owned.get(); 2413 TextureStateTrackingContext* context = context_owned.get();
2367 2414
2368 FakeOutputSurfaceClient output_surface_client; 2415 FakeOutputSurfaceClient output_surface_client;
2369 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( 2416 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
2370 context_owned.PassAs<TestWebGraphicsContext3D>())); 2417 context_owned.PassAs<TestWebGraphicsContext3D>()));
2371 CHECK(output_surface->BindToClient(&output_surface_client)); 2418 CHECK(output_surface->BindToClient(&output_surface_client));
2372 2419
2373 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 2420 scoped_ptr<ResourceProvider> resource_provider(
2374 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); 2421 ResourceProvider::Create(output_surface.get(),
2422 shared_bitmap_manager_.get(),
2423 NULL,
2424 0,
2425 false,
2426 1,
2427 false));
2375 2428
2376 gfx::Size size(1, 1); 2429 gfx::Size size(1, 1);
2377 ResourceFormat format = RGBA_8888; 2430 ResourceFormat format = RGBA_8888;
2378 int texture_id = 1; 2431 int texture_id = 1;
2379 2432
2380 // Check that the texture gets created with the right sampler settings. 2433 // Check that the texture gets created with the right sampler settings.
2381 ResourceProvider::ResourceId id = resource_provider->CreateManagedResource( 2434 ResourceProvider::ResourceId id = resource_provider->CreateManagedResource(
2382 size, 2435 size,
2383 GL_TEXTURE_2D, 2436 GL_TEXTURE_2D,
2384 GL_CLAMP_TO_EDGE, 2437 GL_CLAMP_TO_EDGE,
(...skipping 27 matching lines...) Expand all
2412 2465
2413 scoped_ptr<TextureStateTrackingContext> context_owned( 2466 scoped_ptr<TextureStateTrackingContext> context_owned(
2414 new TextureStateTrackingContext); 2467 new TextureStateTrackingContext);
2415 TextureStateTrackingContext* context = context_owned.get(); 2468 TextureStateTrackingContext* context = context_owned.get();
2416 2469
2417 FakeOutputSurfaceClient output_surface_client; 2470 FakeOutputSurfaceClient output_surface_client;
2418 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( 2471 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
2419 context_owned.PassAs<TestWebGraphicsContext3D>())); 2472 context_owned.PassAs<TestWebGraphicsContext3D>()));
2420 CHECK(output_surface->BindToClient(&output_surface_client)); 2473 CHECK(output_surface->BindToClient(&output_surface_client));
2421 2474
2422 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 2475 scoped_ptr<ResourceProvider> resource_provider(
2423 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); 2476 ResourceProvider::Create(output_surface.get(),
2477 shared_bitmap_manager_.get(),
2478 NULL,
2479 0,
2480 false,
2481 1,
2482 false));
2424 2483
2425 gfx::Size size(1, 1); 2484 gfx::Size size(1, 1);
2426 ResourceFormat format = RGBA_8888; 2485 ResourceFormat format = RGBA_8888;
2427 GLenum texture_pool = GL_TEXTURE_POOL_UNMANAGED_CHROMIUM; 2486 GLenum texture_pool = GL_TEXTURE_POOL_UNMANAGED_CHROMIUM;
2428 2487
2429 for (int texture_id = 1; texture_id <= 2; ++texture_id) { 2488 for (int texture_id = 1; texture_id <= 2; ++texture_id) {
2430 GLint wrap_mode = texture_id == 1 ? GL_CLAMP_TO_EDGE : GL_REPEAT; 2489 GLint wrap_mode = texture_id == 1 ? GL_CLAMP_TO_EDGE : GL_REPEAT;
2431 // Check that the texture gets created with the right sampler settings. 2490 // Check that the texture gets created with the right sampler settings.
2432 ResourceProvider::ResourceId id = resource_provider->CreateGLTexture( 2491 ResourceProvider::ResourceId id = resource_provider->CreateGLTexture(
2433 size, 2492 size,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2465 new TextureStateTrackingContext); 2524 new TextureStateTrackingContext);
2466 TextureStateTrackingContext* context = context_owned.get(); 2525 TextureStateTrackingContext* context = context_owned.get();
2467 context->set_support_texture_storage(true); 2526 context->set_support_texture_storage(true);
2468 context->set_support_texture_usage(true); 2527 context->set_support_texture_usage(true);
2469 2528
2470 FakeOutputSurfaceClient output_surface_client; 2529 FakeOutputSurfaceClient output_surface_client;
2471 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( 2530 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
2472 context_owned.PassAs<TestWebGraphicsContext3D>())); 2531 context_owned.PassAs<TestWebGraphicsContext3D>()));
2473 CHECK(output_surface->BindToClient(&output_surface_client)); 2532 CHECK(output_surface->BindToClient(&output_surface_client));
2474 2533
2475 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 2534 scoped_ptr<ResourceProvider> resource_provider(
2476 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); 2535 ResourceProvider::Create(output_surface.get(),
2536 shared_bitmap_manager_.get(),
2537 NULL,
2538 0,
2539 false,
2540 1,
2541 false));
2477 2542
2478 gfx::Size size(1, 1); 2543 gfx::Size size(1, 1);
2479 ResourceFormat format = RGBA_8888; 2544 ResourceFormat format = RGBA_8888;
2480 GLenum texture_pool = GL_TEXTURE_POOL_UNMANAGED_CHROMIUM; 2545 GLenum texture_pool = GL_TEXTURE_POOL_UNMANAGED_CHROMIUM;
2481 2546
2482 const ResourceProvider::TextureHint hints[4] = { 2547 const ResourceProvider::TextureHint hints[4] = {
2483 ResourceProvider::TextureHintDefault, 2548 ResourceProvider::TextureHintDefault,
2484 ResourceProvider::TextureHintImmutable, 2549 ResourceProvider::TextureHintImmutable,
2485 ResourceProvider::TextureHintFramebuffer, 2550 ResourceProvider::TextureHintFramebuffer,
2486 ResourceProvider::TextureHintImmutableFramebuffer, 2551 ResourceProvider::TextureHintImmutableFramebuffer,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2532 const uint32_t kBadBeef = 0xbadbeef; 2597 const uint32_t kBadBeef = 0xbadbeef;
2533 scoped_ptr<base::SharedMemory> shared_memory( 2598 scoped_ptr<base::SharedMemory> shared_memory(
2534 CreateAndFillSharedMemory(size, kBadBeef)); 2599 CreateAndFillSharedMemory(size, kBadBeef));
2535 2600
2536 FakeOutputSurfaceClient output_surface_client; 2601 FakeOutputSurfaceClient output_surface_client;
2537 scoped_ptr<OutputSurface> output_surface( 2602 scoped_ptr<OutputSurface> output_surface(
2538 FakeOutputSurface::CreateSoftware(make_scoped_ptr( 2603 FakeOutputSurface::CreateSoftware(make_scoped_ptr(
2539 new SoftwareOutputDevice))); 2604 new SoftwareOutputDevice)));
2540 CHECK(output_surface->BindToClient(&output_surface_client)); 2605 CHECK(output_surface->BindToClient(&output_surface_client));
2541 2606
2542 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 2607 scoped_ptr<ResourceProvider> resource_provider(
2543 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); 2608 ResourceProvider::Create(output_surface.get(),
2609 shared_bitmap_manager_.get(),
2610 main_thread_task_runner_.get(),
2611 0,
2612 false,
2613 1,
2614 false));
2544 2615
2545 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( 2616 uint32 release_sync_point = 0;
2546 base::Bind(&EmptyReleaseCallback)); 2617 bool lost_resource = false;
2618 BlockingTaskRunner* main_thread_task_runner = NULL;
2619 scoped_ptr<SingleReleaseCallbackImpl> callback =
2620 SingleReleaseCallbackImpl::Create(base::Bind(&ReleaseCallback,
2621 &release_sync_point,
2622 &lost_resource,
2623 &main_thread_task_runner));
2547 TextureMailbox mailbox(shared_memory.get(), size); 2624 TextureMailbox mailbox(shared_memory.get(), size);
2548 2625
2549 ResourceProvider::ResourceId id = 2626 ResourceProvider::ResourceId id =
2550 resource_provider->CreateResourceFromTextureMailbox( 2627 resource_provider->CreateResourceFromTextureMailbox(
2551 mailbox, callback.Pass()); 2628 mailbox, callback.Pass());
2552 EXPECT_NE(0u, id); 2629 EXPECT_NE(0u, id);
2553 2630
2554 { 2631 {
2555 ResourceProvider::ScopedReadLockSoftware lock(resource_provider.get(), id); 2632 ResourceProvider::ScopedReadLockSoftware lock(resource_provider.get(), id);
2556 const SkBitmap* sk_bitmap = lock.sk_bitmap(); 2633 const SkBitmap* sk_bitmap = lock.sk_bitmap();
2557 EXPECT_EQ(sk_bitmap->width(), size.width()); 2634 EXPECT_EQ(sk_bitmap->width(), size.width());
2558 EXPECT_EQ(sk_bitmap->height(), size.height()); 2635 EXPECT_EQ(sk_bitmap->height(), size.height());
2559 EXPECT_EQ(*sk_bitmap->getAddr32(16, 16), kBadBeef); 2636 EXPECT_EQ(*sk_bitmap->getAddr32(16, 16), kBadBeef);
2560 } 2637 }
2638
2639 resource_provider->DeleteResource(id);
2640 EXPECT_EQ(0u, release_sync_point);
2641 EXPECT_FALSE(lost_resource);
2642 EXPECT_EQ(main_thread_task_runner_.get(), main_thread_task_runner);
2561 } 2643 }
2562 2644
2563 TEST_P(ResourceProviderTest, TextureMailbox_GLTexture2D) { 2645 TEST_P(ResourceProviderTest, TextureMailbox_GLTexture2D) {
2564 // Mailboxing is only supported for GL textures. 2646 // Mailboxing is only supported for GL textures.
2565 if (GetParam() != ResourceProvider::GLTexture) 2647 if (GetParam() != ResourceProvider::GLTexture)
2566 return; 2648 return;
2567 2649
2568 scoped_ptr<TextureStateTrackingContext> context_owned( 2650 scoped_ptr<TextureStateTrackingContext> context_owned(
2569 new TextureStateTrackingContext); 2651 new TextureStateTrackingContext);
2570 TextureStateTrackingContext* context = context_owned.get(); 2652 TextureStateTrackingContext* context = context_owned.get();
2571 2653
2572 FakeOutputSurfaceClient output_surface_client; 2654 FakeOutputSurfaceClient output_surface_client;
2573 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( 2655 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
2574 context_owned.PassAs<TestWebGraphicsContext3D>())); 2656 context_owned.PassAs<TestWebGraphicsContext3D>()));
2575 CHECK(output_surface->BindToClient(&output_surface_client)); 2657 CHECK(output_surface->BindToClient(&output_surface_client));
2576 2658
2577 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 2659 scoped_ptr<ResourceProvider> resource_provider(
2578 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); 2660 ResourceProvider::Create(output_surface.get(),
2661 shared_bitmap_manager_.get(),
2662 main_thread_task_runner_.get(),
2663 0,
2664 false,
2665 1,
2666 false));
2579 2667
2580 unsigned texture_id = 1; 2668 unsigned texture_id = 1;
2581 uint32 sync_point = 30; 2669 uint32 sync_point = 30;
2582 unsigned target = GL_TEXTURE_2D; 2670 unsigned target = GL_TEXTURE_2D;
2583 2671
2584 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); 2672 EXPECT_CALL(*context, bindTexture(_, _)).Times(0);
2585 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); 2673 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0);
2586 EXPECT_CALL(*context, insertSyncPoint()).Times(0); 2674 EXPECT_CALL(*context, insertSyncPoint()).Times(0);
2587 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); 2675 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0);
2588 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0); 2676 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0);
2589 2677
2590 gpu::Mailbox gpu_mailbox; 2678 gpu::Mailbox gpu_mailbox;
2591 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1); 2679 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1);
2592 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( 2680 uint32 release_sync_point = 0;
2593 base::Bind(&EmptyReleaseCallback)); 2681 bool lost_resource = false;
2682 BlockingTaskRunner* main_thread_task_runner = NULL;
2683 scoped_ptr<SingleReleaseCallbackImpl> callback =
2684 SingleReleaseCallbackImpl::Create(base::Bind(&ReleaseCallback,
2685 &release_sync_point,
2686 &lost_resource,
2687 &main_thread_task_runner));
2594 2688
2595 TextureMailbox mailbox(gpu_mailbox, target, sync_point); 2689 TextureMailbox mailbox(gpu_mailbox, target, sync_point);
2596 2690
2597 ResourceProvider::ResourceId id = 2691 ResourceProvider::ResourceId id =
2598 resource_provider->CreateResourceFromTextureMailbox( 2692 resource_provider->CreateResourceFromTextureMailbox(
2599 mailbox, callback.Pass()); 2693 mailbox, callback.Pass());
2600 EXPECT_NE(0u, id); 2694 EXPECT_NE(0u, id);
2601 2695
2602 Mock::VerifyAndClearExpectations(context); 2696 Mock::VerifyAndClearExpectations(context);
2603 2697
(...skipping 15 matching lines...) Expand all
2619 2713
2620 // When done with it, a sync point should be inserted, but no produce is 2714 // When done with it, a sync point should be inserted, but no produce is
2621 // necessary. 2715 // necessary.
2622 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); 2716 EXPECT_CALL(*context, bindTexture(_, _)).Times(0);
2623 EXPECT_CALL(*context, insertSyncPoint()); 2717 EXPECT_CALL(*context, insertSyncPoint());
2624 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); 2718 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0);
2625 2719
2626 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); 2720 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0);
2627 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0); 2721 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0);
2628 } 2722 }
2723
2724 resource_provider->DeleteResource(id);
2725 EXPECT_EQ(0u, release_sync_point);
2726 EXPECT_FALSE(lost_resource);
2727 EXPECT_EQ(main_thread_task_runner_.get(), main_thread_task_runner);
2629 } 2728 }
2630 2729
2631 TEST_P(ResourceProviderTest, TextureMailbox_GLTextureExternalOES) { 2730 TEST_P(ResourceProviderTest, TextureMailbox_GLTextureExternalOES) {
2632 // Mailboxing is only supported for GL textures. 2731 // Mailboxing is only supported for GL textures.
2633 if (GetParam() != ResourceProvider::GLTexture) 2732 if (GetParam() != ResourceProvider::GLTexture)
2634 return; 2733 return;
2635 2734
2636 scoped_ptr<TextureStateTrackingContext> context_owned( 2735 scoped_ptr<TextureStateTrackingContext> context_owned(
2637 new TextureStateTrackingContext); 2736 new TextureStateTrackingContext);
2638 TextureStateTrackingContext* context = context_owned.get(); 2737 TextureStateTrackingContext* context = context_owned.get();
2639 2738
2640 FakeOutputSurfaceClient output_surface_client; 2739 FakeOutputSurfaceClient output_surface_client;
2641 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( 2740 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
2642 context_owned.PassAs<TestWebGraphicsContext3D>())); 2741 context_owned.PassAs<TestWebGraphicsContext3D>()));
2643 CHECK(output_surface->BindToClient(&output_surface_client)); 2742 CHECK(output_surface->BindToClient(&output_surface_client));
2644 2743
2645 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 2744 scoped_ptr<ResourceProvider> resource_provider(
2646 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); 2745 ResourceProvider::Create(output_surface.get(),
2746 shared_bitmap_manager_.get(),
2747 NULL,
2748 0,
2749 false,
2750 1,
2751 false));
2647 2752
2648 unsigned texture_id = 1; 2753 unsigned texture_id = 1;
2649 uint32 sync_point = 30; 2754 uint32 sync_point = 30;
2650 unsigned target = GL_TEXTURE_EXTERNAL_OES; 2755 unsigned target = GL_TEXTURE_EXTERNAL_OES;
2651 2756
2652 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); 2757 EXPECT_CALL(*context, bindTexture(_, _)).Times(0);
2653 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); 2758 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0);
2654 EXPECT_CALL(*context, insertSyncPoint()).Times(0); 2759 EXPECT_CALL(*context, insertSyncPoint()).Times(0);
2655 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); 2760 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0);
2656 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0); 2761 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0);
2657 2762
2658 gpu::Mailbox gpu_mailbox; 2763 gpu::Mailbox gpu_mailbox;
2659 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1); 2764 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1);
2660 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( 2765 scoped_ptr<SingleReleaseCallbackImpl> callback =
2661 base::Bind(&EmptyReleaseCallback)); 2766 SingleReleaseCallbackImpl::Create(base::Bind(&EmptyReleaseCallback));
2662 2767
2663 TextureMailbox mailbox(gpu_mailbox, target, sync_point); 2768 TextureMailbox mailbox(gpu_mailbox, target, sync_point);
2664 2769
2665 ResourceProvider::ResourceId id = 2770 ResourceProvider::ResourceId id =
2666 resource_provider->CreateResourceFromTextureMailbox( 2771 resource_provider->CreateResourceFromTextureMailbox(
2667 mailbox, callback.Pass()); 2772 mailbox, callback.Pass());
2668 EXPECT_NE(0u, id); 2773 EXPECT_NE(0u, id);
2669 2774
2670 Mock::VerifyAndClearExpectations(context); 2775 Mock::VerifyAndClearExpectations(context);
2671 2776
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2704 2809
2705 scoped_ptr<TextureStateTrackingContext> context_owned( 2810 scoped_ptr<TextureStateTrackingContext> context_owned(
2706 new TextureStateTrackingContext); 2811 new TextureStateTrackingContext);
2707 TextureStateTrackingContext* context = context_owned.get(); 2812 TextureStateTrackingContext* context = context_owned.get();
2708 2813
2709 FakeOutputSurfaceClient output_surface_client; 2814 FakeOutputSurfaceClient output_surface_client;
2710 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( 2815 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
2711 context_owned.PassAs<TestWebGraphicsContext3D>())); 2816 context_owned.PassAs<TestWebGraphicsContext3D>()));
2712 CHECK(output_surface->BindToClient(&output_surface_client)); 2817 CHECK(output_surface->BindToClient(&output_surface_client));
2713 2818
2714 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 2819 scoped_ptr<ResourceProvider> resource_provider(
2715 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); 2820 ResourceProvider::Create(output_surface.get(),
2821 shared_bitmap_manager_.get(),
2822 NULL,
2823 0,
2824 false,
2825 1,
2826 false));
2716 2827
2717 uint32 sync_point = 30; 2828 uint32 sync_point = 30;
2718 unsigned target = GL_TEXTURE_2D; 2829 unsigned target = GL_TEXTURE_2D;
2719 2830
2720 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); 2831 EXPECT_CALL(*context, bindTexture(_, _)).Times(0);
2721 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); 2832 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0);
2722 EXPECT_CALL(*context, insertSyncPoint()).Times(0); 2833 EXPECT_CALL(*context, insertSyncPoint()).Times(0);
2723 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); 2834 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0);
2724 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0); 2835 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0);
2725 2836
2726 gpu::Mailbox gpu_mailbox; 2837 gpu::Mailbox gpu_mailbox;
2727 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1); 2838 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1);
2728 scoped_ptr<SingleReleaseCallback> callback = 2839 scoped_ptr<SingleReleaseCallbackImpl> callback =
2729 SingleReleaseCallback::Create(base::Bind(&EmptyReleaseCallback)); 2840 SingleReleaseCallbackImpl::Create(base::Bind(&EmptyReleaseCallback));
2730 2841
2731 TextureMailbox mailbox(gpu_mailbox, target, sync_point); 2842 TextureMailbox mailbox(gpu_mailbox, target, sync_point);
2732 2843
2733 ResourceProvider::ResourceId id = 2844 ResourceProvider::ResourceId id =
2734 resource_provider->CreateResourceFromTextureMailbox(mailbox, 2845 resource_provider->CreateResourceFromTextureMailbox(mailbox,
2735 callback.Pass()); 2846 callback.Pass());
2736 EXPECT_NE(0u, id); 2847 EXPECT_NE(0u, id);
2737 2848
2738 Mock::VerifyAndClearExpectations(context); 2849 Mock::VerifyAndClearExpectations(context);
2739 2850
(...skipping 17 matching lines...) Expand all
2757 2868
2758 scoped_ptr<TextureStateTrackingContext> context_owned( 2869 scoped_ptr<TextureStateTrackingContext> context_owned(
2759 new TextureStateTrackingContext); 2870 new TextureStateTrackingContext);
2760 TextureStateTrackingContext* context = context_owned.get(); 2871 TextureStateTrackingContext* context = context_owned.get();
2761 2872
2762 FakeOutputSurfaceClient output_surface_client; 2873 FakeOutputSurfaceClient output_surface_client;
2763 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( 2874 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
2764 context_owned.PassAs<TestWebGraphicsContext3D>())); 2875 context_owned.PassAs<TestWebGraphicsContext3D>()));
2765 CHECK(output_surface->BindToClient(&output_surface_client)); 2876 CHECK(output_surface->BindToClient(&output_surface_client));
2766 2877
2767 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 2878 scoped_ptr<ResourceProvider> resource_provider(
2768 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); 2879 ResourceProvider::Create(output_surface.get(),
2880 shared_bitmap_manager_.get(),
2881 NULL,
2882 0,
2883 false,
2884 1,
2885 false));
2769 2886
2770 uint32 sync_point = 0; 2887 uint32 sync_point = 0;
2771 unsigned target = GL_TEXTURE_2D; 2888 unsigned target = GL_TEXTURE_2D;
2772 2889
2773 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); 2890 EXPECT_CALL(*context, bindTexture(_, _)).Times(0);
2774 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); 2891 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0);
2775 EXPECT_CALL(*context, insertSyncPoint()).Times(0); 2892 EXPECT_CALL(*context, insertSyncPoint()).Times(0);
2776 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); 2893 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0);
2777 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0); 2894 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0);
2778 2895
2779 gpu::Mailbox gpu_mailbox; 2896 gpu::Mailbox gpu_mailbox;
2780 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1); 2897 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1);
2781 scoped_ptr<SingleReleaseCallback> callback = 2898 scoped_ptr<SingleReleaseCallbackImpl> callback =
2782 SingleReleaseCallback::Create(base::Bind(&EmptyReleaseCallback)); 2899 SingleReleaseCallbackImpl::Create(base::Bind(&EmptyReleaseCallback));
2783 2900
2784 TextureMailbox mailbox(gpu_mailbox, target, sync_point); 2901 TextureMailbox mailbox(gpu_mailbox, target, sync_point);
2785 2902
2786 ResourceProvider::ResourceId id = 2903 ResourceProvider::ResourceId id =
2787 resource_provider->CreateResourceFromTextureMailbox(mailbox, 2904 resource_provider->CreateResourceFromTextureMailbox(mailbox,
2788 callback.Pass()); 2905 callback.Pass());
2789 EXPECT_NE(0u, id); 2906 EXPECT_NE(0u, id);
2790 2907
2791 Mock::VerifyAndClearExpectations(context); 2908 Mock::VerifyAndClearExpectations(context);
2792 2909
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
2879 return; 2996 return;
2880 scoped_ptr<AllocationTrackingContext3D> context_owned( 2997 scoped_ptr<AllocationTrackingContext3D> context_owned(
2881 new StrictMock<AllocationTrackingContext3D>); 2998 new StrictMock<AllocationTrackingContext3D>);
2882 AllocationTrackingContext3D* context = context_owned.get(); 2999 AllocationTrackingContext3D* context = context_owned.get();
2883 3000
2884 FakeOutputSurfaceClient output_surface_client; 3001 FakeOutputSurfaceClient output_surface_client;
2885 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( 3002 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
2886 context_owned.PassAs<TestWebGraphicsContext3D>())); 3003 context_owned.PassAs<TestWebGraphicsContext3D>()));
2887 CHECK(output_surface->BindToClient(&output_surface_client)); 3004 CHECK(output_surface->BindToClient(&output_surface_client));
2888 3005
2889 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3006 scoped_ptr<ResourceProvider> resource_provider(
2890 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); 3007 ResourceProvider::Create(output_surface.get(),
3008 shared_bitmap_manager_.get(),
3009 NULL,
3010 0,
3011 false,
3012 1,
3013 false));
2891 3014
2892 gfx::Size size(2, 2); 3015 gfx::Size size(2, 2);
2893 gfx::Vector2d offset(0, 0); 3016 gfx::Vector2d offset(0, 0);
2894 gfx::Rect rect(0, 0, 2, 2); 3017 gfx::Rect rect(0, 0, 2, 2);
2895 ResourceFormat format = RGBA_8888; 3018 ResourceFormat format = RGBA_8888;
2896 ResourceProvider::ResourceId id = 0; 3019 ResourceProvider::ResourceId id = 0;
2897 uint8_t pixels[16] = { 0 }; 3020 uint8_t pixels[16] = { 0 };
2898 int texture_id = 123; 3021 int texture_id = 123;
2899 3022
2900 // Lazy allocation. Don't allocate when creating the resource. 3023 // Lazy allocation. Don't allocate when creating the resource.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
2956 new StrictMock<AllocationTrackingContext3D>); 3079 new StrictMock<AllocationTrackingContext3D>);
2957 AllocationTrackingContext3D* context = context_owned.get(); 3080 AllocationTrackingContext3D* context = context_owned.get();
2958 context->set_support_texture_storage(true); 3081 context->set_support_texture_storage(true);
2959 context->set_support_texture_usage(true); 3082 context->set_support_texture_usage(true);
2960 3083
2961 FakeOutputSurfaceClient output_surface_client; 3084 FakeOutputSurfaceClient output_surface_client;
2962 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( 3085 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
2963 context_owned.PassAs<TestWebGraphicsContext3D>())); 3086 context_owned.PassAs<TestWebGraphicsContext3D>()));
2964 CHECK(output_surface->BindToClient(&output_surface_client)); 3087 CHECK(output_surface->BindToClient(&output_surface_client));
2965 3088
2966 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3089 scoped_ptr<ResourceProvider> resource_provider(
2967 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); 3090 ResourceProvider::Create(output_surface.get(),
3091 shared_bitmap_manager_.get(),
3092 NULL,
3093 0,
3094 false,
3095 1,
3096 false));
2968 3097
2969 gfx::Size size(2, 2); 3098 gfx::Size size(2, 2);
2970 3099
2971 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888}; 3100 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888};
2972 const ResourceProvider::TextureHint hints[4] = { 3101 const ResourceProvider::TextureHint hints[4] = {
2973 ResourceProvider::TextureHintDefault, 3102 ResourceProvider::TextureHintDefault,
2974 ResourceProvider::TextureHintImmutable, 3103 ResourceProvider::TextureHintImmutable,
2975 ResourceProvider::TextureHintFramebuffer, 3104 ResourceProvider::TextureHintFramebuffer,
2976 ResourceProvider::TextureHintImmutableFramebuffer, 3105 ResourceProvider::TextureHintImmutableFramebuffer,
2977 }; 3106 };
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
3010 AllocationTrackingContext3D* context = context_owned.get(); 3139 AllocationTrackingContext3D* context = context_owned.get();
3011 context->set_support_texture_format_bgra8888(true); 3140 context->set_support_texture_format_bgra8888(true);
3012 context->set_support_texture_storage(true); 3141 context->set_support_texture_storage(true);
3013 context->set_support_texture_usage(true); 3142 context->set_support_texture_usage(true);
3014 3143
3015 FakeOutputSurfaceClient output_surface_client; 3144 FakeOutputSurfaceClient output_surface_client;
3016 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( 3145 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
3017 context_owned.PassAs<TestWebGraphicsContext3D>())); 3146 context_owned.PassAs<TestWebGraphicsContext3D>()));
3018 CHECK(output_surface->BindToClient(&output_surface_client)); 3147 CHECK(output_surface->BindToClient(&output_surface_client));
3019 3148
3020 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3149 scoped_ptr<ResourceProvider> resource_provider(
3021 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); 3150 ResourceProvider::Create(output_surface.get(),
3151 shared_bitmap_manager_.get(),
3152 NULL,
3153 0,
3154 false,
3155 1,
3156 false));
3022 3157
3023 gfx::Size size(2, 2); 3158 gfx::Size size(2, 2);
3024 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888}; 3159 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888};
3025 3160
3026 const ResourceProvider::TextureHint hints[4] = { 3161 const ResourceProvider::TextureHint hints[4] = {
3027 ResourceProvider::TextureHintDefault, 3162 ResourceProvider::TextureHintDefault,
3028 ResourceProvider::TextureHintImmutable, 3163 ResourceProvider::TextureHintImmutable,
3029 ResourceProvider::TextureHintFramebuffer, 3164 ResourceProvider::TextureHintFramebuffer,
3030 ResourceProvider::TextureHintImmutableFramebuffer, 3165 ResourceProvider::TextureHintImmutableFramebuffer,
3031 }; 3166 };
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
3063 FakeOutputSurfaceClient output_surface_client; 3198 FakeOutputSurfaceClient output_surface_client;
3064 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( 3199 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
3065 context_owned.PassAs<TestWebGraphicsContext3D>())); 3200 context_owned.PassAs<TestWebGraphicsContext3D>()));
3066 CHECK(output_surface->BindToClient(&output_surface_client)); 3201 CHECK(output_surface->BindToClient(&output_surface_client));
3067 3202
3068 gfx::Size size(2, 2); 3203 gfx::Size size(2, 2);
3069 ResourceFormat format = RGBA_8888; 3204 ResourceFormat format = RGBA_8888;
3070 ResourceProvider::ResourceId id = 0; 3205 ResourceProvider::ResourceId id = 0;
3071 int texture_id = 123; 3206 int texture_id = 123;
3072 3207
3073 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3208 scoped_ptr<ResourceProvider> resource_provider(
3074 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); 3209 ResourceProvider::Create(output_surface.get(),
3210 shared_bitmap_manager_.get(),
3211 NULL,
3212 0,
3213 false,
3214 1,
3215 false));
3075 3216
3076 id = resource_provider->CreateResource( 3217 id = resource_provider->CreateResource(
3077 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); 3218 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
3078 RasterBuffer* raster_buffer = resource_provider->AcquirePixelRasterBuffer(id); 3219 RasterBuffer* raster_buffer = resource_provider->AcquirePixelRasterBuffer(id);
3079 skia::RefPtr<SkCanvas> canvas = raster_buffer->AcquireSkCanvas(); 3220 skia::RefPtr<SkCanvas> canvas = raster_buffer->AcquireSkCanvas();
3080 raster_buffer->ReleaseSkCanvas(canvas); 3221 raster_buffer->ReleaseSkCanvas(canvas);
3081 canvas.clear(); 3222 canvas.clear();
3082 3223
3083 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); 3224 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id));
3084 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); 3225 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2);
(...skipping 22 matching lines...) Expand all
3107 FakeOutputSurfaceClient output_surface_client; 3248 FakeOutputSurfaceClient output_surface_client;
3108 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( 3249 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
3109 context_owned.PassAs<TestWebGraphicsContext3D>())); 3250 context_owned.PassAs<TestWebGraphicsContext3D>()));
3110 CHECK(output_surface->BindToClient(&output_surface_client)); 3251 CHECK(output_surface->BindToClient(&output_surface_client));
3111 3252
3112 gfx::Size size(2, 2); 3253 gfx::Size size(2, 2);
3113 ResourceFormat format = RGBA_8888; 3254 ResourceFormat format = RGBA_8888;
3114 ResourceProvider::ResourceId id = 0; 3255 ResourceProvider::ResourceId id = 0;
3115 int texture_id = 123; 3256 int texture_id = 123;
3116 3257
3117 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3258 scoped_ptr<ResourceProvider> resource_provider(
3118 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); 3259 ResourceProvider::Create(output_surface.get(),
3260 shared_bitmap_manager_.get(),
3261 NULL,
3262 0,
3263 false,
3264 1,
3265 false));
3119 3266
3120 id = resource_provider->CreateResource( 3267 id = resource_provider->CreateResource(
3121 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); 3268 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
3122 RasterBuffer* raster_buffer = resource_provider->AcquirePixelRasterBuffer(id); 3269 RasterBuffer* raster_buffer = resource_provider->AcquirePixelRasterBuffer(id);
3123 skia::RefPtr<SkCanvas> canvas = raster_buffer->AcquireSkCanvas(); 3270 skia::RefPtr<SkCanvas> canvas = raster_buffer->AcquireSkCanvas();
3124 raster_buffer->ReleaseSkCanvas(canvas); 3271 raster_buffer->ReleaseSkCanvas(canvas);
3125 canvas.clear(); 3272 canvas.clear();
3126 3273
3127 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); 3274 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id));
3128 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); 3275 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2);
(...skipping 22 matching lines...) Expand all
3151 FakeOutputSurfaceClient output_surface_client; 3298 FakeOutputSurfaceClient output_surface_client;
3152 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( 3299 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
3153 context_owned.PassAs<TestWebGraphicsContext3D>())); 3300 context_owned.PassAs<TestWebGraphicsContext3D>()));
3154 CHECK(output_surface->BindToClient(&output_surface_client)); 3301 CHECK(output_surface->BindToClient(&output_surface_client));
3155 3302
3156 gfx::Size size(2, 2); 3303 gfx::Size size(2, 2);
3157 ResourceFormat format = RGBA_8888; 3304 ResourceFormat format = RGBA_8888;
3158 ResourceProvider::ResourceId id = 0; 3305 ResourceProvider::ResourceId id = 0;
3159 int texture_id = 123; 3306 int texture_id = 123;
3160 3307
3161 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3308 scoped_ptr<ResourceProvider> resource_provider(
3162 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); 3309 ResourceProvider::Create(output_surface.get(),
3310 shared_bitmap_manager_.get(),
3311 NULL,
3312 0,
3313 false,
3314 1,
3315 false));
3163 3316
3164 EXPECT_CALL(*context, NextTextureId()).WillRepeatedly(Return(texture_id)); 3317 EXPECT_CALL(*context, NextTextureId()).WillRepeatedly(Return(texture_id));
3165 3318
3166 id = resource_provider->CreateResource( 3319 id = resource_provider->CreateResource(
3167 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); 3320 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
3168 context->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, 3321 context->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB,
3169 GL_INNOCENT_CONTEXT_RESET_ARB); 3322 GL_INNOCENT_CONTEXT_RESET_ARB);
3170 3323
3171 RasterBuffer* raster_buffer = resource_provider->AcquirePixelRasterBuffer(id); 3324 RasterBuffer* raster_buffer = resource_provider->AcquirePixelRasterBuffer(id);
3172 skia::RefPtr<SkCanvas> canvas = raster_buffer->AcquireSkCanvas(); 3325 skia::RefPtr<SkCanvas> canvas = raster_buffer->AcquireSkCanvas();
(...skipping 18 matching lines...) Expand all
3191 CHECK(output_surface->BindToClient(&output_surface_client)); 3344 CHECK(output_surface->BindToClient(&output_surface_client));
3192 3345
3193 const int kWidth = 2; 3346 const int kWidth = 2;
3194 const int kHeight = 2; 3347 const int kHeight = 2;
3195 gfx::Size size(kWidth, kHeight); 3348 gfx::Size size(kWidth, kHeight);
3196 ResourceFormat format = RGBA_8888; 3349 ResourceFormat format = RGBA_8888;
3197 ResourceProvider::ResourceId id = 0; 3350 ResourceProvider::ResourceId id = 0;
3198 const unsigned kTextureId = 123u; 3351 const unsigned kTextureId = 123u;
3199 const unsigned kImageId = 234u; 3352 const unsigned kImageId = 234u;
3200 3353
3201 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3354 scoped_ptr<ResourceProvider> resource_provider(
3202 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); 3355 ResourceProvider::Create(output_surface.get(),
3356 shared_bitmap_manager_.get(),
3357 NULL,
3358 0,
3359 false,
3360 1,
3361 false));
3203 3362
3204 id = resource_provider->CreateResource( 3363 id = resource_provider->CreateResource(
3205 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); 3364 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
3206 3365
3207 const int kStride = 4; 3366 const int kStride = 4;
3208 void* dummy_mapped_buffer_address = NULL; 3367 void* dummy_mapped_buffer_address = NULL;
3209 EXPECT_CALL( 3368 EXPECT_CALL(
3210 *context, 3369 *context,
3211 createImageCHROMIUM(kWidth, kHeight, GL_RGBA8_OES, GL_IMAGE_MAP_CHROMIUM)) 3370 createImageCHROMIUM(kWidth, kHeight, GL_RGBA8_OES, GL_IMAGE_MAP_CHROMIUM))
3212 .WillOnce(Return(kImageId)) 3371 .WillOnce(Return(kImageId))
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
3277 scoped_ptr<OutputSurface> output_surface( 3436 scoped_ptr<OutputSurface> output_surface(
3278 FakeOutputSurface::CreateSoftware(make_scoped_ptr( 3437 FakeOutputSurface::CreateSoftware(make_scoped_ptr(
3279 new SoftwareOutputDevice))); 3438 new SoftwareOutputDevice)));
3280 CHECK(output_surface->BindToClient(&output_surface_client)); 3439 CHECK(output_surface->BindToClient(&output_surface_client));
3281 3440
3282 gfx::Size size(1, 1); 3441 gfx::Size size(1, 1);
3283 ResourceFormat format = RGBA_8888; 3442 ResourceFormat format = RGBA_8888;
3284 ResourceProvider::ResourceId id = 0; 3443 ResourceProvider::ResourceId id = 0;
3285 const uint32_t kBadBeef = 0xbadbeef; 3444 const uint32_t kBadBeef = 0xbadbeef;
3286 3445
3287 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3446 scoped_ptr<ResourceProvider> resource_provider(
3288 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); 3447 ResourceProvider::Create(output_surface.get(),
3448 shared_bitmap_manager_.get(),
3449 NULL,
3450 0,
3451 false,
3452 1,
3453 false));
3289 3454
3290 id = resource_provider->CreateResource( 3455 id = resource_provider->CreateResource(
3291 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); 3456 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
3292 3457
3293 SkBitmap bitmap; 3458 SkBitmap bitmap;
3294 bitmap.allocN32Pixels(size.width(), size.height()); 3459 bitmap.allocN32Pixels(size.width(), size.height());
3295 *(bitmap.getAddr32(0, 0)) = kBadBeef; 3460 *(bitmap.getAddr32(0, 0)) = kBadBeef;
3296 RasterBuffer* raster_buffer = resource_provider->AcquireImageRasterBuffer(id); 3461 RasterBuffer* raster_buffer = resource_provider->AcquireImageRasterBuffer(id);
3297 skia::RefPtr<SkCanvas> canvas = raster_buffer->AcquireSkCanvas(); 3462 skia::RefPtr<SkCanvas> canvas = raster_buffer->AcquireSkCanvas();
3298 ASSERT_TRUE(!!canvas); 3463 ASSERT_TRUE(!!canvas);
(...skipping 29 matching lines...) Expand all
3328 const int kWidth = 2; 3493 const int kWidth = 2;
3329 const int kHeight = 2; 3494 const int kHeight = 2;
3330 gfx::Size size(kWidth, kHeight); 3495 gfx::Size size(kWidth, kHeight);
3331 ResourceFormat format = RGBA_8888; 3496 ResourceFormat format = RGBA_8888;
3332 ResourceProvider::ResourceId source_id = 0; 3497 ResourceProvider::ResourceId source_id = 0;
3333 ResourceProvider::ResourceId dest_id = 0; 3498 ResourceProvider::ResourceId dest_id = 0;
3334 const unsigned kSourceTextureId = 123u; 3499 const unsigned kSourceTextureId = 123u;
3335 const unsigned kDestTextureId = 321u; 3500 const unsigned kDestTextureId = 321u;
3336 const unsigned kImageId = 234u; 3501 const unsigned kImageId = 234u;
3337 3502
3338 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3503 scoped_ptr<ResourceProvider> resource_provider(
3339 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); 3504 ResourceProvider::Create(output_surface.get(),
3505 shared_bitmap_manager_.get(),
3506 NULL,
3507 0,
3508 false,
3509 1,
3510 false));
3340 3511
3341 source_id = resource_provider->CreateResource( 3512 source_id = resource_provider->CreateResource(
3342 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); 3513 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
3343 3514
3344 const int kStride = 4; 3515 const int kStride = 4;
3345 void* dummy_mapped_buffer_address = NULL; 3516 void* dummy_mapped_buffer_address = NULL;
3346 EXPECT_CALL( 3517 EXPECT_CALL(
3347 *context, 3518 *context,
3348 createImageCHROMIUM(kWidth, kHeight, GL_RGBA8_OES, GL_IMAGE_MAP_CHROMIUM)) 3519 createImageCHROMIUM(kWidth, kHeight, GL_RGBA8_OES, GL_IMAGE_MAP_CHROMIUM))
3349 .WillOnce(Return(kImageId)) 3520 .WillOnce(Return(kImageId))
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
3401 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::CreateSoftware( 3572 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::CreateSoftware(
3402 make_scoped_ptr(new SoftwareOutputDevice))); 3573 make_scoped_ptr(new SoftwareOutputDevice)));
3403 CHECK(output_surface->BindToClient(&output_surface_client)); 3574 CHECK(output_surface->BindToClient(&output_surface_client));
3404 3575
3405 gfx::Size size(1, 1); 3576 gfx::Size size(1, 1);
3406 ResourceFormat format = RGBA_8888; 3577 ResourceFormat format = RGBA_8888;
3407 ResourceProvider::ResourceId source_id = 0; 3578 ResourceProvider::ResourceId source_id = 0;
3408 ResourceProvider::ResourceId dest_id = 0; 3579 ResourceProvider::ResourceId dest_id = 0;
3409 const uint32_t kBadBeef = 0xbadbeef; 3580 const uint32_t kBadBeef = 0xbadbeef;
3410 3581
3411 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3582 scoped_ptr<ResourceProvider> resource_provider(
3412 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); 3583 ResourceProvider::Create(output_surface.get(),
3584 shared_bitmap_manager_.get(),
3585 NULL,
3586 0,
3587 false,
3588 1,
3589 false));
3413 3590
3414 source_id = resource_provider->CreateResource( 3591 source_id = resource_provider->CreateResource(
3415 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); 3592 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
3416 3593
3417 SkBitmap bitmap; 3594 SkBitmap bitmap;
3418 bitmap.allocN32Pixels(size.width(), size.height()); 3595 bitmap.allocN32Pixels(size.width(), size.height());
3419 *(bitmap.getAddr32(0, 0)) = kBadBeef; 3596 *(bitmap.getAddr32(0, 0)) = kBadBeef;
3420 RasterBuffer* raster_buffer = 3597 RasterBuffer* raster_buffer =
3421 resource_provider->AcquireImageRasterBuffer(source_id); 3598 resource_provider->AcquireImageRasterBuffer(source_id);
3422 skia::RefPtr<SkCanvas> canvas = raster_buffer->AcquireSkCanvas(); 3599 skia::RefPtr<SkCanvas> canvas = raster_buffer->AcquireSkCanvas();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
3464 scoped_ptr<ContextSharedData> shared_data = ContextSharedData::Create(); 3641 scoped_ptr<ContextSharedData> shared_data = ContextSharedData::Create();
3465 bool delegated_rendering = false; 3642 bool delegated_rendering = false;
3466 scoped_ptr<FakeOutputSurface> output_surface( 3643 scoped_ptr<FakeOutputSurface> output_surface(
3467 FakeOutputSurface::CreateDeferredGL( 3644 FakeOutputSurface::CreateDeferredGL(
3468 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice), 3645 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice),
3469 delegated_rendering)); 3646 delegated_rendering));
3470 FakeOutputSurfaceClient client(output_surface.get()); 3647 FakeOutputSurfaceClient client(output_surface.get());
3471 EXPECT_TRUE(output_surface->BindToClient(&client)); 3648 EXPECT_TRUE(output_surface->BindToClient(&client));
3472 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 3649 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
3473 new TestSharedBitmapManager()); 3650 new TestSharedBitmapManager());
3474 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 3651 scoped_ptr<ResourceProvider> resource_provider(
3475 output_surface.get(), shared_bitmap_manager.get(), 0, false, 1, false)); 3652 ResourceProvider::Create(output_surface.get(),
3653 shared_bitmap_manager.get(),
3654 NULL,
3655 0,
3656 false,
3657 1,
3658 false));
3476 3659
3477 CheckCreateResource(ResourceProvider::Bitmap, resource_provider.get(), NULL); 3660 CheckCreateResource(ResourceProvider::Bitmap, resource_provider.get(), NULL);
3478 3661
3479 InitializeGLAndCheck(shared_data.get(), 3662 InitializeGLAndCheck(shared_data.get(),
3480 resource_provider.get(), 3663 resource_provider.get(),
3481 output_surface.get()); 3664 output_surface.get());
3482 3665
3483 resource_provider->InitializeSoftware(); 3666 resource_provider->InitializeSoftware();
3484 output_surface->ReleaseGL(); 3667 output_surface->ReleaseGL();
3485 CheckCreateResource(ResourceProvider::Bitmap, resource_provider.get(), NULL); 3668 CheckCreateResource(ResourceProvider::Bitmap, resource_provider.get(), NULL);
(...skipping 14 matching lines...) Expand all
3500 3683
3501 FakeOutputSurfaceClient output_surface_client; 3684 FakeOutputSurfaceClient output_surface_client;
3502 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( 3685 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
3503 context_owned.PassAs<TestWebGraphicsContext3D>())); 3686 context_owned.PassAs<TestWebGraphicsContext3D>()));
3504 CHECK(output_surface->BindToClient(&output_surface_client)); 3687 CHECK(output_surface->BindToClient(&output_surface_client));
3505 3688
3506 gfx::Size size(4, 4); 3689 gfx::Size size(4, 4);
3507 scoped_ptr<ResourceProvider> resource_provider( 3690 scoped_ptr<ResourceProvider> resource_provider(
3508 ResourceProvider::Create(output_surface.get(), 3691 ResourceProvider::Create(output_surface.get(),
3509 shared_bitmap_manager_.get(), 3692 shared_bitmap_manager_.get(),
3693 NULL,
3510 0, 3694 0,
3511 false, 3695 false,
3512 1, 3696 1,
3513 false)); 3697 false));
3514 int texture_id = 123; 3698 int texture_id = 123;
3515 3699
3516 ResourceProvider::ResourceId id = resource_provider->CreateResource( 3700 ResourceProvider::ResourceId id = resource_provider->CreateResource(
3517 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, ETC1); 3701 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, ETC1);
3518 EXPECT_NE(0u, id); 3702 EXPECT_NE(0u, id);
3519 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); 3703 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id));
(...skipping 15 matching lines...) Expand all
3535 3719
3536 FakeOutputSurfaceClient output_surface_client; 3720 FakeOutputSurfaceClient output_surface_client;
3537 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( 3721 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
3538 context_owned.PassAs<TestWebGraphicsContext3D>())); 3722 context_owned.PassAs<TestWebGraphicsContext3D>()));
3539 CHECK(output_surface->BindToClient(&output_surface_client)); 3723 CHECK(output_surface->BindToClient(&output_surface_client));
3540 3724
3541 gfx::Size size(4, 4); 3725 gfx::Size size(4, 4);
3542 scoped_ptr<ResourceProvider> resource_provider( 3726 scoped_ptr<ResourceProvider> resource_provider(
3543 ResourceProvider::Create(output_surface.get(), 3727 ResourceProvider::Create(output_surface.get(),
3544 shared_bitmap_manager_.get(), 3728 shared_bitmap_manager_.get(),
3729 NULL,
3545 0, 3730 0,
3546 false, 3731 false,
3547 1, 3732 1,
3548 false)); 3733 false));
3549 int texture_id = 123; 3734 int texture_id = 123;
3550 uint8_t pixels[8]; 3735 uint8_t pixels[8];
3551 3736
3552 ResourceProvider::ResourceId id = resource_provider->CreateResource( 3737 ResourceProvider::ResourceId id = resource_provider->CreateResource(
3553 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, ETC1); 3738 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, ETC1);
3554 EXPECT_NE(0u, id); 3739 EXPECT_NE(0u, id);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
3595 new TestSharedBitmapManager()); 3780 new TestSharedBitmapManager());
3596 3781
3597 gfx::Size size(1, 1); 3782 gfx::Size size(1, 1);
3598 ResourceFormat format = RGBA_8888; 3783 ResourceFormat format = RGBA_8888;
3599 3784
3600 { 3785 {
3601 size_t kTextureAllocationChunkSize = 1; 3786 size_t kTextureAllocationChunkSize = 1;
3602 scoped_ptr<ResourceProvider> resource_provider( 3787 scoped_ptr<ResourceProvider> resource_provider(
3603 ResourceProvider::Create(output_surface.get(), 3788 ResourceProvider::Create(output_surface.get(),
3604 shared_bitmap_manager.get(), 3789 shared_bitmap_manager.get(),
3790 NULL,
3605 0, 3791 0,
3606 false, 3792 false,
3607 kTextureAllocationChunkSize, 3793 kTextureAllocationChunkSize,
3608 false)); 3794 false));
3609 3795
3610 ResourceProvider::ResourceId id = resource_provider->CreateResource( 3796 ResourceProvider::ResourceId id = resource_provider->CreateResource(
3611 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); 3797 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
3612 resource_provider->AllocateForTesting(id); 3798 resource_provider->AllocateForTesting(id);
3613 Mock::VerifyAndClearExpectations(context); 3799 Mock::VerifyAndClearExpectations(context);
3614 3800
3615 DCHECK_EQ(2u, context->PeekTextureId()); 3801 DCHECK_EQ(2u, context->PeekTextureId());
3616 resource_provider->DeleteResource(id); 3802 resource_provider->DeleteResource(id);
3617 } 3803 }
3618 3804
3619 { 3805 {
3620 size_t kTextureAllocationChunkSize = 8; 3806 size_t kTextureAllocationChunkSize = 8;
3621 scoped_ptr<ResourceProvider> resource_provider( 3807 scoped_ptr<ResourceProvider> resource_provider(
3622 ResourceProvider::Create(output_surface.get(), 3808 ResourceProvider::Create(output_surface.get(),
3623 shared_bitmap_manager.get(), 3809 shared_bitmap_manager.get(),
3810 NULL,
3624 0, 3811 0,
3625 false, 3812 false,
3626 kTextureAllocationChunkSize, 3813 kTextureAllocationChunkSize,
3627 false)); 3814 false));
3628 3815
3629 ResourceProvider::ResourceId id = resource_provider->CreateResource( 3816 ResourceProvider::ResourceId id = resource_provider->CreateResource(
3630 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); 3817 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
3631 resource_provider->AllocateForTesting(id); 3818 resource_provider->AllocateForTesting(id);
3632 Mock::VerifyAndClearExpectations(context); 3819 Mock::VerifyAndClearExpectations(context);
3633 3820
3634 DCHECK_EQ(10u, context->PeekTextureId()); 3821 DCHECK_EQ(10u, context->PeekTextureId());
3635 resource_provider->DeleteResource(id); 3822 resource_provider->DeleteResource(id);
3636 } 3823 }
3637 } 3824 }
3638 3825
3639 } // namespace 3826 } // namespace
3640 } // namespace cc 3827 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/resource_provider.cc ('k') | cc/resources/resource_update_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698