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 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 int highp_threshold_min, | 391 int highp_threshold_min, |
392 size_t id_allocation_chunk_size, | 392 size_t id_allocation_chunk_size, |
393 bool delegated_sync_points_required, | 393 bool delegated_sync_points_required, |
394 bool use_gpu_memory_buffer_resources, | 394 bool use_gpu_memory_buffer_resources, |
395 bool enable_color_correct_rendering, | 395 bool enable_color_correct_rendering, |
396 const BufferToTextureTargetMap& buffer_to_texture_target_map) | 396 const BufferToTextureTargetMap& buffer_to_texture_target_map) |
397 : compositor_context_provider_(compositor_context_provider), | 397 : compositor_context_provider_(compositor_context_provider), |
398 shared_bitmap_manager_(shared_bitmap_manager), | 398 shared_bitmap_manager_(shared_bitmap_manager), |
399 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), | 399 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), |
400 blocking_main_thread_task_runner_(blocking_main_thread_task_runner), | 400 blocking_main_thread_task_runner_(blocking_main_thread_task_runner), |
401 lost_output_surface_(false), | 401 lost_context_provider_(false), |
402 highp_threshold_min_(highp_threshold_min), | 402 highp_threshold_min_(highp_threshold_min), |
403 next_id_(1), | 403 next_id_(1), |
404 next_child_(1), | 404 next_child_(1), |
405 delegated_sync_points_required_(delegated_sync_points_required), | 405 delegated_sync_points_required_(delegated_sync_points_required), |
406 default_resource_type_(use_gpu_memory_buffer_resources | 406 default_resource_type_(use_gpu_memory_buffer_resources |
407 ? RESOURCE_TYPE_GPU_MEMORY_BUFFER | 407 ? RESOURCE_TYPE_GPU_MEMORY_BUFFER |
408 : RESOURCE_TYPE_GL_TEXTURE), | 408 : RESOURCE_TYPE_GL_TEXTURE), |
409 use_texture_storage_ext_(false), | 409 use_texture_storage_ext_(false), |
410 use_texture_format_bgra_(false), | 410 use_texture_format_bgra_(false), |
411 use_texture_usage_hint_(false), | 411 use_texture_usage_hint_(false), |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 | 713 |
714 void ResourceProvider::DeleteResourceInternal(ResourceMap::iterator it, | 714 void ResourceProvider::DeleteResourceInternal(ResourceMap::iterator it, |
715 DeleteStyle style) { | 715 DeleteStyle style) { |
716 TRACE_EVENT0("cc", "ResourceProvider::DeleteResourceInternal"); | 716 TRACE_EVENT0("cc", "ResourceProvider::DeleteResourceInternal"); |
717 Resource* resource = &it->second; | 717 Resource* resource = &it->second; |
718 DCHECK(resource->exported_count == 0 || style != NORMAL); | 718 DCHECK(resource->exported_count == 0 || style != NORMAL); |
719 | 719 |
720 // Exported resources are lost on shutdown. | 720 // Exported resources are lost on shutdown. |
721 bool exported_resource_lost = | 721 bool exported_resource_lost = |
722 style == FOR_SHUTDOWN && resource->exported_count > 0; | 722 style == FOR_SHUTDOWN && resource->exported_count > 0; |
723 // GPU resources are lost when output surface is lost. | 723 // GPU resources are lost when context is lost. |
724 bool gpu_resource_lost = | 724 bool gpu_resource_lost = |
725 IsGpuResourceType(resource->type) && lost_output_surface_; | 725 IsGpuResourceType(resource->type) && lost_context_provider_; |
726 bool lost_resource = | 726 bool lost_resource = |
727 resource->lost || exported_resource_lost || gpu_resource_lost; | 727 resource->lost || exported_resource_lost || gpu_resource_lost; |
728 | 728 |
729 // Wait on sync token before deleting resources we own. | 729 // Wait on sync token before deleting resources we own. |
730 if (!lost_resource && resource->origin == Resource::INTERNAL && | 730 if (!lost_resource && resource->origin == Resource::INTERNAL && |
731 resource->synchronization_state() == Resource::NEEDS_WAIT) { | 731 resource->synchronization_state() == Resource::NEEDS_WAIT) { |
732 DCHECK(resource->allocated); | 732 DCHECK(resource->allocated); |
733 DCHECK(IsGpuResourceType(resource->type)); | 733 DCHECK(IsGpuResourceType(resource->type)); |
734 GLES2Interface* gl = ContextGL(); | 734 GLES2Interface* gl = ContextGL(); |
735 DCHECK(gl); | 735 DCHECK(gl); |
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1680 CHECK(it != resources_.end()); | 1680 CHECK(it != resources_.end()); |
1681 Resource& resource = it->second; | 1681 Resource& resource = it->second; |
1682 | 1682 |
1683 DCHECK(!resource.locked_for_write); | 1683 DCHECK(!resource.locked_for_write); |
1684 DCHECK(child_info->parent_to_child_map.count(local_id)); | 1684 DCHECK(child_info->parent_to_child_map.count(local_id)); |
1685 | 1685 |
1686 ResourceId child_id = child_info->parent_to_child_map[local_id]; | 1686 ResourceId child_id = child_info->parent_to_child_map[local_id]; |
1687 DCHECK(child_info->child_to_parent_map.count(child_id)); | 1687 DCHECK(child_info->child_to_parent_map.count(child_id)); |
1688 | 1688 |
1689 bool is_lost = resource.lost || | 1689 bool is_lost = resource.lost || |
1690 (IsGpuResourceType(resource.type) && lost_output_surface_); | 1690 (IsGpuResourceType(resource.type) && lost_context_provider_); |
1691 if (resource.exported_count > 0 || resource.lock_for_read_count > 0) { | 1691 if (resource.exported_count > 0 || resource.lock_for_read_count > 0) { |
1692 if (style != FOR_SHUTDOWN) { | 1692 if (style != FOR_SHUTDOWN) { |
1693 // Defer this resource deletion. | 1693 // Defer this resource deletion. |
1694 resource.marked_for_deletion = true; | 1694 resource.marked_for_deletion = true; |
1695 continue; | 1695 continue; |
1696 } | 1696 } |
1697 // We can't postpone the deletion, so we'll have to lose it. | 1697 // We can't postpone the deletion, so we'll have to lose it. |
1698 is_lost = true; | 1698 is_lost = true; |
1699 } else if (!ReadLockFenceHasPassed(&resource)) { | 1699 } else if (!ReadLockFenceHasPassed(&resource)) { |
1700 // TODO(dcastagna): see if it's possible to use this logic for | 1700 // TODO(dcastagna): see if it's possible to use this logic for |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2039 | 2039 |
2040 const int kImportance = 2; | 2040 const int kImportance = 2; |
2041 pmd->CreateSharedGlobalAllocatorDump(guid); | 2041 pmd->CreateSharedGlobalAllocatorDump(guid); |
2042 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); | 2042 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); |
2043 } | 2043 } |
2044 | 2044 |
2045 return true; | 2045 return true; |
2046 } | 2046 } |
2047 | 2047 |
2048 } // namespace cc | 2048 } // namespace cc |
OLD | NEW |