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

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

Issue 634083002: gpu: Compositor management of GpuMemoryBuffer instances. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cc-pre-chromium-image-refactor
Patch Set: some build fixes Created 6 years, 2 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
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_gpu_memory_buffer_manager.h"
22 #include "cc/test/test_shared_bitmap_manager.h" 23 #include "cc/test/test_shared_bitmap_manager.h"
23 #include "cc/test/test_texture.h" 24 #include "cc/test/test_texture.h"
24 #include "cc/test/test_web_graphics_context_3d.h" 25 #include "cc/test/test_web_graphics_context_3d.h"
25 #include "cc/trees/blocking_task_runner.h" 26 #include "cc/trees/blocking_task_runner.h"
26 #include "gpu/GLES2/gl2extchromium.h" 27 #include "gpu/GLES2/gl2extchromium.h"
27 #include "testing/gmock/include/gmock/gmock.h" 28 #include "testing/gmock/include/gmock/gmock.h"
28 #include "testing/gtest/include/gtest/gtest.h" 29 #include "testing/gtest/include/gtest/gtest.h"
29 #include "third_party/khronos/GLES2/gl2.h" 30 #include "third_party/khronos/GLES2/gl2.h"
30 #include "third_party/khronos/GLES2/gl2ext.h" 31 #include "third_party/khronos/GLES2/gl2ext.h"
32 #include "ui/gfx/gpu_memory_buffer.h"
31 #include "ui/gfx/rect.h" 33 #include "ui/gfx/rect.h"
32 34
33 using testing::Mock; 35 using testing::Mock;
34 using testing::NiceMock; 36 using testing::NiceMock;
35 using testing::Return; 37 using testing::Return;
36 using testing::SetArgPointee; 38 using testing::SetArgPointee;
37 using testing::StrictMock; 39 using testing::StrictMock;
38 using testing::_; 40 using testing::_;
39 41
40 namespace cc { 42 namespace cc {
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 child_output_surface_ = FakeOutputSurface::CreateSoftware( 408 child_output_surface_ = FakeOutputSurface::CreateSoftware(
407 make_scoped_ptr(new SoftwareOutputDevice)); 409 make_scoped_ptr(new SoftwareOutputDevice));
408 break; 410 break;
409 case ResourceProvider::InvalidType: 411 case ResourceProvider::InvalidType:
410 NOTREACHED(); 412 NOTREACHED();
411 break; 413 break;
412 } 414 }
413 CHECK(output_surface_->BindToClient(&output_surface_client_)); 415 CHECK(output_surface_->BindToClient(&output_surface_client_));
414 CHECK(child_output_surface_->BindToClient(&child_output_surface_client_)); 416 CHECK(child_output_surface_->BindToClient(&child_output_surface_client_));
415 417
416 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); 418 shared_bitmap_manager_.reset(new TestSharedBitmapManager);
419 gpu_memory_buffer_manager_.reset(new TestGpuMemoryBufferManager);
417 420
418 resource_provider_ = 421 resource_provider_ =
419 ResourceProvider::Create(output_surface_.get(), 422 ResourceProvider::Create(output_surface_.get(),
420 shared_bitmap_manager_.get(), 423 shared_bitmap_manager_.get(),
424 gpu_memory_buffer_manager_.get(),
421 main_thread_task_runner_.get(), 425 main_thread_task_runner_.get(),
422 0, 426 0,
423 false, 427 false,
424 1, 428 1,
425 false); 429 false);
426 child_resource_provider_ = 430 child_resource_provider_ =
427 ResourceProvider::Create(child_output_surface_.get(), 431 ResourceProvider::Create(child_output_surface_.get(),
428 shared_bitmap_manager_.get(), 432 shared_bitmap_manager_.get(),
433 gpu_memory_buffer_manager_.get(),
429 main_thread_task_runner_.get(), 434 main_thread_task_runner_.get(),
430 0, 435 0,
431 false, 436 false,
432 1, 437 1,
433 false); 438 false);
434 } 439 }
435 440
436 static void CollectResources(ReturnedResourceArray* array, 441 static void CollectResources(ReturnedResourceArray* array,
437 const ReturnedResourceArray& returned, 442 const ReturnedResourceArray& returned,
438 BlockingTaskRunner* main_thread_task_runner) { 443 BlockingTaskRunner* main_thread_task_runner) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 ResourceProviderContext* context3d_; 504 ResourceProviderContext* context3d_;
500 ResourceProviderContext* child_context_; 505 ResourceProviderContext* child_context_;
501 FakeOutputSurfaceClient output_surface_client_; 506 FakeOutputSurfaceClient output_surface_client_;
502 FakeOutputSurfaceClient child_output_surface_client_; 507 FakeOutputSurfaceClient child_output_surface_client_;
503 scoped_ptr<OutputSurface> output_surface_; 508 scoped_ptr<OutputSurface> output_surface_;
504 scoped_ptr<OutputSurface> child_output_surface_; 509 scoped_ptr<OutputSurface> child_output_surface_;
505 scoped_ptr<BlockingTaskRunner> main_thread_task_runner_; 510 scoped_ptr<BlockingTaskRunner> main_thread_task_runner_;
506 scoped_ptr<ResourceProvider> resource_provider_; 511 scoped_ptr<ResourceProvider> resource_provider_;
507 scoped_ptr<ResourceProvider> child_resource_provider_; 512 scoped_ptr<ResourceProvider> child_resource_provider_;
508 scoped_ptr<TestSharedBitmapManager> shared_bitmap_manager_; 513 scoped_ptr<TestSharedBitmapManager> shared_bitmap_manager_;
514 scoped_ptr<TestGpuMemoryBufferManager> gpu_memory_buffer_manager_;
509 }; 515 };
510 516
511 void CheckCreateResource(ResourceProvider::ResourceType expected_default_type, 517 void CheckCreateResource(ResourceProvider::ResourceType expected_default_type,
512 ResourceProvider* resource_provider, 518 ResourceProvider* resource_provider,
513 ResourceProviderContext* context) { 519 ResourceProviderContext* context) {
514 DCHECK_EQ(expected_default_type, resource_provider->default_resource_type()); 520 DCHECK_EQ(expected_default_type, resource_provider->default_resource_type());
515 521
516 gfx::Size size(1, 1); 522 gfx::Size size(1, 1);
517 ResourceFormat format = RGBA_8888; 523 ResourceFormat format = RGBA_8888;
518 size_t pixel_size = TextureSizeBytes(size, format); 524 size_t pixel_size = TextureSizeBytes(size, format);
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after
1153 ResourceProviderContext::Create(shared_data_.get())); 1159 ResourceProviderContext::Create(shared_data_.get()));
1154 1160
1155 FakeOutputSurfaceClient child_output_surface_client; 1161 FakeOutputSurfaceClient child_output_surface_client;
1156 scoped_ptr<OutputSurface> child_output_surface( 1162 scoped_ptr<OutputSurface> child_output_surface(
1157 FakeOutputSurface::Create3d(child_context_owned.Pass())); 1163 FakeOutputSurface::Create3d(child_context_owned.Pass()));
1158 CHECK(child_output_surface->BindToClient(&child_output_surface_client)); 1164 CHECK(child_output_surface->BindToClient(&child_output_surface_client));
1159 1165
1160 scoped_ptr<ResourceProvider> child_resource_provider( 1166 scoped_ptr<ResourceProvider> child_resource_provider(
1161 ResourceProvider::Create(child_output_surface.get(), 1167 ResourceProvider::Create(child_output_surface.get(),
1162 shared_bitmap_manager_.get(), 1168 shared_bitmap_manager_.get(),
1169 gpu_memory_buffer_manager_.get(),
1163 NULL, 1170 NULL,
1164 0, 1171 0,
1165 false, 1172 false,
1166 1, 1173 1,
1167 false)); 1174 false));
1168 1175
1169 gfx::Size size(1, 1); 1176 gfx::Size size(1, 1);
1170 ResourceFormat format = RGBA_8888; 1177 ResourceFormat format = RGBA_8888;
1171 size_t pixel_size = TextureSizeBytes(size, format); 1178 size_t pixel_size = TextureSizeBytes(size, format);
1172 ASSERT_EQ(4U, pixel_size); 1179 ASSERT_EQ(4U, pixel_size);
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
1636 scoped_ptr<OutputSurface> child_output_surface( 1643 scoped_ptr<OutputSurface> child_output_surface(
1637 FakeOutputSurface::Create3d(child_context_owned.Pass())); 1644 FakeOutputSurface::Create3d(child_context_owned.Pass()));
1638 CHECK(child_output_surface->BindToClient(&child_output_surface_client)); 1645 CHECK(child_output_surface->BindToClient(&child_output_surface_client));
1639 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 1646 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
1640 new TestSharedBitmapManager()); 1647 new TestSharedBitmapManager());
1641 1648
1642 scoped_ptr<ResourceProvider> child_resource_provider( 1649 scoped_ptr<ResourceProvider> child_resource_provider(
1643 ResourceProvider::Create(child_output_surface.get(), 1650 ResourceProvider::Create(child_output_surface.get(),
1644 shared_bitmap_manager.get(), 1651 shared_bitmap_manager.get(),
1645 NULL, 1652 NULL,
1653 NULL,
1646 0, 1654 0,
1647 false, 1655 false,
1648 1, 1656 1,
1649 false)); 1657 false));
1650 1658
1651 scoped_ptr<TextureStateTrackingContext> parent_context_owned( 1659 scoped_ptr<TextureStateTrackingContext> parent_context_owned(
1652 new TextureStateTrackingContext); 1660 new TextureStateTrackingContext);
1653 TextureStateTrackingContext* parent_context = parent_context_owned.get(); 1661 TextureStateTrackingContext* parent_context = parent_context_owned.get();
1654 1662
1655 FakeOutputSurfaceClient parent_output_surface_client; 1663 FakeOutputSurfaceClient parent_output_surface_client;
1656 scoped_ptr<OutputSurface> parent_output_surface( 1664 scoped_ptr<OutputSurface> parent_output_surface(
1657 FakeOutputSurface::Create3d(parent_context_owned.Pass())); 1665 FakeOutputSurface::Create3d(parent_context_owned.Pass()));
1658 CHECK(parent_output_surface->BindToClient(&parent_output_surface_client)); 1666 CHECK(parent_output_surface->BindToClient(&parent_output_surface_client));
1659 1667
1660 scoped_ptr<ResourceProvider> parent_resource_provider( 1668 scoped_ptr<ResourceProvider> parent_resource_provider(
1661 ResourceProvider::Create(parent_output_surface.get(), 1669 ResourceProvider::Create(parent_output_surface.get(),
1662 shared_bitmap_manager.get(), 1670 shared_bitmap_manager.get(),
1663 NULL, 1671 NULL,
1672 NULL,
1664 0, 1673 0,
1665 false, 1674 false,
1666 1, 1675 1,
1667 false)); 1676 false));
1668 1677
1669 gfx::Size size(1, 1); 1678 gfx::Size size(1, 1);
1670 ResourceFormat format = RGBA_8888; 1679 ResourceFormat format = RGBA_8888;
1671 int child_texture_id = 1; 1680 int child_texture_id = 1;
1672 int parent_texture_id = 2; 1681 int parent_texture_id = 2;
1673 1682
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
2285 TextureStateTrackingContext* context = context_owned.get(); 2294 TextureStateTrackingContext* context = context_owned.get();
2286 2295
2287 FakeOutputSurfaceClient output_surface_client; 2296 FakeOutputSurfaceClient output_surface_client;
2288 scoped_ptr<OutputSurface> output_surface( 2297 scoped_ptr<OutputSurface> output_surface(
2289 FakeOutputSurface::Create3d(context_owned.Pass())); 2298 FakeOutputSurface::Create3d(context_owned.Pass()));
2290 CHECK(output_surface->BindToClient(&output_surface_client)); 2299 CHECK(output_surface->BindToClient(&output_surface_client));
2291 2300
2292 scoped_ptr<ResourceProvider> resource_provider( 2301 scoped_ptr<ResourceProvider> resource_provider(
2293 ResourceProvider::Create(output_surface.get(), 2302 ResourceProvider::Create(output_surface.get(),
2294 shared_bitmap_manager_.get(), 2303 shared_bitmap_manager_.get(),
2304 gpu_memory_buffer_manager_.get(),
2295 NULL, 2305 NULL,
2296 0, 2306 0,
2297 false, 2307 false,
2298 1, 2308 1,
2299 false)); 2309 false));
2300 2310
2301 gfx::Size size(1, 1); 2311 gfx::Size size(1, 1);
2302 ResourceFormat format = RGBA_8888; 2312 ResourceFormat format = RGBA_8888;
2303 int texture_id = 1; 2313 int texture_id = 1;
2304 2314
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
2372 TextureStateTrackingContext* context = context_owned.get(); 2382 TextureStateTrackingContext* context = context_owned.get();
2373 2383
2374 FakeOutputSurfaceClient output_surface_client; 2384 FakeOutputSurfaceClient output_surface_client;
2375 scoped_ptr<OutputSurface> output_surface( 2385 scoped_ptr<OutputSurface> output_surface(
2376 FakeOutputSurface::Create3d(context_owned.Pass())); 2386 FakeOutputSurface::Create3d(context_owned.Pass()));
2377 CHECK(output_surface->BindToClient(&output_surface_client)); 2387 CHECK(output_surface->BindToClient(&output_surface_client));
2378 2388
2379 scoped_ptr<ResourceProvider> resource_provider( 2389 scoped_ptr<ResourceProvider> resource_provider(
2380 ResourceProvider::Create(output_surface.get(), 2390 ResourceProvider::Create(output_surface.get(),
2381 shared_bitmap_manager_.get(), 2391 shared_bitmap_manager_.get(),
2392 gpu_memory_buffer_manager_.get(),
2382 NULL, 2393 NULL,
2383 0, 2394 0,
2384 false, 2395 false,
2385 1, 2396 1,
2386 false)); 2397 false));
2387 2398
2388 gfx::Size size(1, 1); 2399 gfx::Size size(1, 1);
2389 ResourceFormat format = RGBA_8888; 2400 ResourceFormat format = RGBA_8888;
2390 int texture_id = 1; 2401 int texture_id = 1;
2391 2402
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2427 TextureStateTrackingContext* context = context_owned.get(); 2438 TextureStateTrackingContext* context = context_owned.get();
2428 2439
2429 FakeOutputSurfaceClient output_surface_client; 2440 FakeOutputSurfaceClient output_surface_client;
2430 scoped_ptr<OutputSurface> output_surface( 2441 scoped_ptr<OutputSurface> output_surface(
2431 FakeOutputSurface::Create3d(context_owned.Pass())); 2442 FakeOutputSurface::Create3d(context_owned.Pass()));
2432 CHECK(output_surface->BindToClient(&output_surface_client)); 2443 CHECK(output_surface->BindToClient(&output_surface_client));
2433 2444
2434 scoped_ptr<ResourceProvider> resource_provider( 2445 scoped_ptr<ResourceProvider> resource_provider(
2435 ResourceProvider::Create(output_surface.get(), 2446 ResourceProvider::Create(output_surface.get(),
2436 shared_bitmap_manager_.get(), 2447 shared_bitmap_manager_.get(),
2448 gpu_memory_buffer_manager_.get(),
2437 NULL, 2449 NULL,
2438 0, 2450 0,
2439 false, 2451 false,
2440 1, 2452 1,
2441 false)); 2453 false));
2442 2454
2443 gfx::Size size(1, 1); 2455 gfx::Size size(1, 1);
2444 ResourceFormat format = RGBA_8888; 2456 ResourceFormat format = RGBA_8888;
2445 GLenum texture_pool = GL_TEXTURE_POOL_UNMANAGED_CHROMIUM; 2457 GLenum texture_pool = GL_TEXTURE_POOL_UNMANAGED_CHROMIUM;
2446 2458
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2486 context->set_support_texture_usage(true); 2498 context->set_support_texture_usage(true);
2487 2499
2488 FakeOutputSurfaceClient output_surface_client; 2500 FakeOutputSurfaceClient output_surface_client;
2489 scoped_ptr<OutputSurface> output_surface( 2501 scoped_ptr<OutputSurface> output_surface(
2490 FakeOutputSurface::Create3d(context_owned.Pass())); 2502 FakeOutputSurface::Create3d(context_owned.Pass()));
2491 CHECK(output_surface->BindToClient(&output_surface_client)); 2503 CHECK(output_surface->BindToClient(&output_surface_client));
2492 2504
2493 scoped_ptr<ResourceProvider> resource_provider( 2505 scoped_ptr<ResourceProvider> resource_provider(
2494 ResourceProvider::Create(output_surface.get(), 2506 ResourceProvider::Create(output_surface.get(),
2495 shared_bitmap_manager_.get(), 2507 shared_bitmap_manager_.get(),
2508 gpu_memory_buffer_manager_.get(),
2496 NULL, 2509 NULL,
2497 0, 2510 0,
2498 false, 2511 false,
2499 1, 2512 1,
2500 false)); 2513 false));
2501 2514
2502 gfx::Size size(1, 1); 2515 gfx::Size size(1, 1);
2503 ResourceFormat format = RGBA_8888; 2516 ResourceFormat format = RGBA_8888;
2504 GLenum texture_pool = GL_TEXTURE_POOL_UNMANAGED_CHROMIUM; 2517 GLenum texture_pool = GL_TEXTURE_POOL_UNMANAGED_CHROMIUM;
2505 2518
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
2559 2572
2560 FakeOutputSurfaceClient output_surface_client; 2573 FakeOutputSurfaceClient output_surface_client;
2561 scoped_ptr<OutputSurface> output_surface( 2574 scoped_ptr<OutputSurface> output_surface(
2562 FakeOutputSurface::CreateSoftware(make_scoped_ptr( 2575 FakeOutputSurface::CreateSoftware(make_scoped_ptr(
2563 new SoftwareOutputDevice))); 2576 new SoftwareOutputDevice)));
2564 CHECK(output_surface->BindToClient(&output_surface_client)); 2577 CHECK(output_surface->BindToClient(&output_surface_client));
2565 2578
2566 scoped_ptr<ResourceProvider> resource_provider( 2579 scoped_ptr<ResourceProvider> resource_provider(
2567 ResourceProvider::Create(output_surface.get(), 2580 ResourceProvider::Create(output_surface.get(),
2568 shared_bitmap_manager_.get(), 2581 shared_bitmap_manager_.get(),
2582 gpu_memory_buffer_manager_.get(),
2569 main_thread_task_runner_.get(), 2583 main_thread_task_runner_.get(),
2570 0, 2584 0,
2571 false, 2585 false,
2572 1, 2586 1,
2573 false)); 2587 false));
2574 2588
2575 uint32 release_sync_point = 0; 2589 uint32 release_sync_point = 0;
2576 bool lost_resource = false; 2590 bool lost_resource = false;
2577 BlockingTaskRunner* main_thread_task_runner = NULL; 2591 BlockingTaskRunner* main_thread_task_runner = NULL;
2578 scoped_ptr<SingleReleaseCallbackImpl> callback = 2592 scoped_ptr<SingleReleaseCallbackImpl> callback =
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2611 TextureStateTrackingContext* context = context_owned.get(); 2625 TextureStateTrackingContext* context = context_owned.get();
2612 2626
2613 FakeOutputSurfaceClient output_surface_client; 2627 FakeOutputSurfaceClient output_surface_client;
2614 scoped_ptr<OutputSurface> output_surface( 2628 scoped_ptr<OutputSurface> output_surface(
2615 FakeOutputSurface::Create3d(context_owned.Pass())); 2629 FakeOutputSurface::Create3d(context_owned.Pass()));
2616 CHECK(output_surface->BindToClient(&output_surface_client)); 2630 CHECK(output_surface->BindToClient(&output_surface_client));
2617 2631
2618 scoped_ptr<ResourceProvider> resource_provider( 2632 scoped_ptr<ResourceProvider> resource_provider(
2619 ResourceProvider::Create(output_surface.get(), 2633 ResourceProvider::Create(output_surface.get(),
2620 shared_bitmap_manager_.get(), 2634 shared_bitmap_manager_.get(),
2635 gpu_memory_buffer_manager_.get(),
2621 main_thread_task_runner_.get(), 2636 main_thread_task_runner_.get(),
2622 0, 2637 0,
2623 false, 2638 false,
2624 1, 2639 1,
2625 false)); 2640 false));
2626 2641
2627 unsigned texture_id = 1; 2642 unsigned texture_id = 1;
2628 uint32 sync_point = 30; 2643 uint32 sync_point = 30;
2629 unsigned target = GL_TEXTURE_2D; 2644 unsigned target = GL_TEXTURE_2D;
2630 2645
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
2696 TextureStateTrackingContext* context = context_owned.get(); 2711 TextureStateTrackingContext* context = context_owned.get();
2697 2712
2698 FakeOutputSurfaceClient output_surface_client; 2713 FakeOutputSurfaceClient output_surface_client;
2699 scoped_ptr<OutputSurface> output_surface( 2714 scoped_ptr<OutputSurface> output_surface(
2700 FakeOutputSurface::Create3d(context_owned.Pass())); 2715 FakeOutputSurface::Create3d(context_owned.Pass()));
2701 CHECK(output_surface->BindToClient(&output_surface_client)); 2716 CHECK(output_surface->BindToClient(&output_surface_client));
2702 2717
2703 scoped_ptr<ResourceProvider> resource_provider( 2718 scoped_ptr<ResourceProvider> resource_provider(
2704 ResourceProvider::Create(output_surface.get(), 2719 ResourceProvider::Create(output_surface.get(),
2705 shared_bitmap_manager_.get(), 2720 shared_bitmap_manager_.get(),
2721 gpu_memory_buffer_manager_.get(),
2706 NULL, 2722 NULL,
2707 0, 2723 0,
2708 false, 2724 false,
2709 1, 2725 1,
2710 false)); 2726 false));
2711 2727
2712 unsigned texture_id = 1; 2728 unsigned texture_id = 1;
2713 uint32 sync_point = 30; 2729 uint32 sync_point = 30;
2714 unsigned target = GL_TEXTURE_EXTERNAL_OES; 2730 unsigned target = GL_TEXTURE_EXTERNAL_OES;
2715 2731
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
2771 TextureStateTrackingContext* context = context_owned.get(); 2787 TextureStateTrackingContext* context = context_owned.get();
2772 2788
2773 FakeOutputSurfaceClient output_surface_client; 2789 FakeOutputSurfaceClient output_surface_client;
2774 scoped_ptr<OutputSurface> output_surface( 2790 scoped_ptr<OutputSurface> output_surface(
2775 FakeOutputSurface::Create3d(context_owned.Pass())); 2791 FakeOutputSurface::Create3d(context_owned.Pass()));
2776 CHECK(output_surface->BindToClient(&output_surface_client)); 2792 CHECK(output_surface->BindToClient(&output_surface_client));
2777 2793
2778 scoped_ptr<ResourceProvider> resource_provider( 2794 scoped_ptr<ResourceProvider> resource_provider(
2779 ResourceProvider::Create(output_surface.get(), 2795 ResourceProvider::Create(output_surface.get(),
2780 shared_bitmap_manager_.get(), 2796 shared_bitmap_manager_.get(),
2797 gpu_memory_buffer_manager_.get(),
2781 NULL, 2798 NULL,
2782 0, 2799 0,
2783 false, 2800 false,
2784 1, 2801 1,
2785 false)); 2802 false));
2786 2803
2787 uint32 sync_point = 30; 2804 uint32 sync_point = 30;
2788 unsigned target = GL_TEXTURE_2D; 2805 unsigned target = GL_TEXTURE_2D;
2789 2806
2790 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); 2807 EXPECT_CALL(*context, bindTexture(_, _)).Times(0);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2830 TextureStateTrackingContext* context = context_owned.get(); 2847 TextureStateTrackingContext* context = context_owned.get();
2831 2848
2832 FakeOutputSurfaceClient output_surface_client; 2849 FakeOutputSurfaceClient output_surface_client;
2833 scoped_ptr<OutputSurface> output_surface( 2850 scoped_ptr<OutputSurface> output_surface(
2834 FakeOutputSurface::Create3d(context_owned.Pass())); 2851 FakeOutputSurface::Create3d(context_owned.Pass()));
2835 CHECK(output_surface->BindToClient(&output_surface_client)); 2852 CHECK(output_surface->BindToClient(&output_surface_client));
2836 2853
2837 scoped_ptr<ResourceProvider> resource_provider( 2854 scoped_ptr<ResourceProvider> resource_provider(
2838 ResourceProvider::Create(output_surface.get(), 2855 ResourceProvider::Create(output_surface.get(),
2839 shared_bitmap_manager_.get(), 2856 shared_bitmap_manager_.get(),
2857 gpu_memory_buffer_manager_.get(),
2840 NULL, 2858 NULL,
2841 0, 2859 0,
2842 false, 2860 false,
2843 1, 2861 1,
2844 false)); 2862 false));
2845 2863
2846 uint32 sync_point = 0; 2864 uint32 sync_point = 0;
2847 unsigned target = GL_TEXTURE_2D; 2865 unsigned target = GL_TEXTURE_2D;
2848 2866
2849 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); 2867 EXPECT_CALL(*context, bindTexture(_, _)).Times(0);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
2928 MOCK_METHOD8(compressedTexImage2D, 2946 MOCK_METHOD8(compressedTexImage2D,
2929 void(GLenum target, 2947 void(GLenum target,
2930 GLint level, 2948 GLint level,
2931 GLenum internalformat, 2949 GLenum internalformat,
2932 GLsizei width, 2950 GLsizei width,
2933 GLsizei height, 2951 GLsizei height,
2934 GLint border, 2952 GLint border,
2935 GLsizei image_size, 2953 GLsizei image_size,
2936 const void* data)); 2954 const void* data));
2937 MOCK_METHOD1(waitAsyncTexImage2DCHROMIUM, void(GLenum)); 2955 MOCK_METHOD1(waitAsyncTexImage2DCHROMIUM, void(GLenum));
2938 MOCK_METHOD4(createImageCHROMIUM, GLuint(GLsizei, GLsizei, GLenum, GLenum)); 2956 MOCK_METHOD3(createImageCHROMIUM, GLuint(GLsizei, GLsizei, GLenum));
2939 MOCK_METHOD1(destroyImageCHROMIUM, void(GLuint)); 2957 MOCK_METHOD1(destroyImageCHROMIUM, void(GLuint));
2940 MOCK_METHOD1(mapImageCHROMIUM, void*(GLuint)); 2958 MOCK_METHOD1(mapImageCHROMIUM, void*(GLuint));
2941 MOCK_METHOD3(getImageParameterivCHROMIUM, void(GLuint, GLenum, GLint*)); 2959 MOCK_METHOD3(getImageParameterivCHROMIUM, void(GLuint, GLenum, GLint*));
2942 MOCK_METHOD1(unmapImageCHROMIUM, void(GLuint)); 2960 MOCK_METHOD1(unmapImageCHROMIUM, void(GLuint));
2943 MOCK_METHOD2(bindTexImage2DCHROMIUM, void(GLenum, GLint)); 2961 MOCK_METHOD2(bindTexImage2DCHROMIUM, void(GLenum, GLint));
2944 MOCK_METHOD2(releaseTexImage2DCHROMIUM, void(GLenum, GLint)); 2962 MOCK_METHOD2(releaseTexImage2DCHROMIUM, void(GLenum, GLint));
2945 2963
2946 // We're mocking bindTexture, so we override 2964 // We're mocking bindTexture, so we override
2947 // TestWebGraphicsContext3D::texParameteri to avoid assertions related to the 2965 // TestWebGraphicsContext3D::texParameteri to avoid assertions related to the
2948 // currently bound texture. 2966 // currently bound texture.
2949 virtual void texParameteri(GLenum target, GLenum pname, GLint param) {} 2967 virtual void texParameteri(GLenum target, GLenum pname, GLint param) {}
2950 }; 2968 };
2951 2969
2952 TEST_P(ResourceProviderTest, TextureAllocation) { 2970 TEST_P(ResourceProviderTest, TextureAllocation) {
2953 // Only for GL textures. 2971 // Only for GL textures.
2954 if (GetParam() != ResourceProvider::GLTexture) 2972 if (GetParam() != ResourceProvider::GLTexture)
2955 return; 2973 return;
2956 scoped_ptr<AllocationTrackingContext3D> context_owned( 2974 scoped_ptr<AllocationTrackingContext3D> context_owned(
2957 new StrictMock<AllocationTrackingContext3D>); 2975 new StrictMock<AllocationTrackingContext3D>);
2958 AllocationTrackingContext3D* context = context_owned.get(); 2976 AllocationTrackingContext3D* context = context_owned.get();
2959 2977
2960 FakeOutputSurfaceClient output_surface_client; 2978 FakeOutputSurfaceClient output_surface_client;
2961 scoped_ptr<OutputSurface> output_surface( 2979 scoped_ptr<OutputSurface> output_surface(
2962 FakeOutputSurface::Create3d(context_owned.Pass())); 2980 FakeOutputSurface::Create3d(context_owned.Pass()));
2963 CHECK(output_surface->BindToClient(&output_surface_client)); 2981 CHECK(output_surface->BindToClient(&output_surface_client));
2964 2982
2965 scoped_ptr<ResourceProvider> resource_provider( 2983 scoped_ptr<ResourceProvider> resource_provider(
2966 ResourceProvider::Create(output_surface.get(), 2984 ResourceProvider::Create(output_surface.get(),
2967 shared_bitmap_manager_.get(), 2985 shared_bitmap_manager_.get(),
2986 gpu_memory_buffer_manager_.get(),
2968 NULL, 2987 NULL,
2969 0, 2988 0,
2970 false, 2989 false,
2971 1, 2990 1,
2972 false)); 2991 false));
2973 2992
2974 gfx::Size size(2, 2); 2993 gfx::Size size(2, 2);
2975 gfx::Vector2d offset(0, 0); 2994 gfx::Vector2d offset(0, 0);
2976 gfx::Rect rect(0, 0, 2, 2); 2995 gfx::Rect rect(0, 0, 2, 2);
2977 ResourceFormat format = RGBA_8888; 2996 ResourceFormat format = RGBA_8888;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
3038 context->set_support_texture_usage(true); 3057 context->set_support_texture_usage(true);
3039 3058
3040 FakeOutputSurfaceClient output_surface_client; 3059 FakeOutputSurfaceClient output_surface_client;
3041 scoped_ptr<OutputSurface> output_surface( 3060 scoped_ptr<OutputSurface> output_surface(
3042 FakeOutputSurface::Create3d(context_owned.Pass())); 3061 FakeOutputSurface::Create3d(context_owned.Pass()));
3043 CHECK(output_surface->BindToClient(&output_surface_client)); 3062 CHECK(output_surface->BindToClient(&output_surface_client));
3044 3063
3045 scoped_ptr<ResourceProvider> resource_provider( 3064 scoped_ptr<ResourceProvider> resource_provider(
3046 ResourceProvider::Create(output_surface.get(), 3065 ResourceProvider::Create(output_surface.get(),
3047 shared_bitmap_manager_.get(), 3066 shared_bitmap_manager_.get(),
3067 gpu_memory_buffer_manager_.get(),
3048 NULL, 3068 NULL,
3049 0, 3069 0,
3050 false, 3070 false,
3051 1, 3071 1,
3052 false)); 3072 false));
3053 3073
3054 gfx::Size size(2, 2); 3074 gfx::Size size(2, 2);
3055 3075
3056 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888}; 3076 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888};
3057 const ResourceProvider::TextureHint hints[4] = { 3077 const ResourceProvider::TextureHint hints[4] = {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
3098 context->set_support_texture_usage(true); 3118 context->set_support_texture_usage(true);
3099 3119
3100 FakeOutputSurfaceClient output_surface_client; 3120 FakeOutputSurfaceClient output_surface_client;
3101 scoped_ptr<OutputSurface> output_surface( 3121 scoped_ptr<OutputSurface> output_surface(
3102 FakeOutputSurface::Create3d(context_owned.Pass())); 3122 FakeOutputSurface::Create3d(context_owned.Pass()));
3103 CHECK(output_surface->BindToClient(&output_surface_client)); 3123 CHECK(output_surface->BindToClient(&output_surface_client));
3104 3124
3105 scoped_ptr<ResourceProvider> resource_provider( 3125 scoped_ptr<ResourceProvider> resource_provider(
3106 ResourceProvider::Create(output_surface.get(), 3126 ResourceProvider::Create(output_surface.get(),
3107 shared_bitmap_manager_.get(), 3127 shared_bitmap_manager_.get(),
3128 gpu_memory_buffer_manager_.get(),
3108 NULL, 3129 NULL,
3109 0, 3130 0,
3110 false, 3131 false,
3111 1, 3132 1,
3112 false)); 3133 false));
3113 3134
3114 gfx::Size size(2, 2); 3135 gfx::Size size(2, 2);
3115 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888}; 3136 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888};
3116 3137
3117 const ResourceProvider::TextureHint hints[4] = { 3138 const ResourceProvider::TextureHint hints[4] = {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
3157 CHECK(output_surface->BindToClient(&output_surface_client)); 3178 CHECK(output_surface->BindToClient(&output_surface_client));
3158 3179
3159 gfx::Size size(2, 2); 3180 gfx::Size size(2, 2);
3160 ResourceFormat format = RGBA_8888; 3181 ResourceFormat format = RGBA_8888;
3161 ResourceProvider::ResourceId id = 0; 3182 ResourceProvider::ResourceId id = 0;
3162 int texture_id = 123; 3183 int texture_id = 123;
3163 3184
3164 scoped_ptr<ResourceProvider> resource_provider( 3185 scoped_ptr<ResourceProvider> resource_provider(
3165 ResourceProvider::Create(output_surface.get(), 3186 ResourceProvider::Create(output_surface.get(),
3166 shared_bitmap_manager_.get(), 3187 shared_bitmap_manager_.get(),
3188 gpu_memory_buffer_manager_.get(),
3167 NULL, 3189 NULL,
3168 0, 3190 0,
3169 false, 3191 false,
3170 1, 3192 1,
3171 false)); 3193 false));
3172 3194
3173 id = resource_provider->CreateResource( 3195 id = resource_provider->CreateResource(
3174 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); 3196 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
3175 resource_provider->AcquirePixelBuffer(id); 3197 resource_provider->AcquirePixelBuffer(id);
3176 3198
(...skipping 27 matching lines...) Expand all
3204 CHECK(output_surface->BindToClient(&output_surface_client)); 3226 CHECK(output_surface->BindToClient(&output_surface_client));
3205 3227
3206 gfx::Size size(2, 2); 3228 gfx::Size size(2, 2);
3207 ResourceFormat format = RGBA_8888; 3229 ResourceFormat format = RGBA_8888;
3208 ResourceProvider::ResourceId id = 0; 3230 ResourceProvider::ResourceId id = 0;
3209 int texture_id = 123; 3231 int texture_id = 123;
3210 3232
3211 scoped_ptr<ResourceProvider> resource_provider( 3233 scoped_ptr<ResourceProvider> resource_provider(
3212 ResourceProvider::Create(output_surface.get(), 3234 ResourceProvider::Create(output_surface.get(),
3213 shared_bitmap_manager_.get(), 3235 shared_bitmap_manager_.get(),
3236 gpu_memory_buffer_manager_.get(),
3214 NULL, 3237 NULL,
3215 0, 3238 0,
3216 false, 3239 false,
3217 1, 3240 1,
3218 false)); 3241 false));
3219 3242
3220 id = resource_provider->CreateResource( 3243 id = resource_provider->CreateResource(
3221 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); 3244 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
3222 resource_provider->AcquirePixelBuffer(id); 3245 resource_provider->AcquirePixelBuffer(id);
3223 3246
(...skipping 27 matching lines...) Expand all
3251 CHECK(output_surface->BindToClient(&output_surface_client)); 3274 CHECK(output_surface->BindToClient(&output_surface_client));
3252 3275
3253 gfx::Size size(2, 2); 3276 gfx::Size size(2, 2);
3254 ResourceFormat format = RGBA_8888; 3277 ResourceFormat format = RGBA_8888;
3255 ResourceProvider::ResourceId id = 0; 3278 ResourceProvider::ResourceId id = 0;
3256 int texture_id = 123; 3279 int texture_id = 123;
3257 3280
3258 scoped_ptr<ResourceProvider> resource_provider( 3281 scoped_ptr<ResourceProvider> resource_provider(
3259 ResourceProvider::Create(output_surface.get(), 3282 ResourceProvider::Create(output_surface.get(),
3260 shared_bitmap_manager_.get(), 3283 shared_bitmap_manager_.get(),
3284 gpu_memory_buffer_manager_.get(),
3261 NULL, 3285 NULL,
3262 0, 3286 0,
3263 false, 3287 false,
3264 1, 3288 1,
3265 false)); 3289 false));
3266 3290
3267 EXPECT_CALL(*context, NextTextureId()).WillRepeatedly(Return(texture_id)); 3291 EXPECT_CALL(*context, NextTextureId()).WillRepeatedly(Return(texture_id));
3268 3292
3269 id = resource_provider->CreateResource( 3293 id = resource_provider->CreateResource(
3270 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); 3294 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
(...skipping 25 matching lines...) Expand all
3296 const int kHeight = 2; 3320 const int kHeight = 2;
3297 gfx::Size size(kWidth, kHeight); 3321 gfx::Size size(kWidth, kHeight);
3298 ResourceFormat format = RGBA_8888; 3322 ResourceFormat format = RGBA_8888;
3299 ResourceProvider::ResourceId id = 0; 3323 ResourceProvider::ResourceId id = 0;
3300 const unsigned kTextureId = 123u; 3324 const unsigned kTextureId = 123u;
3301 const unsigned kImageId = 234u; 3325 const unsigned kImageId = 234u;
3302 3326
3303 scoped_ptr<ResourceProvider> resource_provider( 3327 scoped_ptr<ResourceProvider> resource_provider(
3304 ResourceProvider::Create(output_surface.get(), 3328 ResourceProvider::Create(output_surface.get(),
3305 shared_bitmap_manager_.get(), 3329 shared_bitmap_manager_.get(),
3330 gpu_memory_buffer_manager_.get(),
3306 NULL, 3331 NULL,
3307 0, 3332 0,
3308 false, 3333 false,
3309 1, 3334 1,
3310 false)); 3335 false));
3311 3336
3312 id = resource_provider->CreateResource( 3337 id = resource_provider->CreateResource(
3313 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); 3338 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
3314 3339
3315 const int kStride = 8; 3340 EXPECT_CALL(*context, createImageCHROMIUM(kWidth, kHeight, GL_RGBA))
3316 uint8 buffer_data[kStride * kHeight];
3317 EXPECT_CALL(
3318 *context,
3319 createImageCHROMIUM(kWidth, kHeight, GL_RGBA8_OES, GL_IMAGE_MAP_CHROMIUM))
3320 .WillOnce(Return(kImageId)) 3341 .WillOnce(Return(kImageId))
3321 .RetiresOnSaturation(); 3342 .RetiresOnSaturation();
3322 EXPECT_CALL(*context, mapImageCHROMIUM(kImageId))
3323 .WillOnce(Return(buffer_data))
3324 .RetiresOnSaturation();
3325 EXPECT_CALL(*context, getImageParameterivCHROMIUM(kImageId,
3326 GL_IMAGE_ROWBYTES_CHROMIUM,
3327 _))
3328 .WillOnce(SetArgPointee<2>(kStride))
3329 .RetiresOnSaturation();
3330 EXPECT_CALL(*context, unmapImageCHROMIUM(kImageId))
3331 .Times(1)
3332 .RetiresOnSaturation();
3333 { 3343 {
3334 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock( 3344 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock(
3335 resource_provider.get(), id); 3345 resource_provider.get(), id);
3336 EXPECT_TRUE(!!lock.gpu_memory_buffer()); 3346 EXPECT_TRUE(!!lock.gpu_memory_buffer());
3337 } 3347 }
3338 3348
3339 EXPECT_CALL(*context, NextTextureId()) 3349 EXPECT_CALL(*context, NextTextureId())
3340 .WillOnce(Return(kTextureId)) 3350 .WillOnce(Return(kTextureId))
3341 .RetiresOnSaturation(); 3351 .RetiresOnSaturation();
3342 // Once in CreateTextureId and once in BindForSampling 3352 // Once in CreateTextureId and once in BindForSampling
3343 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)).Times(2) 3353 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)).Times(2)
3344 .RetiresOnSaturation(); 3354 .RetiresOnSaturation();
3345 EXPECT_CALL(*context, bindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId)) 3355 EXPECT_CALL(*context, bindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId))
3346 .Times(1) 3356 .Times(1)
3347 .RetiresOnSaturation(); 3357 .RetiresOnSaturation();
3348 { 3358 {
3349 ResourceProvider::ScopedSamplerGL lock_gl( 3359 ResourceProvider::ScopedSamplerGL lock_gl(
3350 resource_provider.get(), id, GL_TEXTURE_2D, GL_LINEAR); 3360 resource_provider.get(), id, GL_TEXTURE_2D, GL_LINEAR);
3351 EXPECT_EQ(kTextureId, lock_gl.texture_id()); 3361 EXPECT_EQ(kTextureId, lock_gl.texture_id());
3352 } 3362 }
3353 3363
3354 EXPECT_CALL(*context, mapImageCHROMIUM(kImageId))
3355 .WillOnce(Return(buffer_data))
3356 .RetiresOnSaturation();
3357 EXPECT_CALL(
3358 *context,
3359 getImageParameterivCHROMIUM(kImageId, GL_IMAGE_ROWBYTES_CHROMIUM, _))
3360 .WillOnce(SetArgPointee<2>(kStride))
3361 .RetiresOnSaturation();
3362 EXPECT_CALL(*context, unmapImageCHROMIUM(kImageId))
3363 .Times(1)
3364 .RetiresOnSaturation();
3365 { 3364 {
3366 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock( 3365 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock(
3367 resource_provider.get(), id); 3366 resource_provider.get(), id);
3368 EXPECT_TRUE(!!lock.gpu_memory_buffer()); 3367 EXPECT_TRUE(!!lock.gpu_memory_buffer());
3369 } 3368 }
3370 3369
3371 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)).Times(1) 3370 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)).Times(1)
3372 .RetiresOnSaturation(); 3371 .RetiresOnSaturation();
3373 EXPECT_CALL(*context, releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId)) 3372 EXPECT_CALL(*context, releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId))
3374 .Times(1) 3373 .Times(1)
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
3409 ResourceFormat format = RGBA_8888; 3408 ResourceFormat format = RGBA_8888;
3410 ResourceProvider::ResourceId source_id = 0; 3409 ResourceProvider::ResourceId source_id = 0;
3411 ResourceProvider::ResourceId dest_id = 0; 3410 ResourceProvider::ResourceId dest_id = 0;
3412 const unsigned kSourceTextureId = 123u; 3411 const unsigned kSourceTextureId = 123u;
3413 const unsigned kDestTextureId = 321u; 3412 const unsigned kDestTextureId = 321u;
3414 const unsigned kImageId = 234u; 3413 const unsigned kImageId = 234u;
3415 3414
3416 scoped_ptr<ResourceProvider> resource_provider( 3415 scoped_ptr<ResourceProvider> resource_provider(
3417 ResourceProvider::Create(output_surface.get(), 3416 ResourceProvider::Create(output_surface.get(),
3418 shared_bitmap_manager_.get(), 3417 shared_bitmap_manager_.get(),
3418 gpu_memory_buffer_manager_.get(),
3419 NULL, 3419 NULL,
3420 0, 3420 0,
3421 false, 3421 false,
3422 1, 3422 1,
3423 false)); 3423 false));
3424 3424
3425 source_id = resource_provider->CreateResource( 3425 source_id = resource_provider->CreateResource(
3426 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); 3426 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
3427 3427
3428 const int kStride = 8; 3428 EXPECT_CALL(*context, createImageCHROMIUM(kWidth, kHeight, GL_RGBA))
3429 uint8 buffer_data[kStride * kHeight];
3430 EXPECT_CALL(
3431 *context,
3432 createImageCHROMIUM(kWidth, kHeight, GL_RGBA8_OES, GL_IMAGE_MAP_CHROMIUM))
3433 .WillOnce(Return(kImageId)) 3429 .WillOnce(Return(kImageId))
3434 .RetiresOnSaturation(); 3430 .RetiresOnSaturation();
3435 EXPECT_CALL(*context, mapImageCHROMIUM(kImageId))
3436 .WillOnce(Return(buffer_data))
3437 .RetiresOnSaturation();
3438 EXPECT_CALL(
3439 *context,
3440 getImageParameterivCHROMIUM(kImageId, GL_IMAGE_ROWBYTES_CHROMIUM, _))
3441 .WillOnce(SetArgPointee<2>(kStride))
3442 .RetiresOnSaturation();
3443 EXPECT_CALL(*context, unmapImageCHROMIUM(kImageId))
3444 .Times(1)
3445 .RetiresOnSaturation();
3446 { 3431 {
3447 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock( 3432 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock(
3448 resource_provider.get(), source_id); 3433 resource_provider.get(), source_id);
3449 EXPECT_TRUE(!!lock.gpu_memory_buffer()); 3434 EXPECT_TRUE(!!lock.gpu_memory_buffer());
3450 } 3435 }
3451 Mock::VerifyAndClearExpectations(context); 3436 Mock::VerifyAndClearExpectations(context);
3452 3437
3453 dest_id = resource_provider->CreateResource( 3438 dest_id = resource_provider->CreateResource(
3454 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); 3439 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
3455 3440
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
3507 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice), 3492 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice),
3508 delegated_rendering)); 3493 delegated_rendering));
3509 FakeOutputSurfaceClient client(output_surface.get()); 3494 FakeOutputSurfaceClient client(output_surface.get());
3510 EXPECT_TRUE(output_surface->BindToClient(&client)); 3495 EXPECT_TRUE(output_surface->BindToClient(&client));
3511 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 3496 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
3512 new TestSharedBitmapManager()); 3497 new TestSharedBitmapManager());
3513 scoped_ptr<ResourceProvider> resource_provider( 3498 scoped_ptr<ResourceProvider> resource_provider(
3514 ResourceProvider::Create(output_surface.get(), 3499 ResourceProvider::Create(output_surface.get(),
3515 shared_bitmap_manager.get(), 3500 shared_bitmap_manager.get(),
3516 NULL, 3501 NULL,
3502 NULL,
3517 0, 3503 0,
3518 false, 3504 false,
3519 1, 3505 1,
3520 false)); 3506 false));
3521 3507
3522 CheckCreateResource(ResourceProvider::Bitmap, resource_provider.get(), NULL); 3508 CheckCreateResource(ResourceProvider::Bitmap, resource_provider.get(), NULL);
3523 3509
3524 InitializeGLAndCheck(shared_data.get(), 3510 InitializeGLAndCheck(shared_data.get(),
3525 resource_provider.get(), 3511 resource_provider.get(),
3526 output_surface.get()); 3512 output_surface.get());
(...skipping 18 matching lines...) Expand all
3545 3531
3546 FakeOutputSurfaceClient output_surface_client; 3532 FakeOutputSurfaceClient output_surface_client;
3547 scoped_ptr<OutputSurface> output_surface( 3533 scoped_ptr<OutputSurface> output_surface(
3548 FakeOutputSurface::Create3d(context_owned.Pass())); 3534 FakeOutputSurface::Create3d(context_owned.Pass()));
3549 CHECK(output_surface->BindToClient(&output_surface_client)); 3535 CHECK(output_surface->BindToClient(&output_surface_client));
3550 3536
3551 gfx::Size size(4, 4); 3537 gfx::Size size(4, 4);
3552 scoped_ptr<ResourceProvider> resource_provider( 3538 scoped_ptr<ResourceProvider> resource_provider(
3553 ResourceProvider::Create(output_surface.get(), 3539 ResourceProvider::Create(output_surface.get(),
3554 shared_bitmap_manager_.get(), 3540 shared_bitmap_manager_.get(),
3541 gpu_memory_buffer_manager_.get(),
3555 NULL, 3542 NULL,
3556 0, 3543 0,
3557 false, 3544 false,
3558 1, 3545 1,
3559 false)); 3546 false));
3560 int texture_id = 123; 3547 int texture_id = 123;
3561 3548
3562 ResourceProvider::ResourceId id = resource_provider->CreateResource( 3549 ResourceProvider::ResourceId id = resource_provider->CreateResource(
3563 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, ETC1); 3550 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, ETC1);
3564 EXPECT_NE(0u, id); 3551 EXPECT_NE(0u, id);
(...skipping 16 matching lines...) Expand all
3581 3568
3582 FakeOutputSurfaceClient output_surface_client; 3569 FakeOutputSurfaceClient output_surface_client;
3583 scoped_ptr<OutputSurface> output_surface( 3570 scoped_ptr<OutputSurface> output_surface(
3584 FakeOutputSurface::Create3d(context_owned.Pass())); 3571 FakeOutputSurface::Create3d(context_owned.Pass()));
3585 CHECK(output_surface->BindToClient(&output_surface_client)); 3572 CHECK(output_surface->BindToClient(&output_surface_client));
3586 3573
3587 gfx::Size size(4, 4); 3574 gfx::Size size(4, 4);
3588 scoped_ptr<ResourceProvider> resource_provider( 3575 scoped_ptr<ResourceProvider> resource_provider(
3589 ResourceProvider::Create(output_surface.get(), 3576 ResourceProvider::Create(output_surface.get(),
3590 shared_bitmap_manager_.get(), 3577 shared_bitmap_manager_.get(),
3578 gpu_memory_buffer_manager_.get(),
3591 NULL, 3579 NULL,
3592 0, 3580 0,
3593 false, 3581 false,
3594 1, 3582 1,
3595 false)); 3583 false));
3596 int texture_id = 123; 3584 int texture_id = 123;
3597 uint8_t pixels[8]; 3585 uint8_t pixels[8];
3598 3586
3599 ResourceProvider::ResourceId id = resource_provider->CreateResource( 3587 ResourceProvider::ResourceId id = resource_provider->CreateResource(
3600 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, ETC1); 3588 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, ETC1);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
3643 3631
3644 gfx::Size size(1, 1); 3632 gfx::Size size(1, 1);
3645 ResourceFormat format = RGBA_8888; 3633 ResourceFormat format = RGBA_8888;
3646 3634
3647 { 3635 {
3648 size_t kTextureAllocationChunkSize = 1; 3636 size_t kTextureAllocationChunkSize = 1;
3649 scoped_ptr<ResourceProvider> resource_provider( 3637 scoped_ptr<ResourceProvider> resource_provider(
3650 ResourceProvider::Create(output_surface.get(), 3638 ResourceProvider::Create(output_surface.get(),
3651 shared_bitmap_manager.get(), 3639 shared_bitmap_manager.get(),
3652 NULL, 3640 NULL,
3641 NULL,
3653 0, 3642 0,
3654 false, 3643 false,
3655 kTextureAllocationChunkSize, 3644 kTextureAllocationChunkSize,
3656 false)); 3645 false));
3657 3646
3658 ResourceProvider::ResourceId id = resource_provider->CreateResource( 3647 ResourceProvider::ResourceId id = resource_provider->CreateResource(
3659 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); 3648 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
3660 resource_provider->AllocateForTesting(id); 3649 resource_provider->AllocateForTesting(id);
3661 Mock::VerifyAndClearExpectations(context); 3650 Mock::VerifyAndClearExpectations(context);
3662 3651
3663 DCHECK_EQ(2u, context->PeekTextureId()); 3652 DCHECK_EQ(2u, context->PeekTextureId());
3664 resource_provider->DeleteResource(id); 3653 resource_provider->DeleteResource(id);
3665 } 3654 }
3666 3655
3667 { 3656 {
3668 size_t kTextureAllocationChunkSize = 8; 3657 size_t kTextureAllocationChunkSize = 8;
3669 scoped_ptr<ResourceProvider> resource_provider( 3658 scoped_ptr<ResourceProvider> resource_provider(
3670 ResourceProvider::Create(output_surface.get(), 3659 ResourceProvider::Create(output_surface.get(),
3671 shared_bitmap_manager.get(), 3660 shared_bitmap_manager.get(),
3672 NULL, 3661 NULL,
3662 NULL,
3673 0, 3663 0,
3674 false, 3664 false,
3675 kTextureAllocationChunkSize, 3665 kTextureAllocationChunkSize,
3676 false)); 3666 false));
3677 3667
3678 ResourceProvider::ResourceId id = resource_provider->CreateResource( 3668 ResourceProvider::ResourceId id = resource_provider->CreateResource(
3679 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); 3669 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
3680 resource_provider->AllocateForTesting(id); 3670 resource_provider->AllocateForTesting(id);
3681 Mock::VerifyAndClearExpectations(context); 3671 Mock::VerifyAndClearExpectations(context);
3682 3672
3683 DCHECK_EQ(10u, context->PeekTextureId()); 3673 DCHECK_EQ(10u, context->PeekTextureId());
3684 resource_provider->DeleteResource(id); 3674 resource_provider->DeleteResource(id);
3685 } 3675 }
3686 } 3676 }
3687 3677
3688 } // namespace 3678 } // namespace
3689 } // namespace cc 3679 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698