| 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/renderer/android/synchronous_compositor_output_surface.h" | 5 #include "content/renderer/android/synchronous_compositor_output_surface.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 // Ignore message if it's a stale one coming from a different output surface | 361 // Ignore message if it's a stale one coming from a different output surface |
| 362 // (e.g. after a lost context). | 362 // (e.g. after a lost context). |
| 363 if (output_surface_id != output_surface_id_) | 363 if (output_surface_id != output_surface_id_) |
| 364 return; | 364 return; |
| 365 ReclaimResources(resources); | 365 ReclaimResources(resources); |
| 366 } | 366 } |
| 367 | 367 |
| 368 void SynchronousCompositorOutputSurface::SetMemoryPolicy(size_t bytes_limit) { | 368 void SynchronousCompositorOutputSurface::SetMemoryPolicy(size_t bytes_limit) { |
| 369 DCHECK(CalledOnValidThread()); | 369 DCHECK(CalledOnValidThread()); |
| 370 bool became_zero = memory_policy_.bytes_limit_when_visible && !bytes_limit; | 370 bool became_zero = memory_policy_.bytes_limit_when_visible && !bytes_limit; |
| 371 bool became_non_zero = | |
| 372 !memory_policy_.bytes_limit_when_visible && bytes_limit; | |
| 373 memory_policy_.bytes_limit_when_visible = bytes_limit; | 371 memory_policy_.bytes_limit_when_visible = bytes_limit; |
| 374 memory_policy_.num_resources_limit = kNumResourcesLimit; | 372 memory_policy_.num_resources_limit = kNumResourcesLimit; |
| 375 | 373 |
| 376 if (client_) | 374 if (client_) |
| 377 client_->SetMemoryPolicy(memory_policy_); | 375 client_->SetMemoryPolicy(memory_policy_); |
| 378 | 376 |
| 379 if (became_zero) { | 377 if (became_zero) { |
| 380 // This is small hack to drop context resources without destroying it | 378 // This is small hack to drop context resources without destroying it |
| 381 // when this compositor is put into the background. | 379 // when this compositor is put into the background. |
| 382 context_provider()->ContextSupport()->SetAggressivelyFreeResources( | 380 context_provider()->DeleteCachedResources(); |
| 383 true /* aggressively_free_resources */); | |
| 384 } else if (became_non_zero) { | |
| 385 context_provider()->ContextSupport()->SetAggressivelyFreeResources( | |
| 386 false /* aggressively_free_resources */); | |
| 387 } | 381 } |
| 388 } | 382 } |
| 389 | 383 |
| 390 void SynchronousCompositorOutputSurface::DidActivatePendingTree() { | 384 void SynchronousCompositorOutputSurface::DidActivatePendingTree() { |
| 391 DCHECK(CalledOnValidThread()); | 385 DCHECK(CalledOnValidThread()); |
| 392 if (sync_client_) | 386 if (sync_client_) |
| 393 sync_client_->DidActivatePendingTree(); | 387 sync_client_->DidActivatePendingTree(); |
| 394 DeliverMessages(); | 388 DeliverMessages(); |
| 395 } | 389 } |
| 396 | 390 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 419 client_->ReclaimResources(resources); | 413 client_->ReclaimResources(resources); |
| 420 } | 414 } |
| 421 | 415 |
| 422 void SynchronousCompositorOutputSurface::SetBeginFrameSource( | 416 void SynchronousCompositorOutputSurface::SetBeginFrameSource( |
| 423 cc::BeginFrameSource* begin_frame_source) { | 417 cc::BeginFrameSource* begin_frame_source) { |
| 424 // Software output is synchronous and doesn't use a BeginFrameSource. | 418 // Software output is synchronous and doesn't use a BeginFrameSource. |
| 425 NOTREACHED(); | 419 NOTREACHED(); |
| 426 } | 420 } |
| 427 | 421 |
| 428 } // namespace content | 422 } // namespace content |
| OLD | NEW |