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

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

Issue 1707143002: Added methods to generate sync tokens for resource id(s). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added reserve Created 4 years, 10 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
« no previous file with comments | « cc/resources/resource_provider.h ('k') | cc/trees/layer_tree_host_impl.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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 image_size.width(), image_size.height(), 0, 746 image_size.width(), image_size.height(), 0,
747 image_bytes, image); 747 image_bytes, image);
748 } else { 748 } else {
749 gl->TexSubImage2D(resource->target, 0, 0, 0, image_size.width(), 749 gl->TexSubImage2D(resource->target, 0, 0, 0, image_size.width(),
750 image_size.height(), GLDataFormat(resource->format), 750 image_size.height(), GLDataFormat(resource->format),
751 GLDataType(resource->format), image); 751 GLDataType(resource->format), image);
752 } 752 }
753 } 753 }
754 } 754 }
755 755
756 void ResourceProvider::GenerateSyncTokenForResource(ResourceId resource_id) {
757 Resource* resource = GetResource(resource_id);
758 if (!resource->needs_sync_token())
759 return;
760
761 gpu::SyncToken sync_token;
762 GLES2Interface* gl = ContextGL();
763 DCHECK(gl);
764
765 const uint64_t fence_sync = gl->InsertFenceSyncCHROMIUM();
766 gl->OrderingBarrierCHROMIUM();
767 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData());
768
769 resource->UpdateSyncToken(sync_token);
770 }
771
772 void ResourceProvider::GenerateSyncTokenForResources(
773 const ResourceIdArray& resource_ids) {
774 gpu::SyncToken sync_token;
775 bool created_sync_token = false;
776 for (ResourceId id : resource_ids) {
777 Resource* resource = GetResource(id);
778 if (resource->needs_sync_token()) {
779 if (!created_sync_token) {
780 GLES2Interface* gl = ContextGL();
781 DCHECK(gl);
782
783 const uint64_t fence_sync = gl->InsertFenceSyncCHROMIUM();
784 gl->OrderingBarrierCHROMIUM();
785 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData());
786 created_sync_token = true;
787 }
788
789 resource->UpdateSyncToken(sync_token);
790 }
791 }
792 }
793
756 ResourceProvider::Resource* ResourceProvider::InsertResource( 794 ResourceProvider::Resource* ResourceProvider::InsertResource(
757 ResourceId id, 795 ResourceId id,
758 const Resource& resource) { 796 const Resource& resource) {
759 std::pair<ResourceMap::iterator, bool> result = 797 std::pair<ResourceMap::iterator, bool> result =
760 resources_.insert(ResourceMap::value_type(id, resource)); 798 resources_.insert(ResourceMap::value_type(id, resource));
761 DCHECK(result.second); 799 DCHECK(result.second);
762 return &result.first->second; 800 return &result.first->second;
763 } 801 }
764 802
765 ResourceProvider::Resource* ResourceProvider::GetResource(ResourceId id) { 803 ResourceProvider::Resource* ResourceProvider::GetResource(ResourceId id) {
(...skipping 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after
1856 1894
1857 const int kImportance = 2; 1895 const int kImportance = 2;
1858 pmd->CreateSharedGlobalAllocatorDump(guid); 1896 pmd->CreateSharedGlobalAllocatorDump(guid);
1859 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); 1897 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance);
1860 } 1898 }
1861 1899
1862 return true; 1900 return true;
1863 } 1901 }
1864 1902
1865 } // namespace cc 1903 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/resource_provider.h ('k') | cc/trees/layer_tree_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698