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

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

Issue 1957583002: cc: Add GpuMemoryBufferId to TextureMailbox (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: unsigned -> signed Created 4 years, 7 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
« no previous file with comments | « cc/resources/resource_provider.h ('k') | cc/resources/texture_mailbox.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 id, Resource(pixels, shared_bitmap, mailbox.size_in_pixels(), 607 id, Resource(pixels, shared_bitmap, mailbox.size_in_pixels(),
608 Resource::EXTERNAL, GL_LINEAR)); 608 Resource::EXTERNAL, GL_LINEAR));
609 } 609 }
610 resource->allocated = true; 610 resource->allocated = true;
611 resource->set_mailbox(mailbox); 611 resource->set_mailbox(mailbox);
612 resource->release_callback_impl = 612 resource->release_callback_impl =
613 base::Bind(&SingleReleaseCallbackImpl::Run, 613 base::Bind(&SingleReleaseCallbackImpl::Run,
614 base::Owned(release_callback_impl.release())); 614 base::Owned(release_callback_impl.release()));
615 resource->read_lock_fences_enabled = read_lock_fences_enabled; 615 resource->read_lock_fences_enabled = read_lock_fences_enabled;
616 resource->is_overlay_candidate = mailbox.is_overlay_candidate(); 616 resource->is_overlay_candidate = mailbox.is_overlay_candidate();
617 resource->gpu_memory_buffer_id = mailbox.gpu_memory_buffer_id();
617 618
618 return id; 619 return id;
619 } 620 }
620 621
621 ResourceId ResourceProvider::CreateResourceFromTextureMailbox( 622 ResourceId ResourceProvider::CreateResourceFromTextureMailbox(
622 const TextureMailbox& mailbox, 623 const TextureMailbox& mailbox,
623 std::unique_ptr<SingleReleaseCallbackImpl> release_callback_impl) { 624 std::unique_ptr<SingleReleaseCallbackImpl> release_callback_impl) {
624 return CreateResourceFromTextureMailbox( 625 return CreateResourceFromTextureMailbox(
625 mailbox, std::move(release_callback_impl), false); 626 mailbox, std::move(release_callback_impl), false);
626 } 627 }
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 ResourceProvider::ScopedWriteLockGpuMemoryBuffer:: 1055 ResourceProvider::ScopedWriteLockGpuMemoryBuffer::
1055 ~ScopedWriteLockGpuMemoryBuffer() { 1056 ~ScopedWriteLockGpuMemoryBuffer() {
1056 DCHECK(thread_checker_.CalledOnValidThread()); 1057 DCHECK(thread_checker_.CalledOnValidThread());
1057 resource_provider_->UnlockForWrite(resource_); 1058 resource_provider_->UnlockForWrite(resource_);
1058 if (!gpu_memory_buffer_) 1059 if (!gpu_memory_buffer_)
1059 return; 1060 return;
1060 1061
1061 DCHECK(!resource_->gpu_memory_buffer); 1062 DCHECK(!resource_->gpu_memory_buffer);
1062 resource_provider_->LazyCreate(resource_); 1063 resource_provider_->LazyCreate(resource_);
1063 resource_->gpu_memory_buffer = std::move(gpu_memory_buffer_); 1064 resource_->gpu_memory_buffer = std::move(gpu_memory_buffer_);
1065 if (resource_->gpu_memory_buffer)
1066 resource_->gpu_memory_buffer_id = resource_->gpu_memory_buffer->GetId();
1064 resource_->allocated = true; 1067 resource_->allocated = true;
1065 resource_provider_->LazyCreateImage(resource_); 1068 resource_provider_->LazyCreateImage(resource_);
1066 resource_->dirty_image = true; 1069 resource_->dirty_image = true;
1067 resource_->is_overlay_candidate = true; 1070 resource_->is_overlay_candidate = true;
1068 resource_->SetSynchronized(); 1071 resource_->SetSynchronized();
1069 1072
1070 // GpuMemoryBuffer provides direct access to the memory used by the GPU. 1073 // GpuMemoryBuffer provides direct access to the memory used by the GPU.
1071 // Read lock fences are required to ensure that we're not trying to map a 1074 // Read lock fences are required to ensure that we're not trying to map a
1072 // buffer that is currently in-use by the GPU. 1075 // buffer that is currently in-use by the GPU.
1073 resource_->read_lock_fences_enabled = true; 1076 resource_->read_lock_fences_enabled = true;
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
1432 resource = InsertResource( 1435 resource = InsertResource(
1433 local_id, Resource(0, it->size, Resource::DELEGATED, 1436 local_id, Resource(0, it->size, Resource::DELEGATED,
1434 it->mailbox_holder.texture_target, it->filter, 1437 it->mailbox_holder.texture_target, it->filter,
1435 TEXTURE_HINT_IMMUTABLE, RESOURCE_TYPE_GL_TEXTURE, 1438 TEXTURE_HINT_IMMUTABLE, RESOURCE_TYPE_GL_TEXTURE,
1436 it->format)); 1439 it->format));
1437 resource->set_mailbox(TextureMailbox(it->mailbox_holder.mailbox, 1440 resource->set_mailbox(TextureMailbox(it->mailbox_holder.mailbox,
1438 it->mailbox_holder.sync_token, 1441 it->mailbox_holder.sync_token,
1439 it->mailbox_holder.texture_target)); 1442 it->mailbox_holder.texture_target));
1440 resource->read_lock_fences_enabled = it->read_lock_fences_enabled; 1443 resource->read_lock_fences_enabled = it->read_lock_fences_enabled;
1441 resource->is_overlay_candidate = it->is_overlay_candidate; 1444 resource->is_overlay_candidate = it->is_overlay_candidate;
1445 resource->gpu_memory_buffer_id = it->gpu_memory_buffer_id;
1442 } 1446 }
1443 resource->child_id = child; 1447 resource->child_id = child;
1444 // Don't allocate a texture for a child. 1448 // Don't allocate a texture for a child.
1445 resource->allocated = true; 1449 resource->allocated = true;
1446 resource->imported_count = 1; 1450 resource->imported_count = 1;
1447 child_info.parent_to_child_map[local_id] = it->id; 1451 child_info.parent_to_child_map[local_id] = it->id;
1448 child_info.child_to_parent_map[it->id] = local_id; 1452 child_info.child_to_parent_map[it->id] = local_id;
1449 } 1453 }
1450 } 1454 }
1451 1455
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1557 DCHECK(!source->locked_for_write); 1561 DCHECK(!source->locked_for_write);
1558 DCHECK(!source->lock_for_read_count); 1562 DCHECK(!source->lock_for_read_count);
1559 DCHECK(source->origin != Resource::EXTERNAL || source->mailbox().IsValid()); 1563 DCHECK(source->origin != Resource::EXTERNAL || source->mailbox().IsValid());
1560 DCHECK(source->allocated); 1564 DCHECK(source->allocated);
1561 resource->id = id; 1565 resource->id = id;
1562 resource->format = source->format; 1566 resource->format = source->format;
1563 resource->mailbox_holder.texture_target = source->target; 1567 resource->mailbox_holder.texture_target = source->target;
1564 resource->filter = source->filter; 1568 resource->filter = source->filter;
1565 resource->size = source->size; 1569 resource->size = source->size;
1566 resource->read_lock_fences_enabled = source->read_lock_fences_enabled; 1570 resource->read_lock_fences_enabled = source->read_lock_fences_enabled;
1571 resource->gpu_memory_buffer_id = source->gpu_memory_buffer_id;
1567 resource->is_overlay_candidate = source->is_overlay_candidate; 1572 resource->is_overlay_candidate = source->is_overlay_candidate;
1568 1573
1569 if (source->type == RESOURCE_TYPE_BITMAP) { 1574 if (source->type == RESOURCE_TYPE_BITMAP) {
1570 resource->mailbox_holder.mailbox = source->shared_bitmap_id; 1575 resource->mailbox_holder.mailbox = source->shared_bitmap_id;
1571 resource->is_software = true; 1576 resource->is_software = true;
1572 } else { 1577 } else {
1573 DCHECK(source->mailbox().IsValid()); 1578 DCHECK(source->mailbox().IsValid());
1574 DCHECK(source->mailbox().IsTexture()); 1579 DCHECK(source->mailbox().IsTexture());
1575 DCHECK(!source->image_id || !source->dirty_image); 1580 DCHECK(!source->image_id || !source->dirty_image);
1576 // This is either an external resource, or a compositor resource that we 1581 // This is either an external resource, or a compositor resource that we
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
1774 resource->allocated = true; 1779 resource->allocated = true;
1775 GLES2Interface* gl = ContextGL(); 1780 GLES2Interface* gl = ContextGL();
1776 gfx::Size& size = resource->size; 1781 gfx::Size& size = resource->size;
1777 ResourceFormat format = resource->format; 1782 ResourceFormat format = resource->format;
1778 gl->BindTexture(resource->target, resource->gl_id); 1783 gl->BindTexture(resource->target, resource->gl_id);
1779 if (resource->type == RESOURCE_TYPE_GPU_MEMORY_BUFFER) { 1784 if (resource->type == RESOURCE_TYPE_GPU_MEMORY_BUFFER) {
1780 resource->gpu_memory_buffer = 1785 resource->gpu_memory_buffer =
1781 gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer( 1786 gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer(
1782 size, BufferFormat(format), 1787 size, BufferFormat(format),
1783 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE, gpu::kNullSurfaceHandle); 1788 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE, gpu::kNullSurfaceHandle);
1789 if (resource->gpu_memory_buffer)
1790 resource->gpu_memory_buffer_id = resource->gpu_memory_buffer->GetId();
1784 LazyCreateImage(resource); 1791 LazyCreateImage(resource);
1785 resource->dirty_image = true; 1792 resource->dirty_image = true;
1786 resource->is_overlay_candidate = true; 1793 resource->is_overlay_candidate = true;
1787 } else if (use_texture_storage_ext_ && 1794 } else if (use_texture_storage_ext_ &&
1788 IsFormatSupportedForStorage(format, use_texture_format_bgra_) && 1795 IsFormatSupportedForStorage(format, use_texture_format_bgra_) &&
1789 (resource->hint & TEXTURE_HINT_IMMUTABLE)) { 1796 (resource->hint & TEXTURE_HINT_IMMUTABLE)) {
1790 GLenum storage_format = TextureToStorageFormat(format); 1797 GLenum storage_format = TextureToStorageFormat(format);
1791 gl->TexStorage2DEXT(resource->target, 1, storage_format, size.width(), 1798 gl->TexStorage2DEXT(resource->target, 1, storage_format, size.width(),
1792 size.height()); 1799 size.height());
1793 } else { 1800 } else {
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1961 1968
1962 const int kImportance = 2; 1969 const int kImportance = 2;
1963 pmd->CreateSharedGlobalAllocatorDump(guid); 1970 pmd->CreateSharedGlobalAllocatorDump(guid);
1964 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); 1971 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance);
1965 } 1972 }
1966 1973
1967 return true; 1974 return true;
1968 } 1975 }
1969 1976
1970 } // namespace cc 1977 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/resource_provider.h ('k') | cc/resources/texture_mailbox.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698