| 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 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 return; | 688 return; |
| 689 } else { | 689 } else { |
| 690 DeleteResourceInternal(it, NORMAL); | 690 DeleteResourceInternal(it, NORMAL); |
| 691 } | 691 } |
| 692 } | 692 } |
| 693 | 693 |
| 694 void ResourceProvider::DeleteResourceInternal(ResourceMap::iterator it, | 694 void ResourceProvider::DeleteResourceInternal(ResourceMap::iterator it, |
| 695 DeleteStyle style) { | 695 DeleteStyle style) { |
| 696 TRACE_EVENT0("cc", "ResourceProvider::DeleteResourceInternal"); | 696 TRACE_EVENT0("cc", "ResourceProvider::DeleteResourceInternal"); |
| 697 Resource* resource = &it->second; | 697 Resource* resource = &it->second; |
| 698 bool lost_resource = resource->lost; |
| 699 |
| 698 DCHECK(resource->exported_count == 0 || style != NORMAL); | 700 DCHECK(resource->exported_count == 0 || style != NORMAL); |
| 699 | 701 if (style == FOR_SHUTDOWN && resource->exported_count > 0) |
| 700 // Exported resources are lost on shutdown. | 702 lost_resource = true; |
| 701 bool exported_resource_lost = | |
| 702 style == FOR_SHUTDOWN && resource->exported_count > 0; | |
| 703 // GPU resources are lost when output surface is lost. | |
| 704 bool gpu_resource_lost = | |
| 705 IsGpuResourceType(resource->type) && lost_output_surface_; | |
| 706 bool lost_resource = | |
| 707 resource->lost || exported_resource_lost || gpu_resource_lost; | |
| 708 | |
| 709 if (!lost_resource && | |
| 710 resource->synchronization_state() == Resource::NEEDS_WAIT) { | |
| 711 DCHECK(resource->allocated); | |
| 712 DCHECK(IsGpuResourceType(resource->type)); | |
| 713 GLES2Interface* gl = ContextGL(); | |
| 714 DCHECK(gl); | |
| 715 resource->WaitSyncToken(gl); | |
| 716 } | |
| 717 | 703 |
| 718 if (resource->image_id) { | 704 if (resource->image_id) { |
| 719 DCHECK(resource->origin == Resource::INTERNAL); | 705 DCHECK(resource->origin == Resource::INTERNAL); |
| 720 GLES2Interface* gl = ContextGL(); | 706 GLES2Interface* gl = ContextGL(); |
| 721 DCHECK(gl); | 707 DCHECK(gl); |
| 722 gl->DestroyImageCHROMIUM(resource->image_id); | 708 gl->DestroyImageCHROMIUM(resource->image_id); |
| 723 } | 709 } |
| 724 if (resource->gl_upload_query_id) { | 710 if (resource->gl_upload_query_id) { |
| 725 DCHECK(resource->origin == Resource::INTERNAL); | 711 DCHECK(resource->origin == Resource::INTERNAL); |
| 726 GLES2Interface* gl = ContextGL(); | 712 GLES2Interface* gl = ContextGL(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 737 DCHECK(resource->origin == Resource::INTERNAL); | 723 DCHECK(resource->origin == Resource::INTERNAL); |
| 738 GLES2Interface* gl = ContextGL(); | 724 GLES2Interface* gl = ContextGL(); |
| 739 DCHECK(gl); | 725 DCHECK(gl); |
| 740 gl->DeleteBuffers(1, &resource->gl_pixel_buffer_id); | 726 gl->DeleteBuffers(1, &resource->gl_pixel_buffer_id); |
| 741 } | 727 } |
| 742 if (resource->origin == Resource::EXTERNAL) { | 728 if (resource->origin == Resource::EXTERNAL) { |
| 743 DCHECK(resource->mailbox().IsValid()); | 729 DCHECK(resource->mailbox().IsValid()); |
| 744 gpu::SyncToken sync_token = resource->mailbox().sync_token(); | 730 gpu::SyncToken sync_token = resource->mailbox().sync_token(); |
| 745 if (IsGpuResourceType(resource->type)) { | 731 if (IsGpuResourceType(resource->type)) { |
| 746 DCHECK(resource->mailbox().IsTexture()); | 732 DCHECK(resource->mailbox().IsTexture()); |
| 733 lost_resource |= lost_output_surface_; |
| 747 GLES2Interface* gl = ContextGL(); | 734 GLES2Interface* gl = ContextGL(); |
| 748 DCHECK(gl); | 735 DCHECK(gl); |
| 749 if (resource->gl_id) { | 736 if (resource->gl_id) { |
| 750 gl->DeleteTextures(1, &resource->gl_id); | 737 gl->DeleteTextures(1, &resource->gl_id); |
| 751 resource->gl_id = 0; | 738 resource->gl_id = 0; |
| 752 if (!lost_resource) { | 739 if (!lost_resource) { |
| 753 const GLuint64 fence_sync = gl->InsertFenceSyncCHROMIUM(); | 740 const GLuint64 fence_sync = gl->InsertFenceSyncCHROMIUM(); |
| 754 gl->ShallowFlushCHROMIUM(); | 741 gl->ShallowFlushCHROMIUM(); |
| 755 gl->GenSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); | 742 gl->GenSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); |
| 756 } | 743 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 822 DCHECK(resource->allocated); | 809 DCHECK(resource->allocated); |
| 823 DCHECK_EQ(RGBA_8888, resource->format); | 810 DCHECK_EQ(RGBA_8888, resource->format); |
| 824 SkImageInfo source_info = | 811 SkImageInfo source_info = |
| 825 SkImageInfo::MakeN32Premul(image_size.width(), image_size.height()); | 812 SkImageInfo::MakeN32Premul(image_size.width(), image_size.height()); |
| 826 size_t image_stride = image_size.width() * 4; | 813 size_t image_stride = image_size.width() * 4; |
| 827 | 814 |
| 828 ScopedWriteLockSoftware lock(this, id); | 815 ScopedWriteLockSoftware lock(this, id); |
| 829 SkCanvas dest(lock.sk_bitmap()); | 816 SkCanvas dest(lock.sk_bitmap()); |
| 830 dest.writePixels(source_info, image, image_stride, 0, 0); | 817 dest.writePixels(source_info, image, image_stride, 0, 0); |
| 831 } else { | 818 } else { |
| 832 ScopedWriteLockGL lock(this, id, false); | 819 ScopedWriteLockGL lock(this, id); |
| 833 unsigned resource_texture_id = lock.texture_id(); | 820 DCHECK(lock.texture_id()); |
| 834 DCHECK(resource_texture_id); | |
| 835 GLES2Interface* gl = ContextGL(); | 821 GLES2Interface* gl = ContextGL(); |
| 836 DCHECK(gl); | 822 DCHECK(gl); |
| 837 gl->BindTexture(resource->target, resource_texture_id); | 823 gl->BindTexture(resource->target, lock.texture_id()); |
| 838 if (resource->format == ETC1) { | 824 if (resource->format == ETC1) { |
| 839 DCHECK_EQ(resource->target, static_cast<GLenum>(GL_TEXTURE_2D)); | 825 DCHECK_EQ(resource->target, static_cast<GLenum>(GL_TEXTURE_2D)); |
| 840 int image_bytes = ResourceUtil::CheckedSizeInBytes<int>(image_size, ETC1); | 826 int image_bytes = ResourceUtil::CheckedSizeInBytes<int>(image_size, ETC1); |
| 841 gl->CompressedTexImage2D(resource->target, 0, GLInternalFormat(ETC1), | 827 gl->CompressedTexImage2D(resource->target, 0, GLInternalFormat(ETC1), |
| 842 image_size.width(), image_size.height(), 0, | 828 image_size.width(), image_size.height(), 0, |
| 843 image_bytes, image); | 829 image_bytes, image); |
| 844 } else { | 830 } else { |
| 845 gl->TexSubImage2D(resource->target, 0, 0, 0, image_size.width(), | 831 gl->TexSubImage2D(resource->target, 0, 0, 0, image_size.width(), |
| 846 image_size.height(), GLDataFormat(resource->format), | 832 image_size.height(), GLDataFormat(resource->format), |
| 847 GLDataType(resource->format), image); | 833 GLDataType(resource->format), image); |
| 848 } | 834 } |
| 849 const uint64_t fence_sync = gl->InsertFenceSyncCHROMIUM(); | 835 const uint64_t fence_sync = gl->InsertFenceSyncCHROMIUM(); |
| 850 gl->OrderingBarrierCHROMIUM(); | 836 gl->OrderingBarrierCHROMIUM(); |
| 851 gpu::SyncToken sync_token; | 837 gpu::SyncToken sync_token; |
| 852 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); | 838 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); |
| 853 lock.set_sync_token(sync_token); | 839 lock.UpdateResourceSyncToken(sync_token); |
| 854 lock.set_synchronized(true); | |
| 855 } | 840 } |
| 856 } | 841 } |
| 857 | 842 |
| 858 void ResourceProvider::GenerateSyncTokenForResource(ResourceId resource_id) { | 843 void ResourceProvider::GenerateSyncTokenForResource(ResourceId resource_id) { |
| 859 Resource* resource = GetResource(resource_id); | 844 Resource* resource = GetResource(resource_id); |
| 860 if (!resource->needs_sync_token()) | 845 if (!resource->needs_sync_token()) |
| 861 return; | 846 return; |
| 862 | 847 |
| 863 gpu::SyncToken sync_token; | 848 gpu::SyncToken sync_token; |
| 864 GLES2Interface* gl = ContextGL(); | 849 GLES2Interface* gl = ContextGL(); |
| 865 DCHECK(gl); | 850 DCHECK(gl); |
| 866 | 851 |
| 867 const uint64_t fence_sync = gl->InsertFenceSyncCHROMIUM(); | 852 const uint64_t fence_sync = gl->InsertFenceSyncCHROMIUM(); |
| 868 gl->OrderingBarrierCHROMIUM(); | 853 gl->OrderingBarrierCHROMIUM(); |
| 869 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); | 854 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); |
| 870 | 855 |
| 871 resource->UpdateSyncToken(sync_token); | 856 resource->UpdateSyncToken(sync_token); |
| 872 resource->SetSynchronized(); | |
| 873 } | 857 } |
| 874 | 858 |
| 875 void ResourceProvider::GenerateSyncTokenForResources( | 859 void ResourceProvider::GenerateSyncTokenForResources( |
| 876 const ResourceIdArray& resource_ids) { | 860 const ResourceIdArray& resource_ids) { |
| 877 gpu::SyncToken sync_token; | 861 gpu::SyncToken sync_token; |
| 878 bool created_sync_token = false; | 862 bool created_sync_token = false; |
| 879 for (ResourceId id : resource_ids) { | 863 for (ResourceId id : resource_ids) { |
| 880 Resource* resource = GetResource(id); | 864 Resource* resource = GetResource(id); |
| 881 if (resource->needs_sync_token()) { | 865 if (resource->needs_sync_token()) { |
| 882 if (!created_sync_token) { | 866 if (!created_sync_token) { |
| 883 GLES2Interface* gl = ContextGL(); | 867 GLES2Interface* gl = ContextGL(); |
| 884 DCHECK(gl); | 868 DCHECK(gl); |
| 885 | 869 |
| 886 const uint64_t fence_sync = gl->InsertFenceSyncCHROMIUM(); | 870 const uint64_t fence_sync = gl->InsertFenceSyncCHROMIUM(); |
| 887 gl->OrderingBarrierCHROMIUM(); | 871 gl->OrderingBarrierCHROMIUM(); |
| 888 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); | 872 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); |
| 889 created_sync_token = true; | 873 created_sync_token = true; |
| 890 } | 874 } |
| 891 | 875 |
| 892 resource->UpdateSyncToken(sync_token); | 876 resource->UpdateSyncToken(sync_token); |
| 893 resource->SetSynchronized(); | |
| 894 } | 877 } |
| 895 } | 878 } |
| 896 } | 879 } |
| 897 | 880 |
| 898 ResourceProvider::Resource* ResourceProvider::InsertResource( | 881 ResourceProvider::Resource* ResourceProvider::InsertResource( |
| 899 ResourceId id, | 882 ResourceId id, |
| 900 Resource resource) { | 883 Resource resource) { |
| 901 std::pair<ResourceMap::iterator, bool> result = | 884 std::pair<ResourceMap::iterator, bool> result = |
| 902 resources_.insert(ResourceMap::value_type(id, std::move(resource))); | 885 resources_.insert(ResourceMap::value_type(id, std::move(resource))); |
| 903 DCHECK(result.second); | 886 DCHECK(result.second); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 976 ResourceIdArray unused; | 959 ResourceIdArray unused; |
| 977 unused.push_back(id); | 960 unused.push_back(id); |
| 978 DeleteAndReturnUnusedResourcesToChild(child_it, NORMAL, unused); | 961 DeleteAndReturnUnusedResourcesToChild(child_it, NORMAL, unused); |
| 979 } | 962 } |
| 980 } | 963 } |
| 981 } | 964 } |
| 982 | 965 |
| 983 ResourceProvider::Resource* ResourceProvider::LockForWrite(ResourceId id) { | 966 ResourceProvider::Resource* ResourceProvider::LockForWrite(ResourceId id) { |
| 984 Resource* resource = GetResource(id); | 967 Resource* resource = GetResource(id); |
| 985 DCHECK(CanLockForWrite(id)); | 968 DCHECK(CanLockForWrite(id)); |
| 986 if (resource->allocated) | 969 DCHECK_NE(Resource::NEEDS_WAIT, resource->synchronization_state()); |
| 987 WaitSyncTokenIfNeeded(id); | |
| 988 resource->locked_for_write = true; | 970 resource->locked_for_write = true; |
| 989 resource->SetLocallyUsed(); | 971 resource->SetLocallyUsed(); |
| 990 return resource; | 972 return resource; |
| 991 } | 973 } |
| 992 | 974 |
| 993 bool ResourceProvider::CanLockForWrite(ResourceId id) { | 975 bool ResourceProvider::CanLockForWrite(ResourceId id) { |
| 994 Resource* resource = GetResource(id); | 976 Resource* resource = GetResource(id); |
| 995 return !resource->locked_for_write && !resource->lock_for_read_count && | 977 return !resource->locked_for_write && !resource->lock_for_read_count && |
| 996 !resource->exported_count && resource->origin == Resource::INTERNAL && | 978 !resource->exported_count && resource->origin == Resource::INTERNAL && |
| 997 !resource->lost && ReadLockFenceHasPassed(resource); | 979 !resource->lost && ReadLockFenceHasPassed(resource); |
| 998 } | 980 } |
| 999 | 981 |
| 1000 bool ResourceProvider::IsOverlayCandidate(ResourceId id) { | 982 bool ResourceProvider::IsOverlayCandidate(ResourceId id) { |
| 1001 Resource* resource = GetResource(id); | 983 Resource* resource = GetResource(id); |
| 1002 return resource->is_overlay_candidate; | 984 return resource->is_overlay_candidate; |
| 1003 } | 985 } |
| 1004 | 986 |
| 1005 void ResourceProvider::UnlockForWrite(Resource* resource) { | 987 void ResourceProvider::UnlockForWrite(ResourceProvider::Resource* resource) { |
| 1006 DCHECK(resource->locked_for_write); | 988 DCHECK(resource->locked_for_write); |
| 1007 DCHECK_EQ(resource->exported_count, 0); | 989 DCHECK_EQ(resource->exported_count, 0); |
| 1008 DCHECK(resource->origin == Resource::INTERNAL); | 990 DCHECK(resource->origin == Resource::INTERNAL); |
| 1009 resource->locked_for_write = false; | 991 resource->locked_for_write = false; |
| 992 resource->SetSynchronized(); |
| 1010 } | 993 } |
| 1011 | 994 |
| 1012 void ResourceProvider::EnableReadLockFencesForTesting(ResourceId id) { | 995 void ResourceProvider::EnableReadLockFencesForTesting(ResourceId id) { |
| 1013 Resource* resource = GetResource(id); | 996 Resource* resource = GetResource(id); |
| 1014 DCHECK(resource); | 997 DCHECK(resource); |
| 1015 resource->read_lock_fences_enabled = true; | 998 resource->read_lock_fences_enabled = true; |
| 1016 } | 999 } |
| 1017 | 1000 |
| 1018 ResourceProvider::ScopedReadLockGL::ScopedReadLockGL( | 1001 ResourceProvider::ScopedReadLockGL::ScopedReadLockGL( |
| 1019 ResourceProvider* resource_provider, | 1002 ResourceProvider* resource_provider, |
| 1020 ResourceId resource_id) | 1003 ResourceId resource_id) |
| 1021 : resource_provider_(resource_provider), resource_id_(resource_id) { | 1004 : resource_provider_(resource_provider), |
| 1022 const Resource* resource = resource_provider->LockForRead(resource_id); | 1005 resource_id_(resource_id), |
| 1023 texture_id_ = resource->gl_id; | 1006 resource_(resource_provider->LockForRead(resource_id)) { |
| 1024 target_ = resource->target; | 1007 DCHECK(resource_); |
| 1025 size_ = resource->size; | |
| 1026 } | 1008 } |
| 1027 | 1009 |
| 1028 ResourceProvider::ScopedReadLockGL::~ScopedReadLockGL() { | 1010 ResourceProvider::ScopedReadLockGL::~ScopedReadLockGL() { |
| 1029 resource_provider_->UnlockForRead(resource_id_); | 1011 resource_provider_->UnlockForRead(resource_id_); |
| 1030 } | 1012 } |
| 1031 | 1013 |
| 1032 ResourceProvider::ScopedSamplerGL::ScopedSamplerGL( | 1014 ResourceProvider::ScopedSamplerGL::ScopedSamplerGL( |
| 1033 ResourceProvider* resource_provider, | 1015 ResourceProvider* resource_provider, |
| 1034 ResourceId resource_id, | 1016 ResourceId resource_id, |
| 1035 GLenum filter) | 1017 GLenum filter) |
| 1036 : resource_lock_(resource_provider, resource_id), | 1018 : ScopedReadLockGL(resource_provider, resource_id), |
| 1037 unit_(GL_TEXTURE0), | 1019 unit_(GL_TEXTURE0), |
| 1038 target_(resource_provider->BindForSampling(resource_id, unit_, filter)) {} | 1020 target_(resource_provider->BindForSampling(resource_id, unit_, filter)) {} |
| 1039 | 1021 |
| 1040 ResourceProvider::ScopedSamplerGL::ScopedSamplerGL( | 1022 ResourceProvider::ScopedSamplerGL::ScopedSamplerGL( |
| 1041 ResourceProvider* resource_provider, | 1023 ResourceProvider* resource_provider, |
| 1042 ResourceId resource_id, | 1024 ResourceId resource_id, |
| 1043 GLenum unit, | 1025 GLenum unit, |
| 1044 GLenum filter) | 1026 GLenum filter) |
| 1045 : resource_lock_(resource_provider, resource_id), | 1027 : ScopedReadLockGL(resource_provider, resource_id), |
| 1046 unit_(unit), | 1028 unit_(unit), |
| 1047 target_(resource_provider->BindForSampling(resource_id, unit_, filter)) {} | 1029 target_(resource_provider->BindForSampling(resource_id, unit_, filter)) {} |
| 1048 | 1030 |
| 1049 ResourceProvider::ScopedSamplerGL::~ScopedSamplerGL() { | 1031 ResourceProvider::ScopedSamplerGL::~ScopedSamplerGL() {} |
| 1050 } | |
| 1051 | 1032 |
| 1052 ResourceProvider::ScopedWriteLockGL::ScopedWriteLockGL( | 1033 ResourceProvider::ScopedWriteLockGL::ScopedWriteLockGL( |
| 1053 ResourceProvider* resource_provider, | 1034 ResourceProvider* resource_provider, |
| 1054 ResourceId resource_id, | 1035 ResourceId resource_id) |
| 1055 bool create_mailbox) | |
| 1056 : resource_provider_(resource_provider), | 1036 : resource_provider_(resource_provider), |
| 1057 resource_id_(resource_id), | 1037 resource_(resource_provider->LockForWrite(resource_id)), |
| 1058 synchronized_(false) { | 1038 texture_id_(0), |
| 1059 DCHECK(thread_checker_.CalledOnValidThread()); | 1039 set_sync_token_(false) { |
| 1060 Resource* resource = resource_provider->LockForWrite(resource_id); | 1040 resource_provider_->LazyAllocate(resource_); |
| 1061 resource_provider_->LazyAllocate(resource); | 1041 texture_id_ = resource_->gl_id; |
| 1062 if (resource->image_id && resource->dirty_image) | 1042 DCHECK(texture_id_); |
| 1063 resource_provider_->BindImageForSampling(resource); | 1043 if (resource_->image_id && resource_->dirty_image) |
| 1064 if (create_mailbox) { | 1044 resource_provider_->BindImageForSampling(resource_); |
| 1065 resource_provider_->CreateMailboxAndBindResource( | |
| 1066 resource_provider_->ContextGL(), resource); | |
| 1067 } | |
| 1068 texture_id_ = resource->gl_id; | |
| 1069 target_ = resource->target; | |
| 1070 format_ = resource->format; | |
| 1071 size_ = resource->size; | |
| 1072 mailbox_ = resource->mailbox(); | |
| 1073 } | 1045 } |
| 1074 | 1046 |
| 1075 ResourceProvider::ScopedWriteLockGL::~ScopedWriteLockGL() { | 1047 ResourceProvider::ScopedWriteLockGL::~ScopedWriteLockGL() { |
| 1076 DCHECK(thread_checker_.CalledOnValidThread()); | 1048 if (set_sync_token_) |
| 1077 Resource* resource = resource_provider_->GetResource(resource_id_); | 1049 resource_->UpdateSyncToken(sync_token_); |
| 1078 DCHECK(resource->locked_for_write); | 1050 resource_provider_->UnlockForWrite(resource_); |
| 1079 if (sync_token_.HasData()) | |
| 1080 resource->UpdateSyncToken(sync_token_); | |
| 1081 if (synchronized_) | |
| 1082 resource->SetSynchronized(); | |
| 1083 resource_provider_->UnlockForWrite(resource); | |
| 1084 } | 1051 } |
| 1085 | 1052 |
| 1086 ResourceProvider::ScopedTextureProvider::ScopedTextureProvider( | 1053 void ResourceProvider::PopulateSkBitmapWithResource(SkBitmap* sk_bitmap, |
| 1087 gpu::gles2::GLES2Interface* gl, | 1054 const Resource* resource) { |
| 1088 ScopedWriteLockGL* resource_lock, | |
| 1089 bool use_mailbox) | |
| 1090 : gl_(gl), use_mailbox_(use_mailbox) { | |
| 1091 if (use_mailbox_) { | |
| 1092 texture_id_ = gl_->CreateAndConsumeTextureCHROMIUM( | |
| 1093 resource_lock->target(), resource_lock->mailbox().name()); | |
| 1094 } else { | |
| 1095 texture_id_ = resource_lock->texture_id(); | |
| 1096 } | |
| 1097 DCHECK(texture_id_); | |
| 1098 } | |
| 1099 | |
| 1100 ResourceProvider::ScopedTextureProvider::~ScopedTextureProvider() { | |
| 1101 if (use_mailbox_) | |
| 1102 gl_->DeleteTextures(1, &texture_id_); | |
| 1103 } | |
| 1104 | |
| 1105 ResourceProvider::ScopedSkSurfaceProvider::ScopedSkSurfaceProvider( | |
| 1106 ContextProvider* context_provider, | |
| 1107 ScopedWriteLockGL* resource_lock, | |
| 1108 bool use_mailbox, | |
| 1109 bool use_distance_field_text, | |
| 1110 bool can_use_lcd_text, | |
| 1111 int msaa_sample_count) | |
| 1112 : texture_provider_(context_provider->ContextGL(), | |
| 1113 resource_lock, | |
| 1114 use_mailbox) { | |
| 1115 GrGLTextureInfo texture_info; | |
| 1116 texture_info.fID = texture_provider_.texture_id(); | |
| 1117 texture_info.fTarget = resource_lock->target(); | |
| 1118 GrBackendTextureDesc desc; | |
| 1119 desc.fFlags = kRenderTarget_GrBackendTextureFlag; | |
| 1120 desc.fWidth = resource_lock->size().width(); | |
| 1121 desc.fHeight = resource_lock->size().height(); | |
| 1122 desc.fConfig = ToGrPixelConfig(resource_lock->format()); | |
| 1123 desc.fOrigin = kTopLeft_GrSurfaceOrigin; | |
| 1124 desc.fTextureHandle = skia::GrGLTextureInfoToGrBackendObject(texture_info); | |
| 1125 desc.fSampleCnt = msaa_sample_count; | |
| 1126 | |
| 1127 uint32_t flags = | |
| 1128 use_distance_field_text ? SkSurfaceProps::kUseDistanceFieldFonts_Flag : 0; | |
| 1129 // Use unknown pixel geometry to disable LCD text. | |
| 1130 SkSurfaceProps surface_props(flags, kUnknown_SkPixelGeometry); | |
| 1131 if (can_use_lcd_text) { | |
| 1132 // LegacyFontHost will get LCD text and skia figures out what type to use. | |
| 1133 surface_props = | |
| 1134 SkSurfaceProps(flags, SkSurfaceProps::kLegacyFontHost_InitType); | |
| 1135 } | |
| 1136 sk_surface_ = SkSurface::MakeFromBackendTextureAsRenderTarget( | |
| 1137 context_provider->GrContext(), desc, &surface_props); | |
| 1138 } | |
| 1139 | |
| 1140 ResourceProvider::ScopedSkSurfaceProvider::~ScopedSkSurfaceProvider() { | |
| 1141 if (sk_surface_.get()) { | |
| 1142 sk_surface_->prepareForExternalIO(); | |
| 1143 sk_surface_.reset(); | |
| 1144 } | |
| 1145 } | |
| 1146 | |
| 1147 void ResourceProvider::PopulateSkBitmapWithResource( | |
| 1148 SkBitmap* sk_bitmap, const Resource* resource) { | |
| 1149 DCHECK_EQ(RGBA_8888, resource->format); | 1055 DCHECK_EQ(RGBA_8888, resource->format); |
| 1150 SkImageInfo info = SkImageInfo::MakeN32Premul(resource->size.width(), | 1056 SkImageInfo info = SkImageInfo::MakeN32Premul(resource->size.width(), |
| 1151 resource->size.height()); | 1057 resource->size.height()); |
| 1152 sk_bitmap->installPixels(info, resource->pixels, info.minRowBytes()); | 1058 sk_bitmap->installPixels(info, resource->pixels, info.minRowBytes()); |
| 1153 } | 1059 } |
| 1154 | 1060 |
| 1155 ResourceProvider::ScopedReadLockSoftware::ScopedReadLockSoftware( | 1061 ResourceProvider::ScopedReadLockSoftware::ScopedReadLockSoftware( |
| 1156 ResourceProvider* resource_provider, | 1062 ResourceProvider* resource_provider, |
| 1157 ResourceId resource_id) | 1063 ResourceId resource_id) |
| 1158 : resource_provider_(resource_provider), resource_id_(resource_id) { | 1064 : resource_provider_(resource_provider), resource_id_(resource_id) { |
| 1159 const Resource* resource = resource_provider->LockForRead(resource_id); | 1065 const Resource* resource = resource_provider->LockForRead(resource_id); |
| 1160 ResourceProvider::PopulateSkBitmapWithResource(&sk_bitmap_, resource); | 1066 ResourceProvider::PopulateSkBitmapWithResource(&sk_bitmap_, resource); |
| 1161 } | 1067 } |
| 1162 | 1068 |
| 1163 ResourceProvider::ScopedReadLockSoftware::~ScopedReadLockSoftware() { | 1069 ResourceProvider::ScopedReadLockSoftware::~ScopedReadLockSoftware() { |
| 1164 resource_provider_->UnlockForRead(resource_id_); | 1070 resource_provider_->UnlockForRead(resource_id_); |
| 1165 } | 1071 } |
| 1166 | 1072 |
| 1167 ResourceProvider::ScopedWriteLockSoftware::ScopedWriteLockSoftware( | 1073 ResourceProvider::ScopedWriteLockSoftware::ScopedWriteLockSoftware( |
| 1168 ResourceProvider* resource_provider, | 1074 ResourceProvider* resource_provider, |
| 1169 ResourceId resource_id) | 1075 ResourceId resource_id) |
| 1170 : resource_provider_(resource_provider), resource_id_(resource_id) { | 1076 : resource_provider_(resource_provider), |
| 1171 ResourceProvider::PopulateSkBitmapWithResource( | 1077 resource_(resource_provider->LockForWrite(resource_id)) { |
| 1172 &sk_bitmap_, resource_provider->LockForWrite(resource_id)); | 1078 ResourceProvider::PopulateSkBitmapWithResource(&sk_bitmap_, resource_); |
| 1173 DCHECK(valid()); | 1079 DCHECK(valid()); |
| 1174 } | 1080 } |
| 1175 | 1081 |
| 1176 ResourceProvider::ScopedWriteLockSoftware::~ScopedWriteLockSoftware() { | 1082 ResourceProvider::ScopedWriteLockSoftware::~ScopedWriteLockSoftware() { |
| 1177 DCHECK(thread_checker_.CalledOnValidThread()); | 1083 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1178 Resource* resource = resource_provider_->GetResource(resource_id_); | 1084 resource_provider_->UnlockForWrite(resource_); |
| 1179 DCHECK(resource); | |
| 1180 resource->SetSynchronized(); | |
| 1181 resource_provider_->UnlockForWrite(resource); | |
| 1182 } | 1085 } |
| 1183 | 1086 |
| 1184 ResourceProvider::ScopedWriteLockGpuMemoryBuffer:: | 1087 ResourceProvider::ScopedWriteLockGpuMemoryBuffer:: |
| 1185 ScopedWriteLockGpuMemoryBuffer(ResourceProvider* resource_provider, | 1088 ScopedWriteLockGpuMemoryBuffer(ResourceProvider* resource_provider, |
| 1186 ResourceId resource_id) | 1089 ResourceId resource_id) |
| 1187 : resource_provider_(resource_provider), resource_id_(resource_id) { | 1090 : resource_provider_(resource_provider), |
| 1188 Resource* resource = resource_provider->LockForWrite(resource_id); | 1091 resource_(resource_provider->LockForWrite(resource_id)) { |
| 1189 DCHECK(IsGpuResourceType(resource->type)); | 1092 DCHECK(IsGpuResourceType(resource_->type)); |
| 1190 format_ = resource->format; | 1093 gpu_memory_buffer_ = std::move(resource_->gpu_memory_buffer); |
| 1191 size_ = resource->size; | 1094 resource_->gpu_memory_buffer = nullptr; |
| 1192 gpu_memory_buffer_ = std::move(resource->gpu_memory_buffer); | |
| 1193 resource->gpu_memory_buffer = nullptr; | |
| 1194 } | 1095 } |
| 1195 | 1096 |
| 1196 ResourceProvider::ScopedWriteLockGpuMemoryBuffer:: | 1097 ResourceProvider::ScopedWriteLockGpuMemoryBuffer:: |
| 1197 ~ScopedWriteLockGpuMemoryBuffer() { | 1098 ~ScopedWriteLockGpuMemoryBuffer() { |
| 1198 DCHECK(thread_checker_.CalledOnValidThread()); | 1099 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1199 Resource* resource = resource_provider_->GetResource(resource_id_); | 1100 resource_provider_->UnlockForWrite(resource_); |
| 1200 DCHECK(resource); | 1101 if (!gpu_memory_buffer_) |
| 1201 if (gpu_memory_buffer_) { | 1102 return; |
| 1202 DCHECK(!resource->gpu_memory_buffer); | 1103 |
| 1203 resource_provider_->LazyCreate(resource); | 1104 DCHECK(!resource_->gpu_memory_buffer); |
| 1204 resource->gpu_memory_buffer = std::move(gpu_memory_buffer_); | 1105 resource_provider_->LazyCreate(resource_); |
| 1205 if (resource->gpu_memory_buffer) | 1106 resource_->gpu_memory_buffer = std::move(gpu_memory_buffer_); |
| 1206 resource->gpu_memory_buffer_id = resource->gpu_memory_buffer->GetId(); | 1107 if (resource_->gpu_memory_buffer) |
| 1207 resource->allocated = true; | 1108 resource_->gpu_memory_buffer_id = resource_->gpu_memory_buffer->GetId(); |
| 1208 resource_provider_->LazyCreateImage(resource); | 1109 resource_->allocated = true; |
| 1209 resource->dirty_image = true; | 1110 resource_provider_->LazyCreateImage(resource_); |
| 1210 resource->is_overlay_candidate = true; | 1111 resource_->dirty_image = true; |
| 1211 // GpuMemoryBuffer provides direct access to the memory used by the GPU. | 1112 resource_->is_overlay_candidate = true; |
| 1212 // Read lock fences are required to ensure that we're not trying to map a | 1113 resource_->SetSynchronized(); |
| 1213 // buffer that is currently in-use by the GPU. | 1114 |
| 1214 resource->read_lock_fences_enabled = true; | 1115 // GpuMemoryBuffer provides direct access to the memory used by the GPU. |
| 1215 } | 1116 // Read lock fences are required to ensure that we're not trying to map a |
| 1216 resource->SetSynchronized(); | 1117 // buffer that is currently in-use by the GPU. |
| 1217 resource_provider_->UnlockForWrite(resource); | 1118 resource_->read_lock_fences_enabled = true; |
| 1218 } | 1119 } |
| 1219 | 1120 |
| 1220 gfx::GpuMemoryBuffer* | 1121 gfx::GpuMemoryBuffer* |
| 1221 ResourceProvider::ScopedWriteLockGpuMemoryBuffer::GetGpuMemoryBuffer() { | 1122 ResourceProvider::ScopedWriteLockGpuMemoryBuffer::GetGpuMemoryBuffer() { |
| 1222 if (!gpu_memory_buffer_) { | 1123 if (!gpu_memory_buffer_) { |
| 1223 gpu_memory_buffer_ = | 1124 gpu_memory_buffer_ = |
| 1224 resource_provider_->gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer( | 1125 resource_provider_->gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer( |
| 1225 size_, BufferFormat(format_), | 1126 resource_->size, BufferFormat(resource_->format), |
| 1226 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE, gpu::kNullSurfaceHandle); | 1127 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE, gpu::kNullSurfaceHandle); |
| 1227 } | 1128 } |
| 1228 return gpu_memory_buffer_.get(); | 1129 return gpu_memory_buffer_.get(); |
| 1229 } | 1130 } |
| 1230 | 1131 |
| 1132 ResourceProvider::ScopedWriteLockGr::ScopedWriteLockGr( |
| 1133 ResourceProvider* resource_provider, |
| 1134 ResourceId resource_id) |
| 1135 : resource_provider_(resource_provider), |
| 1136 resource_(resource_provider->LockForWrite(resource_id)), |
| 1137 set_sync_token_(false) { |
| 1138 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1139 resource_provider_->LazyAllocate(resource_); |
| 1140 if (resource_->image_id && resource_->dirty_image) |
| 1141 resource_provider_->BindImageForSampling(resource_); |
| 1142 } |
| 1143 |
| 1144 ResourceProvider::ScopedWriteLockGr::~ScopedWriteLockGr() { |
| 1145 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1146 DCHECK(resource_->locked_for_write); |
| 1147 if (set_sync_token_) |
| 1148 resource_->UpdateSyncToken(sync_token_); |
| 1149 |
| 1150 resource_provider_->UnlockForWrite(resource_); |
| 1151 } |
| 1152 |
| 1153 void ResourceProvider::ScopedWriteLockGr::InitSkSurface( |
| 1154 GrContext* gr_context, |
| 1155 bool use_distance_field_text, |
| 1156 bool can_use_lcd_text, |
| 1157 int msaa_sample_count) { |
| 1158 DCHECK(resource_->locked_for_write); |
| 1159 |
| 1160 GrGLTextureInfo texture_info; |
| 1161 texture_info.fID = resource_->gl_id; |
| 1162 texture_info.fTarget = resource_->target; |
| 1163 GrBackendTextureDesc desc; |
| 1164 desc.fFlags = kRenderTarget_GrBackendTextureFlag; |
| 1165 desc.fWidth = resource_->size.width(); |
| 1166 desc.fHeight = resource_->size.height(); |
| 1167 desc.fConfig = ToGrPixelConfig(resource_->format); |
| 1168 desc.fOrigin = kTopLeft_GrSurfaceOrigin; |
| 1169 desc.fTextureHandle = skia::GrGLTextureInfoToGrBackendObject(texture_info); |
| 1170 desc.fSampleCnt = msaa_sample_count; |
| 1171 |
| 1172 uint32_t flags = |
| 1173 use_distance_field_text ? SkSurfaceProps::kUseDistanceFieldFonts_Flag : 0; |
| 1174 // Use unknown pixel geometry to disable LCD text. |
| 1175 SkSurfaceProps surface_props(flags, kUnknown_SkPixelGeometry); |
| 1176 if (can_use_lcd_text) { |
| 1177 // LegacyFontHost will get LCD text and skia figures out what type to use. |
| 1178 surface_props = |
| 1179 SkSurfaceProps(flags, SkSurfaceProps::kLegacyFontHost_InitType); |
| 1180 } |
| 1181 sk_surface_ = SkSurface::MakeFromBackendTextureAsRenderTarget( |
| 1182 gr_context, desc, &surface_props); |
| 1183 } |
| 1184 |
| 1185 void ResourceProvider::ScopedWriteLockGr::ReleaseSkSurface() { |
| 1186 DCHECK(sk_surface_); |
| 1187 sk_surface_->prepareForExternalIO(); |
| 1188 sk_surface_.reset(); |
| 1189 } |
| 1190 |
| 1231 ResourceProvider::SynchronousFence::SynchronousFence( | 1191 ResourceProvider::SynchronousFence::SynchronousFence( |
| 1232 gpu::gles2::GLES2Interface* gl) | 1192 gpu::gles2::GLES2Interface* gl) |
| 1233 : gl_(gl), has_synchronized_(true) { | 1193 : gl_(gl), has_synchronized_(true) {} |
| 1234 } | |
| 1235 | 1194 |
| 1236 ResourceProvider::SynchronousFence::~SynchronousFence() { | 1195 ResourceProvider::SynchronousFence::~SynchronousFence() {} |
| 1237 } | |
| 1238 | 1196 |
| 1239 void ResourceProvider::SynchronousFence::Set() { | 1197 void ResourceProvider::SynchronousFence::Set() { |
| 1240 has_synchronized_ = false; | 1198 has_synchronized_ = false; |
| 1241 } | 1199 } |
| 1242 | 1200 |
| 1243 bool ResourceProvider::SynchronousFence::HasPassed() { | 1201 bool ResourceProvider::SynchronousFence::HasPassed() { |
| 1244 if (!has_synchronized_) { | 1202 if (!has_synchronized_) { |
| 1245 has_synchronized_ = true; | 1203 has_synchronized_ = true; |
| 1246 Synchronize(); | 1204 Synchronize(); |
| 1247 } | 1205 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1285 void ResourceProvider::DestroyChildInternal(ChildMap::iterator it, | 1243 void ResourceProvider::DestroyChildInternal(ChildMap::iterator it, |
| 1286 DeleteStyle style) { | 1244 DeleteStyle style) { |
| 1287 DCHECK(thread_checker_.CalledOnValidThread()); | 1245 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1288 | 1246 |
| 1289 Child& child = it->second; | 1247 Child& child = it->second; |
| 1290 DCHECK(style == FOR_SHUTDOWN || !child.marked_for_deletion); | 1248 DCHECK(style == FOR_SHUTDOWN || !child.marked_for_deletion); |
| 1291 | 1249 |
| 1292 ResourceIdArray resources_for_child; | 1250 ResourceIdArray resources_for_child; |
| 1293 | 1251 |
| 1294 for (ResourceIdMap::iterator child_it = child.child_to_parent_map.begin(); | 1252 for (ResourceIdMap::iterator child_it = child.child_to_parent_map.begin(); |
| 1295 child_it != child.child_to_parent_map.end(); | 1253 child_it != child.child_to_parent_map.end(); ++child_it) { |
| 1296 ++child_it) { | |
| 1297 ResourceId id = child_it->second; | 1254 ResourceId id = child_it->second; |
| 1298 resources_for_child.push_back(id); | 1255 resources_for_child.push_back(id); |
| 1299 } | 1256 } |
| 1300 | 1257 |
| 1301 child.marked_for_deletion = true; | 1258 child.marked_for_deletion = true; |
| 1302 | 1259 |
| 1303 DeleteAndReturnUnusedResourcesToChild(it, style, resources_for_child); | 1260 DeleteAndReturnUnusedResourcesToChild(it, style, resources_for_child); |
| 1304 } | 1261 } |
| 1305 | 1262 |
| 1306 const ResourceProvider::ResourceIdMap& ResourceProvider::GetChildToParentMap( | 1263 const ResourceProvider::ResourceIdMap& ResourceProvider::GetChildToParentMap( |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1384 | 1341 |
| 1385 TransferableResource resource; | 1342 TransferableResource resource; |
| 1386 TransferResource(source, id, &resource); | 1343 TransferResource(source, id, &resource); |
| 1387 | 1344 |
| 1388 source->exported_count++; | 1345 source->exported_count++; |
| 1389 list->push_back(resource); | 1346 list->push_back(resource); |
| 1390 } | 1347 } |
| 1391 } | 1348 } |
| 1392 | 1349 |
| 1393 void ResourceProvider::ReceiveFromChild( | 1350 void ResourceProvider::ReceiveFromChild( |
| 1394 int child, const TransferableResourceArray& resources) { | 1351 int child, |
| 1352 const TransferableResourceArray& resources) { |
| 1395 DCHECK(thread_checker_.CalledOnValidThread()); | 1353 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1396 GLES2Interface* gl = ContextGL(); | 1354 GLES2Interface* gl = ContextGL(); |
| 1397 Child& child_info = children_.find(child)->second; | 1355 Child& child_info = children_.find(child)->second; |
| 1398 DCHECK(!child_info.marked_for_deletion); | 1356 DCHECK(!child_info.marked_for_deletion); |
| 1399 for (TransferableResourceArray::const_iterator it = resources.begin(); | 1357 for (TransferableResourceArray::const_iterator it = resources.begin(); |
| 1400 it != resources.end(); | 1358 it != resources.end(); ++it) { |
| 1401 ++it) { | |
| 1402 ResourceIdMap::iterator resource_in_map_it = | 1359 ResourceIdMap::iterator resource_in_map_it = |
| 1403 child_info.child_to_parent_map.find(it->id); | 1360 child_info.child_to_parent_map.find(it->id); |
| 1404 if (resource_in_map_it != child_info.child_to_parent_map.end()) { | 1361 if (resource_in_map_it != child_info.child_to_parent_map.end()) { |
| 1405 Resource* resource = GetResource(resource_in_map_it->second); | 1362 Resource* resource = GetResource(resource_in_map_it->second); |
| 1406 resource->marked_for_deletion = false; | 1363 resource->marked_for_deletion = false; |
| 1407 resource->imported_count++; | 1364 resource->imported_count++; |
| 1408 continue; | 1365 continue; |
| 1409 } | 1366 } |
| 1410 | 1367 |
| 1411 if ((!it->is_software && !gl) || | 1368 if ((!it->is_software && !gl) || |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1451 const ResourceIdSet& resources_from_child) { | 1408 const ResourceIdSet& resources_from_child) { |
| 1452 DCHECK(thread_checker_.CalledOnValidThread()); | 1409 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1453 | 1410 |
| 1454 ChildMap::iterator child_it = children_.find(child); | 1411 ChildMap::iterator child_it = children_.find(child); |
| 1455 DCHECK(child_it != children_.end()); | 1412 DCHECK(child_it != children_.end()); |
| 1456 Child& child_info = child_it->second; | 1413 Child& child_info = child_it->second; |
| 1457 DCHECK(!child_info.marked_for_deletion); | 1414 DCHECK(!child_info.marked_for_deletion); |
| 1458 | 1415 |
| 1459 ResourceIdArray unused; | 1416 ResourceIdArray unused; |
| 1460 for (ResourceIdMap::iterator it = child_info.child_to_parent_map.begin(); | 1417 for (ResourceIdMap::iterator it = child_info.child_to_parent_map.begin(); |
| 1461 it != child_info.child_to_parent_map.end(); | 1418 it != child_info.child_to_parent_map.end(); ++it) { |
| 1462 ++it) { | |
| 1463 ResourceId local_id = it->second; | 1419 ResourceId local_id = it->second; |
| 1464 bool resource_is_in_use = resources_from_child.count(it->first) > 0; | 1420 bool resource_is_in_use = resources_from_child.count(it->first) > 0; |
| 1465 if (!resource_is_in_use) | 1421 if (!resource_is_in_use) |
| 1466 unused.push_back(local_id); | 1422 unused.push_back(local_id); |
| 1467 } | 1423 } |
| 1468 DeleteAndReturnUnusedResourcesToChild(child_it, NORMAL, unused); | 1424 DeleteAndReturnUnusedResourcesToChild(child_it, NORMAL, unused); |
| 1469 } | 1425 } |
| 1470 | 1426 |
| 1471 void ResourceProvider::ReceiveReturnsFromParent( | 1427 void ResourceProvider::ReceiveReturnsFromParent( |
| 1472 const ReturnedResourceArray& resources) { | 1428 const ReturnedResourceArray& resources) { |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1777 if (resource->type == RESOURCE_TYPE_GPU_MEMORY_BUFFER) { | 1733 if (resource->type == RESOURCE_TYPE_GPU_MEMORY_BUFFER) { |
| 1778 resource->gpu_memory_buffer = | 1734 resource->gpu_memory_buffer = |
| 1779 gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer( | 1735 gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer( |
| 1780 size, BufferFormat(format), | 1736 size, BufferFormat(format), |
| 1781 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE, gpu::kNullSurfaceHandle); | 1737 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE, gpu::kNullSurfaceHandle); |
| 1782 if (resource->gpu_memory_buffer) | 1738 if (resource->gpu_memory_buffer) |
| 1783 resource->gpu_memory_buffer_id = resource->gpu_memory_buffer->GetId(); | 1739 resource->gpu_memory_buffer_id = resource->gpu_memory_buffer->GetId(); |
| 1784 LazyCreateImage(resource); | 1740 LazyCreateImage(resource); |
| 1785 resource->dirty_image = true; | 1741 resource->dirty_image = true; |
| 1786 resource->is_overlay_candidate = true; | 1742 resource->is_overlay_candidate = true; |
| 1787 // GpuMemoryBuffer provides direct access to the memory used by the GPU. | |
| 1788 // Read lock fences are required to ensure that we're not trying to map a | |
| 1789 // buffer that is currently in-use by the GPU. | |
| 1790 resource->read_lock_fences_enabled = true; | |
| 1791 } else if (use_texture_storage_ext_ && | 1743 } else if (use_texture_storage_ext_ && |
| 1792 IsFormatSupportedForStorage(format, use_texture_format_bgra_) && | 1744 IsFormatSupportedForStorage(format, use_texture_format_bgra_) && |
| 1793 (resource->hint & TEXTURE_HINT_IMMUTABLE)) { | 1745 (resource->hint & TEXTURE_HINT_IMMUTABLE)) { |
| 1794 GLenum storage_format = TextureToStorageFormat(format); | 1746 GLenum storage_format = TextureToStorageFormat(format); |
| 1795 gl->TexStorage2DEXT(resource->target, 1, storage_format, size.width(), | 1747 gl->TexStorage2DEXT(resource->target, 1, storage_format, size.width(), |
| 1796 size.height()); | 1748 size.height()); |
| 1797 } else { | 1749 } else { |
| 1798 // ETC1 does not support preallocation. | 1750 // ETC1 does not support preallocation. |
| 1799 if (format != ETC1) { | 1751 if (format != ETC1) { |
| 1800 gl->TexImage2D(resource->target, 0, GLInternalFormat(format), | 1752 gl->TexImage2D(resource->target, 0, GLInternalFormat(format), |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1957 | 1909 |
| 1958 const int kImportance = 2; | 1910 const int kImportance = 2; |
| 1959 pmd->CreateSharedGlobalAllocatorDump(guid); | 1911 pmd->CreateSharedGlobalAllocatorDump(guid); |
| 1960 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); | 1912 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); |
| 1961 } | 1913 } |
| 1962 | 1914 |
| 1963 return true; | 1915 return true; |
| 1964 } | 1916 } |
| 1965 | 1917 |
| 1966 } // namespace cc | 1918 } // namespace cc |
| OLD | NEW |