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

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

Issue 635733004: cc: Add ScopedWriteLock classes for raster to GpuMemoryBuffer or using Ganesh. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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
« 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 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 gfx::Rect rect(size); 625 gfx::Rect rect(size);
626 child_resource_provider_->SetPixels(id1, data1, rect, rect, gfx::Vector2d()); 626 child_resource_provider_->SetPixels(id1, data1, rect, rect, gfx::Vector2d());
627 627
628 ResourceProvider::ResourceId id2 = child_resource_provider_->CreateResource( 628 ResourceProvider::ResourceId id2 = child_resource_provider_->CreateResource(
629 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); 629 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
630 uint8_t data2[4] = { 5, 5, 5, 5 }; 630 uint8_t data2[4] = { 5, 5, 5, 5 };
631 child_resource_provider_->SetPixels(id2, data2, rect, rect, gfx::Vector2d()); 631 child_resource_provider_->SetPixels(id2, data2, rect, rect, gfx::Vector2d());
632 632
633 ResourceProvider::ResourceId id3 = child_resource_provider_->CreateResource( 633 ResourceProvider::ResourceId id3 = child_resource_provider_->CreateResource(
634 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); 634 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
635 child_resource_provider_->AcquireImage(id3); 635 {
636 int stride; 636 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock(
637 child_resource_provider_->MapImage(id3, &stride); 637 child_resource_provider_.get(), id3);
638 child_resource_provider_->UnmapImage(id3); 638 EXPECT_TRUE(!!lock.gpu_memory_buffer());
639 }
639 640
640 GLuint external_texture_id = child_context_->createExternalTexture(); 641 GLuint external_texture_id = child_context_->createExternalTexture();
641 child_context_->bindTexture(GL_TEXTURE_EXTERNAL_OES, external_texture_id); 642 child_context_->bindTexture(GL_TEXTURE_EXTERNAL_OES, external_texture_id);
642 643
643 gpu::Mailbox external_mailbox; 644 gpu::Mailbox external_mailbox;
644 child_context_->genMailboxCHROMIUM(external_mailbox.name); 645 child_context_->genMailboxCHROMIUM(external_mailbox.name);
645 child_context_->produceTextureCHROMIUM(GL_TEXTURE_EXTERNAL_OES, 646 child_context_->produceTextureCHROMIUM(GL_TEXTURE_EXTERNAL_OES,
646 external_mailbox.name); 647 external_mailbox.name);
647 const GLuint external_sync_point = child_context_->insertSyncPoint(); 648 const GLuint external_sync_point = child_context_->insertSyncPoint();
648 ResourceProvider::ResourceId id4 = 649 ResourceProvider::ResourceId id4 =
(...skipping 2655 matching lines...) Expand 10 before | Expand all | Expand 10 after
3304 shared_bitmap_manager_.get(), 3305 shared_bitmap_manager_.get(),
3305 NULL, 3306 NULL,
3306 0, 3307 0,
3307 false, 3308 false,
3308 1, 3309 1,
3309 false)); 3310 false));
3310 3311
3311 id = resource_provider->CreateResource( 3312 id = resource_provider->CreateResource(
3312 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); 3313 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
3313 3314
3314 const int kStride = 4; 3315 const int kStride = 8;
3315 void* dummy_mapped_buffer_address = NULL; 3316 uint8 buffer_data[kStride * kHeight];
3316 EXPECT_CALL( 3317 EXPECT_CALL(
3317 *context, 3318 *context,
3318 createImageCHROMIUM(kWidth, kHeight, GL_RGBA8_OES, GL_IMAGE_MAP_CHROMIUM)) 3319 createImageCHROMIUM(kWidth, kHeight, GL_RGBA8_OES, GL_IMAGE_MAP_CHROMIUM))
3319 .WillOnce(Return(kImageId)) 3320 .WillOnce(Return(kImageId))
3320 .RetiresOnSaturation(); 3321 .RetiresOnSaturation();
3321 resource_provider->AcquireImage(id); 3322 EXPECT_CALL(*context, mapImageCHROMIUM(kImageId))
3322 3323 .WillOnce(Return(buffer_data))
3324 .RetiresOnSaturation();
3323 EXPECT_CALL(*context, getImageParameterivCHROMIUM(kImageId, 3325 EXPECT_CALL(*context, getImageParameterivCHROMIUM(kImageId,
3324 GL_IMAGE_ROWBYTES_CHROMIUM, 3326 GL_IMAGE_ROWBYTES_CHROMIUM,
3325 _)) 3327 _))
3326 .WillOnce(SetArgPointee<2>(kStride)) 3328 .WillOnce(SetArgPointee<2>(kStride))
3327 .RetiresOnSaturation(); 3329 .RetiresOnSaturation();
3328 EXPECT_CALL(*context, mapImageCHROMIUM(kImageId))
3329 .WillOnce(Return(dummy_mapped_buffer_address))
3330 .RetiresOnSaturation();
3331 int stride;
3332 resource_provider->MapImage(id, &stride);
3333
3334 EXPECT_CALL(*context, unmapImageCHROMIUM(kImageId)) 3330 EXPECT_CALL(*context, unmapImageCHROMIUM(kImageId))
3335 .Times(1) 3331 .Times(1)
3336 .RetiresOnSaturation(); 3332 .RetiresOnSaturation();
3337 resource_provider->UnmapImage(id); 3333 {
3334 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock(
3335 resource_provider.get(), id);
3336 EXPECT_TRUE(!!lock.gpu_memory_buffer());
3337 }
3338 3338
3339 EXPECT_CALL(*context, NextTextureId()) 3339 EXPECT_CALL(*context, NextTextureId())
3340 .WillOnce(Return(kTextureId)) 3340 .WillOnce(Return(kTextureId))
3341 .RetiresOnSaturation(); 3341 .RetiresOnSaturation();
3342 // Once in CreateTextureId and once in BindForSampling 3342 // Once in CreateTextureId and once in BindForSampling
3343 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)).Times(2) 3343 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)).Times(2)
3344 .RetiresOnSaturation(); 3344 .RetiresOnSaturation();
3345 EXPECT_CALL(*context, bindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId)) 3345 EXPECT_CALL(*context, bindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId))
3346 .Times(1) 3346 .Times(1)
3347 .RetiresOnSaturation(); 3347 .RetiresOnSaturation();
3348 { 3348 {
3349 ResourceProvider::ScopedSamplerGL lock_gl( 3349 ResourceProvider::ScopedSamplerGL lock_gl(
3350 resource_provider.get(), id, GL_TEXTURE_2D, GL_LINEAR); 3350 resource_provider.get(), id, GL_TEXTURE_2D, GL_LINEAR);
3351 EXPECT_EQ(kTextureId, lock_gl.texture_id()); 3351 EXPECT_EQ(kTextureId, lock_gl.texture_id());
3352 } 3352 }
3353 3353
3354 EXPECT_CALL(*context, mapImageCHROMIUM(kImageId))
3355 .WillOnce(Return(buffer_data))
3356 .RetiresOnSaturation();
3354 EXPECT_CALL( 3357 EXPECT_CALL(
3355 *context, 3358 *context,
3356 getImageParameterivCHROMIUM(kImageId, GL_IMAGE_ROWBYTES_CHROMIUM, _)) 3359 getImageParameterivCHROMIUM(kImageId, GL_IMAGE_ROWBYTES_CHROMIUM, _))
3357 .WillOnce(SetArgPointee<2>(kStride)) 3360 .WillOnce(SetArgPointee<2>(kStride))
3358 .RetiresOnSaturation(); 3361 .RetiresOnSaturation();
3359 EXPECT_CALL(*context, mapImageCHROMIUM(kImageId))
3360 .WillOnce(Return(dummy_mapped_buffer_address))
3361 .RetiresOnSaturation();
3362 resource_provider->MapImage(id, &stride);
3363
3364 EXPECT_CALL(*context, unmapImageCHROMIUM(kImageId)) 3362 EXPECT_CALL(*context, unmapImageCHROMIUM(kImageId))
3365 .Times(1) 3363 .Times(1)
3366 .RetiresOnSaturation(); 3364 .RetiresOnSaturation();
3367 resource_provider->UnmapImage(id); 3365 {
3366 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock(
3367 resource_provider.get(), id);
3368 EXPECT_TRUE(!!lock.gpu_memory_buffer());
3369 }
3368 3370
3369 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)).Times(1) 3371 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)).Times(1)
3370 .RetiresOnSaturation(); 3372 .RetiresOnSaturation();
3371 EXPECT_CALL(*context, releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId)) 3373 EXPECT_CALL(*context, releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId))
3372 .Times(1) 3374 .Times(1)
3373 .RetiresOnSaturation(); 3375 .RetiresOnSaturation();
3374 EXPECT_CALL(*context, bindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId)) 3376 EXPECT_CALL(*context, bindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId))
3375 .Times(1) 3377 .Times(1)
3376 .RetiresOnSaturation(); 3378 .RetiresOnSaturation();
3377 EXPECT_CALL(*context, RetireTextureId(kTextureId)) 3379 EXPECT_CALL(*context, RetireTextureId(kTextureId))
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
3416 shared_bitmap_manager_.get(), 3418 shared_bitmap_manager_.get(),
3417 NULL, 3419 NULL,
3418 0, 3420 0,
3419 false, 3421 false,
3420 1, 3422 1,
3421 false)); 3423 false));
3422 3424
3423 source_id = resource_provider->CreateResource( 3425 source_id = resource_provider->CreateResource(
3424 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); 3426 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
3425 3427
3426 const int kStride = 4; 3428 const int kStride = 8;
3427 void* dummy_mapped_buffer_address = NULL; 3429 uint8 buffer_data[kStride * kHeight];
3428 EXPECT_CALL( 3430 EXPECT_CALL(
3429 *context, 3431 *context,
3430 createImageCHROMIUM(kWidth, kHeight, GL_RGBA8_OES, GL_IMAGE_MAP_CHROMIUM)) 3432 createImageCHROMIUM(kWidth, kHeight, GL_RGBA8_OES, GL_IMAGE_MAP_CHROMIUM))
3431 .WillOnce(Return(kImageId)) 3433 .WillOnce(Return(kImageId))
3432 .RetiresOnSaturation(); 3434 .RetiresOnSaturation();
3435 EXPECT_CALL(*context, mapImageCHROMIUM(kImageId))
3436 .WillOnce(Return(buffer_data))
3437 .RetiresOnSaturation();
3433 EXPECT_CALL( 3438 EXPECT_CALL(
3434 *context, 3439 *context,
3435 getImageParameterivCHROMIUM(kImageId, GL_IMAGE_ROWBYTES_CHROMIUM, _)) 3440 getImageParameterivCHROMIUM(kImageId, GL_IMAGE_ROWBYTES_CHROMIUM, _))
3436 .WillOnce(SetArgPointee<2>(kStride)) 3441 .WillOnce(SetArgPointee<2>(kStride))
3437 .RetiresOnSaturation(); 3442 .RetiresOnSaturation();
3438 EXPECT_CALL(*context, mapImageCHROMIUM(kImageId))
3439 .WillOnce(Return(dummy_mapped_buffer_address))
3440 .RetiresOnSaturation();
3441 resource_provider->AcquireImage(source_id);
3442 int stride;
3443 resource_provider->MapImage(source_id, &stride);
3444 EXPECT_CALL(*context, unmapImageCHROMIUM(kImageId)) 3443 EXPECT_CALL(*context, unmapImageCHROMIUM(kImageId))
3445 .Times(1) 3444 .Times(1)
3446 .RetiresOnSaturation(); 3445 .RetiresOnSaturation();
3447 resource_provider->UnmapImage(source_id); 3446 {
3447 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock(
3448 resource_provider.get(), source_id);
3449 EXPECT_TRUE(!!lock.gpu_memory_buffer());
3450 }
3448 Mock::VerifyAndClearExpectations(context); 3451 Mock::VerifyAndClearExpectations(context);
3449 3452
3450 dest_id = resource_provider->CreateResource( 3453 dest_id = resource_provider->CreateResource(
3451 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); 3454 size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
3452 3455
3453 EXPECT_CALL(*context, NextTextureId()) 3456 EXPECT_CALL(*context, NextTextureId())
3454 .WillOnce(Return(kDestTextureId)) 3457 .WillOnce(Return(kDestTextureId))
3455 .RetiresOnSaturation(); 3458 .RetiresOnSaturation();
3456 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kDestTextureId)) 3459 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kDestTextureId))
3457 .Times(1) 3460 .Times(1)
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
3677 resource_provider->AllocateForTesting(id); 3680 resource_provider->AllocateForTesting(id);
3678 Mock::VerifyAndClearExpectations(context); 3681 Mock::VerifyAndClearExpectations(context);
3679 3682
3680 DCHECK_EQ(10u, context->PeekTextureId()); 3683 DCHECK_EQ(10u, context->PeekTextureId());
3681 resource_provider->DeleteResource(id); 3684 resource_provider->DeleteResource(id);
3682 } 3685 }
3683 } 3686 }
3684 3687
3685 } // namespace 3688 } // namespace
3686 } // namespace cc 3689 } // 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