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

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

Issue 1387283002: cc: Remove redundant is_overlay arguments (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 <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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 lock_for_read_count(0), 214 lock_for_read_count(0),
215 imported_count(0), 215 imported_count(0),
216 exported_count(0), 216 exported_count(0),
217 dirty_image(false), 217 dirty_image(false),
218 locked_for_write(false), 218 locked_for_write(false),
219 lost(false), 219 lost(false),
220 marked_for_deletion(false), 220 marked_for_deletion(false),
221 allocated(false), 221 allocated(false),
222 read_lock_fences_enabled(false), 222 read_lock_fences_enabled(false),
223 has_shared_bitmap_id(false), 223 has_shared_bitmap_id(false),
224 bound_to_image(false),
224 read_lock_fence(NULL), 225 read_lock_fence(NULL),
225 size(size), 226 size(size),
226 origin(origin), 227 origin(origin),
227 target(target), 228 target(target),
228 original_filter(filter), 229 original_filter(filter),
229 filter(filter), 230 filter(filter),
230 image_id(0), 231 image_id(0),
231 bound_image_id(0), 232 bound_image_id(0),
232 texture_pool(texture_pool), 233 texture_pool(texture_pool),
233 wrap_mode(wrap_mode), 234 wrap_mode(wrap_mode),
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 resource = InsertResource( 515 resource = InsertResource(
515 id, Resource(pixels, shared_bitmap, mailbox.size_in_pixels(), 516 id, Resource(pixels, shared_bitmap, mailbox.size_in_pixels(),
516 Resource::EXTERNAL, GL_LINEAR, GL_CLAMP_TO_EDGE)); 517 Resource::EXTERNAL, GL_LINEAR, GL_CLAMP_TO_EDGE));
517 } 518 }
518 resource->allocated = true; 519 resource->allocated = true;
519 resource->mailbox = mailbox; 520 resource->mailbox = mailbox;
520 resource->release_callback_impl = 521 resource->release_callback_impl =
521 base::Bind(&SingleReleaseCallbackImpl::Run, 522 base::Bind(&SingleReleaseCallbackImpl::Run,
522 base::Owned(release_callback_impl.release())); 523 base::Owned(release_callback_impl.release()));
523 resource->read_lock_fences_enabled = read_lock_fences_enabled; 524 resource->read_lock_fences_enabled = read_lock_fences_enabled;
525 resource->bound_to_image = mailbox.bound_to_gl_image();
524 return id; 526 return id;
525 } 527 }
526 528
527 ResourceId ResourceProvider::CreateResourceFromTextureMailbox( 529 ResourceId ResourceProvider::CreateResourceFromTextureMailbox(
528 const TextureMailbox& mailbox, 530 const TextureMailbox& mailbox,
529 scoped_ptr<SingleReleaseCallbackImpl> release_callback_impl) { 531 scoped_ptr<SingleReleaseCallbackImpl> release_callback_impl) {
530 return CreateResourceFromTextureMailbox(mailbox, release_callback_impl.Pass(), 532 return CreateResourceFromTextureMailbox(mailbox, release_callback_impl.Pass(),
531 false); 533 false);
532 } 534 }
533 535
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 return resource; 774 return resource;
773 } 775 }
774 776
775 bool ResourceProvider::CanLockForWrite(ResourceId id) { 777 bool ResourceProvider::CanLockForWrite(ResourceId id) {
776 Resource* resource = GetResource(id); 778 Resource* resource = GetResource(id);
777 return !resource->locked_for_write && !resource->lock_for_read_count && 779 return !resource->locked_for_write && !resource->lock_for_read_count &&
778 !resource->exported_count && resource->origin == Resource::INTERNAL && 780 !resource->exported_count && resource->origin == Resource::INTERNAL &&
779 !resource->lost && ReadLockFenceHasPassed(resource); 781 !resource->lost && ReadLockFenceHasPassed(resource);
780 } 782 }
781 783
784 bool ResourceProvider::IsBoundToImage(ResourceId id) {
785 Resource* resource = GetResource(id);
786 return resource->bound_to_image;
787 }
788
782 void ResourceProvider::UnlockForWrite(ResourceProvider::Resource* resource) { 789 void ResourceProvider::UnlockForWrite(ResourceProvider::Resource* resource) {
783 DCHECK(resource->locked_for_write); 790 DCHECK(resource->locked_for_write);
784 DCHECK_EQ(resource->exported_count, 0); 791 DCHECK_EQ(resource->exported_count, 0);
785 DCHECK(resource->origin == Resource::INTERNAL); 792 DCHECK(resource->origin == Resource::INTERNAL);
786 resource->locked_for_write = false; 793 resource->locked_for_write = false;
787 } 794 }
788 795
789 void ResourceProvider::EnableReadLockFencesForTesting(ResourceId id) { 796 void ResourceProvider::EnableReadLockFencesForTesting(ResourceId id) {
790 Resource* resource = GetResource(id); 797 Resource* resource = GetResource(id);
791 DCHECK(resource); 798 DCHECK(resource);
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 } else { 1220 } else {
1214 resource = InsertResource( 1221 resource = InsertResource(
1215 local_id, Resource(0, it->size, Resource::DELEGATED, 1222 local_id, Resource(0, it->size, Resource::DELEGATED,
1216 it->mailbox_holder.texture_target, it->filter, 0, 1223 it->mailbox_holder.texture_target, it->filter, 0,
1217 it->is_repeated ? GL_REPEAT : GL_CLAMP_TO_EDGE, 1224 it->is_repeated ? GL_REPEAT : GL_CLAMP_TO_EDGE,
1218 TEXTURE_HINT_IMMUTABLE, it->format)); 1225 TEXTURE_HINT_IMMUTABLE, it->format));
1219 resource->mailbox = TextureMailbox(it->mailbox_holder.mailbox, 1226 resource->mailbox = TextureMailbox(it->mailbox_holder.mailbox,
1220 it->mailbox_holder.texture_target, 1227 it->mailbox_holder.texture_target,
1221 it->mailbox_holder.sync_point); 1228 it->mailbox_holder.sync_point);
1222 resource->read_lock_fences_enabled = it->read_lock_fences_enabled; 1229 resource->read_lock_fences_enabled = it->read_lock_fences_enabled;
1230 resource->bound_to_image = it->bound_to_gl_image;
1223 } 1231 }
1224 resource->child_id = child; 1232 resource->child_id = child;
1225 // Don't allocate a texture for a child. 1233 // Don't allocate a texture for a child.
1226 resource->allocated = true; 1234 resource->allocated = true;
1227 resource->imported_count = 1; 1235 resource->imported_count = 1;
1228 child_info.parent_to_child_map[local_id] = it->id; 1236 child_info.parent_to_child_map[local_id] = it->id;
1229 child_info.child_to_parent_map[it->id] = local_id; 1237 child_info.child_to_parent_map[it->id] = local_id;
1230 } 1238 }
1231 } 1239 }
1232 1240
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1314 DCHECK(!source->lock_for_read_count); 1322 DCHECK(!source->lock_for_read_count);
1315 DCHECK(source->origin != Resource::EXTERNAL || source->mailbox.IsValid()); 1323 DCHECK(source->origin != Resource::EXTERNAL || source->mailbox.IsValid());
1316 DCHECK(source->allocated); 1324 DCHECK(source->allocated);
1317 resource->id = id; 1325 resource->id = id;
1318 resource->format = source->format; 1326 resource->format = source->format;
1319 resource->mailbox_holder.texture_target = source->target; 1327 resource->mailbox_holder.texture_target = source->target;
1320 resource->filter = source->filter; 1328 resource->filter = source->filter;
1321 resource->size = source->size; 1329 resource->size = source->size;
1322 resource->read_lock_fences_enabled = source->read_lock_fences_enabled; 1330 resource->read_lock_fences_enabled = source->read_lock_fences_enabled;
1323 resource->is_repeated = (source->wrap_mode == GL_REPEAT); 1331 resource->is_repeated = (source->wrap_mode == GL_REPEAT);
1332 resource->bound_to_gl_image = source->bound_to_image;
1324 1333
1325 if (source->type == RESOURCE_TYPE_BITMAP) { 1334 if (source->type == RESOURCE_TYPE_BITMAP) {
1326 resource->mailbox_holder.mailbox = source->shared_bitmap_id; 1335 resource->mailbox_holder.mailbox = source->shared_bitmap_id;
1327 resource->is_software = true; 1336 resource->is_software = true;
1328 } else if (!source->mailbox.IsValid()) { 1337 } else if (!source->mailbox.IsValid()) {
1329 LazyCreate(source); 1338 LazyCreate(source);
1330 DCHECK(source->gl_id); 1339 DCHECK(source->gl_id);
1331 DCHECK(source->origin == Resource::INTERNAL); 1340 DCHECK(source->origin == Resource::INTERNAL);
1332 if (source->image_id) { 1341 if (source->image_id) {
1333 DCHECK(source->dirty_image); 1342 DCHECK(source->dirty_image);
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1557 void ResourceProvider::BindImageForSampling(Resource* resource) { 1566 void ResourceProvider::BindImageForSampling(Resource* resource) {
1558 GLES2Interface* gl = ContextGL(); 1567 GLES2Interface* gl = ContextGL();
1559 DCHECK(resource->gl_id); 1568 DCHECK(resource->gl_id);
1560 DCHECK(resource->image_id); 1569 DCHECK(resource->image_id);
1561 1570
1562 // Release image currently bound to texture. 1571 // Release image currently bound to texture.
1563 if (resource->bound_image_id) 1572 if (resource->bound_image_id)
1564 gl->ReleaseTexImage2DCHROMIUM(resource->target, resource->bound_image_id); 1573 gl->ReleaseTexImage2DCHROMIUM(resource->target, resource->bound_image_id);
1565 gl->BindTexImage2DCHROMIUM(resource->target, resource->image_id); 1574 gl->BindTexImage2DCHROMIUM(resource->target, resource->image_id);
1566 resource->bound_image_id = resource->image_id; 1575 resource->bound_image_id = resource->image_id;
1567 resource->dirty_image = false; 1576 resource->dirty_image = false;
ccameron 2015/10/07 00:47:58 In a follow-on patch, I will set bound_to_gl_image
1568 } 1577 }
1569 1578
1570 void ResourceProvider::WaitSyncPointIfNeeded(ResourceId id) { 1579 void ResourceProvider::WaitSyncPointIfNeeded(ResourceId id) {
1571 Resource* resource = GetResource(id); 1580 Resource* resource = GetResource(id);
1572 DCHECK_EQ(resource->exported_count, 0); 1581 DCHECK_EQ(resource->exported_count, 0);
1573 DCHECK(resource->allocated); 1582 DCHECK(resource->allocated);
1574 if (resource->type != RESOURCE_TYPE_GL_TEXTURE || resource->gl_id) 1583 if (resource->type != RESOURCE_TYPE_GL_TEXTURE || resource->gl_id)
1575 return; 1584 return;
1576 if (!resource->mailbox.sync_point()) 1585 if (!resource->mailbox.sync_point())
1577 return; 1586 return;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1660 const int kImportance = 2; 1669 const int kImportance = 2;
1661 pmd->CreateSharedGlobalAllocatorDump(guid); 1670 pmd->CreateSharedGlobalAllocatorDump(guid);
1662 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); 1671 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance);
1663 } 1672 }
1664 } 1673 }
1665 1674
1666 return true; 1675 return true;
1667 } 1676 }
1668 1677
1669 } // namespace cc 1678 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698