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