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