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

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

Issue 12967018: cc: Avoid pointless gfx::Point/Size contructors when making Rects. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: RectFs as well Created 7 years, 9 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 | Annotate | Revision Log
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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "cc/base/scoped_ptr_deque.h" 9 #include "cc/base/scoped_ptr_deque.h"
10 #include "cc/base/scoped_ptr_hash_map.h" 10 #include "cc/base/scoped_ptr_hash_map.h"
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 gfx::Size size(1, 1); 391 gfx::Size size(1, 1);
392 WGC3Denum format = GL_RGBA; 392 WGC3Denum format = GL_RGBA;
393 size_t pixel_size = TextureSize(size, format); 393 size_t pixel_size = TextureSize(size, format);
394 ASSERT_EQ(4U, pixel_size); 394 ASSERT_EQ(4U, pixel_size);
395 395
396 ResourceProvider::ResourceId id = resource_provider_->CreateResource( 396 ResourceProvider::ResourceId id = resource_provider_->CreateResource(
397 size, format, ResourceProvider::TextureUsageAny); 397 size, format, ResourceProvider::TextureUsageAny);
398 ExpectNumResources(1); 398 ExpectNumResources(1);
399 399
400 uint8_t data[4] = { 1, 2, 3, 4 }; 400 uint8_t data[4] = { 1, 2, 3, 4 };
401 gfx::Rect rect(gfx::Point(), size); 401 gfx::Rect rect(size);
402 resource_provider_->SetPixels(id, data, rect, rect, gfx::Vector2d()); 402 resource_provider_->SetPixels(id, data, rect, rect, gfx::Vector2d());
403 403
404 uint8_t result[4] = { 0 }; 404 uint8_t result[4] = { 0 };
405 GetResourcePixels(id, size, format, result); 405 GetResourcePixels(id, size, format, result);
406 EXPECT_EQ(0, memcmp(data, result, pixel_size)); 406 EXPECT_EQ(0, memcmp(data, result, pixel_size));
407 407
408 resource_provider_->DeleteResource(id); 408 resource_provider_->DeleteResource(id);
409 ExpectNumResources(0); 409 ExpectNumResources(0);
410 } 410 }
411 411
412 TEST_P(ResourceProviderTest, Upload) { 412 TEST_P(ResourceProviderTest, Upload) {
413 gfx::Size size(2, 2); 413 gfx::Size size(2, 2);
414 WGC3Denum format = GL_RGBA; 414 WGC3Denum format = GL_RGBA;
415 size_t pixel_size = TextureSize(size, format); 415 size_t pixel_size = TextureSize(size, format);
416 ASSERT_EQ(16U, pixel_size); 416 ASSERT_EQ(16U, pixel_size);
417 417
418 ResourceProvider::ResourceId id = resource_provider_->CreateResource( 418 ResourceProvider::ResourceId id = resource_provider_->CreateResource(
419 size, format, ResourceProvider::TextureUsageAny); 419 size, format, ResourceProvider::TextureUsageAny);
420 420
421 uint8_t image[16] = { 0 }; 421 uint8_t image[16] = { 0 };
422 gfx::Rect image_rect(gfx::Point(), size); 422 gfx::Rect image_rect(size);
423 resource_provider_->SetPixels( 423 resource_provider_->SetPixels(
424 id, image, image_rect, image_rect, gfx::Vector2d()); 424 id, image, image_rect, image_rect, gfx::Vector2d());
425 425
426 for (uint8_t i = 0; i < pixel_size; ++i) 426 for (uint8_t i = 0; i < pixel_size; ++i)
427 image[i] = i; 427 image[i] = i;
428 428
429 uint8_t result[16] = { 0 }; 429 uint8_t result[16] = { 0 };
430 { 430 {
431 gfx::Rect source_rect(0, 0, 1, 1); 431 gfx::Rect source_rect(0, 0, 1, 1);
432 gfx::Vector2d dest_offset(0, 0); 432 gfx::Vector2d dest_offset(0, 0);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 ResourceProvider::Create(child_output_surface.get())); 484 ResourceProvider::Create(child_output_surface.get()));
485 485
486 gfx::Size size(1, 1); 486 gfx::Size size(1, 1);
487 WGC3Denum format = GL_RGBA; 487 WGC3Denum format = GL_RGBA;
488 size_t pixel_size = TextureSize(size, format); 488 size_t pixel_size = TextureSize(size, format);
489 ASSERT_EQ(4U, pixel_size); 489 ASSERT_EQ(4U, pixel_size);
490 490
491 ResourceProvider::ResourceId id1 = child_resource_provider->CreateResource( 491 ResourceProvider::ResourceId id1 = child_resource_provider->CreateResource(
492 size, format, ResourceProvider::TextureUsageAny); 492 size, format, ResourceProvider::TextureUsageAny);
493 uint8_t data1[4] = { 1, 2, 3, 4 }; 493 uint8_t data1[4] = { 1, 2, 3, 4 };
494 gfx::Rect rect(gfx::Point(), size); 494 gfx::Rect rect(size);
495 child_resource_provider->SetPixels(id1, data1, rect, rect, gfx::Vector2d()); 495 child_resource_provider->SetPixels(id1, data1, rect, rect, gfx::Vector2d());
496 496
497 ResourceProvider::ResourceId id2 = child_resource_provider->CreateResource( 497 ResourceProvider::ResourceId id2 = child_resource_provider->CreateResource(
498 size, format, ResourceProvider::TextureUsageAny); 498 size, format, ResourceProvider::TextureUsageAny);
499 uint8_t data2[4] = { 5, 5, 5, 5 }; 499 uint8_t data2[4] = { 5, 5, 5, 5 };
500 child_resource_provider->SetPixels(id2, data2, rect, rect, gfx::Vector2d()); 500 child_resource_provider->SetPixels(id2, data2, rect, rect, gfx::Vector2d());
501 501
502 int child_id = resource_provider_->CreateChild(); 502 int child_id = resource_provider_->CreateChild();
503 { 503 {
504 // Transfer some resources to the parent. 504 // Transfer some resources to the parent.
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 ResourceProvider::Create(child_output_surface.get())); 607 ResourceProvider::Create(child_output_surface.get()));
608 608
609 gfx::Size size(1, 1); 609 gfx::Size size(1, 1);
610 WGC3Denum format = GL_RGBA; 610 WGC3Denum format = GL_RGBA;
611 size_t pixel_size = TextureSize(size, format); 611 size_t pixel_size = TextureSize(size, format);
612 ASSERT_EQ(4U, pixel_size); 612 ASSERT_EQ(4U, pixel_size);
613 613
614 ResourceProvider::ResourceId id = child_resource_provider->CreateResource( 614 ResourceProvider::ResourceId id = child_resource_provider->CreateResource(
615 size, format, ResourceProvider::TextureUsageAny); 615 size, format, ResourceProvider::TextureUsageAny);
616 uint8_t data[4] = { 1, 2, 3, 4 }; 616 uint8_t data[4] = { 1, 2, 3, 4 };
617 gfx::Rect rect(gfx::Point(), size); 617 gfx::Rect rect(size);
618 child_resource_provider->SetPixels(id, data, rect, rect, gfx::Vector2d()); 618 child_resource_provider->SetPixels(id, data, rect, rect, gfx::Vector2d());
619 619
620 int child_id = resource_provider_->CreateChild(); 620 int child_id = resource_provider_->CreateChild();
621 { 621 {
622 // Transfer some resource to the parent. 622 // Transfer some resource to the parent.
623 ResourceProvider::ResourceIdArray resource_ids_to_transfer; 623 ResourceProvider::ResourceIdArray resource_ids_to_transfer;
624 resource_ids_to_transfer.push_back(id); 624 resource_ids_to_transfer.push_back(id);
625 TransferableResourceArray list; 625 TransferableResourceArray list;
626 child_resource_provider->PrepareSendToParent(resource_ids_to_transfer, 626 child_resource_provider->PrepareSendToParent(resource_ids_to_transfer,
627 &list); 627 &list);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 ResourceProvider::Create(child_output_surface.get())); 664 ResourceProvider::Create(child_output_surface.get()));
665 665
666 gfx::Size size(1, 1); 666 gfx::Size size(1, 1);
667 WGC3Denum format = GL_RGBA; 667 WGC3Denum format = GL_RGBA;
668 size_t pixel_size = TextureSize(size, format); 668 size_t pixel_size = TextureSize(size, format);
669 ASSERT_EQ(4U, pixel_size); 669 ASSERT_EQ(4U, pixel_size);
670 670
671 ResourceProvider::ResourceId id = child_resource_provider->CreateResource( 671 ResourceProvider::ResourceId id = child_resource_provider->CreateResource(
672 size, format, ResourceProvider::TextureUsageAny); 672 size, format, ResourceProvider::TextureUsageAny);
673 uint8_t data[4] = { 1, 2, 3, 4 }; 673 uint8_t data[4] = { 1, 2, 3, 4 };
674 gfx::Rect rect(gfx::Point(), size); 674 gfx::Rect rect(size);
675 child_resource_provider->SetPixels(id, data, rect, rect, gfx::Vector2d()); 675 child_resource_provider->SetPixels(id, data, rect, rect, gfx::Vector2d());
676 EXPECT_EQ(GL_LINEAR, GetResourceFilter(child_resource_provider.get(), id)); 676 EXPECT_EQ(GL_LINEAR, GetResourceFilter(child_resource_provider.get(), id));
677 SetResourceFilter(child_resource_provider.get(), id, GL_NEAREST); 677 SetResourceFilter(child_resource_provider.get(), id, GL_NEAREST);
678 EXPECT_EQ(GL_NEAREST, GetResourceFilter(child_resource_provider.get(), id)); 678 EXPECT_EQ(GL_NEAREST, GetResourceFilter(child_resource_provider.get(), id));
679 679
680 int child_id = resource_provider_->CreateChild(); 680 int child_id = resource_provider_->CreateChild();
681 { 681 {
682 // Transfer some resource to the parent. 682 // Transfer some resource to the parent.
683 ResourceProvider::ResourceIdArray resource_ids_to_transfer; 683 ResourceProvider::ResourceIdArray resource_ids_to_transfer;
684 resource_ids_to_transfer.push_back(id); 684 resource_ids_to_transfer.push_back(id);
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
1143 Mock::VerifyAndClearExpectations(context); 1143 Mock::VerifyAndClearExpectations(context);
1144 } 1144 }
1145 1145
1146 INSTANTIATE_TEST_CASE_P( 1146 INSTANTIATE_TEST_CASE_P(
1147 ResourceProviderTests, 1147 ResourceProviderTests,
1148 ResourceProviderTest, 1148 ResourceProviderTest,
1149 ::testing::Values(ResourceProvider::GLTexture, ResourceProvider::Bitmap)); 1149 ::testing::Values(ResourceProvider::GLTexture, ResourceProvider::Bitmap));
1150 1150
1151 } // namespace 1151 } // namespace
1152 } // namespace cc 1152 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/picture_layer_tiling_unittest.cc ('k') | cc/scheduler/texture_uploader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698