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

Side by Side Diff: ui/gl/gl_image_shared_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_shared_memory.h ('k') | ui/gl/gl_image_stub.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_shared_memory.h" 5 #include "ui/gl/gl_image_shared_memory.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/shared_memory.h" 8 #include "base/memory/shared_memory.h"
9 #include "base/numerics/safe_math.h" 9 #include "base/numerics/safe_math.h"
10 #include "base/process/process_handle.h" 10 #include "base/process/process_handle.h"
11 #include "base/sys_info.h" 11 #include "base/sys_info.h"
12 #include "base/trace_event/memory_allocator_dump.h" 12 #include "base/trace_event/memory_allocator_dump.h"
13 #include "base/trace_event/memory_dump_manager.h" 13 #include "base/trace_event/memory_dump_manager.h"
14 #include "base/trace_event/process_memory_dump.h" 14 #include "base/trace_event/process_memory_dump.h"
15 #include "ui/gfx/buffer_format_util.h" 15 #include "ui/gfx/buffer_format_util.h"
16 16
17 namespace gl { 17 namespace gl {
18 18
19 GLImageSharedMemory::GLImageSharedMemory(const gfx::Size& size, 19 GLImageSharedMemory::GLImageSharedMemory(const gfx::Size& size,
20 unsigned internalformat) 20 unsigned internalformat)
21 : GLImageMemory(size, internalformat) {} 21 : GLImageMemory(size, internalformat) {}
22 22
23 GLImageSharedMemory::~GLImageSharedMemory() { 23 GLImageSharedMemory::~GLImageSharedMemory() {}
24 DCHECK(!shared_memory_);
25 }
26 24
27 bool GLImageSharedMemory::Initialize( 25 bool GLImageSharedMemory::Initialize(
28 const base::SharedMemoryHandle& handle, 26 const base::SharedMemoryHandle& handle,
29 gfx::GenericSharedMemoryId shared_memory_id, 27 gfx::GenericSharedMemoryId shared_memory_id,
30 gfx::BufferFormat format, 28 gfx::BufferFormat format,
31 size_t offset, 29 size_t offset,
32 size_t stride) { 30 size_t stride) {
33 if (!base::SharedMemory::IsHandleValid(handle)) 31 if (!base::SharedMemory::IsHandleValid(handle))
34 return false; 32 return false;
35 33
(...skipping 29 matching lines...) Expand all
65 format, stride)) { 63 format, stride)) {
66 return false; 64 return false;
67 } 65 }
68 66
69 DCHECK(!shared_memory_); 67 DCHECK(!shared_memory_);
70 shared_memory_ = std::move(shared_memory); 68 shared_memory_ = std::move(shared_memory);
71 shared_memory_id_ = shared_memory_id; 69 shared_memory_id_ = shared_memory_id;
72 return true; 70 return true;
73 } 71 }
74 72
75 void GLImageSharedMemory::Destroy(bool have_context) {
76 GLImageMemory::Destroy(have_context);
77 shared_memory_.reset();
78 }
79
80 void GLImageSharedMemory::OnMemoryDump( 73 void GLImageSharedMemory::OnMemoryDump(
81 base::trace_event::ProcessMemoryDump* pmd, 74 base::trace_event::ProcessMemoryDump* pmd,
82 uint64_t process_tracing_id, 75 uint64_t process_tracing_id,
83 const std::string& dump_name) { 76 const std::string& dump_name) {
84 size_t size_in_bytes = 0; 77 size_t size_in_bytes = 0;
85 78
86 if (shared_memory_) 79 if (shared_memory_)
87 size_in_bytes = stride() * GetSize().height(); 80 size_in_bytes = stride() * GetSize().height();
88 81
89 // Dump under "/shared_memory", as the base class may also dump to 82 // Dump under "/shared_memory", as the base class may also dump to
90 // "/texture_memory". 83 // "/texture_memory".
91 base::trace_event::MemoryAllocatorDump* dump = 84 base::trace_event::MemoryAllocatorDump* dump =
92 pmd->CreateAllocatorDump(dump_name + "/shared_memory"); 85 pmd->CreateAllocatorDump(dump_name + "/shared_memory");
93 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, 86 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
94 base::trace_event::MemoryAllocatorDump::kUnitsBytes, 87 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
95 static_cast<uint64_t>(size_in_bytes)); 88 static_cast<uint64_t>(size_in_bytes));
96 89
97 auto guid = GetGenericSharedMemoryGUIDForTracing(process_tracing_id, 90 auto guid = GetGenericSharedMemoryGUIDForTracing(process_tracing_id,
98 shared_memory_id_); 91 shared_memory_id_);
99 pmd->CreateSharedGlobalAllocatorDump(guid); 92 pmd->CreateSharedGlobalAllocatorDump(guid);
100 pmd->AddOwnershipEdge(dump->guid(), guid); 93 pmd->AddOwnershipEdge(dump->guid(), guid);
101 } 94 }
102 95
103 } // namespace gl 96 } // namespace gl
OLDNEW
« no previous file with comments | « ui/gl/gl_image_shared_memory.h ('k') | ui/gl/gl_image_stub.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698