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

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

Issue 793693003: Tile Compression (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/resources/resource_provider.cc ('k') | cc/resources/resource_update_controller_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/resources/resource_provider.h" 5 #include "cc/resources/resource_provider.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 10
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 case ResourceProvider::InvalidType: 409 case ResourceProvider::InvalidType:
410 NOTREACHED(); 410 NOTREACHED();
411 break; 411 break;
412 } 412 }
413 CHECK(output_surface_->BindToClient(&output_surface_client_)); 413 CHECK(output_surface_->BindToClient(&output_surface_client_));
414 CHECK(child_output_surface_->BindToClient(&child_output_surface_client_)); 414 CHECK(child_output_surface_->BindToClient(&child_output_surface_client_));
415 415
416 shared_bitmap_manager_.reset(new TestSharedBitmapManager); 416 shared_bitmap_manager_.reset(new TestSharedBitmapManager);
417 gpu_memory_buffer_manager_.reset(new TestGpuMemoryBufferManager); 417 gpu_memory_buffer_manager_.reset(new TestGpuMemoryBufferManager);
418 418
419 resource_provider_ = 419 resource_provider_ = ResourceProvider::Create(
420 ResourceProvider::Create(output_surface_.get(), 420 output_surface_.get(), shared_bitmap_manager_.get(),
421 shared_bitmap_manager_.get(), 421 gpu_memory_buffer_manager_.get(), main_thread_task_runner_.get(), 0,
422 gpu_memory_buffer_manager_.get(), 422 false, false, 1);
423 main_thread_task_runner_.get(), 423 child_resource_provider_ = ResourceProvider::Create(
424 0, 424 child_output_surface_.get(), shared_bitmap_manager_.get(),
425 false, 425 gpu_memory_buffer_manager_.get(), main_thread_task_runner_.get(), 0,
426 1); 426 false, false, 1);
427 child_resource_provider_ =
428 ResourceProvider::Create(child_output_surface_.get(),
429 shared_bitmap_manager_.get(),
430 gpu_memory_buffer_manager_.get(),
431 main_thread_task_runner_.get(),
432 0,
433 false,
434 1);
435 } 427 }
436 428
437 static void CollectResources(ReturnedResourceArray* array, 429 static void CollectResources(ReturnedResourceArray* array,
438 const ReturnedResourceArray& returned, 430 const ReturnedResourceArray& returned,
439 BlockingTaskRunner* main_thread_task_runner) { 431 BlockingTaskRunner* main_thread_task_runner) {
440 array->insert(array->end(), returned.begin(), returned.end()); 432 array->insert(array->end(), returned.begin(), returned.end());
441 } 433 }
442 434
443 static ReturnCallback GetReturnCallback(ReturnedResourceArray* array) { 435 static ReturnCallback GetReturnCallback(ReturnedResourceArray* array) {
444 return base::Bind(&ResourceProviderTest::CollectResources, array); 436 return base::Bind(&ResourceProviderTest::CollectResources, array);
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
1152 return; 1144 return;
1153 1145
1154 scoped_ptr<ResourceProviderContext> child_context_owned( 1146 scoped_ptr<ResourceProviderContext> child_context_owned(
1155 ResourceProviderContext::Create(shared_data_.get())); 1147 ResourceProviderContext::Create(shared_data_.get()));
1156 1148
1157 FakeOutputSurfaceClient child_output_surface_client; 1149 FakeOutputSurfaceClient child_output_surface_client;
1158 scoped_ptr<OutputSurface> child_output_surface( 1150 scoped_ptr<OutputSurface> child_output_surface(
1159 FakeOutputSurface::Create3d(child_context_owned.Pass())); 1151 FakeOutputSurface::Create3d(child_context_owned.Pass()));
1160 CHECK(child_output_surface->BindToClient(&child_output_surface_client)); 1152 CHECK(child_output_surface->BindToClient(&child_output_surface_client));
1161 1153
1162 scoped_ptr<ResourceProvider> child_resource_provider( 1154 scoped_ptr<ResourceProvider> child_resource_provider(ResourceProvider::Create(
1163 ResourceProvider::Create(child_output_surface.get(), 1155 child_output_surface.get(), shared_bitmap_manager_.get(),
1164 shared_bitmap_manager_.get(), 1156 gpu_memory_buffer_manager_.get(), NULL, 0, false, false, 1));
1165 gpu_memory_buffer_manager_.get(),
1166 NULL,
1167 0,
1168 false,
1169 1));
1170 1157
1171 gfx::Size size(1, 1); 1158 gfx::Size size(1, 1);
1172 ResourceFormat format = RGBA_8888; 1159 ResourceFormat format = RGBA_8888;
1173 size_t pixel_size = TextureSizeBytes(size, format); 1160 size_t pixel_size = TextureSizeBytes(size, format);
1174 ASSERT_EQ(4U, pixel_size); 1161 ASSERT_EQ(4U, pixel_size);
1175 1162
1176 ResourceProvider::ResourceId id1 = child_resource_provider->CreateResource( 1163 ResourceProvider::ResourceId id1 = child_resource_provider->CreateResource(
1177 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); 1164 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
1178 uint8_t data1[4] = { 1, 2, 3, 4 }; 1165 uint8_t data1[4] = { 1, 2, 3, 4 };
1179 gfx::Rect rect(size); 1166 gfx::Rect rect(size);
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
1636 1623
1637 FakeOutputSurfaceClient child_output_surface_client; 1624 FakeOutputSurfaceClient child_output_surface_client;
1638 scoped_ptr<OutputSurface> child_output_surface( 1625 scoped_ptr<OutputSurface> child_output_surface(
1639 FakeOutputSurface::Create3d(child_context_owned.Pass())); 1626 FakeOutputSurface::Create3d(child_context_owned.Pass()));
1640 CHECK(child_output_surface->BindToClient(&child_output_surface_client)); 1627 CHECK(child_output_surface->BindToClient(&child_output_surface_client));
1641 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 1628 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
1642 new TestSharedBitmapManager()); 1629 new TestSharedBitmapManager());
1643 1630
1644 scoped_ptr<ResourceProvider> child_resource_provider( 1631 scoped_ptr<ResourceProvider> child_resource_provider(
1645 ResourceProvider::Create(child_output_surface.get(), 1632 ResourceProvider::Create(child_output_surface.get(),
1646 shared_bitmap_manager.get(), 1633 shared_bitmap_manager.get(), NULL, NULL, 0,
1647 NULL, 1634 false, false, 1));
1648 NULL,
1649 0,
1650 false,
1651 1));
1652 1635
1653 scoped_ptr<TextureStateTrackingContext> parent_context_owned( 1636 scoped_ptr<TextureStateTrackingContext> parent_context_owned(
1654 new TextureStateTrackingContext); 1637 new TextureStateTrackingContext);
1655 TextureStateTrackingContext* parent_context = parent_context_owned.get(); 1638 TextureStateTrackingContext* parent_context = parent_context_owned.get();
1656 1639
1657 FakeOutputSurfaceClient parent_output_surface_client; 1640 FakeOutputSurfaceClient parent_output_surface_client;
1658 scoped_ptr<OutputSurface> parent_output_surface( 1641 scoped_ptr<OutputSurface> parent_output_surface(
1659 FakeOutputSurface::Create3d(parent_context_owned.Pass())); 1642 FakeOutputSurface::Create3d(parent_context_owned.Pass()));
1660 CHECK(parent_output_surface->BindToClient(&parent_output_surface_client)); 1643 CHECK(parent_output_surface->BindToClient(&parent_output_surface_client));
1661 1644
1662 scoped_ptr<ResourceProvider> parent_resource_provider( 1645 scoped_ptr<ResourceProvider> parent_resource_provider(
1663 ResourceProvider::Create(parent_output_surface.get(), 1646 ResourceProvider::Create(parent_output_surface.get(),
1664 shared_bitmap_manager.get(), 1647 shared_bitmap_manager.get(), NULL, NULL, 0,
1665 NULL, 1648 false, false, 1));
1666 NULL,
1667 0,
1668 false,
1669 1));
1670 1649
1671 gfx::Size size(1, 1); 1650 gfx::Size size(1, 1);
1672 ResourceFormat format = RGBA_8888; 1651 ResourceFormat format = RGBA_8888;
1673 int child_texture_id = 1; 1652 int child_texture_id = 1;
1674 int parent_texture_id = 2; 1653 int parent_texture_id = 2;
1675 1654
1676 size_t pixel_size = TextureSizeBytes(size, format); 1655 size_t pixel_size = TextureSizeBytes(size, format);
1677 ASSERT_EQ(4U, pixel_size); 1656 ASSERT_EQ(4U, pixel_size);
1678 1657
1679 ResourceProvider::ResourceId id = child_resource_provider->CreateResource( 1658 ResourceProvider::ResourceId id = child_resource_provider->CreateResource(
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
2284 2263
2285 scoped_ptr<TextureStateTrackingContext> context_owned( 2264 scoped_ptr<TextureStateTrackingContext> context_owned(
2286 new TextureStateTrackingContext); 2265 new TextureStateTrackingContext);
2287 TextureStateTrackingContext* context = context_owned.get(); 2266 TextureStateTrackingContext* context = context_owned.get();
2288 2267
2289 FakeOutputSurfaceClient output_surface_client; 2268 FakeOutputSurfaceClient output_surface_client;
2290 scoped_ptr<OutputSurface> output_surface( 2269 scoped_ptr<OutputSurface> output_surface(
2291 FakeOutputSurface::Create3d(context_owned.Pass())); 2270 FakeOutputSurface::Create3d(context_owned.Pass()));
2292 CHECK(output_surface->BindToClient(&output_surface_client)); 2271 CHECK(output_surface->BindToClient(&output_surface_client));
2293 2272
2294 scoped_ptr<ResourceProvider> resource_provider( 2273 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
2295 ResourceProvider::Create(output_surface.get(), 2274 output_surface.get(), shared_bitmap_manager_.get(),
2296 shared_bitmap_manager_.get(), 2275 gpu_memory_buffer_manager_.get(), NULL, 0, false, false, 1));
2297 gpu_memory_buffer_manager_.get(),
2298 NULL,
2299 0,
2300 false,
2301 1));
2302 2276
2303 gfx::Size size(1, 1); 2277 gfx::Size size(1, 1);
2304 ResourceFormat format = RGBA_8888; 2278 ResourceFormat format = RGBA_8888;
2305 int texture_id = 1; 2279 int texture_id = 1;
2306 2280
2307 ResourceProvider::ResourceId id = resource_provider->CreateResource( 2281 ResourceProvider::ResourceId id = resource_provider->CreateResource(
2308 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); 2282 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
2309 2283
2310 // Check that the texture gets created with the right sampler settings. 2284 // Check that the texture gets created with the right sampler settings.
2311 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)) 2285 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id))
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
2371 2345
2372 scoped_ptr<TextureStateTrackingContext> context_owned( 2346 scoped_ptr<TextureStateTrackingContext> context_owned(
2373 new TextureStateTrackingContext); 2347 new TextureStateTrackingContext);
2374 TextureStateTrackingContext* context = context_owned.get(); 2348 TextureStateTrackingContext* context = context_owned.get();
2375 2349
2376 FakeOutputSurfaceClient output_surface_client; 2350 FakeOutputSurfaceClient output_surface_client;
2377 scoped_ptr<OutputSurface> output_surface( 2351 scoped_ptr<OutputSurface> output_surface(
2378 FakeOutputSurface::Create3d(context_owned.Pass())); 2352 FakeOutputSurface::Create3d(context_owned.Pass()));
2379 CHECK(output_surface->BindToClient(&output_surface_client)); 2353 CHECK(output_surface->BindToClient(&output_surface_client));
2380 2354
2381 scoped_ptr<ResourceProvider> resource_provider( 2355 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
2382 ResourceProvider::Create(output_surface.get(), 2356 output_surface.get(), shared_bitmap_manager_.get(),
2383 shared_bitmap_manager_.get(), 2357 gpu_memory_buffer_manager_.get(), NULL, 0, false, false, 1));
2384 gpu_memory_buffer_manager_.get(),
2385 NULL,
2386 0,
2387 false,
2388 1));
2389 2358
2390 gfx::Size size(1, 1); 2359 gfx::Size size(1, 1);
2391 ResourceFormat format = RGBA_8888; 2360 ResourceFormat format = RGBA_8888;
2392 int texture_id = 1; 2361 int texture_id = 1;
2393 2362
2394 // Check that the texture gets created with the right sampler settings. 2363 // Check that the texture gets created with the right sampler settings.
2395 ResourceProvider::ResourceId id = resource_provider->CreateManagedResource( 2364 ResourceProvider::ResourceId id = resource_provider->CreateManagedResource(
2396 size, 2365 size,
2397 GL_TEXTURE_2D, 2366 GL_TEXTURE_2D,
2398 GL_CLAMP_TO_EDGE, 2367 GL_CLAMP_TO_EDGE,
(...skipping 27 matching lines...) Expand all
2426 2395
2427 scoped_ptr<TextureStateTrackingContext> context_owned( 2396 scoped_ptr<TextureStateTrackingContext> context_owned(
2428 new TextureStateTrackingContext); 2397 new TextureStateTrackingContext);
2429 TextureStateTrackingContext* context = context_owned.get(); 2398 TextureStateTrackingContext* context = context_owned.get();
2430 2399
2431 FakeOutputSurfaceClient output_surface_client; 2400 FakeOutputSurfaceClient output_surface_client;
2432 scoped_ptr<OutputSurface> output_surface( 2401 scoped_ptr<OutputSurface> output_surface(
2433 FakeOutputSurface::Create3d(context_owned.Pass())); 2402 FakeOutputSurface::Create3d(context_owned.Pass()));
2434 CHECK(output_surface->BindToClient(&output_surface_client)); 2403 CHECK(output_surface->BindToClient(&output_surface_client));
2435 2404
2436 scoped_ptr<ResourceProvider> resource_provider( 2405 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
2437 ResourceProvider::Create(output_surface.get(), 2406 output_surface.get(), shared_bitmap_manager_.get(),
2438 shared_bitmap_manager_.get(), 2407 gpu_memory_buffer_manager_.get(), NULL, 0, false, false, 1));
2439 gpu_memory_buffer_manager_.get(),
2440 NULL,
2441 0,
2442 false,
2443 1));
2444 2408
2445 gfx::Size size(1, 1); 2409 gfx::Size size(1, 1);
2446 ResourceFormat format = RGBA_8888; 2410 ResourceFormat format = RGBA_8888;
2447 GLenum texture_pool = GL_TEXTURE_POOL_UNMANAGED_CHROMIUM; 2411 GLenum texture_pool = GL_TEXTURE_POOL_UNMANAGED_CHROMIUM;
2448 2412
2449 for (int texture_id = 1; texture_id <= 2; ++texture_id) { 2413 for (int texture_id = 1; texture_id <= 2; ++texture_id) {
2450 GLint wrap_mode = texture_id == 1 ? GL_CLAMP_TO_EDGE : GL_REPEAT; 2414 GLint wrap_mode = texture_id == 1 ? GL_CLAMP_TO_EDGE : GL_REPEAT;
2451 // Check that the texture gets created with the right sampler settings. 2415 // Check that the texture gets created with the right sampler settings.
2452 ResourceProvider::ResourceId id = resource_provider->CreateGLTexture( 2416 ResourceProvider::ResourceId id = resource_provider->CreateGLTexture(
2453 size, 2417 size,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2485 new TextureStateTrackingContext); 2449 new TextureStateTrackingContext);
2486 TextureStateTrackingContext* context = context_owned.get(); 2450 TextureStateTrackingContext* context = context_owned.get();
2487 context->set_support_texture_storage(true); 2451 context->set_support_texture_storage(true);
2488 context->set_support_texture_usage(true); 2452 context->set_support_texture_usage(true);
2489 2453
2490 FakeOutputSurfaceClient output_surface_client; 2454 FakeOutputSurfaceClient output_surface_client;
2491 scoped_ptr<OutputSurface> output_surface( 2455 scoped_ptr<OutputSurface> output_surface(
2492 FakeOutputSurface::Create3d(context_owned.Pass())); 2456 FakeOutputSurface::Create3d(context_owned.Pass()));
2493 CHECK(output_surface->BindToClient(&output_surface_client)); 2457 CHECK(output_surface->BindToClient(&output_surface_client));
2494 2458
2495 scoped_ptr<ResourceProvider> resource_provider( 2459 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
2496 ResourceProvider::Create(output_surface.get(), 2460 output_surface.get(), shared_bitmap_manager_.get(),
2497 shared_bitmap_manager_.get(), 2461 gpu_memory_buffer_manager_.get(), NULL, 0, false, false, 1));
2498 gpu_memory_buffer_manager_.get(),
2499 NULL,
2500 0,
2501 false,
2502 1));
2503 2462
2504 gfx::Size size(1, 1); 2463 gfx::Size size(1, 1);
2505 ResourceFormat format = RGBA_8888; 2464 ResourceFormat format = RGBA_8888;
2506 GLenum texture_pool = GL_TEXTURE_POOL_UNMANAGED_CHROMIUM; 2465 GLenum texture_pool = GL_TEXTURE_POOL_UNMANAGED_CHROMIUM;
2507 2466
2508 const ResourceProvider::TextureHint hints[4] = { 2467 const ResourceProvider::TextureHint hints[4] = {
2509 ResourceProvider::TextureHintDefault, 2468 ResourceProvider::TextureHintDefault,
2510 ResourceProvider::TextureHintImmutable, 2469 ResourceProvider::TextureHintImmutable,
2511 ResourceProvider::TextureHintFramebuffer, 2470 ResourceProvider::TextureHintFramebuffer,
2512 ResourceProvider::TextureHintImmutableFramebuffer, 2471 ResourceProvider::TextureHintImmutableFramebuffer,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2558 const uint32_t kBadBeef = 0xbadbeef; 2517 const uint32_t kBadBeef = 0xbadbeef;
2559 scoped_ptr<base::SharedMemory> shared_memory( 2518 scoped_ptr<base::SharedMemory> shared_memory(
2560 CreateAndFillSharedMemory(size, kBadBeef)); 2519 CreateAndFillSharedMemory(size, kBadBeef));
2561 2520
2562 FakeOutputSurfaceClient output_surface_client; 2521 FakeOutputSurfaceClient output_surface_client;
2563 scoped_ptr<OutputSurface> output_surface( 2522 scoped_ptr<OutputSurface> output_surface(
2564 FakeOutputSurface::CreateSoftware(make_scoped_ptr( 2523 FakeOutputSurface::CreateSoftware(make_scoped_ptr(
2565 new SoftwareOutputDevice))); 2524 new SoftwareOutputDevice)));
2566 CHECK(output_surface->BindToClient(&output_surface_client)); 2525 CHECK(output_surface->BindToClient(&output_surface_client));
2567 2526
2568 scoped_ptr<ResourceProvider> resource_provider( 2527 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
2569 ResourceProvider::Create(output_surface.get(), 2528 output_surface.get(), shared_bitmap_manager_.get(),
2570 shared_bitmap_manager_.get(), 2529 gpu_memory_buffer_manager_.get(), main_thread_task_runner_.get(), 0,
2571 gpu_memory_buffer_manager_.get(), 2530 false, false, 1));
2572 main_thread_task_runner_.get(),
2573 0,
2574 false,
2575 1));
2576 2531
2577 uint32 release_sync_point = 0; 2532 uint32 release_sync_point = 0;
2578 bool lost_resource = false; 2533 bool lost_resource = false;
2579 BlockingTaskRunner* main_thread_task_runner = NULL; 2534 BlockingTaskRunner* main_thread_task_runner = NULL;
2580 scoped_ptr<SingleReleaseCallbackImpl> callback = 2535 scoped_ptr<SingleReleaseCallbackImpl> callback =
2581 SingleReleaseCallbackImpl::Create(base::Bind(&ReleaseCallback, 2536 SingleReleaseCallbackImpl::Create(base::Bind(&ReleaseCallback,
2582 &release_sync_point, 2537 &release_sync_point,
2583 &lost_resource, 2538 &lost_resource,
2584 &main_thread_task_runner)); 2539 &main_thread_task_runner));
2585 TextureMailbox mailbox(shared_memory.get(), size); 2540 TextureMailbox mailbox(shared_memory.get(), size);
(...skipping 27 matching lines...) Expand all
2613 GLenum sampler_filter) { 2568 GLenum sampler_filter) {
2614 scoped_ptr<TextureStateTrackingContext> context_owned( 2569 scoped_ptr<TextureStateTrackingContext> context_owned(
2615 new TextureStateTrackingContext); 2570 new TextureStateTrackingContext);
2616 TextureStateTrackingContext* context = context_owned.get(); 2571 TextureStateTrackingContext* context = context_owned.get();
2617 2572
2618 FakeOutputSurfaceClient output_surface_client; 2573 FakeOutputSurfaceClient output_surface_client;
2619 scoped_ptr<OutputSurface> output_surface( 2574 scoped_ptr<OutputSurface> output_surface(
2620 FakeOutputSurface::Create3d(context_owned.Pass())); 2575 FakeOutputSurface::Create3d(context_owned.Pass()));
2621 CHECK(output_surface->BindToClient(&output_surface_client)); 2576 CHECK(output_surface->BindToClient(&output_surface_client));
2622 2577
2623 scoped_ptr<ResourceProvider> resource_provider( 2578 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
2624 ResourceProvider::Create(output_surface.get(), 2579 output_surface.get(), shared_bitmap_manager, gpu_memory_buffer_manager,
2625 shared_bitmap_manager, 2580 main_thread_task_runner, 0, false, false, 1));
2626 gpu_memory_buffer_manager,
2627 main_thread_task_runner,
2628 0,
2629 false,
2630 1));
2631 2581
2632 unsigned texture_id = 1; 2582 unsigned texture_id = 1;
2633 uint32 sync_point = 30; 2583 uint32 sync_point = 30;
2634 unsigned target = GL_TEXTURE_2D; 2584 unsigned target = GL_TEXTURE_2D;
2635 2585
2636 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); 2586 EXPECT_CALL(*context, bindTexture(_, _)).Times(0);
2637 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); 2587 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0);
2638 EXPECT_CALL(*context, insertSyncPoint()).Times(0); 2588 EXPECT_CALL(*context, insertSyncPoint()).Times(0);
2639 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); 2589 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0);
2640 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0); 2590 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0);
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
2762 2712
2763 scoped_ptr<TextureStateTrackingContext> context_owned( 2713 scoped_ptr<TextureStateTrackingContext> context_owned(
2764 new TextureStateTrackingContext); 2714 new TextureStateTrackingContext);
2765 TextureStateTrackingContext* context = context_owned.get(); 2715 TextureStateTrackingContext* context = context_owned.get();
2766 2716
2767 FakeOutputSurfaceClient output_surface_client; 2717 FakeOutputSurfaceClient output_surface_client;
2768 scoped_ptr<OutputSurface> output_surface( 2718 scoped_ptr<OutputSurface> output_surface(
2769 FakeOutputSurface::Create3d(context_owned.Pass())); 2719 FakeOutputSurface::Create3d(context_owned.Pass()));
2770 CHECK(output_surface->BindToClient(&output_surface_client)); 2720 CHECK(output_surface->BindToClient(&output_surface_client));
2771 2721
2772 scoped_ptr<ResourceProvider> resource_provider( 2722 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
2773 ResourceProvider::Create(output_surface.get(), 2723 output_surface.get(), shared_bitmap_manager_.get(),
2774 shared_bitmap_manager_.get(), 2724 gpu_memory_buffer_manager_.get(), NULL, 0, false, false, 1));
2775 gpu_memory_buffer_manager_.get(),
2776 NULL,
2777 0,
2778 false,
2779 1));
2780 2725
2781 unsigned texture_id = 1; 2726 unsigned texture_id = 1;
2782 uint32 sync_point = 30; 2727 uint32 sync_point = 30;
2783 unsigned target = GL_TEXTURE_EXTERNAL_OES; 2728 unsigned target = GL_TEXTURE_EXTERNAL_OES;
2784 2729
2785 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); 2730 EXPECT_CALL(*context, bindTexture(_, _)).Times(0);
2786 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); 2731 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0);
2787 EXPECT_CALL(*context, insertSyncPoint()).Times(0); 2732 EXPECT_CALL(*context, insertSyncPoint()).Times(0);
2788 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); 2733 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0);
2789 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0); 2734 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
2837 2782
2838 scoped_ptr<TextureStateTrackingContext> context_owned( 2783 scoped_ptr<TextureStateTrackingContext> context_owned(
2839 new TextureStateTrackingContext); 2784 new TextureStateTrackingContext);
2840 TextureStateTrackingContext* context = context_owned.get(); 2785 TextureStateTrackingContext* context = context_owned.get();
2841 2786
2842 FakeOutputSurfaceClient output_surface_client; 2787 FakeOutputSurfaceClient output_surface_client;
2843 scoped_ptr<OutputSurface> output_surface( 2788 scoped_ptr<OutputSurface> output_surface(
2844 FakeOutputSurface::Create3d(context_owned.Pass())); 2789 FakeOutputSurface::Create3d(context_owned.Pass()));
2845 CHECK(output_surface->BindToClient(&output_surface_client)); 2790 CHECK(output_surface->BindToClient(&output_surface_client));
2846 2791
2847 scoped_ptr<ResourceProvider> resource_provider( 2792 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
2848 ResourceProvider::Create(output_surface.get(), 2793 output_surface.get(), shared_bitmap_manager_.get(),
2849 shared_bitmap_manager_.get(), 2794 gpu_memory_buffer_manager_.get(), NULL, 0, false, false, 1));
2850 gpu_memory_buffer_manager_.get(),
2851 NULL,
2852 0,
2853 false,
2854 1));
2855 2795
2856 uint32 sync_point = 30; 2796 uint32 sync_point = 30;
2857 unsigned target = GL_TEXTURE_2D; 2797 unsigned target = GL_TEXTURE_2D;
2858 2798
2859 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); 2799 EXPECT_CALL(*context, bindTexture(_, _)).Times(0);
2860 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); 2800 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0);
2861 EXPECT_CALL(*context, insertSyncPoint()).Times(0); 2801 EXPECT_CALL(*context, insertSyncPoint()).Times(0);
2862 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); 2802 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0);
2863 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0); 2803 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0);
2864 2804
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2896 2836
2897 scoped_ptr<TextureStateTrackingContext> context_owned( 2837 scoped_ptr<TextureStateTrackingContext> context_owned(
2898 new TextureStateTrackingContext); 2838 new TextureStateTrackingContext);
2899 TextureStateTrackingContext* context = context_owned.get(); 2839 TextureStateTrackingContext* context = context_owned.get();
2900 2840
2901 FakeOutputSurfaceClient output_surface_client; 2841 FakeOutputSurfaceClient output_surface_client;
2902 scoped_ptr<OutputSurface> output_surface( 2842 scoped_ptr<OutputSurface> output_surface(
2903 FakeOutputSurface::Create3d(context_owned.Pass())); 2843 FakeOutputSurface::Create3d(context_owned.Pass()));
2904 CHECK(output_surface->BindToClient(&output_surface_client)); 2844 CHECK(output_surface->BindToClient(&output_surface_client));
2905 2845
2906 scoped_ptr<ResourceProvider> resource_provider( 2846 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
2907 ResourceProvider::Create(output_surface.get(), 2847 output_surface.get(), shared_bitmap_manager_.get(),
2908 shared_bitmap_manager_.get(), 2848 gpu_memory_buffer_manager_.get(), NULL, 0, false, false, 1));
2909 gpu_memory_buffer_manager_.get(),
2910 NULL,
2911 0,
2912 false,
2913 1));
2914 2849
2915 uint32 sync_point = 0; 2850 uint32 sync_point = 0;
2916 unsigned target = GL_TEXTURE_2D; 2851 unsigned target = GL_TEXTURE_2D;
2917 2852
2918 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); 2853 EXPECT_CALL(*context, bindTexture(_, _)).Times(0);
2919 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); 2854 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0);
2920 EXPECT_CALL(*context, insertSyncPoint()).Times(0); 2855 EXPECT_CALL(*context, insertSyncPoint()).Times(0);
2921 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); 2856 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0);
2922 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0); 2857 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0);
2923 2858
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
2987 MOCK_METHOD9(asyncTexSubImage2DCHROMIUM, 2922 MOCK_METHOD9(asyncTexSubImage2DCHROMIUM,
2988 void(GLenum target, 2923 void(GLenum target,
2989 GLint level, 2924 GLint level,
2990 GLint xoffset, 2925 GLint xoffset,
2991 GLint yoffset, 2926 GLint yoffset,
2992 GLsizei width, 2927 GLsizei width,
2993 GLsizei height, 2928 GLsizei height,
2994 GLenum format, 2929 GLenum format,
2995 GLenum type, 2930 GLenum type,
2996 const void* pixels)); 2931 const void* pixels));
2932 MOCK_METHOD8(asyncCompressedTexImage2DCHROMIUM,
2933 void(GLenum target,
2934 GLint level,
2935 GLint internalformat,
2936 GLsizei width,
2937 GLsizei height,
2938 GLint border,
2939 GLsizei imagesize,
2940 const void* pixels));
2941 MOCK_METHOD9(asyncCompressedTexSubImage2DCHROMIUM,
2942 void(GLenum target,
2943 GLint level,
2944 GLint xoffset,
2945 GLint yoffset,
2946 GLsizei width,
2947 GLsizei height,
2948 GLenum format,
2949 GLsizei imagesize,
2950 const void* pixels));
2997 MOCK_METHOD8(compressedTexImage2D, 2951 MOCK_METHOD8(compressedTexImage2D,
2998 void(GLenum target, 2952 void(GLenum target,
2999 GLint level, 2953 GLint level,
3000 GLenum internalformat, 2954 GLenum internalformat,
3001 GLsizei width, 2955 GLsizei width,
3002 GLsizei height, 2956 GLsizei height,
3003 GLint border, 2957 GLint border,
3004 GLsizei image_size, 2958 GLsizei image_size,
3005 const void* data)); 2959 const void* data));
3006 MOCK_METHOD1(waitAsyncTexImage2DCHROMIUM, void(GLenum)); 2960 MOCK_METHOD1(waitAsyncTexImage2DCHROMIUM, void(GLenum));
(...skipping 15 matching lines...) Expand all
3022 return; 2976 return;
3023 scoped_ptr<AllocationTrackingContext3D> context_owned( 2977 scoped_ptr<AllocationTrackingContext3D> context_owned(
3024 new StrictMock<AllocationTrackingContext3D>); 2978 new StrictMock<AllocationTrackingContext3D>);
3025 AllocationTrackingContext3D* context = context_owned.get(); 2979 AllocationTrackingContext3D* context = context_owned.get();
3026 2980
3027 FakeOutputSurfaceClient output_surface_client; 2981 FakeOutputSurfaceClient output_surface_client;
3028 scoped_ptr<OutputSurface> output_surface( 2982 scoped_ptr<OutputSurface> output_surface(
3029 FakeOutputSurface::Create3d(context_owned.Pass())); 2983 FakeOutputSurface::Create3d(context_owned.Pass()));
3030 CHECK(output_surface->BindToClient(&output_surface_client)); 2984 CHECK(output_surface->BindToClient(&output_surface_client));
3031 2985
3032 scoped_ptr<ResourceProvider> resource_provider( 2986 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3033 ResourceProvider::Create(output_surface.get(), 2987 output_surface.get(), shared_bitmap_manager_.get(),
3034 shared_bitmap_manager_.get(), 2988 gpu_memory_buffer_manager_.get(), NULL, 0, false, false, 1));
3035 gpu_memory_buffer_manager_.get(),
3036 NULL,
3037 0,
3038 false,
3039 1));
3040 2989
3041 gfx::Size size(2, 2); 2990 gfx::Size size(2, 2);
3042 gfx::Vector2d offset(0, 0); 2991 gfx::Vector2d offset(0, 0);
3043 gfx::Rect rect(0, 0, 2, 2); 2992 gfx::Rect rect(0, 0, 2, 2);
3044 ResourceFormat format = RGBA_8888; 2993 ResourceFormat format = RGBA_8888;
3045 ResourceProvider::ResourceId id = 0; 2994 ResourceProvider::ResourceId id = 0;
3046 uint8_t pixels[16] = { 0 }; 2995 uint8_t pixels[16] = { 0 };
3047 int texture_id = 123; 2996 int texture_id = 123;
3048 2997
3049 // Lazy allocation. Don't allocate when creating the resource. 2998 // Lazy allocation. Don't allocate when creating the resource.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
3102 new StrictMock<AllocationTrackingContext3D>); 3051 new StrictMock<AllocationTrackingContext3D>);
3103 AllocationTrackingContext3D* context = context_owned.get(); 3052 AllocationTrackingContext3D* context = context_owned.get();
3104 context->set_support_texture_storage(true); 3053 context->set_support_texture_storage(true);
3105 context->set_support_texture_usage(true); 3054 context->set_support_texture_usage(true);
3106 3055
3107 FakeOutputSurfaceClient output_surface_client; 3056 FakeOutputSurfaceClient output_surface_client;
3108 scoped_ptr<OutputSurface> output_surface( 3057 scoped_ptr<OutputSurface> output_surface(
3109 FakeOutputSurface::Create3d(context_owned.Pass())); 3058 FakeOutputSurface::Create3d(context_owned.Pass()));
3110 CHECK(output_surface->BindToClient(&output_surface_client)); 3059 CHECK(output_surface->BindToClient(&output_surface_client));
3111 3060
3112 scoped_ptr<ResourceProvider> resource_provider( 3061 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3113 ResourceProvider::Create(output_surface.get(), 3062 output_surface.get(), shared_bitmap_manager_.get(),
3114 shared_bitmap_manager_.get(), 3063 gpu_memory_buffer_manager_.get(), NULL, 0, false, false, 1));
3115 gpu_memory_buffer_manager_.get(),
3116 NULL,
3117 0,
3118 false,
3119 1));
3120 3064
3121 gfx::Size size(2, 2); 3065 gfx::Size size(2, 2);
3122 3066
3123 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888}; 3067 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888};
3124 const ResourceProvider::TextureHint hints[4] = { 3068 const ResourceProvider::TextureHint hints[4] = {
3125 ResourceProvider::TextureHintDefault, 3069 ResourceProvider::TextureHintDefault,
3126 ResourceProvider::TextureHintImmutable, 3070 ResourceProvider::TextureHintImmutable,
3127 ResourceProvider::TextureHintFramebuffer, 3071 ResourceProvider::TextureHintFramebuffer,
3128 ResourceProvider::TextureHintImmutableFramebuffer, 3072 ResourceProvider::TextureHintImmutableFramebuffer,
3129 }; 3073 };
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
3162 AllocationTrackingContext3D* context = context_owned.get(); 3106 AllocationTrackingContext3D* context = context_owned.get();
3163 context->set_support_texture_format_bgra8888(true); 3107 context->set_support_texture_format_bgra8888(true);
3164 context->set_support_texture_storage(true); 3108 context->set_support_texture_storage(true);
3165 context->set_support_texture_usage(true); 3109 context->set_support_texture_usage(true);
3166 3110
3167 FakeOutputSurfaceClient output_surface_client; 3111 FakeOutputSurfaceClient output_surface_client;
3168 scoped_ptr<OutputSurface> output_surface( 3112 scoped_ptr<OutputSurface> output_surface(
3169 FakeOutputSurface::Create3d(context_owned.Pass())); 3113 FakeOutputSurface::Create3d(context_owned.Pass()));
3170 CHECK(output_surface->BindToClient(&output_surface_client)); 3114 CHECK(output_surface->BindToClient(&output_surface_client));
3171 3115
3172 scoped_ptr<ResourceProvider> resource_provider( 3116 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3173 ResourceProvider::Create(output_surface.get(), 3117 output_surface.get(), shared_bitmap_manager_.get(),
3174 shared_bitmap_manager_.get(), 3118 gpu_memory_buffer_manager_.get(), NULL, 0, false, false, 1));
3175 gpu_memory_buffer_manager_.get(),
3176 NULL,
3177 0,
3178 false,
3179 1));
3180 3119
3181 gfx::Size size(2, 2); 3120 gfx::Size size(2, 2);
3182 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888}; 3121 const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888};
3183 3122
3184 const ResourceProvider::TextureHint hints[4] = { 3123 const ResourceProvider::TextureHint hints[4] = {
3185 ResourceProvider::TextureHintDefault, 3124 ResourceProvider::TextureHintDefault,
3186 ResourceProvider::TextureHintImmutable, 3125 ResourceProvider::TextureHintImmutable,
3187 ResourceProvider::TextureHintFramebuffer, 3126 ResourceProvider::TextureHintFramebuffer,
3188 ResourceProvider::TextureHintImmutableFramebuffer, 3127 ResourceProvider::TextureHintImmutableFramebuffer,
3189 }; 3128 };
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
3221 FakeOutputSurfaceClient output_surface_client; 3160 FakeOutputSurfaceClient output_surface_client;
3222 scoped_ptr<OutputSurface> output_surface( 3161 scoped_ptr<OutputSurface> output_surface(
3223 FakeOutputSurface::Create3d(context_owned.Pass())); 3162 FakeOutputSurface::Create3d(context_owned.Pass()));
3224 CHECK(output_surface->BindToClient(&output_surface_client)); 3163 CHECK(output_surface->BindToClient(&output_surface_client));
3225 3164
3226 gfx::Size size(2, 2); 3165 gfx::Size size(2, 2);
3227 ResourceFormat format = RGBA_8888; 3166 ResourceFormat format = RGBA_8888;
3228 ResourceProvider::ResourceId id = 0; 3167 ResourceProvider::ResourceId id = 0;
3229 int texture_id = 123; 3168 int texture_id = 123;
3230 3169
3231 scoped_ptr<ResourceProvider> resource_provider( 3170 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3232 ResourceProvider::Create(output_surface.get(), 3171 output_surface.get(), shared_bitmap_manager_.get(),
3233 shared_bitmap_manager_.get(), 3172 gpu_memory_buffer_manager_.get(), NULL, 0, false, false, 1));
3234 gpu_memory_buffer_manager_.get(),
3235 NULL,
3236 0,
3237 false,
3238 1));
3239 3173
3240 id = resource_provider->CreateResource( 3174 id = resource_provider->CreateResource(
3241 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); 3175 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
3242 resource_provider->AcquirePixelBuffer(id); 3176 resource_provider->AcquirePixelBuffer(id);
3243 3177
3244 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); 3178 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id));
3245 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); 3179 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2);
3246 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _)) 3180 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _))
3247 .Times(1); 3181 .Times(1);
3248 resource_provider->BeginSetPixels(id); 3182 resource_provider->BeginSetPixels(id);
(...skipping 19 matching lines...) Expand all
3268 FakeOutputSurfaceClient output_surface_client; 3202 FakeOutputSurfaceClient output_surface_client;
3269 scoped_ptr<OutputSurface> output_surface( 3203 scoped_ptr<OutputSurface> output_surface(
3270 FakeOutputSurface::Create3d(context_owned.Pass())); 3204 FakeOutputSurface::Create3d(context_owned.Pass()));
3271 CHECK(output_surface->BindToClient(&output_surface_client)); 3205 CHECK(output_surface->BindToClient(&output_surface_client));
3272 3206
3273 gfx::Size size(2, 2); 3207 gfx::Size size(2, 2);
3274 ResourceFormat format = RGBA_8888; 3208 ResourceFormat format = RGBA_8888;
3275 ResourceProvider::ResourceId id = 0; 3209 ResourceProvider::ResourceId id = 0;
3276 int texture_id = 123; 3210 int texture_id = 123;
3277 3211
3278 scoped_ptr<ResourceProvider> resource_provider( 3212 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3279 ResourceProvider::Create(output_surface.get(), 3213 output_surface.get(), shared_bitmap_manager_.get(),
3280 shared_bitmap_manager_.get(), 3214 gpu_memory_buffer_manager_.get(), NULL, 0, false, false, 1));
3281 gpu_memory_buffer_manager_.get(),
3282 NULL,
3283 0,
3284 false,
3285 1));
3286 3215
3287 id = resource_provider->CreateResource( 3216 id = resource_provider->CreateResource(
3288 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); 3217 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
3289 resource_provider->AcquirePixelBuffer(id); 3218 resource_provider->AcquirePixelBuffer(id);
3290 3219
3291 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); 3220 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id));
3292 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); 3221 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2);
3293 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _)) 3222 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _))
3294 .Times(1); 3223 .Times(1);
3295 resource_provider->BeginSetPixels(id); 3224 resource_provider->BeginSetPixels(id);
(...skipping 19 matching lines...) Expand all
3315 FakeOutputSurfaceClient output_surface_client; 3244 FakeOutputSurfaceClient output_surface_client;
3316 scoped_ptr<OutputSurface> output_surface( 3245 scoped_ptr<OutputSurface> output_surface(
3317 FakeOutputSurface::Create3d(context_owned.Pass())); 3246 FakeOutputSurface::Create3d(context_owned.Pass()));
3318 CHECK(output_surface->BindToClient(&output_surface_client)); 3247 CHECK(output_surface->BindToClient(&output_surface_client));
3319 3248
3320 gfx::Size size(2, 2); 3249 gfx::Size size(2, 2);
3321 ResourceFormat format = RGBA_8888; 3250 ResourceFormat format = RGBA_8888;
3322 ResourceProvider::ResourceId id = 0; 3251 ResourceProvider::ResourceId id = 0;
3323 int texture_id = 123; 3252 int texture_id = 123;
3324 3253
3325 scoped_ptr<ResourceProvider> resource_provider( 3254 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3326 ResourceProvider::Create(output_surface.get(), 3255 output_surface.get(), shared_bitmap_manager_.get(),
3327 shared_bitmap_manager_.get(), 3256 gpu_memory_buffer_manager_.get(), NULL, 0, false, false, 1));
3328 gpu_memory_buffer_manager_.get(),
3329 NULL,
3330 0,
3331 false,
3332 1));
3333 3257
3334 EXPECT_CALL(*context, NextTextureId()).WillRepeatedly(Return(texture_id)); 3258 EXPECT_CALL(*context, NextTextureId()).WillRepeatedly(Return(texture_id));
3335 3259
3336 id = resource_provider->CreateResource( 3260 id = resource_provider->CreateResource(
3337 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); 3261 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
3338 context->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, 3262 context->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB,
3339 GL_INNOCENT_CONTEXT_RESET_ARB); 3263 GL_INNOCENT_CONTEXT_RESET_ARB);
3340 3264
3341 resource_provider->AcquirePixelBuffer(id); 3265 resource_provider->AcquirePixelBuffer(id);
3342 int stride; 3266 int stride;
(...skipping 17 matching lines...) Expand all
3360 CHECK(output_surface->BindToClient(&output_surface_client)); 3284 CHECK(output_surface->BindToClient(&output_surface_client));
3361 3285
3362 const int kWidth = 2; 3286 const int kWidth = 2;
3363 const int kHeight = 2; 3287 const int kHeight = 2;
3364 gfx::Size size(kWidth, kHeight); 3288 gfx::Size size(kWidth, kHeight);
3365 ResourceFormat format = RGBA_8888; 3289 ResourceFormat format = RGBA_8888;
3366 ResourceProvider::ResourceId id = 0; 3290 ResourceProvider::ResourceId id = 0;
3367 const unsigned kTextureId = 123u; 3291 const unsigned kTextureId = 123u;
3368 const unsigned kImageId = 234u; 3292 const unsigned kImageId = 234u;
3369 3293
3370 scoped_ptr<ResourceProvider> resource_provider( 3294 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3371 ResourceProvider::Create(output_surface.get(), 3295 output_surface.get(), shared_bitmap_manager_.get(),
3372 shared_bitmap_manager_.get(), 3296 gpu_memory_buffer_manager_.get(), NULL, 0, false, false, 1));
3373 gpu_memory_buffer_manager_.get(),
3374 NULL,
3375 0,
3376 false,
3377 1));
3378 3297
3379 id = resource_provider->CreateResource( 3298 id = resource_provider->CreateResource(
3380 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); 3299 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
3381 3300
3382 EXPECT_CALL(*context, createImageCHROMIUM(_, kWidth, kHeight, GL_RGBA)) 3301 EXPECT_CALL(*context, createImageCHROMIUM(_, kWidth, kHeight, GL_RGBA))
3383 .WillOnce(Return(kImageId)) 3302 .WillOnce(Return(kImageId))
3384 .RetiresOnSaturation(); 3303 .RetiresOnSaturation();
3385 { 3304 {
3386 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock( 3305 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock(
3387 resource_provider.get(), id); 3306 resource_provider.get(), id);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
3447 const int kWidth = 2; 3366 const int kWidth = 2;
3448 const int kHeight = 2; 3367 const int kHeight = 2;
3449 gfx::Size size(kWidth, kHeight); 3368 gfx::Size size(kWidth, kHeight);
3450 ResourceFormat format = RGBA_8888; 3369 ResourceFormat format = RGBA_8888;
3451 ResourceProvider::ResourceId source_id = 0; 3370 ResourceProvider::ResourceId source_id = 0;
3452 ResourceProvider::ResourceId dest_id = 0; 3371 ResourceProvider::ResourceId dest_id = 0;
3453 const unsigned kSourceTextureId = 123u; 3372 const unsigned kSourceTextureId = 123u;
3454 const unsigned kDestTextureId = 321u; 3373 const unsigned kDestTextureId = 321u;
3455 const unsigned kImageId = 234u; 3374 const unsigned kImageId = 234u;
3456 3375
3457 scoped_ptr<ResourceProvider> resource_provider( 3376 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3458 ResourceProvider::Create(output_surface.get(), 3377 output_surface.get(), shared_bitmap_manager_.get(),
3459 shared_bitmap_manager_.get(), 3378 gpu_memory_buffer_manager_.get(), NULL, 0, false, false, 1));
3460 gpu_memory_buffer_manager_.get(),
3461 NULL,
3462 0,
3463 false,
3464 1));
3465 3379
3466 source_id = resource_provider->CreateResource( 3380 source_id = resource_provider->CreateResource(
3467 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); 3381 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
3468 3382
3469 EXPECT_CALL(*context, createImageCHROMIUM(_, kWidth, kHeight, GL_RGBA)) 3383 EXPECT_CALL(*context, createImageCHROMIUM(_, kWidth, kHeight, GL_RGBA))
3470 .WillOnce(Return(kImageId)) 3384 .WillOnce(Return(kImageId))
3471 .RetiresOnSaturation(); 3385 .RetiresOnSaturation();
3472 { 3386 {
3473 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock( 3387 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock(
3474 resource_provider.get(), source_id); 3388 resource_provider.get(), source_id);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
3533 scoped_ptr<ContextSharedData> shared_data = ContextSharedData::Create(); 3447 scoped_ptr<ContextSharedData> shared_data = ContextSharedData::Create();
3534 bool delegated_rendering = false; 3448 bool delegated_rendering = false;
3535 scoped_ptr<FakeOutputSurface> output_surface( 3449 scoped_ptr<FakeOutputSurface> output_surface(
3536 FakeOutputSurface::CreateDeferredGL( 3450 FakeOutputSurface::CreateDeferredGL(
3537 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice), 3451 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice),
3538 delegated_rendering)); 3452 delegated_rendering));
3539 FakeOutputSurfaceClient client(output_surface.get()); 3453 FakeOutputSurfaceClient client(output_surface.get());
3540 EXPECT_TRUE(output_surface->BindToClient(&client)); 3454 EXPECT_TRUE(output_surface->BindToClient(&client));
3541 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 3455 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
3542 new TestSharedBitmapManager()); 3456 new TestSharedBitmapManager());
3543 scoped_ptr<ResourceProvider> resource_provider( 3457 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3544 ResourceProvider::Create(output_surface.get(), 3458 output_surface.get(), shared_bitmap_manager.get(), NULL, NULL, 0, false,
3545 shared_bitmap_manager.get(), 3459 false, 1));
3546 NULL,
3547 NULL,
3548 0,
3549 false,
3550 1));
3551 3460
3552 CheckCreateResource(ResourceProvider::Bitmap, resource_provider.get(), NULL); 3461 CheckCreateResource(ResourceProvider::Bitmap, resource_provider.get(), NULL);
3553 3462
3554 InitializeGLAndCheck(shared_data.get(), 3463 InitializeGLAndCheck(shared_data.get(),
3555 resource_provider.get(), 3464 resource_provider.get(),
3556 output_surface.get()); 3465 output_surface.get());
3557 3466
3558 resource_provider->InitializeSoftware(); 3467 resource_provider->InitializeSoftware();
3559 output_surface->ReleaseGL(); 3468 output_surface->ReleaseGL();
3560 CheckCreateResource(ResourceProvider::Bitmap, resource_provider.get(), NULL); 3469 CheckCreateResource(ResourceProvider::Bitmap, resource_provider.get(), NULL);
(...skipping 11 matching lines...) Expand all
3572 new AllocationTrackingContext3D); 3481 new AllocationTrackingContext3D);
3573 AllocationTrackingContext3D* context = context_owned.get(); 3482 AllocationTrackingContext3D* context = context_owned.get();
3574 context_owned->set_support_compressed_texture_etc1(true); 3483 context_owned->set_support_compressed_texture_etc1(true);
3575 3484
3576 FakeOutputSurfaceClient output_surface_client; 3485 FakeOutputSurfaceClient output_surface_client;
3577 scoped_ptr<OutputSurface> output_surface( 3486 scoped_ptr<OutputSurface> output_surface(
3578 FakeOutputSurface::Create3d(context_owned.Pass())); 3487 FakeOutputSurface::Create3d(context_owned.Pass()));
3579 CHECK(output_surface->BindToClient(&output_surface_client)); 3488 CHECK(output_surface->BindToClient(&output_surface_client));
3580 3489
3581 gfx::Size size(4, 4); 3490 gfx::Size size(4, 4);
3582 scoped_ptr<ResourceProvider> resource_provider( 3491 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3583 ResourceProvider::Create(output_surface.get(), 3492 output_surface.get(), shared_bitmap_manager_.get(),
3584 shared_bitmap_manager_.get(), 3493 gpu_memory_buffer_manager_.get(), NULL, 0, false, false, 1));
3585 gpu_memory_buffer_manager_.get(),
3586 NULL,
3587 0,
3588 false,
3589 1));
3590 int texture_id = 123; 3494 int texture_id = 123;
3591 3495
3592 ResourceProvider::ResourceId id = resource_provider->CreateResource( 3496 ResourceProvider::ResourceId id = resource_provider->CreateResource(
3593 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, ETC1); 3497 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, ETC1);
3594 EXPECT_NE(0u, id); 3498 EXPECT_NE(0u, id);
3595 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); 3499 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id));
3596 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); 3500 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2);
3597 resource_provider->AllocateForTesting(id); 3501 resource_provider->AllocateForTesting(id);
3598 3502
3599 EXPECT_CALL(*context, RetireTextureId(texture_id)).Times(1); 3503 EXPECT_CALL(*context, RetireTextureId(texture_id)).Times(1);
3600 resource_provider->DeleteResource(id); 3504 resource_provider->DeleteResource(id);
3601 } 3505 }
3602 3506
3603 TEST_P(ResourceProviderTest, CompressedTextureETC1SetPixels) { 3507 TEST_P(ResourceProviderTest, CompressedTextureETC1SetPixels) {
3604 if (GetParam() != ResourceProvider::GLTexture) 3508 if (GetParam() != ResourceProvider::GLTexture)
3605 return; 3509 return;
3606 3510
3607 scoped_ptr<AllocationTrackingContext3D> context_owned( 3511 scoped_ptr<AllocationTrackingContext3D> context_owned(
3608 new AllocationTrackingContext3D); 3512 new AllocationTrackingContext3D);
3609 AllocationTrackingContext3D* context = context_owned.get(); 3513 AllocationTrackingContext3D* context = context_owned.get();
3610 context_owned->set_support_compressed_texture_etc1(true); 3514 context_owned->set_support_compressed_texture_etc1(true);
3611 3515
3612 FakeOutputSurfaceClient output_surface_client; 3516 FakeOutputSurfaceClient output_surface_client;
3613 scoped_ptr<OutputSurface> output_surface( 3517 scoped_ptr<OutputSurface> output_surface(
3614 FakeOutputSurface::Create3d(context_owned.Pass())); 3518 FakeOutputSurface::Create3d(context_owned.Pass()));
3615 CHECK(output_surface->BindToClient(&output_surface_client)); 3519 CHECK(output_surface->BindToClient(&output_surface_client));
3616 3520
3617 gfx::Size size(4, 4); 3521 gfx::Size size(4, 4);
3618 scoped_ptr<ResourceProvider> resource_provider( 3522 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3619 ResourceProvider::Create(output_surface.get(), 3523 output_surface.get(), shared_bitmap_manager_.get(),
3620 shared_bitmap_manager_.get(), 3524 gpu_memory_buffer_manager_.get(), NULL, 0, false, false, 1));
3621 gpu_memory_buffer_manager_.get(),
3622 NULL,
3623 0,
3624 false,
3625 1));
3626 int texture_id = 123; 3525 int texture_id = 123;
3627 uint8_t pixels[8]; 3526 uint8_t pixels[8];
3628 3527
3629 ResourceProvider::ResourceId id = resource_provider->CreateResource( 3528 ResourceProvider::ResourceId id = resource_provider->CreateResource(
3630 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, ETC1); 3529 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, ETC1);
3631 EXPECT_NE(0u, id); 3530 EXPECT_NE(0u, id);
3632 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); 3531 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id));
3633 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(3); 3532 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(3);
3634 EXPECT_CALL(*context, 3533 EXPECT_CALL(*context,
3635 compressedTexImage2D( 3534 compressedTexImage2D(
3636 _, 0, _, size.width(), size.height(), _, _, _)).Times(1); 3535 _, 0, _, size.width(), size.height(), _, _, _)).Times(1);
3637 resource_provider->SetPixels( 3536 resource_provider->SetPixels(
3638 id, pixels, gfx::Rect(size), gfx::Rect(size), gfx::Vector2d(0, 0)); 3537 id, pixels, gfx::Rect(size), gfx::Rect(size), gfx::Vector2d(0, 0));
3639 3538
3640 EXPECT_CALL(*context, RetireTextureId(texture_id)).Times(1); 3539 EXPECT_CALL(*context, RetireTextureId(texture_id)).Times(1);
3641 resource_provider->DeleteResource(id); 3540 resource_provider->DeleteResource(id);
3642 } 3541 }
3643 3542
3543 TEST_P(ResourceProviderTest, CompressedTextureAllocation) {
3544 // Only for GL textures.
3545 if (GetParam() != ResourceProvider::GLTexture)
3546 return;
3547 scoped_ptr<AllocationTrackingContext3D> context_owned(
3548 new StrictMock<AllocationTrackingContext3D>);
3549 AllocationTrackingContext3D* context = context_owned.get();
3550 context_owned->set_support_compressed_texture_atc(true);
3551 context_owned->set_support_compressed_texture_dxt(true);
3552 context_owned->set_support_compressed_texture_etc1(true);
3553
3554 FakeOutputSurfaceClient output_surface_client;
3555 scoped_ptr<OutputSurface> output_surface(
3556 FakeOutputSurface::Create3d(context_owned.Pass()));
3557 CHECK(output_surface->BindToClient(&output_surface_client));
3558
3559 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3560 output_surface.get(), shared_bitmap_manager_.get(),
3561 gpu_memory_buffer_manager_.get(), NULL, 0, false, true, 1));
3562
3563 gfx::Size size(4, 4);
3564 ResourceProvider::ResourceId id = 0;
3565 int texture_id = 123;
3566 const ResourceFormat formats[5] = {ATC, ATC_IA, DXT1, DXT5, ETC1};
3567
3568 for (size_t i = 0; i < arraysize(formats); ++i) {
3569 // Lazy allocation. Don't allocate when creating the resource.
3570 id = resource_provider->CreateResource(
3571 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable,
3572 formats[i]);
3573
3574 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id));
3575 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(1);
3576 resource_provider->CreateForTesting(id);
3577
3578 EXPECT_CALL(*context, RetireTextureId(texture_id)).Times(1);
3579 resource_provider->DeleteResource(id);
3580
3581 Mock::VerifyAndClearExpectations(context);
3582
3583 // Async version.
3584 id = resource_provider->CreateResource(
3585 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable,
3586 formats[i]);
3587 resource_provider->AcquirePixelBuffer(id);
3588
3589 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id));
3590 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2);
3591 EXPECT_CALL(*context, asyncCompressedTexImage2DCHROMIUM(_, _, _, 4, 4, _, _,
3592 _)).Times(1);
3593 resource_provider->BeginSetPixels(id);
3594 ASSERT_TRUE(resource_provider->DidSetPixelsComplete(id));
3595
3596 resource_provider->ReleasePixelBuffer(id);
3597
3598 EXPECT_CALL(*context, RetireTextureId(texture_id)).Times(1);
3599 resource_provider->DeleteResource(id);
3600
3601 Mock::VerifyAndClearExpectations(context);
3602 }
3603 }
3604
3644 INSTANTIATE_TEST_CASE_P( 3605 INSTANTIATE_TEST_CASE_P(
3645 ResourceProviderTests, 3606 ResourceProviderTests,
3646 ResourceProviderTest, 3607 ResourceProviderTest,
3647 ::testing::Values(ResourceProvider::GLTexture, ResourceProvider::Bitmap)); 3608 ::testing::Values(ResourceProvider::GLTexture, ResourceProvider::Bitmap));
3648 3609
3649 class TextureIdAllocationTrackingContext : public TestWebGraphicsContext3D { 3610 class TextureIdAllocationTrackingContext : public TestWebGraphicsContext3D {
3650 public: 3611 public:
3651 GLuint NextTextureId() override { 3612 GLuint NextTextureId() override {
3652 base::AutoLock lock(namespace_->lock); 3613 base::AutoLock lock(namespace_->lock);
3653 return namespace_->next_texture_id++; 3614 return namespace_->next_texture_id++;
(...skipping 15 matching lines...) Expand all
3669 FakeOutputSurface::Create3d(context_owned.Pass())); 3630 FakeOutputSurface::Create3d(context_owned.Pass()));
3670 CHECK(output_surface->BindToClient(&output_surface_client)); 3631 CHECK(output_surface->BindToClient(&output_surface_client));
3671 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 3632 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
3672 new TestSharedBitmapManager()); 3633 new TestSharedBitmapManager());
3673 3634
3674 gfx::Size size(1, 1); 3635 gfx::Size size(1, 1);
3675 ResourceFormat format = RGBA_8888; 3636 ResourceFormat format = RGBA_8888;
3676 3637
3677 { 3638 {
3678 size_t kTextureAllocationChunkSize = 1; 3639 size_t kTextureAllocationChunkSize = 1;
3679 scoped_ptr<ResourceProvider> resource_provider( 3640 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3680 ResourceProvider::Create(output_surface.get(), 3641 output_surface.get(), shared_bitmap_manager.get(), NULL, NULL, 0, false,
3681 shared_bitmap_manager.get(), 3642 false, kTextureAllocationChunkSize));
3682 NULL,
3683 NULL,
3684 0,
3685 false,
3686 kTextureAllocationChunkSize));
3687 3643
3688 ResourceProvider::ResourceId id = resource_provider->CreateResource( 3644 ResourceProvider::ResourceId id = resource_provider->CreateResource(
3689 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); 3645 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
3690 resource_provider->AllocateForTesting(id); 3646 resource_provider->AllocateForTesting(id);
3691 Mock::VerifyAndClearExpectations(context); 3647 Mock::VerifyAndClearExpectations(context);
3692 3648
3693 DCHECK_EQ(2u, context->PeekTextureId()); 3649 DCHECK_EQ(2u, context->PeekTextureId());
3694 resource_provider->DeleteResource(id); 3650 resource_provider->DeleteResource(id);
3695 } 3651 }
3696 3652
3697 { 3653 {
3698 size_t kTextureAllocationChunkSize = 8; 3654 size_t kTextureAllocationChunkSize = 8;
3699 scoped_ptr<ResourceProvider> resource_provider( 3655 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
3700 ResourceProvider::Create(output_surface.get(), 3656 output_surface.get(), shared_bitmap_manager.get(), NULL, NULL, 0, false,
3701 shared_bitmap_manager.get(), 3657 false, kTextureAllocationChunkSize));
3702 NULL,
3703 NULL,
3704 0,
3705 false,
3706 kTextureAllocationChunkSize));
3707 3658
3708 ResourceProvider::ResourceId id = resource_provider->CreateResource( 3659 ResourceProvider::ResourceId id = resource_provider->CreateResource(
3709 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); 3660 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
3710 resource_provider->AllocateForTesting(id); 3661 resource_provider->AllocateForTesting(id);
3711 Mock::VerifyAndClearExpectations(context); 3662 Mock::VerifyAndClearExpectations(context);
3712 3663
3713 DCHECK_EQ(10u, context->PeekTextureId()); 3664 DCHECK_EQ(10u, context->PeekTextureId());
3714 resource_provider->DeleteResource(id); 3665 resource_provider->DeleteResource(id);
3715 } 3666 }
3716 } 3667 }
3717 3668
3718 } // namespace 3669 } // namespace
3719 } // namespace cc 3670 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/resource_provider.cc ('k') | cc/resources/resource_update_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698