| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 void DidVisibilityChange(LayerTreeHostImpl* id, bool visible) { | 122 void DidVisibilityChange(LayerTreeHostImpl* id, bool visible) { |
| 123 if (visible) { | 123 if (visible) { |
| 124 TRACE_EVENT_ASYNC_BEGIN1("cc", "LayerTreeHostImpl::SetVisible", id, | 124 TRACE_EVENT_ASYNC_BEGIN1("cc", "LayerTreeHostImpl::SetVisible", id, |
| 125 "LayerTreeHostImpl", id); | 125 "LayerTreeHostImpl", id); |
| 126 return; | 126 return; |
| 127 } | 127 } |
| 128 | 128 |
| 129 TRACE_EVENT_ASYNC_END0("cc", "LayerTreeHostImpl::SetVisible", id); | 129 TRACE_EVENT_ASYNC_END0("cc", "LayerTreeHostImpl::SetVisible", id); |
| 130 } | 130 } |
| 131 | 131 |
| 132 size_t GetMaxTransferBufferUsageBytes( | |
| 133 const ContextProvider::Capabilities& context_capabilities, | |
| 134 double refresh_rate) { | |
| 135 // We want to make sure the default transfer buffer size is equal to the | |
| 136 // amount of data that can be uploaded by the compositor to avoid stalling | |
| 137 // the pipeline. | |
| 138 // For reference Chromebook Pixel can upload 1MB in about 0.5ms. | |
| 139 const size_t kMaxBytesUploadedPerMs = 1024 * 1024 * 2; | |
| 140 | |
| 141 // We need to upload at least enough work to keep the GPU process busy until | |
| 142 // the next time it can handle a request to start more uploads from the | |
| 143 // compositor. We assume that it will pick up any sent upload requests within | |
| 144 // the time of a vsync, since the browser will want to swap a frame within | |
| 145 // that time interval, and then uploads should have a chance to be processed. | |
| 146 size_t ms_per_frame = std::floor(1000.0 / refresh_rate); | |
| 147 size_t max_transfer_buffer_usage_bytes = | |
| 148 ms_per_frame * kMaxBytesUploadedPerMs; | |
| 149 | |
| 150 // The context may request a lower limit based on the device capabilities. | |
| 151 return std::min(context_capabilities.max_transfer_buffer_usage_bytes, | |
| 152 max_transfer_buffer_usage_bytes); | |
| 153 } | |
| 154 | |
| 155 size_t GetMaxStagingResourceCount() { | 132 size_t GetMaxStagingResourceCount() { |
| 156 // Upper bound for number of staging resource to allow. | 133 // Upper bound for number of staging resource to allow. |
| 157 return 32; | 134 return 32; |
| 158 } | 135 } |
| 159 | 136 |
| 160 size_t GetDefaultMemoryAllocationLimit() { | 137 size_t GetDefaultMemoryAllocationLimit() { |
| 161 // TODO(ccameron): (http://crbug.com/137094) This 64MB default is a straggler | 138 // TODO(ccameron): (http://crbug.com/137094) This 64MB default is a straggler |
| 162 // from the old texture manager and is just to give us a default memory | 139 // from the old texture manager and is just to give us a default memory |
| 163 // allocation before we get a callback from the GPU memory manager. We | 140 // allocation before we get a callback from the GPU memory manager. We |
| 164 // should probaby either: | 141 // should probaby either: |
| (...skipping 3442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3607 if (active_tree()) { | 3584 if (active_tree()) { |
| 3608 LayerAnimationValueProvider* layer = active_tree()->LayerById(layer_id); | 3585 LayerAnimationValueProvider* layer = active_tree()->LayerById(layer_id); |
| 3609 if (layer) | 3586 if (layer) |
| 3610 return layer->ScrollOffsetForAnimation(); | 3587 return layer->ScrollOffsetForAnimation(); |
| 3611 } | 3588 } |
| 3612 | 3589 |
| 3613 return gfx::ScrollOffset(); | 3590 return gfx::ScrollOffset(); |
| 3614 } | 3591 } |
| 3615 | 3592 |
| 3616 } // namespace cc | 3593 } // namespace cc |
| OLD | NEW |