| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/gl/gl_image_ref_counted_memory.h" | 5 #include "ui/gl/gl_image_ref_counted_memory.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/ref_counted_memory.h" | 8 #include "base/memory/ref_counted_memory.h" |
| 9 #include "base/trace_event/memory_allocator_dump.h" | 9 #include "base/trace_event/memory_allocator_dump.h" |
| 10 #include "base/trace_event/memory_dump_manager.h" | 10 #include "base/trace_event/memory_dump_manager.h" |
| 11 #include "base/trace_event/process_memory_dump.h" | 11 #include "base/trace_event/process_memory_dump.h" |
| 12 #include "ui/gfx/buffer_format_util.h" | |
| 13 | 12 |
| 14 namespace gl { | 13 namespace gl { |
| 15 | 14 |
| 16 GLImageRefCountedMemory::GLImageRefCountedMemory(const gfx::Size& size, | 15 GLImageRefCountedMemory::GLImageRefCountedMemory(const gfx::Size& size, |
| 17 unsigned internalformat) | 16 unsigned internalformat) |
| 18 : GLImageMemory(size, internalformat) {} | 17 : GLImageMemory(size, internalformat) {} |
| 19 | 18 |
| 20 GLImageRefCountedMemory::~GLImageRefCountedMemory() { | 19 GLImageRefCountedMemory::~GLImageRefCountedMemory() { |
| 21 DCHECK(!ref_counted_memory_.get()); | 20 DCHECK(!ref_counted_memory_.get()); |
| 22 } | 21 } |
| 23 | 22 |
| 24 bool GLImageRefCountedMemory::Initialize( | 23 bool GLImageRefCountedMemory::Initialize( |
| 25 base::RefCountedMemory* ref_counted_memory, | 24 base::RefCountedMemory* ref_counted_memory, |
| 26 gfx::BufferFormat format) { | 25 gfx::BufferFormat format) { |
| 27 if (!GLImageMemory::Initialize( | 26 if (!GLImageMemory::Initialize(ref_counted_memory->front(), format)) |
| 28 ref_counted_memory->front(), format, | |
| 29 gfx::RowSizeForBufferFormat(GetSize().width(), format, 0))) { | |
| 30 return false; | 27 return false; |
| 31 } | |
| 32 | 28 |
| 33 DCHECK(!ref_counted_memory_.get()); | 29 DCHECK(!ref_counted_memory_.get()); |
| 34 ref_counted_memory_ = ref_counted_memory; | 30 ref_counted_memory_ = ref_counted_memory; |
| 35 return true; | 31 return true; |
| 36 } | 32 } |
| 37 | 33 |
| 38 void GLImageRefCountedMemory::Destroy(bool have_context) { | 34 void GLImageRefCountedMemory::Destroy(bool have_context) { |
| 39 GLImageMemory::Destroy(have_context); | 35 GLImageMemory::Destroy(have_context); |
| 40 ref_counted_memory_ = nullptr; | 36 ref_counted_memory_ = nullptr; |
| 41 } | 37 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 54 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, | 50 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, |
| 55 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | 51 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
| 56 static_cast<uint64_t>(size_in_bytes)); | 52 static_cast<uint64_t>(size_in_bytes)); |
| 57 | 53 |
| 58 pmd->AddSuballocation(dump->guid(), | 54 pmd->AddSuballocation(dump->guid(), |
| 59 base::trace_event::MemoryDumpManager::GetInstance() | 55 base::trace_event::MemoryDumpManager::GetInstance() |
| 60 ->system_allocator_pool_name()); | 56 ->system_allocator_pool_name()); |
| 61 } | 57 } |
| 62 | 58 |
| 63 } // namespace gl | 59 } // namespace gl |
| OLD | NEW |