OLD | NEW |
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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 "cc/output/context_cache_controller.h" | 5 #include "cc/output/context_cache_controller.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/debug/activity_tracker.h" |
8 #include "base/logging.h" | 9 #include "base/logging.h" |
9 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
10 #include "base/synchronization/lock.h" | 11 #include "base/synchronization/lock.h" |
11 #include "gpu/command_buffer/client/context_support.h" | 12 #include "gpu/command_buffer/client/context_support.h" |
12 #include "third_party/skia/include/gpu/GrContext.h" | 13 #include "third_party/skia/include/gpu/GrContext.h" |
13 | 14 |
14 namespace cc { | 15 namespace cc { |
15 namespace { | 16 namespace { |
16 static const int kIdleCleanupDelaySeconds = 1; | 17 static const int kIdleCleanupDelaySeconds = 1; |
17 } // namespace | 18 } // namespace |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 | 152 |
152 // Try to acquire the context lock - if we can't acquire it then we've become | 153 // Try to acquire the context lock - if we can't acquire it then we've become |
153 // busy since checking |current_idle_generation_| above. In this case, just | 154 // busy since checking |current_idle_generation_| above. In this case, just |
154 // re-post our idle callback and return. | 155 // re-post our idle callback and return. |
155 if (context_lock_ && !context_lock_->Try()) { | 156 if (context_lock_ && !context_lock_->Try()) { |
156 base::AutoLock hold(current_idle_generation_lock_); | 157 base::AutoLock hold(current_idle_generation_lock_); |
157 PostIdleCallback(current_idle_generation_); | 158 PostIdleCallback(current_idle_generation_); |
158 return; | 159 return; |
159 } | 160 } |
160 | 161 |
161 if (gr_context_) | 162 if (gr_context_) { |
| 163 // TODO(manzagop): remove ScopedActivity once crbug.com/703342 is fixed. |
| 164 const uint32_t kActivityId = |
| 165 0x0e38f5d0; // SHA1(ContextCacheController::OnIdle) |
| 166 base::debug::ScopedActivity activity_free(0, kActivityId, 0); |
| 167 |
162 gr_context_->freeGpuResources(); | 168 gr_context_->freeGpuResources(); |
| 169 } |
163 | 170 |
164 // Toggle SetAggressivelyFreeResources to drop command buffer data. | 171 // Toggle SetAggressivelyFreeResources to drop command buffer data. |
165 context_support_->SetAggressivelyFreeResources(true); | 172 context_support_->SetAggressivelyFreeResources(true); |
166 context_support_->SetAggressivelyFreeResources(false); | 173 context_support_->SetAggressivelyFreeResources(false); |
167 | 174 |
168 callback_pending_ = false; | 175 callback_pending_ = false; |
169 | 176 |
170 if (context_lock_) | 177 if (context_lock_) |
171 context_lock_->Release(); | 178 context_lock_->Release(); |
172 } | 179 } |
173 | 180 |
174 } // namespace cc | 181 } // namespace cc |
OLD | NEW |