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

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

Issue 23023005: cc: refcount resources as we send them to the parent (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 7 years, 4 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
« no previous file with comments | « cc/resources/resource_provider.cc ('k') | cc/trees/layer_tree_host_unittest_delegated.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 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 uint8_t result[4] = { 0 }; 572 uint8_t result[4] = { 0 };
573 GetResourcePixels( 573 GetResourcePixels(
574 resource_provider_.get(), context(), mapped_id1, size, format, result); 574 resource_provider_.get(), context(), mapped_id1, size, format, result);
575 EXPECT_EQ(0, memcmp(data1, result, pixel_size)); 575 EXPECT_EQ(0, memcmp(data1, result, pixel_size));
576 576
577 GetResourcePixels( 577 GetResourcePixels(
578 resource_provider_.get(), context(), mapped_id2, size, format, result); 578 resource_provider_.get(), context(), mapped_id2, size, format, result);
579 EXPECT_EQ(0, memcmp(data2, result, pixel_size)); 579 EXPECT_EQ(0, memcmp(data2, result, pixel_size));
580 { 580 {
581 // Check that transfering again the same resource from the child to the 581 // Check that transfering again the same resource from the child to the
582 // parent is a noop. 582 // parent works.
583 ResourceProvider::ResourceIdArray resource_ids_to_transfer; 583 ResourceProvider::ResourceIdArray resource_ids_to_transfer;
584 resource_ids_to_transfer.push_back(id1); 584 resource_ids_to_transfer.push_back(id1);
585 TransferableResourceArray list; 585 TransferableResourceArray list;
586 child_resource_provider->PrepareSendToParent(resource_ids_to_transfer, 586 child_resource_provider->PrepareSendToParent(resource_ids_to_transfer,
587 &list); 587 &list);
588 EXPECT_EQ(0u, list.size()); 588 EXPECT_EQ(1u, list.size());
589 EXPECT_EQ(id1, list[0].id);
590 child_resource_provider->ReceiveFromParent(list);
591 // id1 was exported twice, we returned it only once, it should still be
592 // in-use.
593 EXPECT_TRUE(child_resource_provider->InUseByConsumer(id1));
589 } 594 }
590 { 595 {
591 // Transfer resources back from the parent to the child. 596 // Transfer resources back from the parent to the child.
592 ResourceProvider::ResourceIdArray resource_ids_to_transfer; 597 ResourceProvider::ResourceIdArray resource_ids_to_transfer;
593 resource_ids_to_transfer.push_back(mapped_id1); 598 resource_ids_to_transfer.push_back(mapped_id1);
594 resource_ids_to_transfer.push_back(mapped_id2); 599 resource_ids_to_transfer.push_back(mapped_id2);
595 TransferableResourceArray list; 600 TransferableResourceArray list;
596 resource_provider_->PrepareSendToChild( 601 resource_provider_->PrepareSendToChild(
597 child_id, resource_ids_to_transfer, &list); 602 child_id, resource_ids_to_transfer, &list);
598 ASSERT_EQ(2u, list.size()); 603 ASSERT_EQ(2u, list.size());
(...skipping 1135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1734 output_surface.get()); 1739 output_surface.get());
1735 } 1740 }
1736 1741
1737 INSTANTIATE_TEST_CASE_P( 1742 INSTANTIATE_TEST_CASE_P(
1738 ResourceProviderTests, 1743 ResourceProviderTests,
1739 ResourceProviderTest, 1744 ResourceProviderTest,
1740 ::testing::Values(ResourceProvider::GLTexture, ResourceProvider::Bitmap)); 1745 ::testing::Values(ResourceProvider::GLTexture, ResourceProvider::Bitmap));
1741 1746
1742 } // namespace 1747 } // namespace
1743 } // namespace cc 1748 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/resource_provider.cc ('k') | cc/trees/layer_tree_host_unittest_delegated.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698