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

Unified Diff: cc/resources/resource_provider.cc

Issue 2535213002: [WIP] Add SharedMemoryTracker to dump base::SharedMemory usage
Patch Set: (rebase) Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/raster/staging_buffer_pool.cc ('k') | cc/resources/shared_bitmap.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/resource_provider.cc
diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc
index 8d5a3fce7fe37616bef719b2332ca41d18e7b74d..22d76c5ab006810ee6407b255f78275e21dc47b8 100644
--- a/cc/resources/resource_provider.cc
+++ b/cc/resources/resource_provider.cc
@@ -13,6 +13,7 @@
#include "base/atomic_sequence_num.h"
#include "base/macros.h"
+#include "base/memory/shared_memory_tracker.h"
#include "base/metrics/histogram.h"
#include "base/numerics/safe_math.h"
#include "base/stl_util.h"
@@ -40,7 +41,6 @@
#include "third_party/skia/include/gpu/gl/GrGLTypes.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/vector2d.h"
-#include "ui/gfx/gpu_memory_buffer_tracing.h"
#include "ui/gfx/icc_profile.h"
#include "ui/gl/trace_util.h"
@@ -2169,32 +2169,54 @@ bool ResourceProvider::OnMemoryDump(
base::trace_event::MemoryAllocatorDump::kUnitsBytes,
static_cast<uint64_t>(total_bytes));
- // Resources may be shared across processes and require a shared GUID to
- // prevent double counting the memory.
- base::trace_event::MemoryAllocatorDumpGuid guid;
- switch (resource.type) {
- case RESOURCE_TYPE_GPU_MEMORY_BUFFER:
- guid =
- resource.gpu_memory_buffer->GetGUIDForTracing(tracing_process_id);
- break;
- case RESOURCE_TYPE_GL_TEXTURE:
- DCHECK(resource.gl_id);
- guid = gl::GetGLTextureClientGUIDForTracing(
- compositor_context_provider_->ContextSupport()
- ->ShareGroupTracingGUID(),
- resource.gl_id);
- break;
- case RESOURCE_TYPE_BITMAP:
- DCHECK(resource.has_shared_bitmap_id);
- guid = GetSharedBitmapGUIDForTracing(resource.shared_bitmap_id);
- break;
- }
-
- DCHECK(!guid.empty());
+ if (resource.type == RESOURCE_TYPE_GL_TEXTURE ||
+ (resource.type == RESOURCE_TYPE_GPU_MEMORY_BUFFER &&
+ !resource.gpu_memory_buffer->GetSharedMemory())) {
+ // Resources may be shared across processes and require a shared GUID to
+ // prevent double counting the memory.
+ base::trace_event::MemoryAllocatorDumpGuid guid;
+ switch (resource.type) {
+ case RESOURCE_TYPE_GPU_MEMORY_BUFFER:
+ guid =
+ resource.gpu_memory_buffer->GetGUIDForTracing(tracing_process_id);
+ break;
+ case RESOURCE_TYPE_GL_TEXTURE:
+ DCHECK(resource.gl_id);
+ guid = gl::GetGLTextureClientGUIDForTracing(
+ compositor_context_provider_->ContextSupport()
+ ->ShareGroupTracingGUID(),
+ resource.gl_id);
+ break;
+ case RESOURCE_TYPE_BITMAP:
+ NOTREACHED();
+ break;
+ }
+ DCHECK(!guid.empty());
- const int kImportance = 2;
- pmd->CreateSharedGlobalAllocatorDump(guid);
- pmd->AddOwnershipEdge(dump->guid(), guid, kImportance);
+ const int kImportance = 2;
+ pmd->CreateSharedGlobalAllocatorDump(guid);
+ pmd->AddOwnershipEdge(dump->guid(), guid, kImportance);
+ } else {
+ base::SharedMemory* shared_memory = nullptr;
+ switch (resource.type) {
+ case RESOURCE_TYPE_GPU_MEMORY_BUFFER:
+ shared_memory = resource.gpu_memory_buffer->GetSharedMemory();
+ DCHECK(shared_memory);
+ break;
+ case RESOURCE_TYPE_GL_TEXTURE:
+ NOTREACHED();
+ break;
+ case RESOURCE_TYPE_BITMAP:
+ if (!resource.shared_bitmap)
+ break;
+ shared_memory = resource.shared_bitmap->GetSharedMemory();
+ break;
+ }
+ if (shared_memory) {
+ base::SharedMemoryTracker::AddOwnershipEdges(pmd, dump->guid(),
+ *shared_memory);
+ }
+ }
}
return true;
« no previous file with comments | « cc/raster/staging_buffer_pool.cc ('k') | cc/resources/shared_bitmap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698