| OLD | NEW |
| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 780 ChildMap::iterator child_it = children_.find(resource->child_id); | 780 ChildMap::iterator child_it = children_.find(resource->child_id); |
| 781 ResourceIdArray unused; | 781 ResourceIdArray unused; |
| 782 unused.push_back(id); | 782 unused.push_back(id); |
| 783 DeleteAndReturnUnusedResourcesToChild(child_it, NORMAL, unused); | 783 DeleteAndReturnUnusedResourcesToChild(child_it, NORMAL, unused); |
| 784 } | 784 } |
| 785 } | 785 } |
| 786 } | 786 } |
| 787 | 787 |
| 788 ResourceProvider::Resource* ResourceProvider::LockForWrite(ResourceId id) { | 788 ResourceProvider::Resource* ResourceProvider::LockForWrite(ResourceId id) { |
| 789 Resource* resource = GetResource(id); | 789 Resource* resource = GetResource(id); |
| 790 DCHECK(CanLockForWrite(id)); | 790 // TODO(ccameron): The allowance for IsInUseByMacOSWindowServer should not |
| 791 | 791 // be needed. |
| 792 // http://crbug.com/577121 |
| 793 DCHECK(CanLockForWrite(id) || IsInUseByMacOSWindowServer(id)); |
| 792 resource->locked_for_write = true; | 794 resource->locked_for_write = true; |
| 793 return resource; | 795 return resource; |
| 794 } | 796 } |
| 795 | 797 |
| 796 bool ResourceProvider::CanLockForWrite(ResourceId id) { | 798 bool ResourceProvider::CanLockForWrite(ResourceId id) { |
| 797 Resource* resource = GetResource(id); | 799 Resource* resource = GetResource(id); |
| 798 return !resource->locked_for_write && !resource->lock_for_read_count && | 800 return !resource->locked_for_write && !resource->lock_for_read_count && |
| 799 !resource->exported_count && resource->origin == Resource::INTERNAL && | 801 !resource->exported_count && resource->origin == Resource::INTERNAL && |
| 800 !resource->lost && ReadLockFenceHasPassed(resource) && | 802 !resource->lost && ReadLockFenceHasPassed(resource) && |
| 801 !(resource->gpu_memory_buffer && | 803 !(resource->gpu_memory_buffer && |
| 802 resource->gpu_memory_buffer->IsInUseByMacOSWindowServer()); | 804 resource->gpu_memory_buffer->IsInUseByMacOSWindowServer()); |
| 803 } | 805 } |
| 804 | 806 |
| 805 bool ResourceProvider::IsOverlayCandidate(ResourceId id) { | 807 bool ResourceProvider::IsOverlayCandidate(ResourceId id) { |
| 806 Resource* resource = GetResource(id); | 808 Resource* resource = GetResource(id); |
| 807 return resource->is_overlay_candidate; | 809 return resource->is_overlay_candidate; |
| 808 } | 810 } |
| 809 | 811 |
| 812 bool ResourceProvider::IsInUseByMacOSWindowServer(ResourceId id) { |
| 813 Resource* resource = GetResource(id); |
| 814 return resource->gpu_memory_buffer && |
| 815 resource->gpu_memory_buffer->IsInUseByMacOSWindowServer(); |
| 816 } |
| 817 |
| 810 void ResourceProvider::UnlockForWrite(ResourceProvider::Resource* resource) { | 818 void ResourceProvider::UnlockForWrite(ResourceProvider::Resource* resource) { |
| 811 DCHECK(resource->locked_for_write); | 819 DCHECK(resource->locked_for_write); |
| 812 DCHECK_EQ(resource->exported_count, 0); | 820 DCHECK_EQ(resource->exported_count, 0); |
| 813 DCHECK(resource->origin == Resource::INTERNAL); | 821 DCHECK(resource->origin == Resource::INTERNAL); |
| 814 resource->locked_for_write = false; | 822 resource->locked_for_write = false; |
| 815 } | 823 } |
| 816 | 824 |
| 817 void ResourceProvider::EnableReadLockFencesForTesting(ResourceId id) { | 825 void ResourceProvider::EnableReadLockFencesForTesting(ResourceId id) { |
| 818 Resource* resource = GetResource(id); | 826 Resource* resource = GetResource(id); |
| 819 DCHECK(resource); | 827 DCHECK(resource); |
| (...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1780 | 1788 |
| 1781 const int kImportance = 2; | 1789 const int kImportance = 2; |
| 1782 pmd->CreateSharedGlobalAllocatorDump(guid); | 1790 pmd->CreateSharedGlobalAllocatorDump(guid); |
| 1783 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); | 1791 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); |
| 1784 } | 1792 } |
| 1785 | 1793 |
| 1786 return true; | 1794 return true; |
| 1787 } | 1795 } |
| 1788 | 1796 |
| 1789 } // namespace cc | 1797 } // namespace cc |
| OLD | NEW |