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 <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/atomic_sequence_num.h" | 10 #include "base/atomic_sequence_num.h" |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 image_id(0), | 305 image_id(0), |
306 bound_image_id(0), | 306 bound_image_id(0), |
307 hint(TEXTURE_HINT_IMMUTABLE), | 307 hint(TEXTURE_HINT_IMMUTABLE), |
308 type(RESOURCE_TYPE_BITMAP), | 308 type(RESOURCE_TYPE_BITMAP), |
309 format(RGBA_8888), | 309 format(RGBA_8888), |
310 shared_bitmap_id(bitmap_id), | 310 shared_bitmap_id(bitmap_id), |
311 shared_bitmap(NULL), | 311 shared_bitmap(NULL), |
312 gpu_memory_buffer(NULL) {} | 312 gpu_memory_buffer(NULL) {} |
313 | 313 |
314 ResourceProvider::Child::Child() | 314 ResourceProvider::Child::Child() |
315 : marked_for_deletion(false), needs_sync_points(true) { | 315 : marked_for_deletion(false), needs_sync_tokens(true) {} |
316 } | |
317 | 316 |
318 ResourceProvider::Child::~Child() {} | 317 ResourceProvider::Child::~Child() {} |
319 | 318 |
320 scoped_ptr<ResourceProvider> ResourceProvider::Create( | 319 scoped_ptr<ResourceProvider> ResourceProvider::Create( |
321 OutputSurface* output_surface, | 320 OutputSurface* output_surface, |
322 SharedBitmapManager* shared_bitmap_manager, | 321 SharedBitmapManager* shared_bitmap_manager, |
323 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 322 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
324 BlockingTaskRunner* blocking_main_thread_task_runner, | 323 BlockingTaskRunner* blocking_main_thread_task_runner, |
325 int highp_threshold_min, | 324 int highp_threshold_min, |
326 size_t id_allocation_chunk_size, | 325 size_t id_allocation_chunk_size, |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 gl->DeleteQueriesEXT(1, &resource->gl_read_lock_query_id); | 554 gl->DeleteQueriesEXT(1, &resource->gl_read_lock_query_id); |
556 } | 555 } |
557 if (resource->gl_pixel_buffer_id) { | 556 if (resource->gl_pixel_buffer_id) { |
558 DCHECK(resource->origin == Resource::INTERNAL); | 557 DCHECK(resource->origin == Resource::INTERNAL); |
559 GLES2Interface* gl = ContextGL(); | 558 GLES2Interface* gl = ContextGL(); |
560 DCHECK(gl); | 559 DCHECK(gl); |
561 gl->DeleteBuffers(1, &resource->gl_pixel_buffer_id); | 560 gl->DeleteBuffers(1, &resource->gl_pixel_buffer_id); |
562 } | 561 } |
563 if (resource->origin == Resource::EXTERNAL) { | 562 if (resource->origin == Resource::EXTERNAL) { |
564 DCHECK(resource->mailbox.IsValid()); | 563 DCHECK(resource->mailbox.IsValid()); |
565 GLuint sync_point = resource->mailbox.sync_point(); | 564 gpu::SyncToken sync_token = resource->mailbox.sync_token(); |
566 if (resource->type == RESOURCE_TYPE_GL_TEXTURE) { | 565 if (resource->type == RESOURCE_TYPE_GL_TEXTURE) { |
567 DCHECK(resource->mailbox.IsTexture()); | 566 DCHECK(resource->mailbox.IsTexture()); |
568 lost_resource |= lost_output_surface_; | 567 lost_resource |= lost_output_surface_; |
569 GLES2Interface* gl = ContextGL(); | 568 GLES2Interface* gl = ContextGL(); |
570 DCHECK(gl); | 569 DCHECK(gl); |
571 if (resource->gl_id) { | 570 if (resource->gl_id) { |
572 gl->DeleteTextures(1, &resource->gl_id); | 571 gl->DeleteTextures(1, &resource->gl_id); |
573 resource->gl_id = 0; | 572 resource->gl_id = 0; |
574 if (!lost_resource) | 573 if (!lost_resource) |
575 sync_point = gl->InsertSyncPointCHROMIUM(); | 574 sync_token = gpu::SyncToken(gl->InsertSyncPointCHROMIUM()); |
576 } | 575 } |
577 } else { | 576 } else { |
578 DCHECK(resource->mailbox.IsSharedMemory()); | 577 DCHECK(resource->mailbox.IsSharedMemory()); |
579 resource->shared_bitmap = nullptr; | 578 resource->shared_bitmap = nullptr; |
580 resource->pixels = nullptr; | 579 resource->pixels = nullptr; |
581 } | 580 } |
582 resource->release_callback_impl.Run( | 581 resource->release_callback_impl.Run(sync_token, lost_resource, |
583 sync_point, lost_resource, blocking_main_thread_task_runner_); | 582 blocking_main_thread_task_runner_); |
584 } | 583 } |
585 if (resource->gl_id) { | 584 if (resource->gl_id) { |
586 GLES2Interface* gl = ContextGL(); | 585 GLES2Interface* gl = ContextGL(); |
587 DCHECK(gl); | 586 DCHECK(gl); |
588 gl->DeleteTextures(1, &resource->gl_id); | 587 gl->DeleteTextures(1, &resource->gl_id); |
589 resource->gl_id = 0; | 588 resource->gl_id = 0; |
590 } | 589 } |
591 if (resource->shared_bitmap) { | 590 if (resource->shared_bitmap) { |
592 DCHECK(resource->origin != Resource::EXTERNAL); | 591 DCHECK(resource->origin != Resource::EXTERNAL); |
593 DCHECK_EQ(RESOURCE_TYPE_BITMAP, resource->type); | 592 DCHECK_EQ(RESOURCE_TYPE_BITMAP, resource->type); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 DCHECK_EQ(resource->exported_count, 0); | 679 DCHECK_EQ(resource->exported_count, 0); |
681 // Uninitialized! Call SetPixels or LockForWrite first. | 680 // Uninitialized! Call SetPixels or LockForWrite first. |
682 DCHECK(resource->allocated); | 681 DCHECK(resource->allocated); |
683 | 682 |
684 LazyCreate(resource); | 683 LazyCreate(resource); |
685 | 684 |
686 if (resource->type == RESOURCE_TYPE_GL_TEXTURE && !resource->gl_id) { | 685 if (resource->type == RESOURCE_TYPE_GL_TEXTURE && !resource->gl_id) { |
687 DCHECK(resource->origin != Resource::INTERNAL); | 686 DCHECK(resource->origin != Resource::INTERNAL); |
688 DCHECK(resource->mailbox.IsTexture()); | 687 DCHECK(resource->mailbox.IsTexture()); |
689 | 688 |
690 // Mailbox sync_points must be processed by a call to | 689 // Mailbox sync_tokens must be processed by a call to |
691 // WaitSyncPointIfNeeded() prior to calling LockForRead(). | 690 // WaitSyncTokenIfNeeded() prior to calling LockForRead(). |
692 DCHECK(!resource->mailbox.sync_point()); | 691 DCHECK(!resource->mailbox.sync_token().HasData()); |
693 | 692 |
694 GLES2Interface* gl = ContextGL(); | 693 GLES2Interface* gl = ContextGL(); |
695 DCHECK(gl); | 694 DCHECK(gl); |
696 resource->gl_id = gl->CreateAndConsumeTextureCHROMIUM( | 695 resource->gl_id = gl->CreateAndConsumeTextureCHROMIUM( |
697 resource->mailbox.target(), resource->mailbox.name()); | 696 resource->mailbox.target(), resource->mailbox.name()); |
698 } | 697 } |
699 | 698 |
700 if (!resource->pixels && resource->has_shared_bitmap_id && | 699 if (!resource->pixels && resource->has_shared_bitmap_id && |
701 shared_bitmap_manager_) { | 700 shared_bitmap_manager_) { |
702 scoped_ptr<SharedBitmap> bitmap = | 701 scoped_ptr<SharedBitmap> bitmap = |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1080 DCHECK(thread_checker_.CalledOnValidThread()); | 1079 DCHECK(thread_checker_.CalledOnValidThread()); |
1081 | 1080 |
1082 Child child_info; | 1081 Child child_info; |
1083 child_info.return_callback = return_callback; | 1082 child_info.return_callback = return_callback; |
1084 | 1083 |
1085 int child = next_child_++; | 1084 int child = next_child_++; |
1086 children_[child] = child_info; | 1085 children_[child] = child_info; |
1087 return child; | 1086 return child; |
1088 } | 1087 } |
1089 | 1088 |
1090 void ResourceProvider::SetChildNeedsSyncPoints(int child_id, bool needs) { | 1089 void ResourceProvider::SetChildNeedsSyncTokens(int child_id, bool needs) { |
1091 ChildMap::iterator it = children_.find(child_id); | 1090 ChildMap::iterator it = children_.find(child_id); |
1092 DCHECK(it != children_.end()); | 1091 DCHECK(it != children_.end()); |
1093 it->second.needs_sync_points = needs; | 1092 it->second.needs_sync_tokens = needs; |
1094 } | 1093 } |
1095 | 1094 |
1096 void ResourceProvider::DestroyChild(int child_id) { | 1095 void ResourceProvider::DestroyChild(int child_id) { |
1097 ChildMap::iterator it = children_.find(child_id); | 1096 ChildMap::iterator it = children_.find(child_id); |
1098 DCHECK(it != children_.end()); | 1097 DCHECK(it != children_.end()); |
1099 DestroyChildInternal(it, NORMAL); | 1098 DestroyChildInternal(it, NORMAL); |
1100 } | 1099 } |
1101 | 1100 |
1102 void ResourceProvider::DestroyChildInternal(ChildMap::iterator it, | 1101 void ResourceProvider::DestroyChildInternal(ChildMap::iterator it, |
1103 DeleteStyle style) { | 1102 DeleteStyle style) { |
(...skipping 22 matching lines...) Expand all Loading... |
1126 ChildMap::const_iterator it = children_.find(child); | 1125 ChildMap::const_iterator it = children_.find(child); |
1127 DCHECK(it != children_.end()); | 1126 DCHECK(it != children_.end()); |
1128 DCHECK(!it->second.marked_for_deletion); | 1127 DCHECK(!it->second.marked_for_deletion); |
1129 return it->second.child_to_parent_map; | 1128 return it->second.child_to_parent_map; |
1130 } | 1129 } |
1131 | 1130 |
1132 void ResourceProvider::PrepareSendToParent(const ResourceIdArray& resources, | 1131 void ResourceProvider::PrepareSendToParent(const ResourceIdArray& resources, |
1133 TransferableResourceArray* list) { | 1132 TransferableResourceArray* list) { |
1134 DCHECK(thread_checker_.CalledOnValidThread()); | 1133 DCHECK(thread_checker_.CalledOnValidThread()); |
1135 GLES2Interface* gl = ContextGL(); | 1134 GLES2Interface* gl = ContextGL(); |
1136 bool need_sync_point = false; | 1135 bool need_sync_token = false; |
1137 for (ResourceIdArray::const_iterator it = resources.begin(); | 1136 for (ResourceIdArray::const_iterator it = resources.begin(); |
1138 it != resources.end(); | 1137 it != resources.end(); |
1139 ++it) { | 1138 ++it) { |
1140 TransferableResource resource; | 1139 TransferableResource resource; |
1141 TransferResource(gl, *it, &resource); | 1140 TransferResource(gl, *it, &resource); |
1142 if (!resource.mailbox_holder.sync_point && !resource.is_software) | 1141 need_sync_token |= (!resource.mailbox_holder.sync_token.HasData() && |
1143 need_sync_point = true; | 1142 !resource.is_software); |
1144 ++resources_.find(*it)->second.exported_count; | 1143 ++resources_.find(*it)->second.exported_count; |
1145 list->push_back(resource); | 1144 list->push_back(resource); |
1146 } | 1145 } |
1147 if (need_sync_point && | 1146 if (need_sync_token && |
1148 output_surface_->capabilities().delegated_sync_points_required) { | 1147 output_surface_->capabilities().delegated_sync_points_required) { |
1149 GLuint sync_point = gl->InsertSyncPointCHROMIUM(); | 1148 gpu::SyncToken sync_token(gl->InsertSyncPointCHROMIUM()); |
1150 for (TransferableResourceArray::iterator it = list->begin(); | 1149 for (TransferableResourceArray::iterator it = list->begin(); |
1151 it != list->end(); | 1150 it != list->end(); |
1152 ++it) { | 1151 ++it) { |
1153 if (!it->mailbox_holder.sync_point) | 1152 if (!it->mailbox_holder.sync_token.HasData()) |
1154 it->mailbox_holder.sync_point = sync_point; | 1153 it->mailbox_holder.sync_token = sync_token; |
1155 } | 1154 } |
1156 } | 1155 } |
1157 } | 1156 } |
1158 | 1157 |
1159 void ResourceProvider::ReceiveFromChild( | 1158 void ResourceProvider::ReceiveFromChild( |
1160 int child, const TransferableResourceArray& resources) { | 1159 int child, const TransferableResourceArray& resources) { |
1161 DCHECK(thread_checker_.CalledOnValidThread()); | 1160 DCHECK(thread_checker_.CalledOnValidThread()); |
1162 GLES2Interface* gl = ContextGL(); | 1161 GLES2Interface* gl = ContextGL(); |
1163 Child& child_info = children_.find(child)->second; | 1162 Child& child_info = children_.find(child)->second; |
1164 DCHECK(!child_info.marked_for_deletion); | 1163 DCHECK(!child_info.marked_for_deletion); |
(...skipping 24 matching lines...) Expand all Loading... |
1189 if (it->is_software) { | 1188 if (it->is_software) { |
1190 resource = InsertResource(local_id, | 1189 resource = InsertResource(local_id, |
1191 Resource(it->mailbox_holder.mailbox, it->size, | 1190 Resource(it->mailbox_holder.mailbox, it->size, |
1192 Resource::DELEGATED, GL_LINEAR)); | 1191 Resource::DELEGATED, GL_LINEAR)); |
1193 } else { | 1192 } else { |
1194 resource = InsertResource( | 1193 resource = InsertResource( |
1195 local_id, Resource(0, it->size, Resource::DELEGATED, | 1194 local_id, Resource(0, it->size, Resource::DELEGATED, |
1196 it->mailbox_holder.texture_target, it->filter, | 1195 it->mailbox_holder.texture_target, it->filter, |
1197 TEXTURE_HINT_IMMUTABLE, it->format)); | 1196 TEXTURE_HINT_IMMUTABLE, it->format)); |
1198 resource->mailbox = TextureMailbox(it->mailbox_holder.mailbox, | 1197 resource->mailbox = TextureMailbox(it->mailbox_holder.mailbox, |
1199 it->mailbox_holder.texture_target, | 1198 it->mailbox_holder.sync_token, |
1200 it->mailbox_holder.sync_point); | 1199 it->mailbox_holder.texture_target); |
1201 resource->read_lock_fences_enabled = it->read_lock_fences_enabled; | 1200 resource->read_lock_fences_enabled = it->read_lock_fences_enabled; |
1202 resource->is_overlay_candidate = it->is_overlay_candidate; | 1201 resource->is_overlay_candidate = it->is_overlay_candidate; |
1203 } | 1202 } |
1204 resource->child_id = child; | 1203 resource->child_id = child; |
1205 // Don't allocate a texture for a child. | 1204 // Don't allocate a texture for a child. |
1206 resource->allocated = true; | 1205 resource->allocated = true; |
1207 resource->imported_count = 1; | 1206 resource->imported_count = 1; |
1208 child_info.parent_to_child_map[local_id] = it->id; | 1207 child_info.parent_to_child_map[local_id] = it->id; |
1209 child_info.child_to_parent_map[it->id] = local_id; | 1208 child_info.child_to_parent_map[it->id] = local_id; |
1210 } | 1209 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1248 continue; | 1247 continue; |
1249 | 1248 |
1250 Resource* resource = &map_iterator->second; | 1249 Resource* resource = &map_iterator->second; |
1251 | 1250 |
1252 CHECK_GE(resource->exported_count, returned.count); | 1251 CHECK_GE(resource->exported_count, returned.count); |
1253 resource->exported_count -= returned.count; | 1252 resource->exported_count -= returned.count; |
1254 resource->lost |= returned.lost; | 1253 resource->lost |= returned.lost; |
1255 if (resource->exported_count) | 1254 if (resource->exported_count) |
1256 continue; | 1255 continue; |
1257 | 1256 |
1258 if (returned.sync_point) { | 1257 if (returned.sync_token.HasData()) { |
1259 DCHECK(!resource->has_shared_bitmap_id); | 1258 DCHECK(!resource->has_shared_bitmap_id); |
1260 if (resource->origin == Resource::INTERNAL) { | 1259 if (resource->origin == Resource::INTERNAL) { |
1261 DCHECK(resource->gl_id); | 1260 DCHECK(resource->gl_id); |
1262 gl->WaitSyncPointCHROMIUM(returned.sync_point); | 1261 gl->WaitSyncTokenCHROMIUM(returned.sync_token.GetConstData()); |
1263 } else { | 1262 } else { |
1264 DCHECK(!resource->gl_id); | 1263 DCHECK(!resource->gl_id); |
1265 resource->mailbox.set_sync_point(returned.sync_point); | 1264 resource->mailbox.set_sync_token(returned.sync_token); |
1266 } | 1265 } |
1267 } | 1266 } |
1268 | 1267 |
1269 if (!resource->marked_for_deletion) | 1268 if (!resource->marked_for_deletion) |
1270 continue; | 1269 continue; |
1271 | 1270 |
1272 if (!resource->child_id) { | 1271 if (!resource->child_id) { |
1273 // The resource belongs to this ResourceProvider, so it can be destroyed. | 1272 // The resource belongs to this ResourceProvider, so it can be destroyed. |
1274 DeleteResourceInternal(map_iterator, NORMAL); | 1273 DeleteResourceInternal(map_iterator, NORMAL); |
1275 continue; | 1274 continue; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1327 if (source->image_id && source->dirty_image) { | 1326 if (source->image_id && source->dirty_image) { |
1328 DCHECK(source->gl_id); | 1327 DCHECK(source->gl_id); |
1329 DCHECK(source->origin == Resource::INTERNAL); | 1328 DCHECK(source->origin == Resource::INTERNAL); |
1330 gl->BindTexture(resource->mailbox_holder.texture_target, source->gl_id); | 1329 gl->BindTexture(resource->mailbox_holder.texture_target, source->gl_id); |
1331 BindImageForSampling(source); | 1330 BindImageForSampling(source); |
1332 } | 1331 } |
1333 // This is either an external resource, or a compositor resource that we | 1332 // This is either an external resource, or a compositor resource that we |
1334 // already exported. Make sure to forward the sync point that we were given. | 1333 // already exported. Make sure to forward the sync point that we were given. |
1335 resource->mailbox_holder.mailbox = source->mailbox.mailbox(); | 1334 resource->mailbox_holder.mailbox = source->mailbox.mailbox(); |
1336 resource->mailbox_holder.texture_target = source->mailbox.target(); | 1335 resource->mailbox_holder.texture_target = source->mailbox.target(); |
1337 resource->mailbox_holder.sync_point = source->mailbox.sync_point(); | 1336 resource->mailbox_holder.sync_token = source->mailbox.sync_token(); |
1338 source->mailbox.set_sync_point(0); | 1337 source->mailbox.set_sync_token(gpu::SyncToken()); |
1339 } | 1338 } |
1340 } | 1339 } |
1341 | 1340 |
1342 void ResourceProvider::DeleteAndReturnUnusedResourcesToChild( | 1341 void ResourceProvider::DeleteAndReturnUnusedResourcesToChild( |
1343 ChildMap::iterator child_it, | 1342 ChildMap::iterator child_it, |
1344 DeleteStyle style, | 1343 DeleteStyle style, |
1345 const ResourceIdArray& unused) { | 1344 const ResourceIdArray& unused) { |
1346 DCHECK(thread_checker_.CalledOnValidThread()); | 1345 DCHECK(thread_checker_.CalledOnValidThread()); |
1347 DCHECK(child_it != children_.end()); | 1346 DCHECK(child_it != children_.end()); |
1348 Child* child_info = &child_it->second; | 1347 Child* child_info = &child_it->second; |
1349 | 1348 |
1350 if (unused.empty() && !child_info->marked_for_deletion) | 1349 if (unused.empty() && !child_info->marked_for_deletion) |
1351 return; | 1350 return; |
1352 | 1351 |
1353 ReturnedResourceArray to_return; | 1352 ReturnedResourceArray to_return; |
1354 | 1353 |
1355 GLES2Interface* gl = ContextGL(); | 1354 GLES2Interface* gl = ContextGL(); |
1356 bool need_sync_point = false; | 1355 bool need_sync_token = false; |
1357 for (size_t i = 0; i < unused.size(); ++i) { | 1356 for (size_t i = 0; i < unused.size(); ++i) { |
1358 ResourceId local_id = unused[i]; | 1357 ResourceId local_id = unused[i]; |
1359 | 1358 |
1360 ResourceMap::iterator it = resources_.find(local_id); | 1359 ResourceMap::iterator it = resources_.find(local_id); |
1361 CHECK(it != resources_.end()); | 1360 CHECK(it != resources_.end()); |
1362 Resource& resource = it->second; | 1361 Resource& resource = it->second; |
1363 | 1362 |
1364 DCHECK(!resource.locked_for_write); | 1363 DCHECK(!resource.locked_for_write); |
1365 DCHECK(child_info->parent_to_child_map.count(local_id)); | 1364 DCHECK(child_info->parent_to_child_map.count(local_id)); |
1366 | 1365 |
(...skipping 29 matching lines...) Expand all Loading... |
1396 | 1395 |
1397 gl->BindTexture(resource.target, resource.gl_id); | 1396 gl->BindTexture(resource.target, resource.gl_id); |
1398 gl->TexParameteri(resource.target, GL_TEXTURE_MIN_FILTER, | 1397 gl->TexParameteri(resource.target, GL_TEXTURE_MIN_FILTER, |
1399 resource.original_filter); | 1398 resource.original_filter); |
1400 gl->TexParameteri(resource.target, GL_TEXTURE_MAG_FILTER, | 1399 gl->TexParameteri(resource.target, GL_TEXTURE_MAG_FILTER, |
1401 resource.original_filter); | 1400 resource.original_filter); |
1402 } | 1401 } |
1403 | 1402 |
1404 ReturnedResource returned; | 1403 ReturnedResource returned; |
1405 returned.id = child_id; | 1404 returned.id = child_id; |
1406 returned.sync_point = resource.mailbox.sync_point(); | 1405 returned.sync_token = resource.mailbox.sync_token(); |
1407 if (!returned.sync_point && resource.type == RESOURCE_TYPE_GL_TEXTURE) | 1406 need_sync_token |= (!returned.sync_token.HasData() && |
1408 need_sync_point = true; | 1407 resource.type == RESOURCE_TYPE_GL_TEXTURE); |
1409 returned.count = resource.imported_count; | 1408 returned.count = resource.imported_count; |
1410 returned.lost = is_lost; | 1409 returned.lost = is_lost; |
1411 to_return.push_back(returned); | 1410 to_return.push_back(returned); |
1412 | 1411 |
1413 child_info->parent_to_child_map.erase(local_id); | 1412 child_info->parent_to_child_map.erase(local_id); |
1414 child_info->child_to_parent_map.erase(child_id); | 1413 child_info->child_to_parent_map.erase(child_id); |
1415 resource.imported_count = 0; | 1414 resource.imported_count = 0; |
1416 DeleteResourceInternal(it, style); | 1415 DeleteResourceInternal(it, style); |
1417 } | 1416 } |
1418 if (need_sync_point && child_info->needs_sync_points) { | 1417 if (need_sync_token && child_info->needs_sync_tokens) { |
1419 DCHECK(gl); | 1418 DCHECK(gl); |
1420 GLuint sync_point = gl->InsertSyncPointCHROMIUM(); | 1419 gpu::SyncToken sync_token(gl->InsertSyncPointCHROMIUM()); |
1421 for (size_t i = 0; i < to_return.size(); ++i) { | 1420 for (size_t i = 0; i < to_return.size(); ++i) { |
1422 if (!to_return[i].sync_point) | 1421 if (!to_return[i].sync_token.HasData()) |
1423 to_return[i].sync_point = sync_point; | 1422 to_return[i].sync_token = sync_token; |
1424 } | 1423 } |
1425 } | 1424 } |
1426 | 1425 |
1427 if (!to_return.empty()) | 1426 if (!to_return.empty()) |
1428 child_info->return_callback.Run(to_return, | 1427 child_info->return_callback.Run(to_return, |
1429 blocking_main_thread_task_runner_); | 1428 blocking_main_thread_task_runner_); |
1430 | 1429 |
1431 if (child_info->marked_for_deletion && | 1430 if (child_info->marked_for_deletion && |
1432 child_info->parent_to_child_map.empty()) { | 1431 child_info->parent_to_child_map.empty()) { |
1433 DCHECK(child_info->child_to_parent_map.empty()); | 1432 DCHECK(child_info->child_to_parent_map.empty()); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1537 DCHECK(resource->image_id); | 1536 DCHECK(resource->image_id); |
1538 | 1537 |
1539 // Release image currently bound to texture. | 1538 // Release image currently bound to texture. |
1540 if (resource->bound_image_id) | 1539 if (resource->bound_image_id) |
1541 gl->ReleaseTexImage2DCHROMIUM(resource->target, resource->bound_image_id); | 1540 gl->ReleaseTexImage2DCHROMIUM(resource->target, resource->bound_image_id); |
1542 gl->BindTexImage2DCHROMIUM(resource->target, resource->image_id); | 1541 gl->BindTexImage2DCHROMIUM(resource->target, resource->image_id); |
1543 resource->bound_image_id = resource->image_id; | 1542 resource->bound_image_id = resource->image_id; |
1544 resource->dirty_image = false; | 1543 resource->dirty_image = false; |
1545 } | 1544 } |
1546 | 1545 |
1547 void ResourceProvider::WaitSyncPointIfNeeded(ResourceId id) { | 1546 void ResourceProvider::WaitSyncTokenIfNeeded(ResourceId id) { |
1548 Resource* resource = GetResource(id); | 1547 Resource* resource = GetResource(id); |
1549 DCHECK_EQ(resource->exported_count, 0); | 1548 DCHECK_EQ(resource->exported_count, 0); |
1550 DCHECK(resource->allocated); | 1549 DCHECK(resource->allocated); |
1551 if (resource->type != RESOURCE_TYPE_GL_TEXTURE || resource->gl_id) | 1550 if (resource->type != RESOURCE_TYPE_GL_TEXTURE || resource->gl_id) |
1552 return; | 1551 return; |
1553 if (!resource->mailbox.sync_point()) | 1552 if (resource->mailbox.sync_token().HasData()) { |
1554 return; | 1553 DCHECK(resource->mailbox.IsValid()); |
1555 DCHECK(resource->mailbox.IsValid()); | 1554 GLES2Interface* gl = ContextGL(); |
1556 GLES2Interface* gl = ContextGL(); | 1555 DCHECK(gl); |
1557 DCHECK(gl); | 1556 gl->WaitSyncTokenCHROMIUM(resource->mailbox.sync_token().GetConstData()); |
1558 gl->WaitSyncPointCHROMIUM(resource->mailbox.sync_point()); | 1557 resource->mailbox.set_sync_token(gpu::SyncToken()); |
1559 resource->mailbox.set_sync_point(0); | 1558 } |
1560 } | 1559 } |
1561 | 1560 |
1562 GLint ResourceProvider::GetActiveTextureUnit(GLES2Interface* gl) { | 1561 GLint ResourceProvider::GetActiveTextureUnit(GLES2Interface* gl) { |
1563 GLint active_unit = 0; | 1562 GLint active_unit = 0; |
1564 gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit); | 1563 gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit); |
1565 return active_unit; | 1564 return active_unit; |
1566 } | 1565 } |
1567 | 1566 |
1568 GLenum ResourceProvider::GetImageTextureTarget(ResourceFormat format) { | 1567 GLenum ResourceProvider::GetImageTextureTarget(ResourceFormat format) { |
1569 gfx::BufferFormat buffer_format = BufferFormat(format); | 1568 gfx::BufferFormat buffer_format = BufferFormat(format); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1637 const int kImportance = 2; | 1636 const int kImportance = 2; |
1638 pmd->CreateSharedGlobalAllocatorDump(guid); | 1637 pmd->CreateSharedGlobalAllocatorDump(guid); |
1639 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); | 1638 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); |
1640 } | 1639 } |
1641 } | 1640 } |
1642 | 1641 |
1643 return true; | 1642 return true; |
1644 } | 1643 } |
1645 | 1644 |
1646 } // namespace cc | 1645 } // namespace cc |
OLD | NEW |