OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/resources/resource_provider.h" | 5 #include "cc/resources/resource_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 | 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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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_METHOD4(createImageCHROMIUM, |
| 2957 GLuint(ClientBuffer, GLsizei, GLsizei, GLenum)); |
2939 MOCK_METHOD1(destroyImageCHROMIUM, void(GLuint)); | 2958 MOCK_METHOD1(destroyImageCHROMIUM, void(GLuint)); |
2940 MOCK_METHOD1(mapImageCHROMIUM, void*(GLuint)); | |
2941 MOCK_METHOD3(getImageParameterivCHROMIUM, void(GLuint, GLenum, GLint*)); | |
2942 MOCK_METHOD1(unmapImageCHROMIUM, void(GLuint)); | |
2943 MOCK_METHOD2(bindTexImage2DCHROMIUM, void(GLenum, GLint)); | 2959 MOCK_METHOD2(bindTexImage2DCHROMIUM, void(GLenum, GLint)); |
2944 MOCK_METHOD2(releaseTexImage2DCHROMIUM, void(GLenum, GLint)); | 2960 MOCK_METHOD2(releaseTexImage2DCHROMIUM, void(GLenum, GLint)); |
2945 | 2961 |
2946 // We're mocking bindTexture, so we override | 2962 // We're mocking bindTexture, so we override |
2947 // TestWebGraphicsContext3D::texParameteri to avoid assertions related to the | 2963 // TestWebGraphicsContext3D::texParameteri to avoid assertions related to the |
2948 // currently bound texture. | 2964 // currently bound texture. |
2949 virtual void texParameteri(GLenum target, GLenum pname, GLint param) {} | 2965 virtual void texParameteri(GLenum target, GLenum pname, GLint param) {} |
2950 }; | 2966 }; |
2951 | 2967 |
2952 TEST_P(ResourceProviderTest, TextureAllocation) { | 2968 TEST_P(ResourceProviderTest, TextureAllocation) { |
2953 // Only for GL textures. | 2969 // Only for GL textures. |
2954 if (GetParam() != ResourceProvider::GLTexture) | 2970 if (GetParam() != ResourceProvider::GLTexture) |
2955 return; | 2971 return; |
2956 scoped_ptr<AllocationTrackingContext3D> context_owned( | 2972 scoped_ptr<AllocationTrackingContext3D> context_owned( |
2957 new StrictMock<AllocationTrackingContext3D>); | 2973 new StrictMock<AllocationTrackingContext3D>); |
2958 AllocationTrackingContext3D* context = context_owned.get(); | 2974 AllocationTrackingContext3D* context = context_owned.get(); |
2959 | 2975 |
2960 FakeOutputSurfaceClient output_surface_client; | 2976 FakeOutputSurfaceClient output_surface_client; |
2961 scoped_ptr<OutputSurface> output_surface( | 2977 scoped_ptr<OutputSurface> output_surface( |
2962 FakeOutputSurface::Create3d(context_owned.Pass())); | 2978 FakeOutputSurface::Create3d(context_owned.Pass())); |
2963 CHECK(output_surface->BindToClient(&output_surface_client)); | 2979 CHECK(output_surface->BindToClient(&output_surface_client)); |
2964 | 2980 |
2965 scoped_ptr<ResourceProvider> resource_provider( | 2981 scoped_ptr<ResourceProvider> resource_provider( |
2966 ResourceProvider::Create(output_surface.get(), | 2982 ResourceProvider::Create(output_surface.get(), |
2967 shared_bitmap_manager_.get(), | 2983 shared_bitmap_manager_.get(), |
| 2984 gpu_memory_buffer_manager_.get(), |
2968 NULL, | 2985 NULL, |
2969 0, | 2986 0, |
2970 false, | 2987 false, |
2971 1, | 2988 1, |
2972 false)); | 2989 false)); |
2973 | 2990 |
2974 gfx::Size size(2, 2); | 2991 gfx::Size size(2, 2); |
2975 gfx::Vector2d offset(0, 0); | 2992 gfx::Vector2d offset(0, 0); |
2976 gfx::Rect rect(0, 0, 2, 2); | 2993 gfx::Rect rect(0, 0, 2, 2); |
2977 ResourceFormat format = RGBA_8888; | 2994 ResourceFormat format = RGBA_8888; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3038 context->set_support_texture_usage(true); | 3055 context->set_support_texture_usage(true); |
3039 | 3056 |
3040 FakeOutputSurfaceClient output_surface_client; | 3057 FakeOutputSurfaceClient output_surface_client; |
3041 scoped_ptr<OutputSurface> output_surface( | 3058 scoped_ptr<OutputSurface> output_surface( |
3042 FakeOutputSurface::Create3d(context_owned.Pass())); | 3059 FakeOutputSurface::Create3d(context_owned.Pass())); |
3043 CHECK(output_surface->BindToClient(&output_surface_client)); | 3060 CHECK(output_surface->BindToClient(&output_surface_client)); |
3044 | 3061 |
3045 scoped_ptr<ResourceProvider> resource_provider( | 3062 scoped_ptr<ResourceProvider> resource_provider( |
3046 ResourceProvider::Create(output_surface.get(), | 3063 ResourceProvider::Create(output_surface.get(), |
3047 shared_bitmap_manager_.get(), | 3064 shared_bitmap_manager_.get(), |
| 3065 gpu_memory_buffer_manager_.get(), |
3048 NULL, | 3066 NULL, |
3049 0, | 3067 0, |
3050 false, | 3068 false, |
3051 1, | 3069 1, |
3052 false)); | 3070 false)); |
3053 | 3071 |
3054 gfx::Size size(2, 2); | 3072 gfx::Size size(2, 2); |
3055 | 3073 |
3056 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888}; | 3074 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888}; |
3057 const ResourceProvider::TextureHint hints[4] = { | 3075 const ResourceProvider::TextureHint hints[4] = { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3098 context->set_support_texture_usage(true); | 3116 context->set_support_texture_usage(true); |
3099 | 3117 |
3100 FakeOutputSurfaceClient output_surface_client; | 3118 FakeOutputSurfaceClient output_surface_client; |
3101 scoped_ptr<OutputSurface> output_surface( | 3119 scoped_ptr<OutputSurface> output_surface( |
3102 FakeOutputSurface::Create3d(context_owned.Pass())); | 3120 FakeOutputSurface::Create3d(context_owned.Pass())); |
3103 CHECK(output_surface->BindToClient(&output_surface_client)); | 3121 CHECK(output_surface->BindToClient(&output_surface_client)); |
3104 | 3122 |
3105 scoped_ptr<ResourceProvider> resource_provider( | 3123 scoped_ptr<ResourceProvider> resource_provider( |
3106 ResourceProvider::Create(output_surface.get(), | 3124 ResourceProvider::Create(output_surface.get(), |
3107 shared_bitmap_manager_.get(), | 3125 shared_bitmap_manager_.get(), |
| 3126 gpu_memory_buffer_manager_.get(), |
3108 NULL, | 3127 NULL, |
3109 0, | 3128 0, |
3110 false, | 3129 false, |
3111 1, | 3130 1, |
3112 false)); | 3131 false)); |
3113 | 3132 |
3114 gfx::Size size(2, 2); | 3133 gfx::Size size(2, 2); |
3115 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888}; | 3134 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888}; |
3116 | 3135 |
3117 const ResourceProvider::TextureHint hints[4] = { | 3136 const ResourceProvider::TextureHint hints[4] = { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3157 CHECK(output_surface->BindToClient(&output_surface_client)); | 3176 CHECK(output_surface->BindToClient(&output_surface_client)); |
3158 | 3177 |
3159 gfx::Size size(2, 2); | 3178 gfx::Size size(2, 2); |
3160 ResourceFormat format = RGBA_8888; | 3179 ResourceFormat format = RGBA_8888; |
3161 ResourceProvider::ResourceId id = 0; | 3180 ResourceProvider::ResourceId id = 0; |
3162 int texture_id = 123; | 3181 int texture_id = 123; |
3163 | 3182 |
3164 scoped_ptr<ResourceProvider> resource_provider( | 3183 scoped_ptr<ResourceProvider> resource_provider( |
3165 ResourceProvider::Create(output_surface.get(), | 3184 ResourceProvider::Create(output_surface.get(), |
3166 shared_bitmap_manager_.get(), | 3185 shared_bitmap_manager_.get(), |
| 3186 gpu_memory_buffer_manager_.get(), |
3167 NULL, | 3187 NULL, |
3168 0, | 3188 0, |
3169 false, | 3189 false, |
3170 1, | 3190 1, |
3171 false)); | 3191 false)); |
3172 | 3192 |
3173 id = resource_provider->CreateResource( | 3193 id = resource_provider->CreateResource( |
3174 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); | 3194 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); |
3175 resource_provider->AcquirePixelBuffer(id); | 3195 resource_provider->AcquirePixelBuffer(id); |
3176 | 3196 |
(...skipping 27 matching lines...) Expand all Loading... |
3204 CHECK(output_surface->BindToClient(&output_surface_client)); | 3224 CHECK(output_surface->BindToClient(&output_surface_client)); |
3205 | 3225 |
3206 gfx::Size size(2, 2); | 3226 gfx::Size size(2, 2); |
3207 ResourceFormat format = RGBA_8888; | 3227 ResourceFormat format = RGBA_8888; |
3208 ResourceProvider::ResourceId id = 0; | 3228 ResourceProvider::ResourceId id = 0; |
3209 int texture_id = 123; | 3229 int texture_id = 123; |
3210 | 3230 |
3211 scoped_ptr<ResourceProvider> resource_provider( | 3231 scoped_ptr<ResourceProvider> resource_provider( |
3212 ResourceProvider::Create(output_surface.get(), | 3232 ResourceProvider::Create(output_surface.get(), |
3213 shared_bitmap_manager_.get(), | 3233 shared_bitmap_manager_.get(), |
| 3234 gpu_memory_buffer_manager_.get(), |
3214 NULL, | 3235 NULL, |
3215 0, | 3236 0, |
3216 false, | 3237 false, |
3217 1, | 3238 1, |
3218 false)); | 3239 false)); |
3219 | 3240 |
3220 id = resource_provider->CreateResource( | 3241 id = resource_provider->CreateResource( |
3221 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); | 3242 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); |
3222 resource_provider->AcquirePixelBuffer(id); | 3243 resource_provider->AcquirePixelBuffer(id); |
3223 | 3244 |
(...skipping 27 matching lines...) Expand all Loading... |
3251 CHECK(output_surface->BindToClient(&output_surface_client)); | 3272 CHECK(output_surface->BindToClient(&output_surface_client)); |
3252 | 3273 |
3253 gfx::Size size(2, 2); | 3274 gfx::Size size(2, 2); |
3254 ResourceFormat format = RGBA_8888; | 3275 ResourceFormat format = RGBA_8888; |
3255 ResourceProvider::ResourceId id = 0; | 3276 ResourceProvider::ResourceId id = 0; |
3256 int texture_id = 123; | 3277 int texture_id = 123; |
3257 | 3278 |
3258 scoped_ptr<ResourceProvider> resource_provider( | 3279 scoped_ptr<ResourceProvider> resource_provider( |
3259 ResourceProvider::Create(output_surface.get(), | 3280 ResourceProvider::Create(output_surface.get(), |
3260 shared_bitmap_manager_.get(), | 3281 shared_bitmap_manager_.get(), |
| 3282 gpu_memory_buffer_manager_.get(), |
3261 NULL, | 3283 NULL, |
3262 0, | 3284 0, |
3263 false, | 3285 false, |
3264 1, | 3286 1, |
3265 false)); | 3287 false)); |
3266 | 3288 |
3267 EXPECT_CALL(*context, NextTextureId()).WillRepeatedly(Return(texture_id)); | 3289 EXPECT_CALL(*context, NextTextureId()).WillRepeatedly(Return(texture_id)); |
3268 | 3290 |
3269 id = resource_provider->CreateResource( | 3291 id = resource_provider->CreateResource( |
3270 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); | 3292 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); |
(...skipping 25 matching lines...) Expand all Loading... |
3296 const int kHeight = 2; | 3318 const int kHeight = 2; |
3297 gfx::Size size(kWidth, kHeight); | 3319 gfx::Size size(kWidth, kHeight); |
3298 ResourceFormat format = RGBA_8888; | 3320 ResourceFormat format = RGBA_8888; |
3299 ResourceProvider::ResourceId id = 0; | 3321 ResourceProvider::ResourceId id = 0; |
3300 const unsigned kTextureId = 123u; | 3322 const unsigned kTextureId = 123u; |
3301 const unsigned kImageId = 234u; | 3323 const unsigned kImageId = 234u; |
3302 | 3324 |
3303 scoped_ptr<ResourceProvider> resource_provider( | 3325 scoped_ptr<ResourceProvider> resource_provider( |
3304 ResourceProvider::Create(output_surface.get(), | 3326 ResourceProvider::Create(output_surface.get(), |
3305 shared_bitmap_manager_.get(), | 3327 shared_bitmap_manager_.get(), |
| 3328 gpu_memory_buffer_manager_.get(), |
3306 NULL, | 3329 NULL, |
3307 0, | 3330 0, |
3308 false, | 3331 false, |
3309 1, | 3332 1, |
3310 false)); | 3333 false)); |
3311 | 3334 |
3312 id = resource_provider->CreateResource( | 3335 id = resource_provider->CreateResource( |
3313 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); | 3336 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); |
3314 | 3337 |
3315 const int kStride = 8; | 3338 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)) | 3339 .WillOnce(Return(kImageId)) |
3321 .RetiresOnSaturation(); | 3340 .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 { | 3341 { |
3334 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock( | 3342 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock( |
3335 resource_provider.get(), id); | 3343 resource_provider.get(), id); |
3336 EXPECT_TRUE(!!lock.gpu_memory_buffer()); | 3344 EXPECT_TRUE(!!lock.gpu_memory_buffer()); |
3337 } | 3345 } |
3338 | 3346 |
3339 EXPECT_CALL(*context, NextTextureId()) | 3347 EXPECT_CALL(*context, NextTextureId()) |
3340 .WillOnce(Return(kTextureId)) | 3348 .WillOnce(Return(kTextureId)) |
3341 .RetiresOnSaturation(); | 3349 .RetiresOnSaturation(); |
3342 // Once in CreateTextureId and once in BindForSampling | 3350 // Once in CreateTextureId and once in BindForSampling |
3343 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)).Times(2) | 3351 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)).Times(2) |
3344 .RetiresOnSaturation(); | 3352 .RetiresOnSaturation(); |
3345 EXPECT_CALL(*context, bindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId)) | 3353 EXPECT_CALL(*context, bindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId)) |
3346 .Times(1) | 3354 .Times(1) |
3347 .RetiresOnSaturation(); | 3355 .RetiresOnSaturation(); |
3348 { | 3356 { |
3349 ResourceProvider::ScopedSamplerGL lock_gl( | 3357 ResourceProvider::ScopedSamplerGL lock_gl( |
3350 resource_provider.get(), id, GL_TEXTURE_2D, GL_LINEAR); | 3358 resource_provider.get(), id, GL_TEXTURE_2D, GL_LINEAR); |
3351 EXPECT_EQ(kTextureId, lock_gl.texture_id()); | 3359 EXPECT_EQ(kTextureId, lock_gl.texture_id()); |
3352 } | 3360 } |
3353 | 3361 |
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 { | 3362 { |
3366 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock( | 3363 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock( |
3367 resource_provider.get(), id); | 3364 resource_provider.get(), id); |
3368 EXPECT_TRUE(!!lock.gpu_memory_buffer()); | 3365 EXPECT_TRUE(!!lock.gpu_memory_buffer()); |
3369 } | 3366 } |
3370 | 3367 |
3371 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)).Times(1) | 3368 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)).Times(1) |
3372 .RetiresOnSaturation(); | 3369 .RetiresOnSaturation(); |
3373 EXPECT_CALL(*context, releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId)) | 3370 EXPECT_CALL(*context, releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId)) |
3374 .Times(1) | 3371 .Times(1) |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3409 ResourceFormat format = RGBA_8888; | 3406 ResourceFormat format = RGBA_8888; |
3410 ResourceProvider::ResourceId source_id = 0; | 3407 ResourceProvider::ResourceId source_id = 0; |
3411 ResourceProvider::ResourceId dest_id = 0; | 3408 ResourceProvider::ResourceId dest_id = 0; |
3412 const unsigned kSourceTextureId = 123u; | 3409 const unsigned kSourceTextureId = 123u; |
3413 const unsigned kDestTextureId = 321u; | 3410 const unsigned kDestTextureId = 321u; |
3414 const unsigned kImageId = 234u; | 3411 const unsigned kImageId = 234u; |
3415 | 3412 |
3416 scoped_ptr<ResourceProvider> resource_provider( | 3413 scoped_ptr<ResourceProvider> resource_provider( |
3417 ResourceProvider::Create(output_surface.get(), | 3414 ResourceProvider::Create(output_surface.get(), |
3418 shared_bitmap_manager_.get(), | 3415 shared_bitmap_manager_.get(), |
| 3416 gpu_memory_buffer_manager_.get(), |
3419 NULL, | 3417 NULL, |
3420 0, | 3418 0, |
3421 false, | 3419 false, |
3422 1, | 3420 1, |
3423 false)); | 3421 false)); |
3424 | 3422 |
3425 source_id = resource_provider->CreateResource( | 3423 source_id = resource_provider->CreateResource( |
3426 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); | 3424 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); |
3427 | 3425 |
3428 const int kStride = 8; | 3426 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)) | 3427 .WillOnce(Return(kImageId)) |
3434 .RetiresOnSaturation(); | 3428 .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 { | 3429 { |
3447 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock( | 3430 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock( |
3448 resource_provider.get(), source_id); | 3431 resource_provider.get(), source_id); |
3449 EXPECT_TRUE(!!lock.gpu_memory_buffer()); | 3432 EXPECT_TRUE(!!lock.gpu_memory_buffer()); |
3450 } | 3433 } |
3451 Mock::VerifyAndClearExpectations(context); | 3434 Mock::VerifyAndClearExpectations(context); |
3452 | 3435 |
3453 dest_id = resource_provider->CreateResource( | 3436 dest_id = resource_provider->CreateResource( |
3454 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); | 3437 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); |
3455 | 3438 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3507 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice), | 3490 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice), |
3508 delegated_rendering)); | 3491 delegated_rendering)); |
3509 FakeOutputSurfaceClient client(output_surface.get()); | 3492 FakeOutputSurfaceClient client(output_surface.get()); |
3510 EXPECT_TRUE(output_surface->BindToClient(&client)); | 3493 EXPECT_TRUE(output_surface->BindToClient(&client)); |
3511 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( | 3494 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( |
3512 new TestSharedBitmapManager()); | 3495 new TestSharedBitmapManager()); |
3513 scoped_ptr<ResourceProvider> resource_provider( | 3496 scoped_ptr<ResourceProvider> resource_provider( |
3514 ResourceProvider::Create(output_surface.get(), | 3497 ResourceProvider::Create(output_surface.get(), |
3515 shared_bitmap_manager.get(), | 3498 shared_bitmap_manager.get(), |
3516 NULL, | 3499 NULL, |
| 3500 NULL, |
3517 0, | 3501 0, |
3518 false, | 3502 false, |
3519 1, | 3503 1, |
3520 false)); | 3504 false)); |
3521 | 3505 |
3522 CheckCreateResource(ResourceProvider::Bitmap, resource_provider.get(), NULL); | 3506 CheckCreateResource(ResourceProvider::Bitmap, resource_provider.get(), NULL); |
3523 | 3507 |
3524 InitializeGLAndCheck(shared_data.get(), | 3508 InitializeGLAndCheck(shared_data.get(), |
3525 resource_provider.get(), | 3509 resource_provider.get(), |
3526 output_surface.get()); | 3510 output_surface.get()); |
(...skipping 18 matching lines...) Expand all Loading... |
3545 | 3529 |
3546 FakeOutputSurfaceClient output_surface_client; | 3530 FakeOutputSurfaceClient output_surface_client; |
3547 scoped_ptr<OutputSurface> output_surface( | 3531 scoped_ptr<OutputSurface> output_surface( |
3548 FakeOutputSurface::Create3d(context_owned.Pass())); | 3532 FakeOutputSurface::Create3d(context_owned.Pass())); |
3549 CHECK(output_surface->BindToClient(&output_surface_client)); | 3533 CHECK(output_surface->BindToClient(&output_surface_client)); |
3550 | 3534 |
3551 gfx::Size size(4, 4); | 3535 gfx::Size size(4, 4); |
3552 scoped_ptr<ResourceProvider> resource_provider( | 3536 scoped_ptr<ResourceProvider> resource_provider( |
3553 ResourceProvider::Create(output_surface.get(), | 3537 ResourceProvider::Create(output_surface.get(), |
3554 shared_bitmap_manager_.get(), | 3538 shared_bitmap_manager_.get(), |
| 3539 gpu_memory_buffer_manager_.get(), |
3555 NULL, | 3540 NULL, |
3556 0, | 3541 0, |
3557 false, | 3542 false, |
3558 1, | 3543 1, |
3559 false)); | 3544 false)); |
3560 int texture_id = 123; | 3545 int texture_id = 123; |
3561 | 3546 |
3562 ResourceProvider::ResourceId id = resource_provider->CreateResource( | 3547 ResourceProvider::ResourceId id = resource_provider->CreateResource( |
3563 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, ETC1); | 3548 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, ETC1); |
3564 EXPECT_NE(0u, id); | 3549 EXPECT_NE(0u, id); |
(...skipping 16 matching lines...) Expand all Loading... |
3581 | 3566 |
3582 FakeOutputSurfaceClient output_surface_client; | 3567 FakeOutputSurfaceClient output_surface_client; |
3583 scoped_ptr<OutputSurface> output_surface( | 3568 scoped_ptr<OutputSurface> output_surface( |
3584 FakeOutputSurface::Create3d(context_owned.Pass())); | 3569 FakeOutputSurface::Create3d(context_owned.Pass())); |
3585 CHECK(output_surface->BindToClient(&output_surface_client)); | 3570 CHECK(output_surface->BindToClient(&output_surface_client)); |
3586 | 3571 |
3587 gfx::Size size(4, 4); | 3572 gfx::Size size(4, 4); |
3588 scoped_ptr<ResourceProvider> resource_provider( | 3573 scoped_ptr<ResourceProvider> resource_provider( |
3589 ResourceProvider::Create(output_surface.get(), | 3574 ResourceProvider::Create(output_surface.get(), |
3590 shared_bitmap_manager_.get(), | 3575 shared_bitmap_manager_.get(), |
| 3576 gpu_memory_buffer_manager_.get(), |
3591 NULL, | 3577 NULL, |
3592 0, | 3578 0, |
3593 false, | 3579 false, |
3594 1, | 3580 1, |
3595 false)); | 3581 false)); |
3596 int texture_id = 123; | 3582 int texture_id = 123; |
3597 uint8_t pixels[8]; | 3583 uint8_t pixels[8]; |
3598 | 3584 |
3599 ResourceProvider::ResourceId id = resource_provider->CreateResource( | 3585 ResourceProvider::ResourceId id = resource_provider->CreateResource( |
3600 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, ETC1); | 3586 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, ETC1); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3643 | 3629 |
3644 gfx::Size size(1, 1); | 3630 gfx::Size size(1, 1); |
3645 ResourceFormat format = RGBA_8888; | 3631 ResourceFormat format = RGBA_8888; |
3646 | 3632 |
3647 { | 3633 { |
3648 size_t kTextureAllocationChunkSize = 1; | 3634 size_t kTextureAllocationChunkSize = 1; |
3649 scoped_ptr<ResourceProvider> resource_provider( | 3635 scoped_ptr<ResourceProvider> resource_provider( |
3650 ResourceProvider::Create(output_surface.get(), | 3636 ResourceProvider::Create(output_surface.get(), |
3651 shared_bitmap_manager.get(), | 3637 shared_bitmap_manager.get(), |
3652 NULL, | 3638 NULL, |
| 3639 NULL, |
3653 0, | 3640 0, |
3654 false, | 3641 false, |
3655 kTextureAllocationChunkSize, | 3642 kTextureAllocationChunkSize, |
3656 false)); | 3643 false)); |
3657 | 3644 |
3658 ResourceProvider::ResourceId id = resource_provider->CreateResource( | 3645 ResourceProvider::ResourceId id = resource_provider->CreateResource( |
3659 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); | 3646 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); |
3660 resource_provider->AllocateForTesting(id); | 3647 resource_provider->AllocateForTesting(id); |
3661 Mock::VerifyAndClearExpectations(context); | 3648 Mock::VerifyAndClearExpectations(context); |
3662 | 3649 |
3663 DCHECK_EQ(2u, context->PeekTextureId()); | 3650 DCHECK_EQ(2u, context->PeekTextureId()); |
3664 resource_provider->DeleteResource(id); | 3651 resource_provider->DeleteResource(id); |
3665 } | 3652 } |
3666 | 3653 |
3667 { | 3654 { |
3668 size_t kTextureAllocationChunkSize = 8; | 3655 size_t kTextureAllocationChunkSize = 8; |
3669 scoped_ptr<ResourceProvider> resource_provider( | 3656 scoped_ptr<ResourceProvider> resource_provider( |
3670 ResourceProvider::Create(output_surface.get(), | 3657 ResourceProvider::Create(output_surface.get(), |
3671 shared_bitmap_manager.get(), | 3658 shared_bitmap_manager.get(), |
3672 NULL, | 3659 NULL, |
| 3660 NULL, |
3673 0, | 3661 0, |
3674 false, | 3662 false, |
3675 kTextureAllocationChunkSize, | 3663 kTextureAllocationChunkSize, |
3676 false)); | 3664 false)); |
3677 | 3665 |
3678 ResourceProvider::ResourceId id = resource_provider->CreateResource( | 3666 ResourceProvider::ResourceId id = resource_provider->CreateResource( |
3679 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); | 3667 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); |
3680 resource_provider->AllocateForTesting(id); | 3668 resource_provider->AllocateForTesting(id); |
3681 Mock::VerifyAndClearExpectations(context); | 3669 Mock::VerifyAndClearExpectations(context); |
3682 | 3670 |
3683 DCHECK_EQ(10u, context->PeekTextureId()); | 3671 DCHECK_EQ(10u, context->PeekTextureId()); |
3684 resource_provider->DeleteResource(id); | 3672 resource_provider->DeleteResource(id); |
3685 } | 3673 } |
3686 } | 3674 } |
3687 | 3675 |
3688 } // namespace | 3676 } // namespace |
3689 } // namespace cc | 3677 } // namespace cc |
OLD | NEW |