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

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

Issue 645943002: cc: Move GpuMemoryBuffer allocation to worker threads. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@chromium-image-refactor
Patch Set: address review feedback Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/resources/resource_provider.cc ('k') | cc/resources/zero_copy_raster_worker_pool.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 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 ResourceProvider::ResourceId id2 = child_resource_provider_->CreateResource( 630 ResourceProvider::ResourceId id2 = child_resource_provider_->CreateResource(
631 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); 631 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
632 uint8_t data2[4] = { 5, 5, 5, 5 }; 632 uint8_t data2[4] = { 5, 5, 5, 5 };
633 child_resource_provider_->SetPixels(id2, data2, rect, rect, gfx::Vector2d()); 633 child_resource_provider_->SetPixels(id2, data2, rect, rect, gfx::Vector2d());
634 634
635 ResourceProvider::ResourceId id3 = child_resource_provider_->CreateResource( 635 ResourceProvider::ResourceId id3 = child_resource_provider_->CreateResource(
636 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); 636 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
637 { 637 {
638 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock( 638 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock(
639 child_resource_provider_.get(), id3); 639 child_resource_provider_.get(), id3);
640 EXPECT_TRUE(!!lock.gpu_memory_buffer()); 640 EXPECT_TRUE(!!lock.GetGpuMemoryBuffer());
641 } 641 }
642 642
643 GLuint external_texture_id = child_context_->createExternalTexture(); 643 GLuint external_texture_id = child_context_->createExternalTexture();
644 child_context_->bindTexture(GL_TEXTURE_EXTERNAL_OES, external_texture_id); 644 child_context_->bindTexture(GL_TEXTURE_EXTERNAL_OES, external_texture_id);
645 645
646 gpu::Mailbox external_mailbox; 646 gpu::Mailbox external_mailbox;
647 child_context_->genMailboxCHROMIUM(external_mailbox.name); 647 child_context_->genMailboxCHROMIUM(external_mailbox.name);
648 child_context_->produceTextureCHROMIUM(GL_TEXTURE_EXTERNAL_OES, 648 child_context_->produceTextureCHROMIUM(GL_TEXTURE_EXTERNAL_OES,
649 external_mailbox.name); 649 external_mailbox.name);
650 const GLuint external_sync_point = child_context_->insertSyncPoint(); 650 const GLuint external_sync_point = child_context_->insertSyncPoint();
(...skipping 2660 matching lines...) Expand 10 before | Expand all | Expand 10 after
3311 3311
3312 id = resource_provider->CreateResource( 3312 id = resource_provider->CreateResource(
3313 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); 3313 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
3314 3314
3315 EXPECT_CALL(*context, createImageCHROMIUM(_, kWidth, kHeight, GL_RGBA)) 3315 EXPECT_CALL(*context, createImageCHROMIUM(_, kWidth, kHeight, GL_RGBA))
3316 .WillOnce(Return(kImageId)) 3316 .WillOnce(Return(kImageId))
3317 .RetiresOnSaturation(); 3317 .RetiresOnSaturation();
3318 { 3318 {
3319 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock( 3319 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock(
3320 resource_provider.get(), id); 3320 resource_provider.get(), id);
3321 EXPECT_TRUE(!!lock.gpu_memory_buffer()); 3321 EXPECT_TRUE(!!lock.GetGpuMemoryBuffer());
3322 } 3322 }
3323 3323
3324 EXPECT_CALL(*context, NextTextureId()) 3324 EXPECT_CALL(*context, NextTextureId())
3325 .WillOnce(Return(kTextureId)) 3325 .WillOnce(Return(kTextureId))
3326 .RetiresOnSaturation(); 3326 .RetiresOnSaturation();
3327 // Once in CreateTextureId and once in BindForSampling 3327 // Once in CreateTextureId and once in BindForSampling
3328 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)).Times(2) 3328 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)).Times(2)
3329 .RetiresOnSaturation(); 3329 .RetiresOnSaturation();
3330 EXPECT_CALL(*context, bindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId)) 3330 EXPECT_CALL(*context, bindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId))
3331 .Times(1) 3331 .Times(1)
3332 .RetiresOnSaturation(); 3332 .RetiresOnSaturation();
3333 { 3333 {
3334 ResourceProvider::ScopedSamplerGL lock_gl( 3334 ResourceProvider::ScopedSamplerGL lock_gl(
3335 resource_provider.get(), id, GL_TEXTURE_2D, GL_LINEAR); 3335 resource_provider.get(), id, GL_TEXTURE_2D, GL_LINEAR);
3336 EXPECT_EQ(kTextureId, lock_gl.texture_id()); 3336 EXPECT_EQ(kTextureId, lock_gl.texture_id());
3337 } 3337 }
3338 3338
3339 { 3339 {
3340 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock( 3340 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock(
3341 resource_provider.get(), id); 3341 resource_provider.get(), id);
3342 EXPECT_TRUE(!!lock.gpu_memory_buffer()); 3342 EXPECT_TRUE(!!lock.GetGpuMemoryBuffer());
3343 } 3343 }
3344 3344
3345 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)).Times(1) 3345 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)).Times(1)
3346 .RetiresOnSaturation(); 3346 .RetiresOnSaturation();
3347 EXPECT_CALL(*context, releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId)) 3347 EXPECT_CALL(*context, releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId))
3348 .Times(1) 3348 .Times(1)
3349 .RetiresOnSaturation(); 3349 .RetiresOnSaturation();
3350 EXPECT_CALL(*context, bindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId)) 3350 EXPECT_CALL(*context, bindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId))
3351 .Times(1) 3351 .Times(1)
3352 .RetiresOnSaturation(); 3352 .RetiresOnSaturation();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
3398 3398
3399 source_id = resource_provider->CreateResource( 3399 source_id = resource_provider->CreateResource(
3400 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); 3400 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
3401 3401
3402 EXPECT_CALL(*context, createImageCHROMIUM(_, kWidth, kHeight, GL_RGBA)) 3402 EXPECT_CALL(*context, createImageCHROMIUM(_, kWidth, kHeight, GL_RGBA))
3403 .WillOnce(Return(kImageId)) 3403 .WillOnce(Return(kImageId))
3404 .RetiresOnSaturation(); 3404 .RetiresOnSaturation();
3405 { 3405 {
3406 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock( 3406 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock(
3407 resource_provider.get(), source_id); 3407 resource_provider.get(), source_id);
3408 EXPECT_TRUE(!!lock.gpu_memory_buffer()); 3408 EXPECT_TRUE(!!lock.GetGpuMemoryBuffer());
3409 } 3409 }
3410 Mock::VerifyAndClearExpectations(context); 3410 Mock::VerifyAndClearExpectations(context);
3411 3411
3412 dest_id = resource_provider->CreateResource( 3412 dest_id = resource_provider->CreateResource(
3413 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); 3413 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
3414 3414
3415 EXPECT_CALL(*context, NextTextureId()) 3415 EXPECT_CALL(*context, NextTextureId())
3416 .WillOnce(Return(kDestTextureId)) 3416 .WillOnce(Return(kDestTextureId))
3417 .RetiresOnSaturation(); 3417 .RetiresOnSaturation();
3418 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kDestTextureId)) 3418 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kDestTextureId))
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
3639 resource_provider->AllocateForTesting(id); 3639 resource_provider->AllocateForTesting(id);
3640 Mock::VerifyAndClearExpectations(context); 3640 Mock::VerifyAndClearExpectations(context);
3641 3641
3642 DCHECK_EQ(10u, context->PeekTextureId()); 3642 DCHECK_EQ(10u, context->PeekTextureId());
3643 resource_provider->DeleteResource(id); 3643 resource_provider->DeleteResource(id);
3644 } 3644 }
3645 } 3645 }
3646 3646
3647 } // namespace 3647 } // namespace
3648 } // namespace cc 3648 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/resource_provider.cc ('k') | cc/resources/zero_copy_raster_worker_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698