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

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

Issue 1280513002: Add GenericSharedMemoryId and use w/ GpuMemoryBuffer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@trackpools
Patch Set: Share GUID types between GpuMemoryBuffer and GenericSharedMemory 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 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/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
11 #include "base/memory/generic_shared_memory_id.h"
11 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
12 #include "base/numerics/safe_math.h" 13 #include "base/numerics/safe_math.h"
13 #include "base/stl_util.h" 14 #include "base/stl_util.h"
14 #include "base/strings/string_split.h" 15 #include "base/strings/string_split.h"
15 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
16 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
17 #include "base/thread_task_runner_handle.h" 18 #include "base/thread_task_runner_handle.h"
18 #include "base/trace_event/memory_dump_manager.h" 19 #include "base/trace_event/memory_dump_manager.h"
19 #include "base/trace_event/trace_event.h" 20 #include "base/trace_event/trace_event.h"
20 #include "cc/resources/platform_color.h" 21 #include "cc/resources/platform_color.h"
(...skipping 1966 matching lines...) Expand 10 before | Expand all | Expand 10 after
1987 resource.size, resource.format); 1988 resource.size, resource.format);
1988 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, 1989 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
1989 base::trace_event::MemoryAllocatorDump::kUnitsBytes, 1990 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
1990 static_cast<uint64_t>(total_bytes)); 1991 static_cast<uint64_t>(total_bytes));
1991 1992
1992 // Resources which are shared across processes require a shared GUID to 1993 // Resources which are shared across processes require a shared GUID to
1993 // prevent double counting the memory. We currently support shared GUIDs for 1994 // prevent double counting the memory. We currently support shared GUIDs for
1994 // GpuMemoryBuffer, SharedBitmap, and GL backed resources. 1995 // GpuMemoryBuffer, SharedBitmap, and GL backed resources.
1995 base::trace_event::MemoryAllocatorDumpGuid guid; 1996 base::trace_event::MemoryAllocatorDumpGuid guid;
1996 if (resource.gpu_memory_buffer) { 1997 if (resource.gpu_memory_buffer) {
1997 guid = gfx::GetGpuMemoryBufferGUIDForTracing( 1998 guid = base::GetGenericSharedMemoryGUIDForTracing(
1998 tracing_process_id, resource.gpu_memory_buffer->GetHandle().id); 1999 tracing_process_id, resource.gpu_memory_buffer->GetHandle().id);
1999 } else if (resource.shared_bitmap) { 2000 } else if (resource.shared_bitmap) {
2000 guid = GetSharedBitmapGUIDForTracing(resource.shared_bitmap->id()); 2001 guid = GetSharedBitmapGUIDForTracing(resource.shared_bitmap->id());
2001 } else if (resource.gl_id && resource.allocated) { 2002 } else if (resource.gl_id && resource.allocated) {
2002 guid = 2003 guid =
2003 gfx::GetGLTextureGUIDForTracing(tracing_process_id, resource.gl_id); 2004 gfx::GetGLTextureGUIDForTracing(tracing_process_id, resource.gl_id);
2004 } 2005 }
2005 2006
2006 if (!guid.empty()) { 2007 if (!guid.empty()) {
2007 const int kImportance = 2; 2008 const int kImportance = 2;
2008 pmd->CreateSharedGlobalAllocatorDump(guid); 2009 pmd->CreateSharedGlobalAllocatorDump(guid);
2009 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); 2010 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance);
2010 } 2011 }
2011 } 2012 }
2012 2013
2013 return true; 2014 return true;
2014 } 2015 }
2015 2016
2016 } // namespace cc 2017 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698