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

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

Issue 208213003: Plumb overlay processing into DirectRenderer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase, Build Created 6 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
« no previous file with comments | « cc/quads/render_pass_unittest.cc ('k') | cc/resources/resource_provider_unittest.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 #include <limits> 8 #include <limits>
9 9
10 #include "base/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 base::Owned(release_callback.release())); 792 base::Owned(release_callback.release()));
793 resource.allow_overlay = mailbox.allow_overlay(); 793 resource.allow_overlay = mailbox.allow_overlay();
794 return id; 794 return id;
795 } 795 }
796 796
797 void ResourceProvider::DeleteResource(ResourceId id) { 797 void ResourceProvider::DeleteResource(ResourceId id) {
798 DCHECK(thread_checker_.CalledOnValidThread()); 798 DCHECK(thread_checker_.CalledOnValidThread());
799 ResourceMap::iterator it = resources_.find(id); 799 ResourceMap::iterator it = resources_.find(id);
800 CHECK(it != resources_.end()); 800 CHECK(it != resources_.end());
801 Resource* resource = &it->second; 801 Resource* resource = &it->second;
802 DCHECK(!resource->lock_for_read_count);
803 DCHECK(!resource->marked_for_deletion); 802 DCHECK(!resource->marked_for_deletion);
804 DCHECK_EQ(resource->imported_count, 0); 803 DCHECK_EQ(resource->imported_count, 0);
805 DCHECK(resource->pending_set_pixels || !resource->locked_for_write); 804 DCHECK(resource->pending_set_pixels || !resource->locked_for_write);
806 805
807 if (resource->exported_count > 0) { 806 if (resource->exported_count > 0 || resource->lock_for_read_count > 0) {
808 resource->marked_for_deletion = true; 807 resource->marked_for_deletion = true;
809 return; 808 return;
810 } else { 809 } else {
811 DeleteResourceInternal(it, Normal); 810 DeleteResourceInternal(it, Normal);
812 } 811 }
813 } 812 }
814 813
815 void ResourceProvider::DeleteResourceInternal(ResourceMap::iterator it, 814 void ResourceProvider::DeleteResourceInternal(ResourceMap::iterator it,
816 DeleteStyle style) { 815 DeleteStyle style) {
817 TRACE_EVENT0("cc", "ResourceProvider::DeleteResourceInternal"); 816 TRACE_EVENT0("cc", "ResourceProvider::DeleteResourceInternal");
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
1080 } 1079 }
1081 1080
1082 resource->lock_for_read_count++; 1081 resource->lock_for_read_count++;
1083 if (resource->enable_read_lock_fences) 1082 if (resource->enable_read_lock_fences)
1084 resource->read_lock_fence = current_read_lock_fence_; 1083 resource->read_lock_fence = current_read_lock_fence_;
1085 1084
1086 return resource; 1085 return resource;
1087 } 1086 }
1088 1087
1089 void ResourceProvider::UnlockForRead(ResourceId id) { 1088 void ResourceProvider::UnlockForRead(ResourceId id) {
1090 Resource* resource = GetResource(id); 1089 DCHECK(thread_checker_.CalledOnValidThread());
1090 ResourceMap::iterator it = resources_.find(id);
1091 CHECK(it != resources_.end());
1092
1093 Resource* resource = &it->second;
1091 DCHECK_GT(resource->lock_for_read_count, 0); 1094 DCHECK_GT(resource->lock_for_read_count, 0);
1092 DCHECK_EQ(resource->exported_count, 0); 1095 DCHECK_EQ(resource->exported_count, 0);
1093 resource->lock_for_read_count--; 1096 resource->lock_for_read_count--;
1097 if (resource->marked_for_deletion && !resource->lock_for_read_count) {
1098 if (!resource->child_id) {
1099 // The resource belongs to this ResourceProvider, so it can be destroyed.
1100 DeleteResourceInternal(it, Normal);
1101 } else {
1102 ChildMap::iterator child_it = children_.find(resource->child_id);
1103 ResourceIdArray unused;
1104 unused.push_back(id);
1105 DeleteAndReturnUnusedResourcesToChild(child_it, Normal, unused);
1106 }
1107 }
1094 } 1108 }
1095 1109
1096 const ResourceProvider::Resource* ResourceProvider::LockForWrite( 1110 const ResourceProvider::Resource* ResourceProvider::LockForWrite(
1097 ResourceId id) { 1111 ResourceId id) {
1098 Resource* resource = GetResource(id); 1112 Resource* resource = GetResource(id);
1099 DCHECK(!resource->locked_for_write); 1113 DCHECK(!resource->locked_for_write);
1100 DCHECK(!resource->lock_for_read_count); 1114 DCHECK(!resource->lock_for_read_count);
1101 DCHECK_EQ(resource->exported_count, 0); 1115 DCHECK_EQ(resource->exported_count, 0);
1102 DCHECK(resource->origin == Resource::Internal); 1116 DCHECK(resource->origin == Resource::Internal);
1103 DCHECK(!resource->lost); 1117 DCHECK(!resource->lost);
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
1640 GLES2Interface* gl = ContextGL(); 1654 GLES2Interface* gl = ContextGL();
1641 bool need_sync_point = false; 1655 bool need_sync_point = false;
1642 for (size_t i = 0; i < unused.size(); ++i) { 1656 for (size_t i = 0; i < unused.size(); ++i) {
1643 ResourceId local_id = unused[i]; 1657 ResourceId local_id = unused[i];
1644 1658
1645 ResourceMap::iterator it = resources_.find(local_id); 1659 ResourceMap::iterator it = resources_.find(local_id);
1646 CHECK(it != resources_.end()); 1660 CHECK(it != resources_.end());
1647 Resource& resource = it->second; 1661 Resource& resource = it->second;
1648 1662
1649 DCHECK(!resource.locked_for_write); 1663 DCHECK(!resource.locked_for_write);
1650 DCHECK(!resource.lock_for_read_count);
1651 DCHECK_EQ(0u, child_info->in_use_resources.count(local_id)); 1664 DCHECK_EQ(0u, child_info->in_use_resources.count(local_id));
1652 DCHECK(child_info->parent_to_child_map.count(local_id)); 1665 DCHECK(child_info->parent_to_child_map.count(local_id));
1653 1666
1654 ResourceId child_id = child_info->parent_to_child_map[local_id]; 1667 ResourceId child_id = child_info->parent_to_child_map[local_id];
1655 DCHECK(child_info->child_to_parent_map.count(child_id)); 1668 DCHECK(child_info->child_to_parent_map.count(child_id));
1656 1669
1657 bool is_lost = 1670 bool is_lost =
1658 resource.lost || (resource.type == GLTexture && lost_output_surface_); 1671 resource.lost || (resource.type == GLTexture && lost_output_surface_);
1659 if (resource.exported_count > 0) { 1672 if (resource.exported_count > 0 || resource.lock_for_read_count > 0) {
1660 if (style != ForShutdown) { 1673 if (style != ForShutdown) {
1661 // Defer this until we receive the resource back from the parent. 1674 // Defer this until we receive the resource back from the parent or
1675 // the read lock is released.
1662 resource.marked_for_deletion = true; 1676 resource.marked_for_deletion = true;
1663 continue; 1677 continue;
1664 } 1678 }
1665 1679
1666 // We still have an exported_count, so we'll have to lose it. 1680 // We still have an exported_count, so we'll have to lose it.
1667 is_lost = true; 1681 is_lost = true;
1668 } 1682 }
1669 1683
1670 if (gl && resource.filter != resource.original_filter) { 1684 if (gl && resource.filter != resource.original_filter) {
1671 DCHECK(resource.target); 1685 DCHECK(resource.target);
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
2213 ContextProvider* context_provider = output_surface_->context_provider(); 2227 ContextProvider* context_provider = output_surface_->context_provider();
2214 return context_provider ? context_provider->ContextGL() : NULL; 2228 return context_provider ? context_provider->ContextGL() : NULL;
2215 } 2229 }
2216 2230
2217 class GrContext* ResourceProvider::GrContext() const { 2231 class GrContext* ResourceProvider::GrContext() const {
2218 ContextProvider* context_provider = output_surface_->context_provider(); 2232 ContextProvider* context_provider = output_surface_->context_provider();
2219 return context_provider ? context_provider->GrContext() : NULL; 2233 return context_provider ? context_provider->GrContext() : NULL;
2220 } 2234 }
2221 2235
2222 } // namespace cc 2236 } // namespace cc
OLDNEW
« no previous file with comments | « cc/quads/render_pass_unittest.cc ('k') | cc/resources/resource_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698