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

Unified Diff: content/browser/gpu/browser_gpu_memory_buffer_manager.cc

Issue 1280513002: Add GenericSharedMemoryId and use w/ GpuMemoryBuffer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@trackpools
Patch Set: Comments and tweaks. Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/gpu/browser_gpu_memory_buffer_manager.cc
diff --git a/content/browser/gpu/browser_gpu_memory_buffer_manager.cc b/content/browser/gpu/browser_gpu_memory_buffer_manager.cc
index a1d54b7b365c2f4485e71dfe0bd38a63402556d5..01bc6807b101b66df045b4a6720de377ad11a40a 100644
--- a/content/browser/gpu/browser_gpu_memory_buffer_manager.cc
+++ b/content/browser/gpu/browser_gpu_memory_buffer_manager.cc
@@ -14,6 +14,7 @@
#include "base/trace_event/trace_event.h"
#include "content/browser/gpu/gpu_process_host.h"
#include "content/common/child_process_host_impl.h"
+#include "content/common/generic_shared_memory_id_generator.h"
#include "content/common/gpu/client/gpu_memory_buffer_impl.h"
#include "content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h"
#include "content/common/gpu/gpu_memory_buffer_factory_shared_memory.h"
@@ -120,9 +121,6 @@ GetSupportedGpuMemoryBufferConfigurations(gfx::GpuMemoryBufferType type) {
BrowserGpuMemoryBufferManager* g_gpu_memory_buffer_manager = nullptr;
-// Global atomic to generate gpu memory buffer unique IDs.
-base::StaticAtomicSequenceNumber g_next_gpu_memory_buffer_id;
-
} // namespace
struct BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferRequest {
@@ -213,6 +211,7 @@ BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferForScanout(
}
void BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferForChildProcess(
+ gfx::GpuMemoryBufferId id,
const gfx::Size& size,
gfx::BufferFormat format,
gfx::BufferUsage usage,
@@ -221,11 +220,9 @@ void BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferForChildProcess(
const AllocationCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
- gfx::GpuMemoryBufferId new_id = g_next_gpu_memory_buffer_id.GetNext();
-
// Use service side allocation if this is a supported configuration.
if (IsGpuMemoryBufferConfigurationSupported(format, usage)) {
- AllocateGpuMemoryBufferOnIO(new_id, size, format, usage, child_client_id, 0,
+ AllocateGpuMemoryBufferOnIO(id, size, format, usage, child_client_id, 0,
false, callback);
return;
}
@@ -239,13 +236,12 @@ void BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferForChildProcess(
}
BufferMap& buffers = clients_[child_client_id];
- DCHECK(buffers.find(new_id) == buffers.end());
+ DCHECK(buffers.find(id) == buffers.end());
reveman 2015/08/06 04:25:06 We need to change this now that the child process
ericrk 2015/08/06 18:28:08 Done.
// Allocate shared memory buffer as fallback.
- buffers[new_id] =
- BufferInfo(size, gfx::SHARED_MEMORY_BUFFER, format, usage, 0);
+ buffers[id] = BufferInfo(size, gfx::SHARED_MEMORY_BUFFER, format, usage, 0);
callback.Run(GpuMemoryBufferImplSharedMemory::AllocateForChildProcess(
- new_id, size, format, child_process_handle));
+ id, size, format, child_process_handle));
}
gfx::GpuMemoryBuffer*
@@ -302,6 +298,22 @@ bool BrowserGpuMemoryBufferManager::OnMemoryDump(
buffer_id);
pmd->CreateSharedGlobalAllocatorDump(shared_buffer_guid);
pmd->AddOwnershipEdge(dump->guid(), shared_buffer_guid);
+
+ // Create an additional shared ownership edge with the
reveman 2015/08/06 04:25:06 Ideally we'd instead add the generic shared memory
ericrk 2015/08/06 18:28:08 This isn't necessarily ideal, but might be fine as
+ // GenericSharedMemoryId for the shared memory which backs this
+ // GpuMemoryBuffer.
+ base::trace_event::MemoryAllocatorDumpGuid shared_memory_guid =
+ base::memory::GetGenericSharedMemoryGUIDForTracing(
+ client_tracing_process_id, buffer_id);
+ pmd->CreateSharedGlobalAllocatorDump(shared_memory_guid);
+
+ // The link from the shared memory guid to the gpu memory buffer guid is
+ // higher than the link from the shared memory guid to the various low
+ // level memory dumps. This ensures that memory is tracked on the gpu
+ // memory buffer.
+ const int kImportance = 2;
+ pmd->AddOwnershipEdge(shared_buffer_guid, shared_memory_guid,
+ kImportance);
}
}
@@ -382,7 +394,7 @@ void BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferForSurfaceOnIO(
AllocateGpuMemoryBufferRequest* request) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
- gfx::GpuMemoryBufferId new_id = g_next_gpu_memory_buffer_id.GetNext();
+ gfx::GpuMemoryBufferId new_id = content::GetNextGenericSharedMemoryId();
// Use service side allocation if this is a supported configuration.
if (IsGpuMemoryBufferConfigurationSupported(request->format,

Powered by Google App Engine
This is Rietveld 408576698