| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/common/gpu/gpu_memory_manager.h" | 5 #include "content/common/gpu/gpu_memory_manager.h" |
| 6 #include "content/common/gpu/gpu_memory_manager_client.h" | 6 #include "content/common/gpu/gpu_memory_manager_client.h" |
| 7 #include "content/common/gpu/gpu_memory_tracking.h" | 7 #include "content/common/gpu/gpu_memory_tracking.h" |
| 8 #include "gpu/command_buffer/common/gpu_memory_allocation.h" | 8 #include "gpu/command_buffer/common/gpu_memory_allocation.h" |
| 9 #include "ui/gfx/size_conversions.h" | 9 #include "ui/gfx/size_conversions.h" |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 } | 21 } |
| 22 }; | 22 }; |
| 23 } // namespace BASE_HASH_NAMESPACE | 23 } // namespace BASE_HASH_NAMESPACE |
| 24 #endif // COMPILER | 24 #endif // COMPILER |
| 25 | 25 |
| 26 class FakeMemoryTracker : public gpu::gles2::MemoryTracker { | 26 class FakeMemoryTracker : public gpu::gles2::MemoryTracker { |
| 27 public: | 27 public: |
| 28 virtual void TrackMemoryAllocatedChange( | 28 virtual void TrackMemoryAllocatedChange( |
| 29 size_t /* old_size */, | 29 size_t /* old_size */, |
| 30 size_t /* new_size */, | 30 size_t /* new_size */, |
| 31 gpu::gles2::MemoryTracker::Pool /* pool */) OVERRIDE { | 31 gpu::gles2::MemoryTracker::Pool /* pool */) override { |
| 32 } | 32 } |
| 33 virtual bool EnsureGPUMemoryAvailable(size_t /* size_needed */) OVERRIDE { | 33 virtual bool EnsureGPUMemoryAvailable(size_t /* size_needed */) override { |
| 34 return true; | 34 return true; |
| 35 } | 35 } |
| 36 private: | 36 private: |
| 37 virtual ~FakeMemoryTracker() { | 37 virtual ~FakeMemoryTracker() { |
| 38 } | 38 } |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 namespace content { | 41 namespace content { |
| 42 | 42 |
| 43 // This class is used to collect all stub assignments during a | 43 // This class is used to collect all stub assignments during a |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 client_state_.reset( | 109 client_state_.reset( |
| 110 memmgr_->CreateClientState(this, surface_id != 0, visible)); | 110 memmgr_->CreateClientState(this, surface_id != 0, visible)); |
| 111 } | 111 } |
| 112 | 112 |
| 113 virtual ~FakeClient() { | 113 virtual ~FakeClient() { |
| 114 client_state_.reset(); | 114 client_state_.reset(); |
| 115 tracking_group_.reset(); | 115 tracking_group_.reset(); |
| 116 memory_tracker_ = NULL; | 116 memory_tracker_ = NULL; |
| 117 } | 117 } |
| 118 | 118 |
| 119 virtual void SetMemoryAllocation(const MemoryAllocation& alloc) OVERRIDE { | 119 virtual void SetMemoryAllocation(const MemoryAllocation& alloc) override { |
| 120 allocation_ = alloc; | 120 allocation_ = alloc; |
| 121 ClientAssignmentCollector::AddClientStat(this, alloc); | 121 ClientAssignmentCollector::AddClientStat(this, alloc); |
| 122 } | 122 } |
| 123 | 123 |
| 124 virtual void SuggestHaveFrontBuffer(bool suggest_have_frontbuffer) OVERRIDE { | 124 virtual void SuggestHaveFrontBuffer(bool suggest_have_frontbuffer) override { |
| 125 suggest_have_frontbuffer_ = suggest_have_frontbuffer; | 125 suggest_have_frontbuffer_ = suggest_have_frontbuffer; |
| 126 } | 126 } |
| 127 | 127 |
| 128 virtual bool GetTotalGpuMemory(uint64* bytes) OVERRIDE { | 128 virtual bool GetTotalGpuMemory(uint64* bytes) override { |
| 129 if (total_gpu_memory_) { | 129 if (total_gpu_memory_) { |
| 130 *bytes = total_gpu_memory_; | 130 *bytes = total_gpu_memory_; |
| 131 return true; | 131 return true; |
| 132 } | 132 } |
| 133 return false; | 133 return false; |
| 134 } | 134 } |
| 135 void SetTotalGpuMemory(uint64 bytes) { total_gpu_memory_ = bytes; } | 135 void SetTotalGpuMemory(uint64 bytes) { total_gpu_memory_ = bytes; } |
| 136 | 136 |
| 137 virtual gpu::gles2::MemoryTracker* GetMemoryTracker() const OVERRIDE { | 137 virtual gpu::gles2::MemoryTracker* GetMemoryTracker() const override { |
| 138 if (share_group_) | 138 if (share_group_) |
| 139 return share_group_->GetMemoryTracker(); | 139 return share_group_->GetMemoryTracker(); |
| 140 return memory_tracker_.get(); | 140 return memory_tracker_.get(); |
| 141 } | 141 } |
| 142 | 142 |
| 143 virtual gfx::Size GetSurfaceSize() const OVERRIDE { | 143 virtual gfx::Size GetSurfaceSize() const override { |
| 144 return surface_size_; | 144 return surface_size_; |
| 145 } | 145 } |
| 146 void SetSurfaceSize(gfx::Size size) { surface_size_ = size; } | 146 void SetSurfaceSize(gfx::Size size) { surface_size_ = size; } |
| 147 | 147 |
| 148 void SetVisible(bool visible) { | 148 void SetVisible(bool visible) { |
| 149 client_state_->SetVisible(visible); | 149 client_state_->SetVisible(visible); |
| 150 } | 150 } |
| 151 | 151 |
| 152 uint64 BytesWhenVisible() const { | 152 uint64 BytesWhenVisible() const { |
| 153 return allocation_.bytes_limit_when_visible; | 153 return allocation_.bytes_limit_when_visible; |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 stub_ignore_c.SetVisible(true); | 410 stub_ignore_c.SetVisible(true); |
| 411 stub_ignore_c.SetVisible(false); | 411 stub_ignore_c.SetVisible(false); |
| 412 Manage(); | 412 Manage(); |
| 413 EXPECT_TRUE(IsAllocationHibernatedForSurfaceYes(stub1.allocation_)); | 413 EXPECT_TRUE(IsAllocationHibernatedForSurfaceYes(stub1.allocation_)); |
| 414 EXPECT_TRUE(IsAllocationHibernatedForSurfaceYes(stub2.allocation_)); | 414 EXPECT_TRUE(IsAllocationHibernatedForSurfaceYes(stub2.allocation_)); |
| 415 EXPECT_TRUE(IsAllocationHibernatedForSurfaceNo(stub3.allocation_)); | 415 EXPECT_TRUE(IsAllocationHibernatedForSurfaceNo(stub3.allocation_)); |
| 416 EXPECT_TRUE(IsAllocationHibernatedForSurfaceNo(stub4.allocation_)); | 416 EXPECT_TRUE(IsAllocationHibernatedForSurfaceNo(stub4.allocation_)); |
| 417 } | 417 } |
| 418 | 418 |
| 419 } // namespace content | 419 } // namespace content |
| OLD | NEW |