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_memory.h" | 5 #include "ui/gl/gl_image_memory.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
9 #include "ui/gl/gl_bindings.h" | 9 #include "ui/gl/gl_bindings.h" |
10 #include "ui/gl/scoped_binders.h" | 10 #include "ui/gl/scoped_binders.h" |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 0, // border | 439 0, // border |
440 DataFormat(format_), | 440 DataFormat(format_), |
441 DataType(format_), | 441 DataType(format_), |
442 memory_); | 442 memory_); |
443 } | 443 } |
444 } | 444 } |
445 | 445 |
446 void GLImageMemory::OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd, | 446 void GLImageMemory::OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd, |
447 uint64_t process_tracing_id, | 447 uint64_t process_tracing_id, |
448 const std::string& dump_name) { | 448 const std::string& dump_name) { |
449 // Log size 0 if |ref_counted_memory_| has been released. | 449 // Note that the following calculation does not consider whether this GLImage |
450 size_t size_in_bytes = memory_ ? SizeInBytes(size_, format_) : 0; | 450 // has been un-bound from a texture. It also relies on this GLImage only ever |
| 451 // being bound to a single texture. We could check these conditions more |
| 452 // thoroughly, but at the cost of extra GL queries. |
| 453 bool is_bound_to_texture = target_ && !need_do_bind_tex_image_; |
| 454 |
| 455 #if defined(OS_WIN) || defined(USE_X11) || defined(OS_ANDROID) || \ |
| 456 defined(USE_OZONE) |
| 457 is_bound_to_texture |= !!egl_texture_id_; |
| 458 #endif |
| 459 |
| 460 size_t size_in_bytes = is_bound_to_texture ? SizeInBytes(size_, format_) : 0; |
451 | 461 |
452 base::trace_event::MemoryAllocatorDump* dump = | 462 base::trace_event::MemoryAllocatorDump* dump = |
453 pmd->CreateAllocatorDump(dump_name); | 463 pmd->CreateAllocatorDump(dump_name + "/texture_memory"); |
454 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, | 464 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, |
455 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | 465 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
456 static_cast<uint64_t>(size_in_bytes)); | 466 static_cast<uint64_t>(size_in_bytes)); |
| 467 |
| 468 // No need for a global shared edge here. This object in the GPU process is |
| 469 // the sole owner of this texture id. |
457 } | 470 } |
458 | 471 |
459 } // namespace gfx | 472 } // namespace gfx |
OLD | NEW |