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

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

Issue 2387333003: cc: Set sync token on resource even if context is lost. (Closed)
Patch Set: danakj's review Created 4 years, 2 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
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 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after
1094 target_(resource_provider->BindForSampling(resource_id, unit_, filter)) {} 1094 target_(resource_provider->BindForSampling(resource_id, unit_, filter)) {}
1095 1095
1096 ResourceProvider::ScopedSamplerGL::~ScopedSamplerGL() {} 1096 ResourceProvider::ScopedSamplerGL::~ScopedSamplerGL() {}
1097 1097
1098 ResourceProvider::ScopedWriteLockGL::ScopedWriteLockGL( 1098 ResourceProvider::ScopedWriteLockGL::ScopedWriteLockGL(
1099 ResourceProvider* resource_provider, 1099 ResourceProvider* resource_provider,
1100 ResourceId resource_id, 1100 ResourceId resource_id,
1101 bool create_mailbox) 1101 bool create_mailbox)
1102 : resource_provider_(resource_provider), 1102 : resource_provider_(resource_provider),
1103 resource_id_(resource_id), 1103 resource_id_(resource_id),
1104 has_sync_token_(false),
1104 synchronized_(false) { 1105 synchronized_(false) {
1105 DCHECK(thread_checker_.CalledOnValidThread()); 1106 DCHECK(thread_checker_.CalledOnValidThread());
1106 Resource* resource = resource_provider->LockForWrite(resource_id); 1107 Resource* resource = resource_provider->LockForWrite(resource_id);
1107 resource_provider_->LazyAllocate(resource); 1108 resource_provider_->LazyAllocate(resource);
1108 if (resource->image_id && resource->dirty_image) 1109 if (resource->image_id && resource->dirty_image)
1109 resource_provider_->BindImageForSampling(resource); 1110 resource_provider_->BindImageForSampling(resource);
1110 if (create_mailbox) { 1111 if (create_mailbox) {
1111 resource_provider_->CreateMailboxAndBindResource( 1112 resource_provider_->CreateMailboxAndBindResource(
1112 resource_provider_->ContextGL(), resource); 1113 resource_provider_->ContextGL(), resource);
1113 } 1114 }
1114 texture_id_ = resource->gl_id; 1115 texture_id_ = resource->gl_id;
1115 target_ = resource->target; 1116 target_ = resource->target;
1116 format_ = resource->format; 1117 format_ = resource->format;
1117 size_ = resource->size; 1118 size_ = resource->size;
1118 mailbox_ = resource->mailbox(); 1119 mailbox_ = resource->mailbox();
1119 sk_color_space_ = resource_provider->GetResourceSkColorSpace(resource); 1120 sk_color_space_ = resource_provider->GetResourceSkColorSpace(resource);
1120 } 1121 }
1121 1122
1122 ResourceProvider::ScopedWriteLockGL::~ScopedWriteLockGL() { 1123 ResourceProvider::ScopedWriteLockGL::~ScopedWriteLockGL() {
1123 DCHECK(thread_checker_.CalledOnValidThread()); 1124 DCHECK(thread_checker_.CalledOnValidThread());
1124 Resource* resource = resource_provider_->GetResource(resource_id_); 1125 Resource* resource = resource_provider_->GetResource(resource_id_);
1125 DCHECK(resource->locked_for_write); 1126 DCHECK(resource->locked_for_write);
1126 if (sync_token_.HasData()) 1127 // It's not sufficient to check sync_token_.HasData() here because the sync
1128 // might be null because of context loss. Even in that case we want to set the
1129 // sync token because it's checked in PrepareSendToParent while drawing.
1130 if (has_sync_token_)
1127 resource->UpdateSyncToken(sync_token_); 1131 resource->UpdateSyncToken(sync_token_);
1128 if (synchronized_) 1132 if (synchronized_)
1129 resource->SetSynchronized(); 1133 resource->SetSynchronized();
1130 resource_provider_->UnlockForWrite(resource); 1134 resource_provider_->UnlockForWrite(resource);
1131 } 1135 }
1132 1136
1133 ResourceProvider::ScopedTextureProvider::ScopedTextureProvider( 1137 ResourceProvider::ScopedTextureProvider::ScopedTextureProvider(
1134 gpu::gles2::GLES2Interface* gl, 1138 gpu::gles2::GLES2Interface* gl,
1135 ScopedWriteLockGL* resource_lock, 1139 ScopedWriteLockGL* resource_lock,
1136 bool use_mailbox) 1140 bool use_mailbox)
(...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after
2055 2059
2056 const int kImportance = 2; 2060 const int kImportance = 2;
2057 pmd->CreateSharedGlobalAllocatorDump(guid); 2061 pmd->CreateSharedGlobalAllocatorDump(guid);
2058 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); 2062 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance);
2059 } 2063 }
2060 2064
2061 return true; 2065 return true;
2062 } 2066 }
2063 2067
2064 } // namespace cc 2068 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698