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

Side by Side Diff: ui/gl/gl_image_ref_counted_memory.cc

Issue 2449993005: Remove GLImage::Destroy(). (Closed)
Patch Set: One more Destroy() call on Mac. Created 4 years, 1 month 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
« no previous file with comments | « ui/gl/gl_image_ref_counted_memory.h ('k') | ui/gl/gl_image_shared_memory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ref_counted_memory.h" 10 #include "base/memory/ref_counted_memory.h"
11 #include "base/trace_event/memory_allocator_dump.h" 11 #include "base/trace_event/memory_allocator_dump.h"
12 #include "base/trace_event/memory_dump_manager.h" 12 #include "base/trace_event/memory_dump_manager.h"
13 #include "base/trace_event/process_memory_dump.h" 13 #include "base/trace_event/process_memory_dump.h"
14 #include "ui/gfx/buffer_format_util.h" 14 #include "ui/gfx/buffer_format_util.h"
15 15
16 namespace gl { 16 namespace gl {
17 17
18 GLImageRefCountedMemory::GLImageRefCountedMemory(const gfx::Size& size, 18 GLImageRefCountedMemory::GLImageRefCountedMemory(const gfx::Size& size,
19 unsigned internalformat) 19 unsigned internalformat)
20 : GLImageMemory(size, internalformat) {} 20 : GLImageMemory(size, internalformat) {}
21 21
22 GLImageRefCountedMemory::~GLImageRefCountedMemory() { 22 GLImageRefCountedMemory::~GLImageRefCountedMemory() {}
23 DCHECK(!ref_counted_memory_.get());
24 }
25 23
26 bool GLImageRefCountedMemory::Initialize( 24 bool GLImageRefCountedMemory::Initialize(
27 base::RefCountedMemory* ref_counted_memory, 25 base::RefCountedMemory* ref_counted_memory,
28 gfx::BufferFormat format) { 26 gfx::BufferFormat format) {
29 if (!GLImageMemory::Initialize( 27 if (!GLImageMemory::Initialize(
30 ref_counted_memory->front(), format, 28 ref_counted_memory->front(), format,
31 gfx::RowSizeForBufferFormat(GetSize().width(), format, 0))) { 29 gfx::RowSizeForBufferFormat(GetSize().width(), format, 0))) {
32 return false; 30 return false;
33 } 31 }
34 32
35 DCHECK(!ref_counted_memory_.get()); 33 DCHECK(!ref_counted_memory_.get());
36 ref_counted_memory_ = ref_counted_memory; 34 ref_counted_memory_ = ref_counted_memory;
37 return true; 35 return true;
38 } 36 }
39 37
40 void GLImageRefCountedMemory::Destroy(bool have_context) {
41 GLImageMemory::Destroy(have_context);
42 ref_counted_memory_ = nullptr;
43 }
44
45 void GLImageRefCountedMemory::OnMemoryDump( 38 void GLImageRefCountedMemory::OnMemoryDump(
46 base::trace_event::ProcessMemoryDump* pmd, 39 base::trace_event::ProcessMemoryDump* pmd,
47 uint64_t process_tracing_id, 40 uint64_t process_tracing_id,
48 const std::string& dump_name) { 41 const std::string& dump_name) {
49 // Log size 0 if |ref_counted_memory_| has been released. 42 // Log size 0 if |ref_counted_memory_| has been released.
50 size_t size_in_bytes = ref_counted_memory_ ? ref_counted_memory_->size() : 0; 43 size_t size_in_bytes = ref_counted_memory_ ? ref_counted_memory_->size() : 0;
51 44
52 // Dump under "/private_memory", as the base class may also dump to 45 // Dump under "/private_memory", as the base class may also dump to
53 // "/texture_memory". 46 // "/texture_memory".
54 base::trace_event::MemoryAllocatorDump* dump = 47 base::trace_event::MemoryAllocatorDump* dump =
55 pmd->CreateAllocatorDump(dump_name + "/private_memory"); 48 pmd->CreateAllocatorDump(dump_name + "/private_memory");
56 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, 49 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
57 base::trace_event::MemoryAllocatorDump::kUnitsBytes, 50 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
58 static_cast<uint64_t>(size_in_bytes)); 51 static_cast<uint64_t>(size_in_bytes));
59 52
60 pmd->AddSuballocation(dump->guid(), 53 pmd->AddSuballocation(dump->guid(),
61 base::trace_event::MemoryDumpManager::GetInstance() 54 base::trace_event::MemoryDumpManager::GetInstance()
62 ->system_allocator_pool_name()); 55 ->system_allocator_pool_name());
63 } 56 }
64 57
65 } // namespace gl 58 } // namespace gl
OLDNEW
« no previous file with comments | « ui/gl/gl_image_ref_counted_memory.h ('k') | ui/gl/gl_image_shared_memory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698