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

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

Issue 1401423003: Re-land: ui: Move GLImage::BindTexImage fallback from GLImage implementations to GLES2CmdDecoder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix stream texture issue Created 5 years, 2 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
« no previous file with comments | « ui/gl/gl_image_ref_counted_memory.h ('k') | ui/gl/gl_image_ref_counted_memory_unittest.cc » ('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 "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"
10 #include "base/trace_event/memory_dump_manager.h"
11 #include "base/trace_event/process_memory_dump.h"
9 12
10 namespace gfx { 13 namespace gfx {
11 14
12 GLImageRefCountedMemory::GLImageRefCountedMemory(const gfx::Size& size, 15 GLImageRefCountedMemory::GLImageRefCountedMemory(const Size& size,
13 unsigned internalformat) 16 unsigned internalformat)
14 : GLImageMemory(size, internalformat) { 17 : GLImageMemory(size, internalformat) {}
15 }
16 18
17 GLImageRefCountedMemory::~GLImageRefCountedMemory() { 19 GLImageRefCountedMemory::~GLImageRefCountedMemory() {
18 DCHECK(!ref_counted_memory_.get()); 20 DCHECK(!ref_counted_memory_.get());
19 } 21 }
20 22
21 bool GLImageRefCountedMemory::Initialize( 23 bool GLImageRefCountedMemory::Initialize(
22 base::RefCountedMemory* ref_counted_memory, 24 base::RefCountedMemory* ref_counted_memory,
23 gfx::BufferFormat format) { 25 BufferFormat format) {
24 if (!GLImageMemory::Initialize(ref_counted_memory->front(), format)) 26 if (!GLImageMemory::Initialize(ref_counted_memory->front(), format))
25 return false; 27 return false;
26 28
27 DCHECK(!ref_counted_memory_.get()); 29 DCHECK(!ref_counted_memory_.get());
28 ref_counted_memory_ = ref_counted_memory; 30 ref_counted_memory_ = ref_counted_memory;
29 return true; 31 return true;
30 } 32 }
31 33
32 void GLImageRefCountedMemory::Destroy(bool have_context) { 34 void GLImageRefCountedMemory::Destroy(bool have_context) {
33 GLImageMemory::Destroy(have_context); 35 GLImageMemory::Destroy(have_context);
34 ref_counted_memory_ = NULL; 36 ref_counted_memory_ = nullptr;
35 } 37 }
36 38
37 void GLImageRefCountedMemory::OnMemoryDump( 39 void GLImageRefCountedMemory::OnMemoryDump(
38 base::trace_event::ProcessMemoryDump* pmd, 40 base::trace_event::ProcessMemoryDump* pmd,
39 uint64_t process_tracing_id, 41 uint64_t process_tracing_id,
40 const std::string& dump_name) { 42 const std::string& dump_name) {
41 // Log size 0 if |ref_counted_memory_| has been released. 43 // Log size 0 if |ref_counted_memory_| has been released.
42 size_t size_in_bytes = ref_counted_memory_ ? ref_counted_memory_->size() : 0; 44 size_t size_in_bytes = ref_counted_memory_ ? ref_counted_memory_->size() : 0;
43 45
44 // Dump under "/private_memory", as the base class may also dump to 46 // Dump under "/private_memory", as the base class may also dump to
45 // "/texture_memory". 47 // "/texture_memory".
46 base::trace_event::MemoryAllocatorDump* dump = 48 base::trace_event::MemoryAllocatorDump* dump =
47 pmd->CreateAllocatorDump(dump_name + "/private_memory"); 49 pmd->CreateAllocatorDump(dump_name + "/private_memory");
48 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, 50 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
49 base::trace_event::MemoryAllocatorDump::kUnitsBytes, 51 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
50 static_cast<uint64_t>(size_in_bytes)); 52 static_cast<uint64_t>(size_in_bytes));
51 53
52 pmd->AddSuballocation(dump->guid(), 54 pmd->AddSuballocation(dump->guid(),
53 base::trace_event::MemoryDumpManager::GetInstance() 55 base::trace_event::MemoryDumpManager::GetInstance()
54 ->system_allocator_pool_name()); 56 ->system_allocator_pool_name());
55
56 // Also dump the base class's texture memory.
57 GLImageMemory::OnMemoryDump(pmd, process_tracing_id, dump_name);
58 } 57 }
59 58
60 } // namespace gfx 59 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_image_ref_counted_memory.h ('k') | ui/gl/gl_image_ref_counted_memory_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698