Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/browser/android/in_process/synchronous_compositor_output_surfa ce.h" | 5 #include "content/browser/android/in_process/synchronous_compositor_output_surfa ce.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "cc/output/compositor_frame.h" | 9 #include "cc/output/compositor_frame.h" |
| 10 #include "cc/output/context_provider.h" | 10 #include "cc/output/context_provider.h" |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 251 memory_policy_.num_resources_limit = kNumResourcesLimit; | 251 memory_policy_.num_resources_limit = kNumResourcesLimit; |
| 252 | 252 |
| 253 if (client_) | 253 if (client_) |
| 254 client_->SetMemoryPolicy(memory_policy_); | 254 client_->SetMemoryPolicy(memory_policy_); |
| 255 | 255 |
| 256 if (became_zero) { | 256 if (became_zero) { |
| 257 // This is small hack to drop context resources without destroying it | 257 // This is small hack to drop context resources without destroying it |
| 258 // when this compositor is put into the background. | 258 // when this compositor is put into the background. |
| 259 context_provider()->ContextSupport()->SetAggressivelyFreeResources( | 259 context_provider()->ContextSupport()->SetAggressivelyFreeResources( |
| 260 true /* aggressively_free_resources */); | 260 true /* aggressively_free_resources */); |
| 261 context_provider()->ContextGL()->FlushDriverCachesCHROMIUM(); | |
|
piman
2015/07/13 21:25:29
Should we do this before SetAggressivelyFreeResour
ericrk
2015/07/13 22:11:11
Moved this to FreeEverything.
| |
| 261 } else if (became_non_zero) { | 262 } else if (became_non_zero) { |
| 262 context_provider()->ContextSupport()->SetAggressivelyFreeResources( | 263 context_provider()->ContextSupport()->SetAggressivelyFreeResources( |
| 263 false /* aggressively_free_resources */); | 264 false /* aggressively_free_resources */); |
| 264 } | 265 } |
| 265 } | 266 } |
| 266 | 267 |
| 267 void SynchronousCompositorOutputSurface::SetTreeActivationCallback( | 268 void SynchronousCompositorOutputSurface::SetTreeActivationCallback( |
| 268 const base::Closure& callback) { | 269 const base::Closure& callback) { |
| 269 DCHECK(client_); | 270 DCHECK(client_); |
| 270 client_->SetTreeActivationCallback(callback); | 271 client_->SetTreeActivationCallback(callback); |
| 271 } | 272 } |
| 272 | 273 |
| 273 void SynchronousCompositorOutputSurface::GetMessagesToDeliver( | 274 void SynchronousCompositorOutputSurface::GetMessagesToDeliver( |
| 274 ScopedVector<IPC::Message>* messages) { | 275 ScopedVector<IPC::Message>* messages) { |
| 275 DCHECK(CalledOnValidThread()); | 276 DCHECK(CalledOnValidThread()); |
| 276 scoped_ptr<FrameSwapMessageQueue::SendMessageScope> send_message_scope = | 277 scoped_ptr<FrameSwapMessageQueue::SendMessageScope> send_message_scope = |
| 277 frame_swap_message_queue_->AcquireSendMessageScope(); | 278 frame_swap_message_queue_->AcquireSendMessageScope(); |
| 278 frame_swap_message_queue_->DrainMessages(messages); | 279 frame_swap_message_queue_->DrainMessages(messages); |
| 279 } | 280 } |
| 280 | 281 |
| 281 // Not using base::NonThreadSafe as we want to enforce a more exacting threading | 282 // Not using base::NonThreadSafe as we want to enforce a more exacting threading |
| 282 // requirement: SynchronousCompositorOutputSurface() must only be used on the UI | 283 // requirement: SynchronousCompositorOutputSurface() must only be used on the UI |
| 283 // thread. | 284 // thread. |
| 284 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { | 285 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { |
| 285 return BrowserThread::CurrentlyOn(BrowserThread::UI); | 286 return BrowserThread::CurrentlyOn(BrowserThread::UI); |
| 286 } | 287 } |
| 287 | 288 |
| 288 } // namespace content | 289 } // namespace content |
| OLD | NEW |