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

Side by Side Diff: media/video/gpu_memory_buffer_video_frame_pool.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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "media/video/gpu_memory_buffer_video_frame_pool.h" 5 #include "media/video/gpu_memory_buffer_video_frame_pool.h"
6 6
7 #include <GLES2/gl2.h> 7 #include <GLES2/gl2.h>
8 #include <GLES2/gl2ext.h> 8 #include <GLES2/gl2ext.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <stdint.h> 10 #include <stdint.h>
11 11
12 #include <algorithm> 12 #include <algorithm>
13 #include <list> 13 #include <list>
14 #include <memory> 14 #include <memory>
15 #include <utility> 15 #include <utility>
16 16
17 #include "base/barrier_closure.h" 17 #include "base/barrier_closure.h"
18 #include "base/bind.h" 18 #include "base/bind.h"
19 #include "base/containers/stack_container.h" 19 #include "base/containers/stack_container.h"
20 #include "base/location.h" 20 #include "base/location.h"
21 #include "base/macros.h" 21 #include "base/macros.h"
22 #include "base/memory/shared_memory.h"
23 #include "base/memory/shared_memory_tracker.h"
22 #include "base/strings/stringprintf.h" 24 #include "base/strings/stringprintf.h"
23 #include "base/trace_event/memory_dump_manager.h" 25 #include "base/trace_event/memory_dump_manager.h"
24 #include "base/trace_event/memory_dump_provider.h" 26 #include "base/trace_event/memory_dump_provider.h"
25 #include "base/trace_event/trace_event.h" 27 #include "base/trace_event/trace_event.h"
26 #include "gpu/GLES2/gl2extchromium.h" 28 #include "gpu/GLES2/gl2extchromium.h"
27 #include "gpu/command_buffer/client/gles2_interface.h" 29 #include "gpu/command_buffer/client/gles2_interface.h"
28 #include "media/base/bind_to_current_loop.h" 30 #include "media/base/bind_to_current_loop.h"
29 #include "media/renderers/gpu_video_accelerator_factories.h" 31 #include "media/renderers/gpu_video_accelerator_factories.h"
30 #include "third_party/libyuv/include/libyuv.h" 32 #include "third_party/libyuv/include/libyuv.h"
31 #include "ui/gfx/buffer_format_util.h" 33 #include "ui/gfx/buffer_format_util.h"
32 #include "ui/gfx/gpu_memory_buffer_tracing.h"
33 #include "ui/gl/trace_util.h" 34 #include "ui/gl/trace_util.h"
34 35
35 namespace media { 36 namespace media {
36 37
37 // Implementation of a pool of GpuMemoryBuffers used to back VideoFrames. 38 // Implementation of a pool of GpuMemoryBuffers used to back VideoFrames.
38 class GpuMemoryBufferVideoFramePool::PoolImpl 39 class GpuMemoryBufferVideoFramePool::PoolImpl
39 : public base::RefCountedThreadSafe< 40 : public base::RefCountedThreadSafe<
40 GpuMemoryBufferVideoFramePool::PoolImpl>, 41 GpuMemoryBufferVideoFramePool::PoolImpl>,
41 public base::trace_event::MemoryDumpProvider { 42 public base::trace_event::MemoryDumpProvider {
42 public: 43 public:
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 base::trace_event::MemoryAllocatorDump* dump = 466 base::trace_event::MemoryAllocatorDump* dump =
466 pmd->CreateAllocatorDump(dump_name); 467 pmd->CreateAllocatorDump(dump_name);
467 size_t buffer_size_in_bytes = gfx::BufferSizeForBufferFormat( 468 size_t buffer_size_in_bytes = gfx::BufferSizeForBufferFormat(
468 plane_resource.size, plane_resource.gpu_memory_buffer->GetFormat()); 469 plane_resource.size, plane_resource.gpu_memory_buffer->GetFormat());
469 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, 470 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
470 base::trace_event::MemoryAllocatorDump::kUnitsBytes, 471 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
471 buffer_size_in_bytes); 472 buffer_size_in_bytes);
472 dump->AddScalar("free_size", 473 dump->AddScalar("free_size",
473 base::trace_event::MemoryAllocatorDump::kUnitsBytes, 474 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
474 frame_resources->IsInUse() ? 0 : buffer_size_in_bytes); 475 frame_resources->IsInUse() ? 0 : buffer_size_in_bytes);
475 auto shared_buffer_guid = 476
476 plane_resource.gpu_memory_buffer->GetGUIDForTracing( 477 base::SharedMemory* shared_memory =
477 tracing_process_id); 478 plane_resource.gpu_memory_buffer->GetSharedMemory();
478 pmd->CreateSharedGlobalAllocatorDump(shared_buffer_guid); 479 if (shared_memory) {
479 pmd->AddOwnershipEdge(dump->guid(), shared_buffer_guid, kImportance); 480 base::SharedMemoryTracker::AddOwnershipEdges(pmd, dump->guid(),
481 *shared_memory);
482 } else {
483 auto shared_buffer_guid =
484 plane_resource.gpu_memory_buffer->GetGUIDForTracing(
485 tracing_process_id);
486 pmd->CreateSharedGlobalAllocatorDump(shared_buffer_guid);
487 pmd->AddOwnershipEdge(dump->guid(), shared_buffer_guid, kImportance);
488 }
480 } 489 }
481 } 490 }
482 } 491 }
483 return true; 492 return true;
484 } 493 }
485 494
486 void GpuMemoryBufferVideoFramePool::PoolImpl::OnCopiesDone( 495 void GpuMemoryBufferVideoFramePool::PoolImpl::OnCopiesDone(
487 const scoped_refptr<VideoFrame>& video_frame, 496 const scoped_refptr<VideoFrame>& video_frame,
488 FrameResources* frame_resources, 497 FrameResources* frame_resources,
489 const FrameReadyCB& frame_ready_cb) { 498 const FrameReadyCB& frame_ready_cb) {
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 } 840 }
832 841
833 void GpuMemoryBufferVideoFramePool::MaybeCreateHardwareFrame( 842 void GpuMemoryBufferVideoFramePool::MaybeCreateHardwareFrame(
834 const scoped_refptr<VideoFrame>& video_frame, 843 const scoped_refptr<VideoFrame>& video_frame,
835 const FrameReadyCB& frame_ready_cb) { 844 const FrameReadyCB& frame_ready_cb) {
836 DCHECK(video_frame); 845 DCHECK(video_frame);
837 pool_impl_->CreateHardwareFrame(video_frame, frame_ready_cb); 846 pool_impl_->CreateHardwareFrame(video_frame, frame_ready_cb);
838 } 847 }
839 848
840 } // namespace media 849 } // namespace media
OLDNEW
« no previous file with comments | « gpu/ipc/service/gpu_command_buffer_stub.cc ('k') | services/ui/public/cpp/bitmap/child_shared_bitmap_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698