| 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 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 return caps.texture_half_float_linear; | 453 return caps.texture_half_float_linear; |
| 454 } | 454 } |
| 455 | 455 |
| 456 NOTREACHED(); | 456 NOTREACHED(); |
| 457 return false; | 457 return false; |
| 458 } | 458 } |
| 459 | 459 |
| 460 bool ResourceProvider::InUseByConsumer(ResourceId id) { | 460 bool ResourceProvider::InUseByConsumer(ResourceId id) { |
| 461 Resource* resource = GetResource(id); | 461 Resource* resource = GetResource(id); |
| 462 return resource->lock_for_read_count > 0 || resource->exported_count > 0 || | 462 return resource->lock_for_read_count > 0 || resource->exported_count > 0 || |
| 463 resource->lost || | 463 resource->lost; |
| 464 (resource->gpu_memory_buffer && | |
| 465 resource->gpu_memory_buffer->IsInUseByMacOSWindowServer()); | |
| 466 } | 464 } |
| 467 | 465 |
| 468 bool ResourceProvider::IsLost(ResourceId id) { | 466 bool ResourceProvider::IsLost(ResourceId id) { |
| 469 Resource* resource = GetResource(id); | 467 Resource* resource = GetResource(id); |
| 470 return resource->lost; | 468 return resource->lost; |
| 471 } | 469 } |
| 472 | 470 |
| 473 void ResourceProvider::LoseResourceForTesting(ResourceId id) { | 471 void ResourceProvider::LoseResourceForTesting(ResourceId id) { |
| 474 Resource* resource = GetResource(id); | 472 Resource* resource = GetResource(id); |
| 475 DCHECK(resource); | 473 DCHECK(resource); |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 921 ChildMap::iterator child_it = children_.find(resource->child_id); | 919 ChildMap::iterator child_it = children_.find(resource->child_id); |
| 922 ResourceIdArray unused; | 920 ResourceIdArray unused; |
| 923 unused.push_back(id); | 921 unused.push_back(id); |
| 924 DeleteAndReturnUnusedResourcesToChild(child_it, NORMAL, unused); | 922 DeleteAndReturnUnusedResourcesToChild(child_it, NORMAL, unused); |
| 925 } | 923 } |
| 926 } | 924 } |
| 927 } | 925 } |
| 928 | 926 |
| 929 ResourceProvider::Resource* ResourceProvider::LockForWrite(ResourceId id) { | 927 ResourceProvider::Resource* ResourceProvider::LockForWrite(ResourceId id) { |
| 930 Resource* resource = GetResource(id); | 928 Resource* resource = GetResource(id); |
| 931 // TODO(ccameron): The allowance for IsInUseByMacOSWindowServer should not | 929 DCHECK(CanLockForWrite(id)); |
| 932 // be needed. | |
| 933 // http://crbug.com/577121 | |
| 934 DCHECK(CanLockForWrite(id) || IsInUseByMacOSWindowServer(id)); | |
| 935 DCHECK_NE(Resource::NEEDS_WAIT, resource->synchronization_state()); | 930 DCHECK_NE(Resource::NEEDS_WAIT, resource->synchronization_state()); |
| 936 resource->locked_for_write = true; | 931 resource->locked_for_write = true; |
| 937 resource->SetLocallyUsed(); | 932 resource->SetLocallyUsed(); |
| 938 return resource; | 933 return resource; |
| 939 } | 934 } |
| 940 | 935 |
| 941 bool ResourceProvider::CanLockForWrite(ResourceId id) { | 936 bool ResourceProvider::CanLockForWrite(ResourceId id) { |
| 942 Resource* resource = GetResource(id); | 937 Resource* resource = GetResource(id); |
| 943 return !resource->locked_for_write && !resource->lock_for_read_count && | 938 return !resource->locked_for_write && !resource->lock_for_read_count && |
| 944 !resource->exported_count && resource->origin == Resource::INTERNAL && | 939 !resource->exported_count && resource->origin == Resource::INTERNAL && |
| 945 !resource->lost && ReadLockFenceHasPassed(resource) && | 940 !resource->lost && ReadLockFenceHasPassed(resource); |
| 946 !(resource->gpu_memory_buffer && | |
| 947 resource->gpu_memory_buffer->IsInUseByMacOSWindowServer()); | |
| 948 } | 941 } |
| 949 | 942 |
| 950 bool ResourceProvider::IsOverlayCandidate(ResourceId id) { | 943 bool ResourceProvider::IsOverlayCandidate(ResourceId id) { |
| 951 Resource* resource = GetResource(id); | 944 Resource* resource = GetResource(id); |
| 952 return resource->is_overlay_candidate; | 945 return resource->is_overlay_candidate; |
| 953 } | 946 } |
| 954 | 947 |
| 955 bool ResourceProvider::IsInUseByMacOSWindowServer(ResourceId id) { | |
| 956 Resource* resource = GetResource(id); | |
| 957 return resource->gpu_memory_buffer && | |
| 958 resource->gpu_memory_buffer->IsInUseByMacOSWindowServer(); | |
| 959 } | |
| 960 | |
| 961 void ResourceProvider::UnlockForWrite(ResourceProvider::Resource* resource) { | 948 void ResourceProvider::UnlockForWrite(ResourceProvider::Resource* resource) { |
| 962 DCHECK(resource->locked_for_write); | 949 DCHECK(resource->locked_for_write); |
| 963 DCHECK_EQ(resource->exported_count, 0); | 950 DCHECK_EQ(resource->exported_count, 0); |
| 964 DCHECK(resource->origin == Resource::INTERNAL); | 951 DCHECK(resource->origin == Resource::INTERNAL); |
| 965 resource->locked_for_write = false; | 952 resource->locked_for_write = false; |
| 966 resource->SetSynchronized(); | 953 resource->SetSynchronized(); |
| 967 } | 954 } |
| 968 | 955 |
| 969 void ResourceProvider::EnableReadLockFencesForTesting(ResourceId id) { | 956 void ResourceProvider::EnableReadLockFencesForTesting(ResourceId id) { |
| 970 Resource* resource = GetResource(id); | 957 Resource* resource = GetResource(id); |
| (...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2016 | 2003 |
| 2017 const int kImportance = 2; | 2004 const int kImportance = 2; |
| 2018 pmd->CreateSharedGlobalAllocatorDump(guid); | 2005 pmd->CreateSharedGlobalAllocatorDump(guid); |
| 2019 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); | 2006 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); |
| 2020 } | 2007 } |
| 2021 | 2008 |
| 2022 return true; | 2009 return true; |
| 2023 } | 2010 } |
| 2024 | 2011 |
| 2025 } // namespace cc | 2012 } // namespace cc |
| OLD | NEW |