OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 1430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1441 } | 1441 } |
1442 | 1442 |
1443 void LayerTreeHostImpl::DidReceiveCompositorFrameAck() { | 1443 void LayerTreeHostImpl::DidReceiveCompositorFrameAck() { |
1444 client_->DidReceiveCompositorFrameAckOnImplThread(); | 1444 client_->DidReceiveCompositorFrameAckOnImplThread(); |
1445 } | 1445 } |
1446 | 1446 |
1447 void LayerTreeHostImpl::ReclaimResources( | 1447 void LayerTreeHostImpl::ReclaimResources( |
1448 const ReturnedResourceArray& resources) { | 1448 const ReturnedResourceArray& resources) { |
1449 // TODO(piman): We may need to do some validation on this ack before | 1449 // TODO(piman): We may need to do some validation on this ack before |
1450 // processing it. | 1450 // processing it. |
1451 if (resource_provider_) | 1451 if (!resource_provider_) |
1452 resource_provider_->ReceiveReturnsFromParent(resources); | 1452 return; |
| 1453 |
| 1454 resource_provider_->ReceiveReturnsFromParent(resources); |
1453 | 1455 |
1454 // In OOM, we now might be able to release more resources that were held | 1456 // In OOM, we now might be able to release more resources that were held |
1455 // because they were exported. | 1457 // because they were exported. |
1456 if (resource_pool_) { | 1458 if (resource_pool_) { |
1457 if (resource_pool_->memory_usage_bytes()) { | 1459 if (resource_pool_->memory_usage_bytes()) { |
1458 const size_t kMegabyte = 1024 * 1024; | 1460 const size_t kMegabyte = 1024 * 1024; |
1459 | 1461 |
1460 // This is a good time to log memory usage. A chunk of work has just | 1462 // This is a good time to log memory usage. A chunk of work has just |
1461 // completed but none of the memory used for that work has likely been | 1463 // completed but none of the memory used for that work has likely been |
1462 // freed. | 1464 // freed. |
1463 UMA_HISTOGRAM_MEMORY_MB( | 1465 UMA_HISTOGRAM_MEMORY_MB( |
1464 "Renderer4.ResourcePoolMemoryUsage", | 1466 "Renderer4.ResourcePoolMemoryUsage", |
1465 static_cast<int>(resource_pool_->memory_usage_bytes() / kMegabyte)); | 1467 static_cast<int>(resource_pool_->memory_usage_bytes() / kMegabyte)); |
1466 } | 1468 } |
1467 | 1469 |
1468 resource_pool_->CheckBusyResources(); | 1470 resource_pool_->CheckBusyResources(); |
1469 resource_pool_->ReduceResourceUsage(); | 1471 resource_pool_->ReduceResourceUsage(); |
1470 } | 1472 } |
1471 | 1473 |
1472 // If we're not visible, we likely released resources, so we want to | 1474 // If we're not visible, we likely released resources, so we want to |
1473 // aggressively flush here to make sure those DeleteTextures make it to the | 1475 // aggressively flush here to make sure those DeleteTextures make it to the |
1474 // GPU process to free up the memory. | 1476 // GPU process to free up the memory. |
1475 if (compositor_frame_sink_->context_provider() && !visible_) { | 1477 if (!visible_) |
1476 compositor_frame_sink_->context_provider() | 1478 resource_provider_->FlushPendingDeletions(); |
1477 ->ContextGL() | |
1478 ->ShallowFlushCHROMIUM(); | |
1479 } | |
1480 } | 1479 } |
1481 | 1480 |
1482 void LayerTreeHostImpl::OnDraw(const gfx::Transform& transform, | 1481 void LayerTreeHostImpl::OnDraw(const gfx::Transform& transform, |
1483 const gfx::Rect& viewport, | 1482 const gfx::Rect& viewport, |
1484 bool resourceless_software_draw) { | 1483 bool resourceless_software_draw) { |
1485 DCHECK(!resourceless_software_draw_); | 1484 DCHECK(!resourceless_software_draw_); |
1486 const bool transform_changed = external_transform_ != transform; | 1485 const bool transform_changed = external_transform_ != transform; |
1487 const bool viewport_changed = external_viewport_ != viewport; | 1486 const bool viewport_changed = external_viewport_ != viewport; |
1488 | 1487 |
1489 external_transform_ = transform; | 1488 external_transform_ = transform; |
(...skipping 2602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4092 worker_context_visibility_ = | 4091 worker_context_visibility_ = |
4093 worker_context->CacheController()->ClientBecameVisible(); | 4092 worker_context->CacheController()->ClientBecameVisible(); |
4094 } else { | 4093 } else { |
4095 worker_context->CacheController()->ClientBecameNotVisible( | 4094 worker_context->CacheController()->ClientBecameNotVisible( |
4096 std::move(worker_context_visibility_)); | 4095 std::move(worker_context_visibility_)); |
4097 } | 4096 } |
4098 } | 4097 } |
4099 } | 4098 } |
4100 | 4099 |
4101 } // namespace cc | 4100 } // namespace cc |
OLD | NEW |