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

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: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/resources/resource_provider.h" 5 #include "cc/resources/resource_provider.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 10
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 ResourceProvider::ResourceId id2 = child_resource_provider_->CreateResource( 634 ResourceProvider::ResourceId id2 = child_resource_provider_->CreateResource(
635 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); 635 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
636 uint8_t data2[4] = { 5, 5, 5, 5 }; 636 uint8_t data2[4] = { 5, 5, 5, 5 };
637 child_resource_provider_->SetPixels(id2, data2, rect, rect, gfx::Vector2d()); 637 child_resource_provider_->SetPixels(id2, data2, rect, rect, gfx::Vector2d());
638 638
639 ResourceProvider::ResourceId id3 = child_resource_provider_->CreateResource( 639 ResourceProvider::ResourceId id3 = child_resource_provider_->CreateResource(
640 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); 640 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
641 { 641 {
642 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock( 642 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock(
643 child_resource_provider_.get(), id3); 643 child_resource_provider_.get(), id3);
644 EXPECT_TRUE(!!lock.gpu_memory_buffer()); 644 EXPECT_TRUE(!!lock.GetGpuMemoryBuffer());
645 } 645 }
646 646
647 GLuint external_texture_id = child_context_->createExternalTexture(); 647 GLuint external_texture_id = child_context_->createExternalTexture();
648 child_context_->bindTexture(GL_TEXTURE_EXTERNAL_OES, external_texture_id); 648 child_context_->bindTexture(GL_TEXTURE_EXTERNAL_OES, external_texture_id);
649 649
650 gpu::Mailbox external_mailbox; 650 gpu::Mailbox external_mailbox;
651 child_context_->genMailboxCHROMIUM(external_mailbox.name); 651 child_context_->genMailboxCHROMIUM(external_mailbox.name);
652 child_context_->produceTextureCHROMIUM(GL_TEXTURE_EXTERNAL_OES, 652 child_context_->produceTextureCHROMIUM(GL_TEXTURE_EXTERNAL_OES,
653 external_mailbox.name); 653 external_mailbox.name);
654 const GLuint external_sync_point = child_context_->insertSyncPoint(); 654 const GLuint external_sync_point = child_context_->insertSyncPoint();
(...skipping 2679 matching lines...) Expand 10 before | Expand all | Expand 10 after
3334 3334
3335 id = resource_provider->CreateResource( 3335 id = resource_provider->CreateResource(
3336 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); 3336 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
3337 3337
3338 EXPECT_CALL(*context, createImageCHROMIUM(_, kWidth, kHeight, GL_RGBA)) 3338 EXPECT_CALL(*context, createImageCHROMIUM(_, kWidth, kHeight, GL_RGBA))
3339 .WillOnce(Return(kImageId)) 3339 .WillOnce(Return(kImageId))
3340 .RetiresOnSaturation(); 3340 .RetiresOnSaturation();
3341 { 3341 {
3342 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock( 3342 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock(
3343 resource_provider.get(), id); 3343 resource_provider.get(), id);
3344 EXPECT_TRUE(!!lock.gpu_memory_buffer()); 3344 EXPECT_TRUE(!!lock.GetGpuMemoryBuffer());
3345 } 3345 }
3346 3346
3347 EXPECT_CALL(*context, NextTextureId()) 3347 EXPECT_CALL(*context, NextTextureId())
3348 .WillOnce(Return(kTextureId)) 3348 .WillOnce(Return(kTextureId))
3349 .RetiresOnSaturation(); 3349 .RetiresOnSaturation();
3350 // Once in CreateTextureId and once in BindForSampling 3350 // Once in CreateTextureId and once in BindForSampling
3351 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)).Times(2) 3351 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)).Times(2)
3352 .RetiresOnSaturation(); 3352 .RetiresOnSaturation();
3353 EXPECT_CALL(*context, bindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId)) 3353 EXPECT_CALL(*context, bindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId))
3354 .Times(1) 3354 .Times(1)
3355 .RetiresOnSaturation(); 3355 .RetiresOnSaturation();
3356 { 3356 {
3357 ResourceProvider::ScopedSamplerGL lock_gl( 3357 ResourceProvider::ScopedSamplerGL lock_gl(
3358 resource_provider.get(), id, GL_TEXTURE_2D, GL_LINEAR); 3358 resource_provider.get(), id, GL_TEXTURE_2D, GL_LINEAR);
3359 EXPECT_EQ(kTextureId, lock_gl.texture_id()); 3359 EXPECT_EQ(kTextureId, lock_gl.texture_id());
3360 } 3360 }
3361 3361
3362 { 3362 {
3363 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock( 3363 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock(
3364 resource_provider.get(), id); 3364 resource_provider.get(), id);
3365 EXPECT_TRUE(!!lock.gpu_memory_buffer()); 3365 EXPECT_TRUE(!!lock.GetGpuMemoryBuffer());
3366 } 3366 }
3367 3367
3368 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)).Times(1) 3368 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)).Times(1)
3369 .RetiresOnSaturation(); 3369 .RetiresOnSaturation();
3370 EXPECT_CALL(*context, releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId)) 3370 EXPECT_CALL(*context, releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId))
3371 .Times(1) 3371 .Times(1)
3372 .RetiresOnSaturation(); 3372 .RetiresOnSaturation();
3373 EXPECT_CALL(*context, bindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId)) 3373 EXPECT_CALL(*context, bindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId))
3374 .Times(1) 3374 .Times(1)
3375 .RetiresOnSaturation(); 3375 .RetiresOnSaturation();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
3422 3422
3423 source_id = resource_provider->CreateResource( 3423 source_id = resource_provider->CreateResource(
3424 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); 3424 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
3425 3425
3426 EXPECT_CALL(*context, createImageCHROMIUM(_, kWidth, kHeight, GL_RGBA)) 3426 EXPECT_CALL(*context, createImageCHROMIUM(_, kWidth, kHeight, GL_RGBA))
3427 .WillOnce(Return(kImageId)) 3427 .WillOnce(Return(kImageId))
3428 .RetiresOnSaturation(); 3428 .RetiresOnSaturation();
3429 { 3429 {
3430 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock( 3430 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock(
3431 resource_provider.get(), source_id); 3431 resource_provider.get(), source_id);
3432 EXPECT_TRUE(!!lock.gpu_memory_buffer()); 3432 EXPECT_TRUE(!!lock.GetGpuMemoryBuffer());
3433 } 3433 }
3434 Mock::VerifyAndClearExpectations(context); 3434 Mock::VerifyAndClearExpectations(context);
3435 3435
3436 dest_id = resource_provider->CreateResource( 3436 dest_id = resource_provider->CreateResource(
3437 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); 3437 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
3438 3438
3439 EXPECT_CALL(*context, NextTextureId()) 3439 EXPECT_CALL(*context, NextTextureId())
3440 .WillOnce(Return(kDestTextureId)) 3440 .WillOnce(Return(kDestTextureId))
3441 .RetiresOnSaturation(); 3441 .RetiresOnSaturation();
3442 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kDestTextureId)) 3442 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kDestTextureId))
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
3668 resource_provider->AllocateForTesting(id); 3668 resource_provider->AllocateForTesting(id);
3669 Mock::VerifyAndClearExpectations(context); 3669 Mock::VerifyAndClearExpectations(context);
3670 3670
3671 DCHECK_EQ(10u, context->PeekTextureId()); 3671 DCHECK_EQ(10u, context->PeekTextureId());
3672 resource_provider->DeleteResource(id); 3672 resource_provider->DeleteResource(id);
3673 } 3673 }
3674 } 3674 }
3675 3675
3676 } // namespace 3676 } // namespace
3677 } // namespace cc 3677 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698